mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw-ui.git
synced 2025-11-02 11:47:54 +00:00
Prettier run
This commit is contained in:
@@ -13,7 +13,9 @@ const loading = (
|
|||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const storageToken = sessionStorage.getItem('access_token');
|
const storageToken = sessionStorage.getItem('access_token');
|
||||||
const apiEndpoints = checkIfJson(sessionStorage.getItem('gateway_endpoints')) ? JSON.parse(sessionStorage.getItem('gateway_endpoints')) : {};
|
const apiEndpoints = checkIfJson(sessionStorage.getItem('gateway_endpoints'))
|
||||||
|
? JSON.parse(sessionStorage.getItem('gateway_endpoints'))
|
||||||
|
: {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthProvider token={storageToken ?? ''} apiEndpoints={apiEndpoints}>
|
<AuthProvider token={storageToken ?? ''} apiEndpoints={apiEndpoints}>
|
||||||
|
|||||||
@@ -73,7 +73,11 @@ const BlinkModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/leds`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/leds`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setResult('success');
|
setResult('success');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ const DeviceCommands = () => {
|
|||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(
|
.get(
|
||||||
`${endpoints.ucentralgw}/api/v1/commands?serialNumber=${encodeURIComponent(deviceSerialNumber)}${extraParams}`,
|
`${endpoints.ucentralgw}/api/v1/commands?serialNumber=${encodeURIComponent(
|
||||||
|
deviceSerialNumber,
|
||||||
|
)}${extraParams}`,
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@@ -133,7 +135,10 @@ const DeviceCommands = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/file/${uuid}?serialNumber=${deviceSerialNumber}`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/file/${uuid}?serialNumber=${deviceSerialNumber}`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const blob = new Blob([response.data], { type: 'application/octet-stream' });
|
const blob = new Blob([response.data], { type: 'application/octet-stream' });
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
|||||||
@@ -84,7 +84,11 @@ const ConfigureModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/configure`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/configure`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setHadSuccess(true);
|
setHadSuccess(true);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ const DeviceActions = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/rtty`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/rtty`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const url = `https://${response.data.server}:${response.data.viewport}/connect/${response.data.connectionId}`;
|
const url = `https://${response.data.server}:${response.data.viewport}/connect/${response.data.connectionId}`;
|
||||||
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ const DeviceConfiguration = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setDevice(response.data);
|
setDevice(response.data);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -87,7 +87,12 @@ const DeviceHealth = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/healthchecks${extraParams}`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(
|
||||||
|
deviceSerialNumber,
|
||||||
|
)}/healthchecks${extraParams}`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setHealthChecks(response.data.values);
|
setHealthChecks(response.data.values);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -96,9 +96,14 @@ const DeviceList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/devices?deviceWithStatus=true&select=${encodeURIComponent(serialNumber)}`, {
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/devices?deviceWithStatus=true&select=${encodeURIComponent(
|
||||||
|
serialNumber,
|
||||||
|
)}`,
|
||||||
|
{
|
||||||
headers,
|
headers,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const device = response.data.devicesWithStatus[0];
|
const device = response.data.devicesWithStatus[0];
|
||||||
const foundIndex = devices.findIndex((obj) => obj.serialNumber === serialNumber);
|
const foundIndex = devices.findIndex((obj) => obj.serialNumber === serialNumber);
|
||||||
|
|||||||
@@ -84,7 +84,12 @@ const DeviceLogs = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/logs${extraParams}`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(
|
||||||
|
deviceSerialNumber,
|
||||||
|
)}/logs${extraParams}`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setLogs(response.data.values);
|
setLogs(response.data.values);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ const DeviceStatusCard = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const lastStatsRequest = axiosInstance.get(
|
const lastStatsRequest = axiosInstance.get(
|
||||||
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/statistics?lastOnly=true`,
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(
|
||||||
|
deviceSerialNumber,
|
||||||
|
)}/statistics?lastOnly=true`,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
const statusRequest = axiosInstance.get(
|
const statusRequest = axiosInstance.get(
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ const ConfigureModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/factory`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/factory`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setHadSuccess(true);
|
setHadSuccess(true);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ const UpgradeWaitingBody = ({ serialNumber }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(serialNumber)}/status`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(serialNumber)}/status`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => response.data.connected)
|
.then((response) => response.data.connected)
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,7 +84,11 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (deviceSerialNumber !== null && show) {
|
if (deviceSerialNumber !== null && show) {
|
||||||
const asyncGet = async () => {
|
const asyncGet = async () => {
|
||||||
const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken, endpoints.ucentralgw);
|
const isConnected = await getDeviceConnection(
|
||||||
|
deviceSerialNumber,
|
||||||
|
currentToken,
|
||||||
|
endpoints.ucentralgw,
|
||||||
|
);
|
||||||
setDisableWaiting(!isConnected);
|
setDisableWaiting(!isConnected);
|
||||||
setDeviceConnected(isConnected);
|
setDeviceConnected(isConnected);
|
||||||
};
|
};
|
||||||
@@ -108,7 +112,11 @@ const FirmwareUpgradeModal = ({ show, toggleModal }) => {
|
|||||||
uri: firmware,
|
uri: firmware,
|
||||||
};
|
};
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/upgrade`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/upgrade`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (waitForUpgrade) {
|
if (waitForUpgrade) {
|
||||||
setShowWaitingConsole(true);
|
setShowWaitingConsole(true);
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ const LatestStatisticsModal = ({ show, toggle }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?lastOnly=true`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?lastOnly=true`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setLatestStats(response.data);
|
setLatestStats(response.data);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -128,7 +128,10 @@ const StatisticsChartList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?newest=true&limit=50`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${deviceSerialNumber}/statistics?newest=true&limit=50`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
transformIntoDataset(response.data.data);
|
transformIntoDataset(response.data.data);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -66,7 +66,11 @@ const ActionModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/reboot`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/reboot`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setResult('success');
|
setResult('success');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ const WaitingForTraceBody = ({ serialNumber, commandUuid, toggle }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.get(`${endpoints.ucentralgw}/api/v1/file/${commandUuid}?serialNumber=${serialNumber}`, options)
|
.get(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/file/${commandUuid}?serialNumber=${serialNumber}`,
|
||||||
|
options,
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const blob = new Blob([response.data], { type: 'application/octet-stream' });
|
const blob = new Blob([response.data], { type: 'application/octet-stream' });
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
|||||||
@@ -83,7 +83,11 @@ const TraceModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/trace`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/trace`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setHadSuccess(true);
|
setHadSuccess(true);
|
||||||
if (waitForTrace) {
|
if (waitForTrace) {
|
||||||
@@ -105,7 +109,11 @@ const TraceModal = ({ show, toggleModal }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (deviceSerialNumber !== null && show) {
|
if (deviceSerialNumber !== null && show) {
|
||||||
const asyncGet = async () => {
|
const asyncGet = async () => {
|
||||||
const isConnected = await getDeviceConnection(deviceSerialNumber, currentToken, endpoints.ucentralgw);
|
const isConnected = await getDeviceConnection(
|
||||||
|
deviceSerialNumber,
|
||||||
|
currentToken,
|
||||||
|
endpoints.ucentralgw,
|
||||||
|
);
|
||||||
setIsDeviceConnected(isConnected);
|
setIsDeviceConnected(isConnected);
|
||||||
};
|
};
|
||||||
asyncGet();
|
asyncGet();
|
||||||
|
|||||||
@@ -100,7 +100,11 @@ const WifiScanModal = ({ show, toggleModal }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
axiosInstance
|
axiosInstance
|
||||||
.post(`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/wifiscan`, parameters, { headers })
|
.post(
|
||||||
|
`${endpoints.ucentralgw}/api/v1/device/${encodeURIComponent(deviceSerialNumber)}/wifiscan`,
|
||||||
|
parameters,
|
||||||
|
{ headers },
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const scanList = response?.data?.results?.status?.scan;
|
const scanList = response?.data?.results?.status?.scan;
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ export const AuthProvider = ({ token, apiEndpoints, children }) => {
|
|||||||
AuthProvider.propTypes = {
|
AuthProvider.propTypes = {
|
||||||
token: PropTypes.string.isRequired,
|
token: PropTypes.string.isRequired,
|
||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
apiEndpoints: PropTypes.instanceOf(Object)
|
apiEndpoints: PropTypes.instanceOf(Object),
|
||||||
};
|
};
|
||||||
|
|
||||||
AuthProvider.defaultProps = {
|
AuthProvider.defaultProps = {
|
||||||
apiEndpoints: {}
|
apiEndpoints: {},
|
||||||
}
|
};
|
||||||
|
|
||||||
export const useAuth = () => React.useContext(AuthContext);
|
export const useAuth = () => React.useContext(AuthContext);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { useAuth } from 'contexts/AuthProvider';
|
|||||||
|
|
||||||
const TheHeader = ({ showSidebar, setShowSidebar }) => {
|
const TheHeader = ({ showSidebar, setShowSidebar }) => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const { currentToken, endpoints} = useAuth();
|
const { currentToken, endpoints } = useAuth();
|
||||||
const [translatedRoutes, setTranslatedRoutes] = useState(routes);
|
const [translatedRoutes, setTranslatedRoutes] = useState(routes);
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
@@ -54,7 +54,12 @@ const TheHeader = ({ showSidebar, setShowSidebar }) => {
|
|||||||
<CHeaderNav className="px-3">
|
<CHeaderNav className="px-3">
|
||||||
<CPopover content={t('common.logout')}>
|
<CPopover content={t('common.logout')}>
|
||||||
<CLink className="c-subheader-nav-link">
|
<CLink className="c-subheader-nav-link">
|
||||||
<CIcon name="cilAccountLogout" content={cilAccountLogout} size="2xl" onClick={() => logout(currentToken, endpoints.ucentralsec)} />
|
<CIcon
|
||||||
|
name="cilAccountLogout"
|
||||||
|
content={cilAccountLogout}
|
||||||
|
size="2xl"
|
||||||
|
onClick={() => logout(currentToken, endpoints.ucentralsec)}
|
||||||
|
/>
|
||||||
</CLink>
|
</CLink>
|
||||||
</CPopover>
|
</CPopover>
|
||||||
</CHeaderNav>
|
</CHeaderNav>
|
||||||
|
|||||||
@@ -89,16 +89,18 @@ const Login = () => {
|
|||||||
.then((response) => {
|
.then((response) => {
|
||||||
sessionStorage.setItem('access_token', response.data.access_token);
|
sessionStorage.setItem('access_token', response.data.access_token);
|
||||||
token = response.data.access_token;
|
token = response.data.access_token;
|
||||||
return axiosInstance.get(`${finalUCentralSecUrl}/api/v1/systemEndpoints`, { headers: {
|
return axiosInstance.get(`${finalUCentralSecUrl}/api/v1/systemEndpoints`, {
|
||||||
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
Authorization: `Bearer ${response.data.access_token}`,
|
Authorization: `Bearer ${response.data.access_token}`,
|
||||||
}});
|
},
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then ((response) => {
|
.then((response) => {
|
||||||
const endpoints = {
|
const endpoints = {
|
||||||
ucentralsec: finalUCentralSecUrl
|
ucentralsec: finalUCentralSecUrl,
|
||||||
};
|
};
|
||||||
for (const endpoint of response.data.endpoints){
|
for (const endpoint of response.data.endpoints) {
|
||||||
endpoints[endpoint.type] = endpoint.uri;
|
endpoints[endpoint.type] = endpoint.uri;
|
||||||
}
|
}
|
||||||
sessionStorage.setItem('gateway_endpoints', JSON.stringify(endpoints));
|
sessionStorage.setItem('gateway_endpoints', JSON.stringify(endpoints));
|
||||||
|
|||||||
@@ -12,7 +12,13 @@ const Routes = () => {
|
|||||||
<Route
|
<Route
|
||||||
path="/"
|
path="/"
|
||||||
name="Devices"
|
name="Devices"
|
||||||
render={(props) => (currentToken !== '' && Object.keys(endpoints).length !== 0 ? <TheLayout {...props} /> : <Login {...props} />)}
|
render={(props) =>
|
||||||
|
currentToken !== '' && Object.keys(endpoints).length !== 0 ? (
|
||||||
|
<TheLayout {...props} />
|
||||||
|
) : (
|
||||||
|
<Login {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import axiosInstance from "./axiosInstance";
|
import axiosInstance from './axiosInstance';
|
||||||
|
|
||||||
export const logout = (token, endpoint) => {
|
export const logout = (token, endpoint) => {
|
||||||
axiosInstance
|
axiosInstance
|
||||||
@@ -13,7 +13,7 @@ export const logout = (token, endpoint) => {
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
window.location.replace('/');
|
window.location.replace('/');
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getToken = () => {
|
export const getToken = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user