2022-11-13 10:29:25 +00:00
|
|
|
import * as notifications from '@/portainer/services/notifications';
|
|
|
|
import { EnvironmentId } from '@/react/portainer/environments/types';
|
|
|
|
import { Job } from '@/react/nomad/types';
|
2022-11-22 12:16:34 +00:00
|
|
|
import { deleteJob } from '@/react/nomad/jobs/jobs.service';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
export async function deleteJobs(environmentID: EnvironmentId, jobs: Job[]) {
|
|
|
|
return Promise.all(
|
|
|
|
jobs.map(async (job) => {
|
|
|
|
try {
|
|
|
|
await deleteJob(environmentID, job.ID, job.Namespace);
|
|
|
|
notifications.success('Job successfully removed', job.ID);
|
|
|
|
} catch (err) {
|
|
|
|
notifications.error(
|
|
|
|
'Failure',
|
|
|
|
err as Error,
|
|
|
|
`Failed to delete job ${job.ID}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|