From aecdc20e943b96c564dc510d1cd5688d8c6ca874 Mon Sep 17 00:00:00 2001 From: "Damon L. Montague Jr." Date: Sun, 21 Jan 2024 11:59:21 -0500 Subject: [PATCH] added loading and added winner to confidence --- ui/index.html | 2 +- ui/src/components/display-card.tsx | 2 +- ui/src/components/navbar.tsx | 2 +- ui/src/pages/Games.tsx | 23 ++++++++++++++++++++--- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ui/index.html b/ui/index.html index 09be437..496a840 100644 --- a/ui/index.html +++ b/ui/index.html @@ -5,7 +5,7 @@ - Solid App + Accuribet
diff --git a/ui/src/components/display-card.tsx b/ui/src/components/display-card.tsx index c51e930..a59be9e 100644 --- a/ui/src/components/display-card.tsx +++ b/ui/src/components/display-card.tsx @@ -312,7 +312,7 @@ export const DemoCard: Component = (props: IDisplayCard) => {

The prediction model has a confidence of{' '} {((props.game.prediction?.confidence ?? 0) * 100).toFixed(1)}% - for the winning team. + for the {props.game.prediction?.prediction} to win.

diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index 2d3dad9..51e1c94 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -14,7 +14,7 @@ interface Props { } export const Navbar: Component = (props: Props) => { - let storedPreference = localStorage.getItem('theme'); + // let storedPreference = localStorage.getItem('theme'); const [theme, setTheme] = createSignal(props.theme); const changeTheme = (theme: string) => { diff --git a/ui/src/pages/Games.tsx b/ui/src/pages/Games.tsx index 5796b7a..c0eaa00 100644 --- a/ui/src/pages/Games.tsx +++ b/ui/src/pages/Games.tsx @@ -30,6 +30,7 @@ export const Games = () => { const [selectedModel, setSelectedModel] = createSignal(''); const [liveUpdates, setLiveUpdates] = createSignal(false); const [predictions, setPredictions] = createSignal([]); + const [predictionLoading, setPredictionLoading] = createSignal(false); let intervalId: NodeJS.Timeout; @@ -62,11 +63,23 @@ export const Games = () => { return; } - const res = await fetch( - `https://apidev.accuribet.win/api/v1/model/predict/${model}`, - ); + setPredictionLoading(true); + + let res; + try { + res = await fetch( + `https://apidev.accuribet.win/api/v1/model/predict/${model}`, + ); + } catch (e) { + console.log(e); + } finally { + setPredictionLoading(false); + } + if (!res) return; + const data = (await res.json()) as Prediction[]; + localStorage.setItem(cacheKey, JSON.stringify(data)); setPredictions(data); setSelectedModel(model); @@ -148,6 +161,10 @@ export const Games = () => { >
+ + {/* little loading spinner next to the model select */} +
+