diff --git a/dashboard/src/components/BackupScheduleDialog.vue b/dashboard/src/components/BackupScheduleDialog.vue
index bfb855e9b..af0ce8d97 100644
--- a/dashboard/src/components/BackupScheduleDialog.vue
+++ b/dashboard/src/components/BackupScheduleDialog.vue
@@ -3,6 +3,7 @@
import { ref, useTemplateRef, computed } from 'vue';
import { Checkbox, Dialog, FormGroup, SingleSelect, MultiSelect } from '@cloudron/pankow';
import BackupSitesModel from '../models/BackupSitesModel.js';
+import { cronDays, cronHours } from '../utils.js';
const emit = defineEmits([ 'success' ]);
@@ -80,10 +81,10 @@ defineExpose({
const tmpHours = tmp[2].split(',');
const tmpDays = tmp[5].split(',');
- if (tmpDays[0] === '*') days.value = BackupSitesModel.cronDays.map((day) => { return day.id; });
+ if (tmpDays[0] === '*') days.value = cronDays.map((day) => { return day.id; });
else days.value = tmpDays.map((day) => { return parseInt(day, 10); });
- if (tmpHours[0] === '*') hours.value = BackupSitesModel.cronHours.map(h => h.id);
+ if (tmpHours[0] === '*') hours.value = cronHours.map(h => h.id);
else hours.value = tmpHours.map((hour) => { return parseInt(hour, 10); });
}
@@ -114,8 +115,8 @@ defineExpose({
-
{{ $t('backups.configureBackupSchedule.days') }}:
-
{{ $t('backups.configureBackupSchedule.hours') }}:
+
{{ $t('backups.configureBackupSchedule.days') }}:
+
{{ $t('backups.configureBackupSchedule.hours') }}:
diff --git a/dashboard/src/components/SystemUpdate.vue b/dashboard/src/components/SystemUpdate.vue
index dabc6754a..cb612f8d2 100644
--- a/dashboard/src/components/SystemUpdate.vue
+++ b/dashboard/src/components/SystemUpdate.vue
@@ -11,26 +11,13 @@ import AppsModel from '../models/AppsModel.js';
import UpdaterModel from '../models/UpdaterModel.js';
import TasksModel from '../models/TasksModel.js';
import DashboardModel from '../models/DashboardModel.js';
+import { cronDays, cronHours } from '../utils.js';
const appsModel = AppsModel.create();
const tasksModel = TasksModel.create();
const updaterModel = UpdaterModel.create();
const dashboardModel = DashboardModel.create();
-// values correspond to cron days
-const cronDays = [
- { name: 'Sunday', value: 0 },
- { name: 'Monday', value: 1 },
- { name: 'Tuesday', value: 2 },
- { name: 'Wednesday', value: 3 },
- { name: 'Thursday', value: 4 },
- { name: 'Friday', value: 5 },
- { name: 'Saturday', value: 6 },
-];
-
-// generates 24h time sets (instead of american 12h) to avoid having to translate everything to locales eg. 12:00
-const cronHours = Array.from({ length: 24 }).map((v, i) => { return { name: (i < 10 ? '0' : '') + i + ':00', value: i }; });
-
function prettyAutoUpdateSchedule(pattern) {
if (!pattern) return '';
const tmp = pattern.split(' ');
diff --git a/dashboard/src/models/BackupSitesModel.js b/dashboard/src/models/BackupSitesModel.js
index e5e532059..1579091ab 100644
--- a/dashboard/src/models/BackupSitesModel.js
+++ b/dashboard/src/models/BackupSitesModel.js
@@ -1,6 +1,7 @@
import { fetcher } from '@cloudron/pankow';
import { API_ORIGIN } from '../constants.js';
+import { cronDays, cronHours } from '../utils.js';
function create() {
const accessToken = localStorage.token;
@@ -219,20 +220,6 @@ const backupRetentions = [
{ name: 'Forever', id: { keepWithinSecs: -1 }}
];
-// values correspond to cron days
-const cronDays = [
- { id: 0, name: 'Sunday' },
- { id: 1, name: 'Monday' },
- { id: 2, name: 'Tuesday' },
- { id: 3, name: 'Wednesday' },
- { id: 4, name: 'Thursday' },
- { id: 5, name: 'Friday' },
- { id: 6, name: 'Saturday' },
-];
-
-// generates 24h time sets (instead of american 12h) to avoid having to translate everything to locales eg. 12:00
-const cronHours = Array.from({ length: 24 }).map(function (v, i) { return { id: i, name: (i < 10 ? '0' : '') + i + ':00' }; });
-
function prettyBackupSchedule(pattern) {
if (!pattern) return '';
@@ -267,8 +254,6 @@ function prettyBackupContents(contents) {
export default {
create,
backupRetentions,
- cronDays,
- cronHours,
prettyBackupSchedule,
prettyBackupRetention,
prettyBackupContents
diff --git a/dashboard/src/utils.js b/dashboard/src/utils.js
index a97b0bd73..5fb3fc201 100644
--- a/dashboard/src/utils.js
+++ b/dashboard/src/utils.js
@@ -619,6 +619,20 @@ function getDataURLFromFile(file) {
});
}
+// values correspond to cron days
+const cronDays = [
+ { id: 0, name: 'Sunday' },
+ { id: 1, name: 'Monday' },
+ { id: 2, name: 'Tuesday' },
+ { id: 3, name: 'Wednesday' },
+ { id: 4, name: 'Thursday' },
+ { id: 5, name: 'Friday' },
+ { id: 6, name: 'Saturday' },
+];
+
+// generates 24h time sets (instead of american 12h) to avoid having to translate everything to locales eg. 12:00
+const cronHours = Array.from({ length: 24 }).map(function (v, i) { return { id: i, name: (i < 10 ? '0' : '') + i + ':00' }; });
+
// named exports
export {
download,
@@ -630,7 +644,9 @@ export {
taskNameFromInstallationState,
redirectIfNeeded,
stripSsoInfo,
- getDataURLFromFile
+ getDataURLFromFile,
+ cronDays,
+ cronHours
};
// default export
@@ -644,5 +660,7 @@ export default {
taskNameFromInstallationState,
redirectIfNeeded,
stripSsoInfo,
- getDataURLFromFile
+ getDataURLFromFile,
+ cronDays,
+ cronHours
};