1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(edge/jobs): migrate create view to react [EE-2221] (#11867)

This commit is contained in:
Chaim Lev-Ari 2024-06-02 11:10:38 +03:00 committed by GitHub
parent 94c91035a7
commit 02fbdfec36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 777 additions and 163 deletions

View file

@ -0,0 +1,39 @@
import axios, {
json2formData,
parseAxiosError,
} from '@/portainer/services/axios';
import { EdgeGroup } from '@/react/edge/edge-groups/types';
import { EnvironmentId } from '@/react/portainer/environments/types';
import { EdgeJob } from '../../types';
import { buildUrl } from '../build-url';
/**
* Payload to create an EdgeJob from a file
*/
export type FileUploadPayload = {
Name: string;
CronExpression: string;
Recurring: boolean;
EdgeGroups: Array<EdgeGroup['Id']>;
Endpoints: Array<EnvironmentId>;
File: File;
};
export async function createJobFromFile(payload: FileUploadPayload) {
try {
const { data } = await axios.post<EdgeJob>(
buildUrl({ action: 'create/file' }),
json2formData(payload),
{
headers: {
'Content-Type': 'multipart/form-data',
},
}
);
return data;
} catch (e) {
throw parseAxiosError(e as Error);
}
}