Add session stats to desktop app
This commit is contained in:
parent
857db0caf4
commit
93c53b4285
5 changed files with 17 additions and 3 deletions
2
Makefile
2
Makefile
|
|
@ -20,7 +20,7 @@ devserver:
|
|||
echo -n '' > /tmp/rqbit-log && cargo run -- \
|
||||
--log-file /tmp/rqbit-log \
|
||||
--log-file-rust-log=debug,librqbit=trace \
|
||||
server start --fastresume /tmp/scratch/
|
||||
server start /tmp/scratch/
|
||||
|
||||
@PHONY: devserver
|
||||
devserver-postgres:
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ mod peer_info_reader;
|
|||
mod read_buf;
|
||||
mod session;
|
||||
mod session_persistence;
|
||||
mod session_stats;
|
||||
pub mod session_stats;
|
||||
mod spawn_utils;
|
||||
pub mod storage;
|
||||
mod stream_connect;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { createContext } from "react";
|
||||
import { RqbitAPI } from "./api-types";
|
||||
import { RqbitAPI, SessionStats } from "./api-types";
|
||||
|
||||
export const APIContext = createContext<RqbitAPI>({
|
||||
listTorrents: () => {
|
||||
|
|
@ -38,5 +38,8 @@ export const APIContext = createContext<RqbitAPI>({
|
|||
getPlaylistUrl: function (index: number): string | null {
|
||||
throw new Error("Function not implemented.");
|
||||
},
|
||||
stats: function (): Promise<SessionStats> {
|
||||
throw new Error("Function not implemented.");
|
||||
},
|
||||
});
|
||||
export const RefreshTorrentStatsContext = createContext({ refresh: () => {} });
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use librqbit::{
|
|||
TorrentListResponse, TorrentStats,
|
||||
},
|
||||
dht::PersistentDhtConfig,
|
||||
session_stats::snapshot::SessionStatsSnapshot,
|
||||
tracing_subscriber_config_utils::{init_logging, InitLoggingOptions, InitLoggingResult},
|
||||
AddTorrent, AddTorrentOptions, Api, ApiError, PeerConnectionOptions, Session, SessionOptions,
|
||||
SessionPersistenceConfig,
|
||||
|
|
@ -318,6 +319,11 @@ async fn torrent_action_configure(
|
|||
.await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn stats(state: tauri::State<'_, State>) -> Result<SessionStatsSnapshot, ApiError> {
|
||||
Ok(state.api()?.api_session_stats())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_version() -> &'static str {
|
||||
env!("CARGO_PKG_VERSION")
|
||||
|
|
@ -352,6 +358,7 @@ async fn start() {
|
|||
torrent_action_start,
|
||||
torrent_action_configure,
|
||||
torrent_create_from_base64_file,
|
||||
stats,
|
||||
get_version,
|
||||
config_default,
|
||||
config_current,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import {
|
|||
TorrentDetails,
|
||||
TorrentStats,
|
||||
ErrorDetails,
|
||||
SessionStats,
|
||||
} from "rqbit-webui/src/api-types";
|
||||
|
||||
import { InvokeArgs, invoke } from "@tauri-apps/api/tauri";
|
||||
|
|
@ -141,5 +142,8 @@ export const makeAPI = (configuration: RqbitDesktopConfig): RqbitAPI => {
|
|||
}
|
||||
return `${httpBase}/torrents/${index}/playlist`;
|
||||
},
|
||||
stats: () => {
|
||||
return invokeAPI<SessionStats>("stats");
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue