mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(home): move edge device to view [EE-4559] (#8189)
Co-authored-by: matias.spinarolli <matias.spinarolli@portainer.io>
This commit is contained in:
parent
b4a6f6911c
commit
7fe0712b61
72 changed files with 988 additions and 1593 deletions
|
@ -0,0 +1,22 @@
|
|||
import { useMutation } from 'react-query';
|
||||
|
||||
import { promiseSequence } from '@/portainer/helpers/promise-utils';
|
||||
import { mutationOptions, withError } from '@/react-tools/react-query';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
|
||||
export function useActivateDevicesMutation() {
|
||||
return useMutation(
|
||||
(environmentIds: EnvironmentId[]) =>
|
||||
promiseSequence(environmentIds.map((id) => () => activateDevice(id))),
|
||||
mutationOptions(withError('Unable to associate with OpenAMT'))
|
||||
);
|
||||
}
|
||||
|
||||
async function activateDevice(environmentId: EnvironmentId) {
|
||||
try {
|
||||
await axios.post(`/open_amt/${environmentId}/activate`);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error, 'Unable to activate device');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue