add: 添加每月最后一天调度
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
formatBytes,
|
||||
formatSpeed,
|
||||
formatDuration,
|
||||
} from "../state.js?v=recurring-jobs-5";
|
||||
import { t } from "../i18n.js?v=recurring-jobs-5";
|
||||
} from "../state.js?v=monthly-last-day-1";
|
||||
import { t } from "../i18n.js?v=monthly-last-day-1";
|
||||
import {
|
||||
createRecurringJob,
|
||||
deleteRecurringJob,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
listRecurringJobs,
|
||||
runRecurringJobNow,
|
||||
stopRecurringJob,
|
||||
} from "../jobs_api.js?v=recurring-jobs-5";
|
||||
} from "../jobs_api.js?v=monthly-last-day-1";
|
||||
|
||||
let pollTimer = null;
|
||||
const WEBGUI_JOB_GROUP_PREFIX = "webgui/transfer";
|
||||
@@ -276,10 +276,12 @@ function renderWeekdayOptions() {
|
||||
}
|
||||
|
||||
function renderMonthdayOptions() {
|
||||
return Array.from({ length: 31 }, (_, index) => {
|
||||
const lastDay = `<option value="0">${t("jobs.monthday_last")}</option>`;
|
||||
const numberedDays = Array.from({ length: 31 }, (_, index) => {
|
||||
const day = index + 1;
|
||||
return `<option value="${day}">${t("jobs.monthday", day)}</option>`;
|
||||
}).join("");
|
||||
return lastDay + numberedDays;
|
||||
}
|
||||
|
||||
function buildTransferBody(action, src, dst) {
|
||||
@@ -322,7 +324,7 @@ function readRecurringSchedule(form) {
|
||||
}
|
||||
if (scheduleKind === "monthly") {
|
||||
schedule.scheduleMonthday = Number(form.elements.scheduleMonthday.value);
|
||||
if (!Number.isInteger(schedule.scheduleMonthday) || schedule.scheduleMonthday < 1 || schedule.scheduleMonthday > 31) {
|
||||
if (!Number.isInteger(schedule.scheduleMonthday) || schedule.scheduleMonthday < 0 || schedule.scheduleMonthday > 31) {
|
||||
throw new Error(t("error.no_schedule_selected"));
|
||||
}
|
||||
}
|
||||
@@ -764,6 +766,9 @@ function formatSchedule(job) {
|
||||
case "weekly":
|
||||
return t("jobs.schedule_label_weekly", weekdayName(job.scheduleWeekday), time);
|
||||
case "monthly":
|
||||
if (Number(job.scheduleMonthday) === 0) {
|
||||
return t("jobs.schedule_label_monthly_last", time);
|
||||
}
|
||||
return t("jobs.schedule_label_monthly", job.scheduleMonthday, time);
|
||||
default:
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user