mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw-ui.git
synced 2025-11-02 11:47:54 +00:00
[WIFI-12285] Add support for FMS database refreshes
Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ export const useGetAvailableFirmware = ({ deviceType }: { deviceType: string })
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
|
||||
return useQuery(['firmware'], () => getAllAvailableFirmware(deviceType), {
|
||||
return useQuery(['get-device-profile'], () => getAllAvailableFirmware(deviceType), {
|
||||
enabled: deviceType !== '',
|
||||
onError: (e: AxiosError) => {
|
||||
if (!toast.isActive('firmware-fetching-error'))
|
||||
@@ -242,3 +242,23 @@ export const useGetFirmwareDashboard = () =>
|
||||
keepPreviousData: true,
|
||||
refetchInterval: 30000,
|
||||
});
|
||||
|
||||
const getLastDbUpdate = async () =>
|
||||
axiosFms.get(`firmwares?updateTimeOnly=true`).then((response) => response.data as { lastUpdateTime: number });
|
||||
export const useGetFirmwareDbUpdate = () =>
|
||||
useQuery(['firmware', 'db'], getLastDbUpdate, {
|
||||
keepPreviousData: true,
|
||||
staleTime: 30 * 1000,
|
||||
});
|
||||
|
||||
const updateDb = async () => axiosFms.put(`firmwares?update=true`);
|
||||
|
||||
export const useUpdateFirmwareDb = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(updateDb, {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(['firmware', 'db']);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user