mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov-ui.git
synced 2025-11-02 11:38:06 +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",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "wlan-cloud-owprov-ui",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/anatomy": "^2.1.1",
|
"@chakra-ui/anatomy": "^2.1.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wlan-cloud-owprov-ui",
|
"name": "wlan-cloud-owprov-ui",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.tsx",
|
"main": "index.tsx",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -56,26 +56,73 @@ export const useUpdateDeviceFirmware = ({ serialNumber, onClose }: { serialNumbe
|
|||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
({ keepRedirector, uri }: { keepRedirector: boolean; uri: string }) =>
|
({ keepRedirector, uri, signature }: { keepRedirector: boolean; uri: string; signature?: string }) =>
|
||||||
axiosGw.post(`device/${serialNumber}/upgrade`, { serialNumber, when: 0, keepRedirector, uri }),
|
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: () => {
|
onSuccess: ({ data }) => {
|
||||||
toast({
|
if (data.errorCode === 0) {
|
||||||
id: `device-upgrade-success-${uuid()}`,
|
toast({
|
||||||
title: t('common.success'),
|
id: `device-upgrade-success-${uuid()}`,
|
||||||
description: t('commands.upgrade_success'),
|
title: t('common.success'),
|
||||||
status: 'success',
|
description: t('commands.firmware_upgrade_success'),
|
||||||
duration: 5000,
|
status: 'success',
|
||||||
isClosable: true,
|
duration: 5000,
|
||||||
position: 'top-right',
|
isClosable: true,
|
||||||
});
|
position: 'top-right',
|
||||||
onClose();
|
});
|
||||||
|
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) => {
|
onError: (e: AxiosError) => {
|
||||||
toast({
|
toast({
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
title: t('common.error'),
|
title: t('common.error'),
|
||||||
description: t('commands.upgrade_error', {
|
description: t('commands.firmware_upgrade_error', {
|
||||||
e: e?.response?.data?.ErrorDescription,
|
e: e?.response?.data?.ErrorDescription,
|
||||||
}),
|
}),
|
||||||
status: 'error',
|
status: 'error',
|
||||||
|
|||||||
@@ -142,7 +142,9 @@ const ChannelPicker = ({ namePrefix, isDisabled }: Props) => {
|
|||||||
|
|
||||||
options.sort((a, b) => a.toString().localeCompare(b.toString(), 'en', { numeric: true }));
|
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]);
|
onChannelChange(options[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user