mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 18:26:43 +00:00
57 lines
1.5 KiB
Vue
57 lines
1.5 KiB
Vue
<template>
|
|
<div>
|
|
<b-form-checkbox :checked="desktopNotificationsEnabled" @change="updateNotifications($event)">
|
|
{{ $t("jobOptions.desktopNotifications") }}
|
|
</b-form-checkbox>
|
|
|
|
<b-form-checkbox v-model="job.schedule_enabled" @change="update()">
|
|
{{ $t("jobOptions.scheduleEnabled") }}
|
|
</b-form-checkbox>
|
|
|
|
<label>{{ $t("jobOptions.cron") }}</label>
|
|
<b-form-input class="text-monospace" :state="cronValid" v-model="job.cron_expression" :disabled="!job.schedule_enabled" @change="update()"></b-form-input>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
name: "JobOptions",
|
|
props: ["job"],
|
|
data() {
|
|
return {
|
|
cronValid: undefined
|
|
}
|
|
},
|
|
computed: {
|
|
desktopNotificationsEnabled() {
|
|
return this.$store.state.jobDesktopNotificationMap[this.job.name];
|
|
}
|
|
},
|
|
mounted() {
|
|
this.cronValid = this.checkCron(this.job.cron_expression)
|
|
},
|
|
methods: {
|
|
checkCron(expression) {
|
|
return /((((\d+,)+\d+|(\d+([/-])\d+)|\d+|\*) ?){5,7})/.test(expression);
|
|
},
|
|
updateNotifications(value) {
|
|
this.$store.dispatch("setJobDesktopNotification", {
|
|
job: this.job.name,
|
|
enabled: value
|
|
});
|
|
},
|
|
update() {
|
|
if (this.job.schedule_enabled) {
|
|
this.cronValid = this.checkCron(this.job.cron_expression);
|
|
} else {
|
|
this.cronValid = undefined;
|
|
}
|
|
|
|
if (this.cronValid !== false) {
|
|
this.$emit("change", this.job);
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script> |