roll out the previous commit to other products
This commit is contained in:
parent
cb61c2bd42
commit
69148410f2
|
|
@ -200,6 +200,7 @@ function Installation(props: singleInstallationProps) {
|
||||||
currentTab == 'live' ||
|
currentTab == 'live' ||
|
||||||
currentTab == 'pvview' ||
|
currentTab == 'pvview' ||
|
||||||
currentTab == 'configuration' ||
|
currentTab == 'configuration' ||
|
||||||
|
currentTab == 'overview' ||
|
||||||
location.includes('batteryview')
|
location.includes('batteryview')
|
||||||
) {
|
) {
|
||||||
//Fetch periodically if the tab is live, pvview or 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
|
//Fetch only one time in configuration tab
|
||||||
if (currentTab == 'configuration') {
|
if (currentTab == 'configuration') {
|
||||||
fetchDataForOneTime();
|
fetchDataForOneTime();
|
||||||
|
|
@ -376,7 +381,6 @@ function Installation(props: singleInstallationProps) {
|
||||||
currentTab != 'information' &&
|
currentTab != 'information' &&
|
||||||
currentTab != 'history' &&
|
currentTab != 'history' &&
|
||||||
currentTab != 'manage' &&
|
currentTab != 'manage' &&
|
||||||
currentTab != 'overview' &&
|
|
||||||
currentTab != 'log' && (
|
currentTab != 'log' && (
|
||||||
<Container
|
<Container
|
||||||
maxWidth="xl"
|
maxWidth="xl"
|
||||||
|
|
@ -447,6 +451,8 @@ function Installation(props: singleInstallationProps) {
|
||||||
<Overview
|
<Overview
|
||||||
s3Credentials={s3Credentials}
|
s3Credentials={s3Credentials}
|
||||||
id={props.current_installation.id}
|
id={props.current_installation.id}
|
||||||
|
connected={connected}
|
||||||
|
loading={loading}
|
||||||
></Overview>
|
></Overview>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@ import { UserType } from '../../../interfaces/UserTypes';
|
||||||
interface salidomoOverviewProps {
|
interface salidomoOverviewProps {
|
||||||
s3Credentials: I_S3Credentials;
|
s3Credentials: I_S3Credentials;
|
||||||
id: number;
|
id: number;
|
||||||
|
connected?: boolean;
|
||||||
|
loading?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const computeLast7Days = (): string[] => {
|
const computeLast7Days = (): string[] => {
|
||||||
|
|
@ -750,6 +752,23 @@ function SalidomoOverview(props: salidomoOverviewProps) {
|
||||||
const renderGraphs = () => {
|
const renderGraphs = () => {
|
||||||
return (
|
return (
|
||||||
<Container maxWidth="xl">
|
<Container maxWidth="xl">
|
||||||
|
{!props.connected && !props.loading && (
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{
|
||||||
|
color: 'red',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
textAlign: 'center',
|
||||||
|
marginTop: '10px',
|
||||||
|
marginBottom: '10px'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="installationOffline"
|
||||||
|
defaultMessage="Installation is currently offline. Showing last available data."
|
||||||
|
/>
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
{isErrorDateModalOpen && (
|
{isErrorDateModalOpen && (
|
||||||
<Modal open={isErrorDateModalOpen} onClose={() => {}}>
|
<Modal open={isErrorDateModalOpen} onClose={() => {}}>
|
||||||
<Box
|
<Box
|
||||||
|
|
@ -874,6 +893,7 @@ function SalidomoOverview(props: salidomoOverviewProps) {
|
||||||
</LocalizationProvider>
|
</LocalizationProvider>
|
||||||
)}
|
)}
|
||||||
<Grid container>
|
<Grid container>
|
||||||
|
{!props.loading && (props.connected !== false || aggregatedDataArray.length > 0) && (<>
|
||||||
<Grid item xs={6} md={6}>
|
<Grid item xs={6} md={6}>
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|
@ -931,6 +951,7 @@ function SalidomoOverview(props: salidomoOverviewProps) {
|
||||||
<FormattedMessage id="goback" defaultMessage="Zoom in" />
|
<FormattedMessage id="goback" defaultMessage="Zoom in" />
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</>)}
|
||||||
|
|
||||||
{loading && (
|
{loading && (
|
||||||
<Container
|
<Container
|
||||||
|
|
@ -1123,6 +1144,10 @@ function SalidomoOverview(props: salidomoOverviewProps) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (props.loading) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return <>{renderGraphs()}</>;
|
return <>{renderGraphs()}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,31 @@ function SalidomoInstallation(props: singleInstallationProps) {
|
||||||
setCurrentTab(path[path.length - 1]);
|
setCurrentTab(path[path.length - 1]);
|
||||||
}, [location]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
if (location.includes('batteryview')) {
|
if (location.includes('batteryview') || currentTab == 'overview') {
|
||||||
if (location.includes('batteryview') && !location.includes('mainstats')) {
|
if (location.includes('batteryview') && !location.includes('mainstats')) {
|
||||||
if (!continueFetching.current) {
|
if (!continueFetching.current) {
|
||||||
continueFetching.current = true;
|
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 () => {
|
return () => {
|
||||||
continueFetching.current = false;
|
continueFetching.current = false;
|
||||||
|
|
@ -295,7 +322,6 @@ function SalidomoInstallation(props: singleInstallationProps) {
|
||||||
</div>
|
</div>
|
||||||
{loading &&
|
{loading &&
|
||||||
currentTab != 'information' &&
|
currentTab != 'information' &&
|
||||||
currentTab != 'overview' &&
|
|
||||||
currentTab != 'manage' &&
|
currentTab != 'manage' &&
|
||||||
currentTab != 'history' &&
|
currentTab != 'history' &&
|
||||||
currentTab != 'log' && (
|
currentTab != 'log' && (
|
||||||
|
|
@ -357,6 +383,8 @@ function SalidomoInstallation(props: singleInstallationProps) {
|
||||||
<SalidomoOverview
|
<SalidomoOverview
|
||||||
s3Credentials={s3Credentials}
|
s3Credentials={s3Credentials}
|
||||||
id={props.current_installation.id}
|
id={props.current_installation.id}
|
||||||
|
connected={connected}
|
||||||
|
loading={loading}
|
||||||
></SalidomoOverview>
|
></SalidomoOverview>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue