Desktop: button to show a modal with logs (#48)
* Add an endpoint to stream logs /stream_logs * Display logs in desktop app * UI component to stream logs
This commit is contained in:
parent
f7345ae6df
commit
9385524a1a
21 changed files with 521 additions and 125 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { RqbitDesktopConfig } from "./configuration";
|
||||
import {
|
||||
AddTorrentResponse,
|
||||
ListTorrentsResponse,
|
||||
|
|
@ -66,42 +67,49 @@ async function readFileAsBase64(file: File): Promise<string> {
|
|||
});
|
||||
}
|
||||
|
||||
export const API: RqbitAPI = {
|
||||
listTorrents: async function (): Promise<ListTorrentsResponse> {
|
||||
return await invokeAPI<ListTorrentsResponse>("torrents_list");
|
||||
},
|
||||
getTorrentDetails: async function (id: number): Promise<TorrentDetails> {
|
||||
return await invokeAPI<TorrentDetails>("torrent_details", { id });
|
||||
},
|
||||
getTorrentStats: async function (id: number): Promise<TorrentStats> {
|
||||
return await invokeAPI<TorrentStats>("torrent_stats", { id });
|
||||
},
|
||||
uploadTorrent: async function (data, opts): Promise<AddTorrentResponse> {
|
||||
if (data instanceof File) {
|
||||
let contents = await readFileAsBase64(data);
|
||||
return await invokeAPI<AddTorrentResponse>(
|
||||
"torrent_create_from_base64_file",
|
||||
{
|
||||
contents,
|
||||
opts: opts ?? {},
|
||||
}
|
||||
);
|
||||
}
|
||||
return await invokeAPI<AddTorrentResponse>("torrent_create_from_url", {
|
||||
url: data,
|
||||
opts: opts ?? {},
|
||||
});
|
||||
},
|
||||
pause: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_pause", { id });
|
||||
},
|
||||
start: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_start", { id });
|
||||
},
|
||||
forget: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_forget", { id });
|
||||
},
|
||||
delete: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_delete", { id });
|
||||
},
|
||||
export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
|
||||
return {
|
||||
getHttpBaseUrl: () => {
|
||||
return configuration.http_api.listen_addr
|
||||
? `http://${configuration.http_api.listen_addr}`
|
||||
: null;
|
||||
},
|
||||
listTorrents: async function (): Promise<ListTorrentsResponse> {
|
||||
return await invokeAPI<ListTorrentsResponse>("torrents_list");
|
||||
},
|
||||
getTorrentDetails: async function (id: number): Promise<TorrentDetails> {
|
||||
return await invokeAPI<TorrentDetails>("torrent_details", { id });
|
||||
},
|
||||
getTorrentStats: async function (id: number): Promise<TorrentStats> {
|
||||
return await invokeAPI<TorrentStats>("torrent_stats", { id });
|
||||
},
|
||||
uploadTorrent: async function (data, opts): Promise<AddTorrentResponse> {
|
||||
if (data instanceof File) {
|
||||
let contents = await readFileAsBase64(data);
|
||||
return await invokeAPI<AddTorrentResponse>(
|
||||
"torrent_create_from_base64_file",
|
||||
{
|
||||
contents,
|
||||
opts: opts ?? {},
|
||||
}
|
||||
);
|
||||
}
|
||||
return await invokeAPI<AddTorrentResponse>("torrent_create_from_url", {
|
||||
url: data,
|
||||
opts: opts ?? {},
|
||||
});
|
||||
},
|
||||
pause: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_pause", { id });
|
||||
},
|
||||
start: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_start", { id });
|
||||
},
|
||||
forget: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_forget", { id });
|
||||
},
|
||||
delete: function (id: number): Promise<void> {
|
||||
return invokeAPI<void>("torrent_action_delete", { id });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue