Add more data to stats footer
This commit is contained in:
parent
f1688add01
commit
ddc725d1a9
5 changed files with 27 additions and 3 deletions
|
|
@ -17,6 +17,7 @@ pub struct SessionStats {
|
||||||
pub atomic: Arc<AtomicSessionStats>,
|
pub atomic: Arc<AtomicSessionStats>,
|
||||||
pub down_speed_estimator: SpeedEstimator,
|
pub down_speed_estimator: SpeedEstimator,
|
||||||
pub up_speed_estimator: SpeedEstimator,
|
pub up_speed_estimator: SpeedEstimator,
|
||||||
|
pub startup_time: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SessionStats {
|
impl SessionStats {
|
||||||
|
|
@ -25,6 +26,7 @@ impl SessionStats {
|
||||||
atomic: Default::default(),
|
atomic: Default::default(),
|
||||||
down_speed_estimator: SpeedEstimator::new(5),
|
down_speed_estimator: SpeedEstimator::new(5),
|
||||||
up_speed_estimator: SpeedEstimator::new(5),
|
up_speed_estimator: SpeedEstimator::new(5),
|
||||||
|
startup_time: Instant::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::torrent_state::{peers::stats::snapshot::AggregatePeerStats, stats::Speed};
|
use crate::torrent_state::{peers::stats::snapshot::AggregatePeerStats, stats::Speed};
|
||||||
|
|
@ -6,9 +8,12 @@ use super::SessionStats;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct SessionStatsSnapshot {
|
pub struct SessionStatsSnapshot {
|
||||||
|
fetched_bytes: u64,
|
||||||
|
uploaded_bytes: u64,
|
||||||
download_speed: Speed,
|
download_speed: Speed,
|
||||||
upload_speed: Speed,
|
upload_speed: Speed,
|
||||||
peers: AggregatePeerStats,
|
peers: AggregatePeerStats,
|
||||||
|
uptime_seconds: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&SessionStats> for SessionStatsSnapshot {
|
impl From<&SessionStats> for SessionStatsSnapshot {
|
||||||
|
|
@ -16,7 +21,10 @@ impl From<&SessionStats> for SessionStatsSnapshot {
|
||||||
Self {
|
Self {
|
||||||
download_speed: s.down_speed_estimator.mbps().into(),
|
download_speed: s.down_speed_estimator.mbps().into(),
|
||||||
upload_speed: s.up_speed_estimator.mbps().into(),
|
upload_speed: s.up_speed_estimator.mbps().into(),
|
||||||
|
fetched_bytes: s.atomic.fetched_bytes.load(Ordering::Relaxed),
|
||||||
|
uploaded_bytes: s.atomic.uploaded_bytes.load(Ordering::Relaxed),
|
||||||
peers: AggregatePeerStats::from(&s.atomic.peers),
|
peers: AggregatePeerStats::from(&s.atomic.peers),
|
||||||
|
uptime_seconds: s.startup_time.elapsed().as_secs(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,10 @@ export interface AggregatePeerStats {
|
||||||
export interface SessionStats {
|
export interface SessionStats {
|
||||||
download_speed: Speed;
|
download_speed: Speed;
|
||||||
upload_speed: Speed;
|
upload_speed: Speed;
|
||||||
|
fetched_bytes: number;
|
||||||
|
uploaded_bytes: number;
|
||||||
peers: AggregatePeerStats;
|
peers: AggregatePeerStats;
|
||||||
|
uptime_seconds: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface for the Torrent Stats API response
|
// Interface for the Torrent Stats API response
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
|
import { formatBytes } from "../helper/formatBytes";
|
||||||
|
import { formatSecondsToTime } from "../helper/formatSecondsToTime";
|
||||||
import { useStatsStore } from "../stores/statsStore";
|
import { useStatsStore } from "../stores/statsStore";
|
||||||
import { Speed } from "./Speed";
|
|
||||||
|
|
||||||
export const Footer: React.FC<{}> = () => {
|
export const Footer: React.FC<{}> = () => {
|
||||||
let stats = useStatsStore((stats) => stats.stats);
|
let stats = useStatsStore((stats) => stats.stats);
|
||||||
return (
|
return (
|
||||||
<div className="sticky bottom-0 bg-white/10 dark:text-gray-200 backdrop-blur text-nowrap text-xs font-medium text-gray-500 flex p-1 gap-x-3 justify-center">
|
<div className="sticky bottom-0 bg-white/10 dark:text-gray-200 backdrop-blur text-nowrap text-xs font-medium text-gray-500 flex p-1 gap-x-3 justify-center">
|
||||||
<div>↓ {stats.download_speed.human_readable}</div>
|
<div>
|
||||||
<div>↑ {stats.upload_speed.human_readable}</div>
|
↓ {stats.download_speed.human_readable} (total{" "}
|
||||||
|
{formatBytes(stats.fetched_bytes)})
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
↑ {stats.upload_speed.human_readable} (total{" "}
|
||||||
|
{formatBytes(stats.uploaded_bytes)})
|
||||||
|
</div>
|
||||||
|
<div>up {formatSecondsToTime(stats.uptime_seconds)}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ export const useStatsStore = create<StatsStore>((set) => ({
|
||||||
queued: 0,
|
queued: 0,
|
||||||
seen: 0,
|
seen: 0,
|
||||||
},
|
},
|
||||||
|
fetched_bytes: 0,
|
||||||
|
uploaded_bytes: 0,
|
||||||
|
uptime_seconds: 0,
|
||||||
},
|
},
|
||||||
setStats: (stats) => {
|
setStats: (stats) => {
|
||||||
set({ stats });
|
set({ stats });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue