[WIFI-12612] Add support for connectReason

Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
Charles
2023-05-17 10:10:32 +02:00
parent e6307648da
commit cafb950aa7
5 changed files with 41 additions and 5 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ucentral-client",
"version": "2.10.0(40)",
"version": "2.10.0(41)",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ucentral-client",
"version": "2.10.0(40)",
"version": "2.10.0(41)",
"license": "ISC",
"dependencies": {
"@chakra-ui/icons": "^2.0.18",

View File

@@ -1,6 +1,6 @@
{
"name": "ucentral-client",
"version": "2.10.0(40)",
"version": "2.10.0(41)",
"description": "",
"private": true,
"main": "index.tsx",

View File

@@ -44,6 +44,7 @@ export type DeviceWithStatus = {
associations_6G: number;
compatible: string;
connected: boolean;
connectReason?: string;
certificateExpiryDate?: number;
createdTimestamp: number;
devicePassword: string;
@@ -82,6 +83,18 @@ export type DeviceWithStatus = {
verifiedCertificate: string;
};
export const getSingleDeviceWithStatus = (serialNumber: string) =>
axiosGw
.get(`devices?deviceWithStatus=true&select=${serialNumber}`)
.then((response) => {
const deviceWithStatus: DeviceWithStatus | undefined = response.data.devicesWithStatus[0];
if (deviceWithStatus === undefined) {
return undefined;
}
return deviceWithStatus;
})
.catch(() => undefined);
const getDevices = (limit: number, offset: number) =>
axiosGw
.get(`devices?deviceWithStatus=true&limit=${limit}&offset=${offset}`)
@@ -136,6 +149,7 @@ export type DeviceStatus = {
associations_2G: number;
associations_5G: number;
connected: boolean;
connectReason?: string;
certificateExpiryDate: number;
connectionCompletionTime: number;
firmware: string;

View File

@@ -171,6 +171,14 @@ const DeviceSummary = ({ serialNumber }: Props) => {
<FormattedDate date={getStatus.data?.certificateExpiryDate} hidePrefix />
)}
</GridItem>
<GridItem colSpan={1} alignContent="center" alignItems="center">
<Heading size="sm">Connect Reason:</Heading>
</GridItem>
<GridItem colSpan={1}>
{getStatus.data?.connectReason && getStatus.data?.connectReason.length > 0
? getStatus.data?.connectReason
: '-'}
</GridItem>
</Grid>
</Flex>
</CardBody>

View File

@@ -104,6 +104,7 @@ const DeviceListCard = () => {
'2G',
'5G',
'6G',
'connectReason',
'certificateExpiryDate',
'actions',
],
@@ -648,6 +649,19 @@ const DeviceListCard = () => {
},
},
},
{
id: 'connectReason',
header: 'Connect Reason',
footer: '',
accessorKey: 'connectReason',
cell: (v) => (v.cell.row.original.connectReason ? v.cell.row.original.connectReason : '-'),
enableSorting: false,
meta: {
headerOptions: {
tooltip: 'Reason supplied by the device for the last connection',
},
},
},
{
id: 'certificateExpiryDate',
header: 'Exp',
@@ -689,7 +703,7 @@ const DeviceListCard = () => {
}, [getAges, getDevices.data, getDevices.dataUpdatedAt]);
return (
<>
<Box>
<DataGrid<DeviceWithStatus>
controller={tableController}
header={{
@@ -723,7 +737,7 @@ const DeviceListCard = () => {
<TelemetryModal modalProps={telemetryModalProps} serialNumber={serialNumber} />
<RebootModal modalProps={rebootModalProps} serialNumber={serialNumber} />
{scriptModal.modal}
</>
</Box>
);
};