fix parsing of cron pattern
in some old instances, we had "00 00 * * *" (note double space and only 5 components).
This commit is contained in:
@@ -17,7 +17,7 @@ import SystemBackupList from '../components/SystemBackupList.vue';
|
||||
import { TASK_TYPES } from '../constants.js';
|
||||
import BackupSitesModel from '../models/BackupSitesModel.js';
|
||||
import TasksModel from '../models/TasksModel.js';
|
||||
import { cronDays, cronHours, regionName } from '../utils.js';
|
||||
import { prettySchedule, regionName } from '../utils.js';
|
||||
|
||||
const profile = inject('profile');
|
||||
|
||||
@@ -50,30 +50,6 @@ function onEditConfig(site) {
|
||||
backupSiteConfigDialog.value.open(site);
|
||||
}
|
||||
|
||||
function prettyBackupSchedule(pattern) {
|
||||
if (!pattern) return '';
|
||||
|
||||
const tmp = pattern.split(' ');
|
||||
if (tmp.length === 1) return pattern.charAt(0).toUpperCase() + pattern.slice(1); // case for 'never' - capitalize
|
||||
|
||||
const hours = tmp[2].split(',').sort((a, b) => Number(a) - Number(b));
|
||||
const days = tmp[5].split(',').sort((a, b) => Number(a) - Number(b));
|
||||
let prettyDay;
|
||||
if (days.length === 7 || days[0] === '*') {
|
||||
prettyDay = 'Everyday';
|
||||
} else {
|
||||
prettyDay = days.map(function (day) { return cronDays[parseInt(day, 10)].name.substr(0, 3); }).join(',');
|
||||
}
|
||||
|
||||
let prettyHour;
|
||||
if (hours.length === 24 || hours[0] === '*') {
|
||||
prettyHour = 'hourly';
|
||||
} else {
|
||||
prettyHour = hours.map(function (hour) { return cronHours[parseInt(hour, 10)].name; }).join(',');
|
||||
}
|
||||
return prettyDay + ' @ ' + prettyHour;
|
||||
};
|
||||
|
||||
function prettyBackupRetention(retention) {
|
||||
function stableStringify(obj) { return JSON.stringify(obj, Object.keys(obj).sort()); }
|
||||
const tmp = BackupSitesModel.backupRetentions.find(function (p) { return stableStringify(p.id) === stableStringify(retention); });
|
||||
@@ -326,7 +302,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $t('backups.schedule.schedule') }}: <b>{{ prettyBackupSchedule(site.schedule) }}</b>
|
||||
{{ $t('backups.schedule.schedule') }}: <b>{{ prettySchedule(site.schedule) }}</b>
|
||||
</div>
|
||||
<div>
|
||||
{{ $t('backups.schedule.retentionPolicy') }}: <b>{{ prettyBackupRetention(site.retention) }}</b>
|
||||
|
||||
Reference in New Issue
Block a user