fix tree path issues of all products
This commit is contained in:
parent
3521da7a1d
commit
2681248bdc
|
|
@ -95,11 +95,19 @@ function App() {
|
||||||
const Login = Loader(lazy(() => import('src/components/login')));
|
const Login = Loader(lazy(() => import('src/components/login')));
|
||||||
const Users = Loader(lazy(() => import('src/content/dashboards/Users')));
|
const Users = Loader(lazy(() => import('src/content/dashboards/Users')));
|
||||||
|
|
||||||
const loginToResetPassword = () => {
|
useEffect(() => {
|
||||||
|
if (!username || token) return;
|
||||||
|
|
||||||
axiosConfigWithoutToken
|
axiosConfigWithoutToken
|
||||||
.post('/Login', null, { params: { username, password: '' } })
|
.post('/Login', null, { params: { username, password: '' } })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data && response.data.token) {
|
if (response.data && response.data.token) {
|
||||||
|
// Clear the username param from URL to prevent re-login loops
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.delete('username');
|
||||||
|
url.searchParams.delete('reset');
|
||||||
|
window.history.replaceState({}, '', url.pathname);
|
||||||
|
|
||||||
setNewToken(response.data.token);
|
setNewToken(response.data.token);
|
||||||
setUser(response.data.user);
|
setUser(response.data.user);
|
||||||
setAccessToSalimax(response.data.accessToSalimax);
|
setAccessToSalimax(response.data.accessToSalimax);
|
||||||
|
|
@ -108,27 +116,10 @@ function App() {
|
||||||
setAccessToSodistore(response.data.accessToSodistoreMax);
|
setAccessToSodistore(response.data.accessToSodistoreMax);
|
||||||
setAccessToSodistoreGrid(response.data.accessToSodistoreGrid);
|
setAccessToSodistoreGrid(response.data.accessToSodistoreGrid);
|
||||||
setAccessToSodistorePro(response.data.accessToSodistorePro);
|
setAccessToSodistorePro(response.data.accessToSodistorePro);
|
||||||
if (response.data.accessToSalimax) {
|
|
||||||
navigate(routes.installations);
|
|
||||||
} else if (response.data.accessToSalidomo) {
|
|
||||||
navigate(routes.salidomo_installations);
|
|
||||||
} else if (response.data.accessToSodistoreMax) {
|
|
||||||
navigate(routes.sodistore_installations);
|
|
||||||
} else if (response.data.accessToSodistoreGrid) {
|
|
||||||
navigate(routes.sodistoregrid_installations);
|
|
||||||
} else if (response.data.accessToSodistorePro) {
|
|
||||||
navigate(routes.sodistorepro_installations);
|
|
||||||
} else {
|
|
||||||
navigate(routes.sodiohome_installations);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
}, [username]);
|
||||||
|
|
||||||
if (username) {
|
|
||||||
loginToResetPassword();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return (
|
return (
|
||||||
|
|
@ -162,8 +153,14 @@ function App() {
|
||||||
if (token && currentUser?.mustResetPassword) {
|
if (token && currentUser?.mustResetPassword) {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<CssBaseline />
|
<IntlProvider
|
||||||
<SetNewPassword></SetNewPassword>
|
messages={getTranslations()}
|
||||||
|
locale={language}
|
||||||
|
defaultLocale="en"
|
||||||
|
>
|
||||||
|
<CssBaseline />
|
||||||
|
<SetNewPassword></SetNewPassword>
|
||||||
|
</IntlProvider>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ function Information(props: InformationProps) {
|
||||||
|
|
||||||
const canEdit = currentUser.userType == UserType.admin;
|
const canEdit = currentUser.userType == UserType.admin;
|
||||||
const isPartner = currentUser.userType == UserType.partner;
|
const isPartner = currentUser.userType == UserType.partner;
|
||||||
const isSodistore = formValues.product === 3 || formValues.product === 4;
|
const isSodistore = formValues.product === 3 || formValues.product === 4 || formValues.product === 5;
|
||||||
|
|
||||||
const [networkProviders, setNetworkProviders] = useState<string[]>([]);
|
const [networkProviders, setNetworkProviders] = useState<string[]>([]);
|
||||||
const [loadingProviders, setLoadingProviders] = useState(false);
|
const [loadingProviders, setLoadingProviders] = useState(false);
|
||||||
|
|
@ -426,12 +426,18 @@ function Information(props: InformationProps) {
|
||||||
label="S3 Bucket Name"
|
label="S3 Bucket Name"
|
||||||
name="s3bucketname"
|
name="s3bucketname"
|
||||||
value={
|
value={
|
||||||
formValues.product === 0 || formValues.product == 3
|
formValues.product === 0 || formValues.product === 3
|
||||||
? formValues.s3BucketId +
|
? formValues.s3BucketId +
|
||||||
'-3e5b3069-214a-43ee-8d85-57d72000c19d'
|
'-3e5b3069-214a-43ee-8d85-57d72000c19d'
|
||||||
: formValues.product == 4
|
: formValues.product === 4
|
||||||
? formValues.s3BucketId +
|
? formValues.s3BucketId +
|
||||||
'-5109c126-e141-43ab-8658-f3c44c838ae8'
|
'-5109c126-e141-43ab-8658-f3c44c838ae8'
|
||||||
|
: formValues.product === 5
|
||||||
|
? formValues.s3BucketId +
|
||||||
|
'-325c9373-9025-4a8d-bf5a-f9eedf1f155c'
|
||||||
|
: formValues.product === 1
|
||||||
|
? formValues.s3BucketId +
|
||||||
|
'-c0436b6a-d276-4cd8-9c44-1eae86cf5d0e'
|
||||||
: formValues.s3BucketId +
|
: formValues.s3BucketId +
|
||||||
'-e7b9a240-3c5d-4d2e-a019-6d8b1f7b73fa'
|
'-e7b9a240-3c5d-4d2e-a019-6d8b1f7b73fa'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -458,6 +458,10 @@ function InstallationTabs(props: InstallationTabsProps) {
|
||||||
<Navigate
|
<Navigate
|
||||||
to={routes.sodistoregrid_installations + routes.list}
|
to={routes.sodistoregrid_installations + routes.list}
|
||||||
/>
|
/>
|
||||||
|
) : props.product === 5 ? (
|
||||||
|
<Navigate
|
||||||
|
to={routes.sodistorepro_installations + routes.list}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Navigate
|
<Navigate
|
||||||
to={routes.sodistore_installations + routes.list}
|
to={routes.sodistore_installations + routes.list}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
const {
|
const {
|
||||||
sodiohomeInstallations,
|
sodiohomeInstallations,
|
||||||
|
sodistoreProInstallations,
|
||||||
fetchAllInstallations,
|
fetchAllInstallations,
|
||||||
socket,
|
socket,
|
||||||
openSocket,
|
openSocket,
|
||||||
|
|
@ -67,6 +68,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
} = useContext(InstallationsContext);
|
} = useContext(InstallationsContext);
|
||||||
const { product, setProduct } = useContext(ProductIdContext);
|
const { product, setProduct } = useContext(ProductIdContext);
|
||||||
const baseRoute = props.product === 5 ? routes.sodistorepro_installations : routes.sodiohome_installations;
|
const baseRoute = props.product === 5 ? routes.sodistorepro_installations : routes.sodiohome_installations;
|
||||||
|
const installations = props.product === 5 ? sodistoreProInstallations : sodiohomeInstallations;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let path = location.pathname.split('/');
|
let path = location.pathname.split('/');
|
||||||
|
|
@ -258,11 +260,11 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
!location.pathname.includes('folder');
|
!location.pathname.includes('folder');
|
||||||
|
|
||||||
// Determine if current installation is Growatt (device=3) to hide report tab
|
// Determine if current installation is Growatt (device=3) to hide report tab
|
||||||
const currentInstallation = sodiohomeInstallations.find((i) =>
|
const currentInstallation = installations.find((i) =>
|
||||||
location.pathname.includes(`/${i.id}/`)
|
location.pathname.includes(`/${i.id}/`)
|
||||||
);
|
);
|
||||||
const isGrowatt = currentInstallation?.device === 3
|
const isGrowatt = currentInstallation?.device === 3
|
||||||
|| (sodiohomeInstallations.length === 1 && sodiohomeInstallations[0].device === 3);
|
|| (installations.length === 1 && installations[0].device === 3);
|
||||||
|
|
||||||
const tabs = inInstallationView && currentUser.userType == UserType.admin
|
const tabs = inInstallationView && currentUser.userType == UserType.admin
|
||||||
? [
|
? [
|
||||||
|
|
@ -434,7 +436,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
return sodiohomeInstallations.length > 1 ? (
|
return installations.length > 1 ? (
|
||||||
<>
|
<>
|
||||||
<AcknowledgementDialog
|
<AcknowledgementDialog
|
||||||
open={showTermsDialog}
|
open={showTermsDialog}
|
||||||
|
|
@ -484,7 +486,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box p={4}>
|
<Box p={4}>
|
||||||
<InstallationSearch
|
<InstallationSearch
|
||||||
installations={sodiohomeInstallations}
|
installations={installations}
|
||||||
product={props.product}
|
product={props.product}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
@ -507,7 +509,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
</Card>
|
</Card>
|
||||||
</Container>
|
</Container>
|
||||||
</>
|
</>
|
||||||
) : sodiohomeInstallations.length === 1 ? (
|
) : installations.length === 1 ? (
|
||||||
<>
|
<>
|
||||||
<AcknowledgementDialog
|
<AcknowledgementDialog
|
||||||
open={showTermsDialog}
|
open={showTermsDialog}
|
||||||
|
|
@ -552,7 +554,7 @@ function SodioHomeInstallationTabs(props: SodioHomeInstallationTabsProps) {
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box p={4}>
|
<Box p={4}>
|
||||||
<SodioHomeInstallation
|
<SodioHomeInstallation
|
||||||
current_installation={sodiohomeInstallations[0]}
|
current_installation={installations[0]}
|
||||||
type="installation"
|
type="installation"
|
||||||
></SodioHomeInstallation>
|
></SodioHomeInstallation>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ const productOptions = [
|
||||||
{ value: 1, label: 'Salidomo' },
|
{ value: 1, label: 'Salidomo' },
|
||||||
{ value: 2, label: 'Sodistore Home' },
|
{ value: 2, label: 'Sodistore Home' },
|
||||||
{ value: 3, label: 'Sodistore Max' },
|
{ value: 3, label: 'Sodistore Max' },
|
||||||
{ value: 4, label: 'Sodistore Grid' }
|
{ value: 4, label: 'Sodistore Grid' },
|
||||||
|
{ value: 5, label: 'Sodistore Pro' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const deviceOptionsByProduct: Record<number, { value: number; label: string }[]> = {
|
const deviceOptionsByProduct: Record<number, { value: number; label: string }[]> = {
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
? routes.salidomo_installations
|
? routes.salidomo_installations
|
||||||
: installation.product == 2
|
: installation.product == 2
|
||||||
? routes.sodiohome_installations
|
? routes.sodiohome_installations
|
||||||
|
: installation.product == 4
|
||||||
|
? routes.sodistoregrid_installations
|
||||||
: installation.product == 5
|
: installation.product == 5
|
||||||
? routes.sodistorepro_installations
|
? routes.sodistorepro_installations
|
||||||
: routes.sodistore_installations;
|
: routes.sodistore_installations;
|
||||||
|
|
@ -71,6 +73,8 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
? routes.salidomo_installations
|
? routes.salidomo_installations
|
||||||
: product == 2
|
: product == 2
|
||||||
? routes.sodiohome_installations
|
? routes.sodiohome_installations
|
||||||
|
: product == 4
|
||||||
|
? routes.sodistoregrid_installations
|
||||||
: product == 5
|
: product == 5
|
||||||
? routes.sodistorepro_installations
|
? routes.sodistorepro_installations
|
||||||
: routes.sodistore_installations;
|
: routes.sodistore_installations;
|
||||||
|
|
@ -213,6 +217,10 @@ function CustomTreeItem(props: CustomTreeItemProps) {
|
||||||
currentLocation.pathname === routes.installations + routes.tree ||
|
currentLocation.pathname === routes.installations + routes.tree ||
|
||||||
currentLocation.pathname ===
|
currentLocation.pathname ===
|
||||||
routes.sodiohome_installations + routes.tree ||
|
routes.sodiohome_installations + routes.tree ||
|
||||||
|
currentLocation.pathname ===
|
||||||
|
routes.sodistoregrid_installations + routes.tree ||
|
||||||
|
currentLocation.pathname ===
|
||||||
|
routes.sodistorepro_installations + routes.tree ||
|
||||||
currentLocation.pathname.includes('folder')
|
currentLocation.pathname.includes('folder')
|
||||||
? 'block'
|
? 'block'
|
||||||
: 'none',
|
: 'none',
|
||||||
|
|
|
||||||
|
|
@ -72,22 +72,24 @@ function userForm(props: userFormProps) {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// fetch product 0
|
const [res0, res1, res2, res3, res4, res5] = await Promise.all([
|
||||||
const res0 = await axiosConfig.get(
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=0`),
|
||||||
`/GetAllInstallationsFromProduct?product=0`
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=1`),
|
||||||
);
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=2`),
|
||||||
const installations0 = res0.data;
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=3`),
|
||||||
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=4`),
|
||||||
|
axiosConfig.get(`/GetAllInstallationsFromProduct?product=5`)
|
||||||
|
]);
|
||||||
|
|
||||||
// fetch product 1
|
const combined = [
|
||||||
const res1 = await axiosConfig.get(
|
...res0.data,
|
||||||
`/GetAllInstallationsFromProduct?product=3`
|
...res1.data,
|
||||||
);
|
...res2.data,
|
||||||
const installations1 = res1.data;
|
...res3.data,
|
||||||
|
...res4.data,
|
||||||
|
...res5.data
|
||||||
|
];
|
||||||
|
|
||||||
// aggregate
|
|
||||||
const combined = [...installations0, ...installations1];
|
|
||||||
|
|
||||||
// update
|
|
||||||
setInstallations(combined);
|
setInstallations(combined);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response && err.response.status === 401) {
|
if (err.response && err.response.status === 401) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ const InstallationsContextProvider = ({
|
||||||
const [sodistoreGridInstallations, setSodistoreGridInstallations] = useState<
|
const [sodistoreGridInstallations, setSodistoreGridInstallations] = useState<
|
||||||
I_Installation[]
|
I_Installation[]
|
||||||
>([]);
|
>([]);
|
||||||
|
const [sodistoreProInstallations, setSodistoreProInstallations] = useState<
|
||||||
|
I_Installation[]
|
||||||
|
>([]);
|
||||||
const [foldersAndInstallations, setFoldersAndInstallations] = useState([]);
|
const [foldersAndInstallations, setFoldersAndInstallations] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
|
@ -105,10 +108,24 @@ const InstallationsContextProvider = ({
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updatedSodistorePro = sodistoreProInstallations.map(
|
||||||
|
(installation) => {
|
||||||
|
const update = pendingUpdates.current[installation.id];
|
||||||
|
return update
|
||||||
|
? {
|
||||||
|
...installation,
|
||||||
|
status: update.status,
|
||||||
|
testingMode: update.testingMode
|
||||||
|
}
|
||||||
|
: installation;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
setSalidomoInstallations(updatedSalidomo);
|
setSalidomoInstallations(updatedSalidomo);
|
||||||
setSalimax_Or_Sodistore_Installations(updatedSalimax);
|
setSalimax_Or_Sodistore_Installations(updatedSalimax);
|
||||||
setSodiohomeInstallations(updatedSodiohome);
|
setSodiohomeInstallations(updatedSodiohome);
|
||||||
setSodistoreGridInstallations(updatedSodistoreGrid);
|
setSodistoreGridInstallations(updatedSodistoreGrid);
|
||||||
|
setSodistoreProInstallations(updatedSodistorePro);
|
||||||
|
|
||||||
// Clear the pending updates after applying
|
// Clear the pending updates after applying
|
||||||
pendingUpdates.current = {};
|
pendingUpdates.current = {};
|
||||||
|
|
@ -116,7 +133,8 @@ const InstallationsContextProvider = ({
|
||||||
salidomoInstallations,
|
salidomoInstallations,
|
||||||
salimax_or_sodistore_Installations,
|
salimax_or_sodistore_Installations,
|
||||||
sodiohomeInstallations,
|
sodiohomeInstallations,
|
||||||
sodistoreGridInstallations
|
sodistoreGridInstallations,
|
||||||
|
sodistoreProInstallations
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -191,8 +209,10 @@ const InstallationsContextProvider = ({
|
||||||
`/GetAllInstallationsFromProduct?product=${product}`
|
`/GetAllInstallationsFromProduct?product=${product}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (product === 2 || product === 5) {
|
if (product === 2) {
|
||||||
setSodiohomeInstallations(res.data);
|
setSodiohomeInstallations(res.data);
|
||||||
|
} else if (product === 5) {
|
||||||
|
setSodistoreProInstallations(res.data);
|
||||||
} else if (product === 1) {
|
} else if (product === 1) {
|
||||||
setSalidomoInstallations(res.data);
|
setSalidomoInstallations(res.data);
|
||||||
} else if (product === 0 || product === 3) {
|
} else if (product === 0 || product === 3) {
|
||||||
|
|
@ -418,6 +438,7 @@ const InstallationsContextProvider = ({
|
||||||
salidomoInstallations,
|
salidomoInstallations,
|
||||||
sodiohomeInstallations,
|
sodiohomeInstallations,
|
||||||
sodistoreGridInstallations,
|
sodistoreGridInstallations,
|
||||||
|
sodistoreProInstallations,
|
||||||
foldersAndInstallations,
|
foldersAndInstallations,
|
||||||
fetchAllInstallations,
|
fetchAllInstallations,
|
||||||
fetchAllFoldersAndInstallations,
|
fetchAllFoldersAndInstallations,
|
||||||
|
|
@ -445,6 +466,7 @@ const InstallationsContextProvider = ({
|
||||||
salidomoInstallations,
|
salidomoInstallations,
|
||||||
sodiohomeInstallations,
|
sodiohomeInstallations,
|
||||||
sodistoreGridInstallations,
|
sodistoreGridInstallations,
|
||||||
|
sodistoreProInstallations,
|
||||||
foldersAndInstallations,
|
foldersAndInstallations,
|
||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue