mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 22:03:44 +02:00
Finish building out schedule management functionality
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { rawDataToServerSchedule, Schedule } from '@/api/server/schedules/getServerSchedules';
|
||||
import http from '@/api/http';
|
||||
|
||||
type Data = Pick<Schedule, 'cron' | 'name' | 'isActive'> & { id?: number }
|
||||
|
||||
export default (uuid: string, schedule: Data): Promise<Schedule> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post(`/api/client/servers/${uuid}/schedules${schedule.id ? `/${schedule.id}` : ''}`, {
|
||||
is_active: schedule.isActive,
|
||||
name: schedule.name,
|
||||
minute: schedule.cron.minute,
|
||||
hour: schedule.cron.hour,
|
||||
day_of_month: schedule.cron.dayOfMonth,
|
||||
day_of_week: schedule.cron.dayOfWeek,
|
||||
})
|
||||
.then(({ data }) => resolve(rawDataToServerSchedule(data.attributes)))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
9
resources/scripts/api/server/schedules/deleteSchedule.ts
Normal file
9
resources/scripts/api/server/schedules/deleteSchedule.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import http from '@/api/http';
|
||||
|
||||
export default (uuid: string, schedule: number): Promise<void> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.delete(`/api/client/servers/${uuid}/schedules/${schedule}`)
|
||||
.then(() => resolve())
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user