diff --git a/frontend/src/components/stats/Provider.tsx b/frontend/src/components/stats/Provider.tsx index e3e6c400b..24db99f22 100644 --- a/frontend/src/components/stats/Provider.tsx +++ b/frontend/src/components/stats/Provider.tsx @@ -4,9 +4,15 @@ import { client } from "../.."; import { SystemInformation, Timelength } from "../../types"; import { useLocalStorage } from "../../util/hooks"; +export enum StatsView { + Current = "current", + Historical = "historical", + Info = "info" +} + const value = () => { const params = useParams(); - const [view, setView] = useLocalStorage("current", "stats-view-v1"); + const [view, setView] = useLocalStorage(StatsView.Current, "stats-view-v2"); const [timelength, setTimelength] = useLocalStorage( Timelength.OneMinute, "stats-timelength-v3" diff --git a/frontend/src/components/stats/Stats.tsx b/frontend/src/components/stats/Stats.tsx index 71fd539d1..810ebe4bd 100644 --- a/frontend/src/components/stats/Stats.tsx +++ b/frontend/src/components/stats/Stats.tsx @@ -1,6 +1,5 @@ import { A, useParams } from "@solidjs/router"; -import { Component, Match, Show, Switch } from "solid-js"; -import { MAX_PAGE_WIDTH } from "../.."; +import { Component, For, Match, Show, Switch } from "solid-js"; import { useAppState } from "../../state/StateProvider"; import { ServerStatus, Timelength } from "../../types"; import Icon from "../shared/Icon"; @@ -9,7 +8,7 @@ import Grid from "../shared/layout/Grid"; import Selector from "../shared/menu/Selector"; import CurrentStats from "./CurrentStats"; import HistoricalStats from "./HistoricalStats"; -import { StatsProvider, useStatsState } from "./Provider"; +import { StatsProvider, useStatsState, StatsView } from "./Provider"; const TIMELENGTHS = [ Timelength.FifteenSeconds, @@ -33,28 +32,23 @@ const Stats = () => { const StatsComp: Component<{}> = () => { const { view } = useStatsState(); return ( - - -
- - - + +
+ - + - + + + + ); @@ -95,28 +89,19 @@ export const Header: Component<{}> = (p) => { > {server()?.status.replaceAll("_", " ").toUpperCase()} - - - - + setView(v as StatsView)} + position="bottom right" + /> t.replaceAll("-", " ")} + itemMap={(t) => t.replaceAll("-", " ")} itemClass="full-width" onSelect={(selected) => { setPage(0); @@ -126,17 +111,16 @@ export const Header: Component<{}> = (p) => { /> - -
poll:
- { - setPollRate(selected as Timelength); - }} - /> -
+ { + setPollRate(selected as Timelength); + }} + position="bottom right" + />
); @@ -144,16 +128,35 @@ export const Header: Component<{}> = (p) => { const SysInfo = () => { const { sysInfo } = useStatsState(); + const cards = () => { + return [ + { + label: "os", + info: sysInfo()?.os, + }, + { + label: "cpu", + info: sysInfo()?.cpu_brand, + }, + { + label: "core count", + info: `${sysInfo()?.core_count} cores`, + }, + ]; + }; return ( - -
{sysInfo()?.os}
- {/*
{sysInfo()?.kernel}
*/} -
{sysInfo()?.cpu_brand}
-
{sysInfo()?.core_count} cores
-
+ + + + {(c) => ( + +
{c.label}
+
{c.info}
+
+ )} +
+
+
); };