mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov-ui.git
synced 2025-11-01 19:17:50 +00:00
Merge pull request #192 from stephb9959/main
[WIFI-13245] Channel picker fix
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "wlan-cloud-owprov-ui",
|
||||
"version": "3.0.0(2)",
|
||||
"version": "3.0.0(4)",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wlan-cloud-owprov-ui",
|
||||
"version": "3.0.0(2)",
|
||||
"version": "3.0.0(4)",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@chakra-ui/anatomy": "^2.1.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "wlan-cloud-owprov-ui",
|
||||
"version": "3.0.0(2)",
|
||||
"version": "3.0.0(4)",
|
||||
"description": "",
|
||||
"main": "index.tsx",
|
||||
"scripts": {
|
||||
|
||||
@@ -56,26 +56,73 @@ export const useUpdateDeviceFirmware = ({ serialNumber, onClose }: { serialNumbe
|
||||
const toast = useToast();
|
||||
|
||||
return useMutation(
|
||||
({ keepRedirector, uri }: { keepRedirector: boolean; uri: string }) =>
|
||||
axiosGw.post(`device/${serialNumber}/upgrade`, { serialNumber, when: 0, keepRedirector, uri }),
|
||||
({ keepRedirector, uri, signature }: { keepRedirector: boolean; uri: string; signature?: string }) =>
|
||||
axiosGw
|
||||
.post(`device/${serialNumber}/upgrade${signature ? `?FWsignature=${signature}` : ''}`, {
|
||||
serialNumber,
|
||||
when: 0,
|
||||
keepRedirector,
|
||||
uri,
|
||||
signature,
|
||||
})
|
||||
.then(
|
||||
(response) =>
|
||||
response as {
|
||||
data: {
|
||||
errorCode: number;
|
||||
errorText: string;
|
||||
status: string;
|
||||
results?: {
|
||||
status?: {
|
||||
error?: number;
|
||||
resultCode?: number;
|
||||
text?: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
},
|
||||
),
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast({
|
||||
id: `device-upgrade-success-${uuid()}`,
|
||||
title: t('common.success'),
|
||||
description: t('commands.upgrade_success'),
|
||||
status: 'success',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
onClose();
|
||||
onSuccess: ({ data }) => {
|
||||
if (data.errorCode === 0) {
|
||||
toast({
|
||||
id: `device-upgrade-success-${uuid()}`,
|
||||
title: t('common.success'),
|
||||
description: t('commands.firmware_upgrade_success'),
|
||||
status: 'success',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
onClose();
|
||||
} else if (data.errorCode === 1) {
|
||||
toast({
|
||||
id: `device-upgrade-warning-${uuid()}`,
|
||||
title: 'Warning',
|
||||
description: `${data?.errorText ?? 'Unknown Warning'}`,
|
||||
status: 'warning',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
onClose();
|
||||
} else {
|
||||
toast({
|
||||
id: `device-upgrade-error-${uuid()}`,
|
||||
title: t('common.error'),
|
||||
description: `${data?.errorText ?? 'Unknown Error'} (Err. ${data.errorCode})`,
|
||||
status: 'error',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
}
|
||||
},
|
||||
onError: (e: AxiosError) => {
|
||||
toast({
|
||||
id: uuid(),
|
||||
title: t('common.error'),
|
||||
description: t('commands.upgrade_error', {
|
||||
description: t('commands.firmware_upgrade_error', {
|
||||
e: e?.response?.data?.ErrorDescription,
|
||||
}),
|
||||
status: 'error',
|
||||
|
||||
@@ -142,7 +142,9 @@ const ChannelPicker = ({ namePrefix, isDisabled }: Props) => {
|
||||
|
||||
options.sort((a, b) => a.toString().localeCompare(b.toString(), 'en', { numeric: true }));
|
||||
|
||||
if (channel !== 'auto' && !options.includes(parseInt(channel, 10))) {
|
||||
if (Number.isNaN(channel)) {
|
||||
onChannelChange('auto');
|
||||
} else if (channel !== 'auto' && !options.includes(parseInt(channel, 10))) {
|
||||
onChannelChange(options[0]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user