From 69148410f214c39c352214c7c383b7e89e5c5104 Mon Sep 17 00:00:00 2001 From: Yinyin Liu Date: Thu, 12 Mar 2026 11:03:59 +0100 Subject: [PATCH] roll out the previous commit to other products --- .../dashboards/Installations/Installation.tsx | 8 ++++- .../dashboards/Overview/salidomoOverview.tsx | 25 +++++++++++++++ .../SalidomoInstallations/Installation.tsx | 32 +++++++++++++++++-- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx index 6894d5546..377f869bf 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Installations/Installation.tsx @@ -200,6 +200,7 @@ function Installation(props: singleInstallationProps) { currentTab == 'live' || currentTab == 'pvview' || currentTab == 'configuration' || + currentTab == 'overview' || location.includes('batteryview') ) { //Fetch periodically if the tab is live, pvview or batteryview @@ -217,6 +218,10 @@ function Installation(props: singleInstallationProps) { } } } + // Fetch one time in overview tab to determine connectivity + if (currentTab == 'overview') { + fetchDataForOneTime(); + } //Fetch only one time in configuration tab if (currentTab == 'configuration') { fetchDataForOneTime(); @@ -376,7 +381,6 @@ function Installation(props: singleInstallationProps) { currentTab != 'information' && currentTab != 'history' && currentTab != 'manage' && - currentTab != 'overview' && currentTab != 'log' && ( } /> diff --git a/typescript/frontend-marios2/src/content/dashboards/Overview/salidomoOverview.tsx b/typescript/frontend-marios2/src/content/dashboards/Overview/salidomoOverview.tsx index 35ce941b0..e396bf63e 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Overview/salidomoOverview.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Overview/salidomoOverview.tsx @@ -28,6 +28,8 @@ import { UserType } from '../../../interfaces/UserTypes'; interface salidomoOverviewProps { s3Credentials: I_S3Credentials; id: number; + connected?: boolean; + loading?: boolean; } const computeLast7Days = (): string[] => { @@ -750,6 +752,23 @@ function SalidomoOverview(props: salidomoOverviewProps) { const renderGraphs = () => { return ( + {!props.connected && !props.loading && ( + + + + )} {isErrorDateModalOpen && ( {}}> )} + {!props.loading && (props.connected !== false || aggregatedDataArray.length > 0) && (<> + )} {loading && ( {renderGraphs()}; } diff --git a/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/Installation.tsx b/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/Installation.tsx index 73ca52dd4..c0f432645 100644 --- a/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/Installation.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/SalidomoInstallations/Installation.tsx @@ -157,8 +157,31 @@ function SalidomoInstallation(props: singleInstallationProps) { setCurrentTab(path[path.length - 1]); }, [location]); + const fetchDataForOneTime = async () => { + var timeperiodToSearch = 30; + for (var i = 0; i < timeperiodToSearch; i += 1) { + var timestampToFetch = UnixTime.now().earlier(TimeSpan.fromMinutes(i)); + try { + var res = await fetchDataJson(timestampToFetch, s3Credentials, true); + if (res !== FetchResult.notAvailable && res !== FetchResult.tryLater) { + setConnected(true); + setLoading(false); + return true; + } + } catch (err) { + console.error('Error fetching data:', err); + setConnected(false); + setLoading(false); + return false; + } + } + setConnected(false); + setLoading(false); + return false; + }; + useEffect(() => { - if (location.includes('batteryview')) { + if (location.includes('batteryview') || currentTab == 'overview') { if (location.includes('batteryview') && !location.includes('mainstats')) { if (!continueFetching.current) { continueFetching.current = true; @@ -168,6 +191,10 @@ function SalidomoInstallation(props: singleInstallationProps) { } } } + // Fetch one time in overview tab to determine connectivity + if (currentTab == 'overview') { + fetchDataForOneTime(); + } return () => { continueFetching.current = false; @@ -295,7 +322,6 @@ function SalidomoInstallation(props: singleInstallationProps) { {loading && currentTab != 'information' && - currentTab != 'overview' && currentTab != 'manage' && currentTab != 'history' && currentTab != 'log' && ( @@ -357,6 +383,8 @@ function SalidomoInstallation(props: singleInstallationProps) { } />