Use keys api

This commit is contained in:
Nicolas Mowen 2024-04-01 07:20:04 -06:00
parent 135ca53113
commit 1e62643c56
5 changed files with 12 additions and 5 deletions

View File

@ -127,7 +127,9 @@ def stats():
@bp.route("/stats/history") @bp.route("/stats/history")
def stats_history(): def stats_history():
return jsonify(current_app.stats_emitter.get_stats_history()) json: dict[str, any] = request.get_json(silent=True) or {}
keys = json.get("keys")
return jsonify(current_app.stats_emitter.get_stats_history(keys))
@bp.route("/config") @bp.route("/config")

View File

@ -67,7 +67,7 @@ class StatsEmitter(threading.Thread):
def run(self) -> None: def run(self) -> None:
time.sleep(10) time.sleep(10)
for counter in itertools.cycle(range(self.config.record.expire_interval)): for counter in itertools.cycle(range(int(self.config.record.expire_interval / 10))):
if self.stop_event.wait(10): if self.stop_event.wait(10):
break break

View File

@ -51,7 +51,7 @@ export default function SystemGraph({
if (value >= threshold.error) { if (value >= threshold.error) {
return "#FA5252"; return "#FA5252";
} else if (value >= threshold.warning) { } else if (value >= threshold.warning) {
return "#aa00aa"; return "#FF9966";
} else { } else {
return "#404040"; return "#404040";
} }

View File

@ -57,7 +57,10 @@ function StatusAlertNav() {
<DrawerContent className="max-h-[75dvh] px-2 mx-1 rounded-t-2xl overflow-hidden"> <DrawerContent className="max-h-[75dvh] px-2 mx-1 rounded-t-2xl overflow-hidden">
<div className="w-full h-auto py-4 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-2"> <div className="w-full h-auto py-4 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-2">
{potentialProblems.map((prob) => ( {potentialProblems.map((prob) => (
<div className="w-full flex items-center text-xs gap-2 capitalize"> <div
key={prob.text}
className="w-full flex items-center text-xs gap-2 capitalize"
>
<IoIosWarning className={`size-5 ${prob.color}`} /> <IoIosWarning className={`size-5 ${prob.color}`} />
{prob.text} {prob.text}
</div> </div>

View File

@ -14,7 +14,9 @@ import {
function System() { function System() {
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
// stats // stats chunks
// stats collection
const { data: initialStats } = useSWR<FrigateStats[]>("stats/history", { const { data: initialStats } = useSWR<FrigateStats[]>("stats/history", {
revalidateOnFocus: false, revalidateOnFocus: false,