Switch UI to display statuses better
This commit is contained in:
parent
876afbf41b
commit
66d2f224ed
7 changed files with 80 additions and 26 deletions
|
|
@ -29,7 +29,7 @@ export interface ListTorrentsResponse {
|
|||
}
|
||||
|
||||
// Interface for the Torrent Stats API response
|
||||
export interface TorrentStats {
|
||||
export interface LiveTorrentStats {
|
||||
snapshot: {
|
||||
have_bytes: number;
|
||||
downloaded_and_checked_bytes: number;
|
||||
|
|
@ -69,6 +69,15 @@ export interface TorrentStats {
|
|||
} | null;
|
||||
}
|
||||
|
||||
export interface TorrentStats {
|
||||
state: string,
|
||||
error: string | null,
|
||||
progress_bytes: number,
|
||||
finished: boolean,
|
||||
total_bytes: number,
|
||||
live: LiveTorrentStats | null;
|
||||
}
|
||||
|
||||
|
||||
export interface ErrorDetails {
|
||||
id?: number,
|
||||
|
|
@ -129,7 +138,7 @@ export const API = {
|
|||
return makeRequest('GET', `/torrents/${index}`);
|
||||
},
|
||||
getTorrentStats: (index: number): Promise<TorrentStats> => {
|
||||
return makeRequest('GET', `/torrents/${index}/stats`);
|
||||
return makeRequest('GET', `/torrents/${index}/stats/v1`);
|
||||
},
|
||||
|
||||
uploadTorrent: (data: string | File, opts?: {
|
||||
|
|
@ -144,5 +153,21 @@ export const API = {
|
|||
url += `&only_files=${opts.selectedFiles.join(',')}`;
|
||||
}
|
||||
return makeRequest('POST', url, data)
|
||||
},
|
||||
|
||||
pause: (index: number): Promise<void> => {
|
||||
return makeRequest('POST', `/torrents/${index}/pause`);
|
||||
},
|
||||
|
||||
start: (index: number): Promise<void> => {
|
||||
return makeRequest('POST', `/torrents/${index}/start`);
|
||||
},
|
||||
|
||||
forget: (index: number): Promise<void> => {
|
||||
return makeRequest('POST', `/torrents/${index}/forget`);
|
||||
},
|
||||
|
||||
delete: (index: number): Promise<void> => {
|
||||
return makeRequest('POST', `/torrents/${index}/delete`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue