Fixed frontend to load data from S3 only when the overview tab is open.
Fixed information update
This commit is contained in:
parent
62b0efb67f
commit
f1cad8d69a
|
@ -133,7 +133,10 @@ function Installation(props: singleInstallationProps) {
|
||||||
const s3Credentials = { s3Bucket, ...S3data };
|
const s3Credentials = { s3Bucket, ...S3data };
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (installationId == props.current_installation.id) {
|
if (
|
||||||
|
installationId == props.current_installation.id &&
|
||||||
|
(currentTab == 'live' || currentTab == 'configuration')
|
||||||
|
) {
|
||||||
let isMounted = true;
|
let isMounted = true;
|
||||||
setFormValues(props.current_installation);
|
setFormValues(props.current_installation);
|
||||||
setErrorLoadingS3Data(false);
|
setErrorLoadingS3Data(false);
|
||||||
|
@ -193,7 +196,7 @@ function Installation(props: singleInstallationProps) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [installationId]);
|
}, [installationId, currentTab]);
|
||||||
|
|
||||||
if (installationId == props.current_installation.id) {
|
if (installationId == props.current_installation.id) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -27,10 +27,11 @@ function InstallationTabs() {
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(location.search);
|
const searchParams = new URLSearchParams(location.search);
|
||||||
const installationId = parseInt(searchParams.get('installation'));
|
const installationId = parseInt(searchParams.get('installation'));
|
||||||
|
//const currentTab = searchParams.get('tab');
|
||||||
const [singleInstallationID, setSingleInstallationID] = useState(-1);
|
const [singleInstallationID, setSingleInstallationID] = useState(-1);
|
||||||
const context = useContext(UserContext);
|
const context = useContext(UserContext);
|
||||||
const { currentUser, setUser } = context;
|
const { currentUser, setUser } = context;
|
||||||
const [currentTab, setCurrentTab] = useState<string>('list');
|
const [currentTab, setCurrentTab] = useState<string>(searchParams.get('tab'));
|
||||||
const { installations, fetchAllInstallations } =
|
const { installations, fetchAllInstallations } =
|
||||||
useContext(InstallationsContext);
|
useContext(InstallationsContext);
|
||||||
|
|
||||||
|
@ -49,10 +50,16 @@ function InstallationTabs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installations.length === 1) {
|
if (installations.length === 1) {
|
||||||
navigate(`list?installation=${installations[0].id}&tab=live`, {
|
if (!currentTab) {
|
||||||
replace: true
|
navigate(`?installation=${installationId}&tab=live`, {
|
||||||
});
|
replace: true
|
||||||
setCurrentTab('live');
|
});
|
||||||
|
setCurrentTab('live');
|
||||||
|
} else {
|
||||||
|
navigate(`?installation=${installationId}&tab=${currentTab}`, {
|
||||||
|
replace: true
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
location.pathname === '/installations' ||
|
location.pathname === '/installations' ||
|
||||||
|
@ -61,17 +68,29 @@ function InstallationTabs() {
|
||||||
navigate(routes.installations + routes.list, {
|
navigate(routes.installations + routes.list, {
|
||||||
replace: true
|
replace: true
|
||||||
});
|
});
|
||||||
} else if (location.pathname === '/installations/tree/') {
|
} else if (
|
||||||
|
location.pathname === '/installations/tree/' &&
|
||||||
|
!installationId
|
||||||
|
) {
|
||||||
setCurrentTab('tree');
|
setCurrentTab('tree');
|
||||||
} else if (location.pathname === '/installations/list/') {
|
} else if (
|
||||||
|
location.pathname === '/installations/list/' &&
|
||||||
|
!installationId
|
||||||
|
) {
|
||||||
setCurrentTab('list');
|
setCurrentTab('list');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (installationId) {
|
if (installationId) {
|
||||||
navigate(`?installation=${installationId}&tab=live`, {
|
if (currentTab == 'list' || currentTab == 'tree') {
|
||||||
replace: true
|
navigate(`?installation=${installationId}&tab=live`, {
|
||||||
});
|
replace: true
|
||||||
setCurrentTab('live');
|
});
|
||||||
|
setCurrentTab('live');
|
||||||
|
} else {
|
||||||
|
navigate(`?installation=${installationId}&tab=${currentTab}`, {
|
||||||
|
replace: true
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [location.pathname, navigate, installationId, installations]);
|
}, [location.pathname, navigate, installationId, installations]);
|
||||||
|
|
|
@ -29,9 +29,10 @@ function installationForm(props: installationFormProps) {
|
||||||
region: '',
|
region: '',
|
||||||
location: '',
|
location: '',
|
||||||
country: '',
|
country: '',
|
||||||
|
vpnIp: '',
|
||||||
orderNumbers: ''
|
orderNumbers: ''
|
||||||
});
|
});
|
||||||
const requiredFields = ['name', 'region', 'location', 'country'];
|
const requiredFields = ['name', 'region', 'location', 'country', 'vpnIp'];
|
||||||
const tokencontext = useContext(TokenContext);
|
const tokencontext = useContext(TokenContext);
|
||||||
const { removeToken } = tokencontext;
|
const { removeToken } = tokencontext;
|
||||||
|
|
||||||
|
@ -151,6 +152,18 @@ function installationForm(props: installationFormProps) {
|
||||||
error={formValues.country === ''}
|
error={formValues.country === ''}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
label={<FormattedMessage id="VpnIp" defaultMessage="VpnIp" />}
|
||||||
|
name="VpnIp"
|
||||||
|
value={formValues.vpnIp}
|
||||||
|
onChange={handleChange}
|
||||||
|
fullWidth
|
||||||
|
required
|
||||||
|
error={formValues.vpnIp === ''}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<TextField
|
<TextField
|
||||||
label={
|
label={
|
||||||
|
|
|
@ -117,7 +117,7 @@ function Overview(props: OverviewProps) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(input);
|
//console.log(input);
|
||||||
input.forEach((item) => {
|
input.forEach((item) => {
|
||||||
const csvContent = item.value;
|
const csvContent = item.value;
|
||||||
pathsToSearch.forEach((path) => {
|
pathsToSearch.forEach((path) => {
|
||||||
|
|
|
@ -44,7 +44,7 @@ const WebSocketContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
if (socket.readyState === WebSocket.OPEN) {
|
if (socket.readyState === WebSocket.OPEN) {
|
||||||
socket.send(JSON.stringify([-1]));
|
socket.send(JSON.stringify([-1]));
|
||||||
}
|
}
|
||||||
}, 10000); // Send a ping every 5 seconds
|
}, 10000); // Send a ping every 10 seconds
|
||||||
|
|
||||||
// Listen for messages
|
// Listen for messages
|
||||||
socket.addEventListener('message', (event) => {
|
socket.addEventListener('message', (event) => {
|
||||||
|
@ -54,7 +54,7 @@ const WebSocketContextProvider = ({ children }: { children: ReactNode }) => {
|
||||||
const installation_id = message.id;
|
const installation_id = message.id;
|
||||||
const status = message.status;
|
const status = message.status;
|
||||||
|
|
||||||
console.log('Message from server ', installation_id, status);
|
//console.log('Message from server ', installation_id, status);
|
||||||
|
|
||||||
setInstallationStatus((prevStatus) => {
|
setInstallationStatus((prevStatus) => {
|
||||||
// Create a new object by spreading the previous state
|
// Create a new object by spreading the previous state
|
||||||
|
|
Loading…
Reference in New Issue