2022-01-23 14:22:00 +00:00
|
|
|
|
<template>
|
|
|
|
|
<transition name="slide-fade" appear>
|
|
|
|
|
<div>
|
|
|
|
|
<h1 class="mb-3">{{ pageName }}</h1>
|
|
|
|
|
<form @submit.prevent="submit">
|
|
|
|
|
<div class="shadow-box">
|
|
|
|
|
<div class="row">
|
2022-09-18 14:34:05 +00:00
|
|
|
|
<div class="col-xl-7">
|
2022-01-23 14:22:00 +00:00
|
|
|
|
<!-- Title -->
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<div class="mb-3">
|
2022-01-23 14:22:00 +00:00
|
|
|
|
<label for="name" class="form-label">{{ $t("Title") }}</label>
|
2022-04-30 12:57:08 +00:00
|
|
|
|
<input
|
|
|
|
|
id="name" v-model="maintenance.title" type="text" class="form-control"
|
2022-09-17 14:00:11 +00:00
|
|
|
|
required
|
2022-04-30 12:57:08 +00:00
|
|
|
|
>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Description -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="description" class="form-label">{{ $t("Description") }}</label>
|
2022-04-30 12:57:08 +00:00
|
|
|
|
<textarea
|
|
|
|
|
id="description" v-model="maintenance.description" class="form-control"
|
|
|
|
|
></textarea>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Affected Monitors -->
|
2022-09-18 14:34:05 +00:00
|
|
|
|
<h2 class="mt-5">{{ $t("Affected Monitors") }}</h2>
|
|
|
|
|
{{ $t("affectedMonitorsDescription") }}
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
2022-09-18 14:34:05 +00:00
|
|
|
|
<div class="my-3">
|
2022-01-23 14:22:00 +00:00
|
|
|
|
<VueMultiselect
|
|
|
|
|
id="affected_monitors"
|
|
|
|
|
v-model="affectedMonitors"
|
|
|
|
|
:options="affectedMonitorsOptions"
|
|
|
|
|
track-by="id"
|
|
|
|
|
label="name"
|
|
|
|
|
:multiple="true"
|
|
|
|
|
:close-on-select="false"
|
|
|
|
|
:clear-on-select="false"
|
|
|
|
|
:preserve-search="true"
|
|
|
|
|
:placeholder="$t('Pick Affected Monitors...')"
|
|
|
|
|
:preselect-first="false"
|
|
|
|
|
:max-height="600"
|
|
|
|
|
:taggable="false"
|
|
|
|
|
></VueMultiselect>
|
2022-09-18 14:34:05 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Status pages to display maintenance info on -->
|
|
|
|
|
<h2 class="mt-5">{{ $t("Status Pages") }}</h2>
|
|
|
|
|
{{ $t("affectedStatusPages") }}
|
|
|
|
|
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<!-- Show on all pages -->
|
|
|
|
|
<div class="form-check mb-2">
|
|
|
|
|
<input
|
|
|
|
|
id="show-on-all-pages" v-model="showOnAllPages" class="form-check-input"
|
|
|
|
|
type="checkbox"
|
|
|
|
|
>
|
|
|
|
|
<label class="form-check-label" for="show-powered-by">{{
|
|
|
|
|
$t("All Status Pages")
|
|
|
|
|
}}</label>
|
|
|
|
|
</div>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
2022-09-18 14:34:05 +00:00
|
|
|
|
<div v-if="!showOnAllPages">
|
|
|
|
|
<VueMultiselect
|
|
|
|
|
id="selected_status_pages"
|
|
|
|
|
v-model="selectedStatusPages"
|
|
|
|
|
:options="selectedStatusPagesOptions"
|
|
|
|
|
track-by="id"
|
|
|
|
|
label="name"
|
|
|
|
|
:multiple="true"
|
|
|
|
|
:close-on-select="false"
|
|
|
|
|
:clear-on-select="false"
|
|
|
|
|
:preserve-search="true"
|
|
|
|
|
:placeholder="$t('Select status pages...')"
|
|
|
|
|
:preselect-first="false"
|
|
|
|
|
:max-height="600"
|
|
|
|
|
:taggable="false"
|
|
|
|
|
></VueMultiselect>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<h2 class="mt-5">{{ $t("Date and Time") }}</h2>
|
2022-09-18 14:34:05 +00:00
|
|
|
|
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<div>⚠️ {{ $t("warningTimezone") }}</div>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<!-- Strategy -->
|
2022-01-23 14:22:00 +00:00
|
|
|
|
<div class="my-3">
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<label for="strategy" class="form-label">{{ $t("Strategy") }}</label>
|
|
|
|
|
<select id="strategy" v-model="maintenance.strategy" class="form-select">
|
|
|
|
|
<option value="manual">{{ $t("strategyManual") }}</option>
|
|
|
|
|
<option value="single">Single Maintenance Window</option>
|
|
|
|
|
<option value="recurring-interval">{{ $t("Recurring") }} - {{ $t("recurringInterval") }}</option>
|
|
|
|
|
<option value="recurring-weekday">{{ $t("Recurring") }} - Weekday</option>
|
|
|
|
|
<option value="recurring-day-of-month">{{ $t("Recurring") }} - Day of Month</option>
|
|
|
|
|
<option v-if="false" value="recurring-day-of-year">{{ $t("Recurring") }} - Day of Year</option>
|
|
|
|
|
</select>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
2022-09-23 18:33:29 +00:00
|
|
|
|
<!-- Single Maintenance Window -->
|
|
|
|
|
<template v-if="maintenance.strategy === 'single'">
|
|
|
|
|
<!-- DateTime Range -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label class="form-label">{{ $t("DateTime Range") }}</label>
|
|
|
|
|
<Datepicker
|
|
|
|
|
v-model="maintenance.dateTimeRange"
|
|
|
|
|
:dark="$root.isDark"
|
|
|
|
|
range textInput
|
|
|
|
|
:monthChangeOnScroll="false"
|
|
|
|
|
:minDate="minDate"
|
|
|
|
|
format="yyyy-MM-dd HH:mm"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- Recurring - Interval -->
|
|
|
|
|
<template v-if="maintenance.strategy === 'recurring-interval'">
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="interval-day" class="form-label">
|
|
|
|
|
{{ $t("recurringInterval") }}
|
|
|
|
|
|
|
|
|
|
<template v-if="maintenance.intervalDay >= 1">
|
|
|
|
|
({{
|
|
|
|
|
$tc("recurringIntervalMessage", maintenance.intervalDay, [
|
|
|
|
|
maintenance.intervalDay
|
|
|
|
|
])
|
|
|
|
|
}})
|
|
|
|
|
</template>
|
|
|
|
|
</label>
|
|
|
|
|
<input id="interval-day" v-model="maintenance.intervalDay" type="number" class="form-control" required min="1" max="3650" step="1">
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- Recurring - Weekday -->
|
|
|
|
|
<template v-if="maintenance.strategy === 'recurring-weekday'">
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="interval-day" class="form-label">
|
|
|
|
|
{{ $t("Weekday") }}
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<!-- Weekday Picker -->
|
|
|
|
|
<div class="weekday-picker">
|
|
|
|
|
<div v-for="(weekday, index) in weekdays" :key="index">
|
|
|
|
|
<label class="form-check-label" :for="weekday.id">{{ $t(weekday.langKey) }}</label>
|
|
|
|
|
<div class="form-check-inline"><input :id="weekday.id" v-model="maintenance.weekdays" type="checkbox" :value="weekday.value" class="form-check-input"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- Recurring - Day of month -->
|
|
|
|
|
<template v-if="maintenance.strategy === 'recurring-day-of-month'">
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="interval-day" class="form-label">
|
|
|
|
|
{{ $t("dayOfMonth") }}
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<!-- Day Picker -->
|
|
|
|
|
<div class="day-picker">
|
|
|
|
|
<div v-for="index in 31" :key="index">
|
|
|
|
|
<label class="form-check-label" :for="'day' + index">{{ index }}</label>
|
|
|
|
|
<div class="form-check-inline">
|
|
|
|
|
<input :id="'day' + index" v-model="maintenance.daysOfMonth" type="checkbox" :value="index" class="form-check-input">
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mt-3 mb-2">{{ $t("lastDay") }}</div>
|
|
|
|
|
|
|
|
|
|
<div v-for="(lastDay, index) in lastDays" :key="index" class="form-check">
|
|
|
|
|
<input :id="lastDay.langKey" v-model="maintenance.daysOfMonth" type="checkbox" :value="lastDay.value" class="form-check-input">
|
|
|
|
|
<label class="form-check-label" :for="lastDay.langKey">
|
|
|
|
|
{{ $t(lastDay.langKey) }}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<!-- For any recurring types -->
|
|
|
|
|
<template v-if="maintenance.strategy === 'recurring-interval' || maintenance.strategy === 'recurring-weekday' || maintenance.strategy === 'recurring-day-of-month'">
|
|
|
|
|
<!-- Maintenance Time Window of a Day -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label class="form-label">{{ $t("Maintenance Time Window of a Day") }}</label>
|
|
|
|
|
<Datepicker
|
|
|
|
|
v-model="maintenance.timeRange"
|
|
|
|
|
:dark="$root.isDark"
|
2022-09-25 11:38:28 +00:00
|
|
|
|
timePicker
|
|
|
|
|
disableTimeRangeValidation range
|
2022-09-23 18:33:29 +00:00
|
|
|
|
textInput
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Date Range -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label class="form-label">{{ $t("Effective Date Range") }}</label>
|
|
|
|
|
<Datepicker
|
|
|
|
|
v-model="maintenance.dateRange"
|
|
|
|
|
:dark="$root.isDark"
|
|
|
|
|
range textInput datePicker
|
|
|
|
|
:monthChangeOnScroll="false"
|
|
|
|
|
:minDate="minDate"
|
|
|
|
|
:enableTimePicker="false"
|
2022-09-25 11:38:28 +00:00
|
|
|
|
:utc="true"
|
2022-09-23 18:33:29 +00:00
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2022-09-18 14:34:05 +00:00
|
|
|
|
<div class="mt-4 mb-1">
|
2022-04-30 12:57:08 +00:00
|
|
|
|
<button
|
|
|
|
|
id="monitor-submit-btn" class="btn btn-primary" type="submit"
|
|
|
|
|
:disabled="processing"
|
|
|
|
|
>
|
|
|
|
|
{{ $t("Save") }}
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
</transition>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
2022-04-30 12:57:08 +00:00
|
|
|
|
import { useToast } from "vue-toastification";
|
2022-01-23 14:22:00 +00:00
|
|
|
|
import VueMultiselect from "vue-multiselect";
|
2022-09-23 18:33:29 +00:00
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
import Datepicker from "@vuepic/vue-datepicker";
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
VueMultiselect,
|
2022-09-23 18:33:29 +00:00
|
|
|
|
Datepicker
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
processing: false,
|
|
|
|
|
maintenance: {},
|
|
|
|
|
affectedMonitors: [],
|
|
|
|
|
affectedMonitorsOptions: [],
|
2022-09-17 18:13:29 +00:00
|
|
|
|
showOnAllPages: false,
|
2022-04-30 15:17:22 +00:00
|
|
|
|
selectedStatusPages: [],
|
2022-01-23 14:22:00 +00:00
|
|
|
|
dark: (this.$root.theme === "dark"),
|
2022-09-23 18:33:29 +00:00
|
|
|
|
neverEnd: false,
|
|
|
|
|
minDate: this.$root.date(dayjs()) + " 00:00",
|
|
|
|
|
lastDays: [
|
|
|
|
|
{
|
|
|
|
|
langKey: "lastDay1",
|
|
|
|
|
value: "lastDay1",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
langKey: "lastDay2",
|
|
|
|
|
value: "lastDay2",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
langKey: "lastDay3",
|
|
|
|
|
value: "lastDay3",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
langKey: "lastDay4",
|
|
|
|
|
value: "lastDay4",
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
weekdays: [
|
|
|
|
|
{
|
|
|
|
|
id: "weekday1",
|
|
|
|
|
langKey: "weekdayShortMon",
|
|
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday2",
|
|
|
|
|
langKey: "weekdayShortTue",
|
|
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday3",
|
|
|
|
|
langKey: "weekdayShortWed",
|
|
|
|
|
value: 3,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday4",
|
|
|
|
|
langKey: "weekdayShortTue",
|
|
|
|
|
value: 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday5",
|
|
|
|
|
langKey: "weekdayShortFri",
|
|
|
|
|
value: 5,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday6",
|
|
|
|
|
langKey: "weekdayShortSat",
|
|
|
|
|
value: 6,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "weekday7",
|
|
|
|
|
langKey: "weekdayShortSun",
|
|
|
|
|
value: 7,
|
|
|
|
|
},
|
|
|
|
|
],
|
2022-01-23 14:22:00 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
2022-09-18 14:40:53 +00:00
|
|
|
|
selectedStatusPagesOptions() {
|
|
|
|
|
return Object.values(this.$root.statusPageList).map(statusPage => {
|
|
|
|
|
return {
|
|
|
|
|
id: statusPage.id,
|
|
|
|
|
name: statusPage.title
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
|
pageName() {
|
2022-09-17 14:00:11 +00:00
|
|
|
|
return this.$t((this.isAdd) ? "Schedule Maintenance" : "Edit Maintenance");
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isAdd() {
|
2022-09-17 14:00:11 +00:00
|
|
|
|
return this.$route.path === "/add-maintenance";
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isEdit() {
|
2022-09-17 14:00:11 +00:00
|
|
|
|
return this.$route.path.startsWith("/maintenance/edit");
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
"$route.fullPath"() {
|
|
|
|
|
this.init();
|
2022-09-23 18:33:29 +00:00
|
|
|
|
},
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
2022-09-23 18:33:29 +00:00
|
|
|
|
neverEnd(value) {
|
|
|
|
|
if (value) {
|
|
|
|
|
this.maintenance.recurringEndDate = "";
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.init();
|
|
|
|
|
|
|
|
|
|
this.$root.getMonitorList((res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
Object.values(this.$root.monitorList).map(monitor => {
|
|
|
|
|
this.affectedMonitorsOptions.push({
|
|
|
|
|
id: monitor.id,
|
2022-01-23 19:33:39 +00:00
|
|
|
|
name: monitor.name,
|
2022-01-23 14:22:00 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
init() {
|
2022-09-25 11:38:28 +00:00
|
|
|
|
// Use browser's timezone!
|
|
|
|
|
let timezone = dayjs.tz.guess();
|
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
|
this.affectedMonitors = [];
|
2022-04-30 15:17:22 +00:00
|
|
|
|
this.selectedStatusPages = [];
|
2022-04-30 12:57:08 +00:00
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
|
if (this.isAdd) {
|
|
|
|
|
this.maintenance = {
|
|
|
|
|
title: "",
|
|
|
|
|
description: "",
|
2022-09-23 18:33:29 +00:00
|
|
|
|
strategy: "single",
|
|
|
|
|
active: 1,
|
|
|
|
|
intervalDay: 1,
|
|
|
|
|
dateTimeRange: [ this.minDate ],
|
2022-09-24 11:18:24 +00:00
|
|
|
|
dateRange: [],
|
2022-09-23 18:33:29 +00:00
|
|
|
|
timeRange: [{
|
|
|
|
|
hours: 2,
|
|
|
|
|
minutes: 0,
|
|
|
|
|
}, {
|
|
|
|
|
hours: 3,
|
|
|
|
|
minutes: 0,
|
|
|
|
|
}],
|
|
|
|
|
weekdays: [],
|
|
|
|
|
daysOfMonth: [],
|
2022-01-23 14:22:00 +00:00
|
|
|
|
};
|
|
|
|
|
} else if (this.isEdit) {
|
2022-09-25 11:38:28 +00:00
|
|
|
|
this.$root.getSocket().emit("getMaintenance", this.$route.params.id, timezone, (res) => {
|
2022-01-23 14:22:00 +00:00
|
|
|
|
if (res.ok) {
|
|
|
|
|
this.maintenance = res.maintenance;
|
|
|
|
|
|
|
|
|
|
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
Object.values(res.monitors).map(monitor => {
|
|
|
|
|
this.affectedMonitors.push(monitor);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-04-30 15:17:22 +00:00
|
|
|
|
|
|
|
|
|
this.$root.getSocket().emit("getMaintenanceStatusPage", this.$route.params.id, (res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
Object.values(res.statusPages).map(statusPage => {
|
|
|
|
|
this.selectedStatusPages.push({
|
|
|
|
|
id: statusPage.id,
|
|
|
|
|
name: statusPage.title
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.showOnAllPages = Object.values(res.statusPages).length === this.selectedStatusPagesOptions.length;
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-01-23 14:22:00 +00:00
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
|
this.processing = true;
|
|
|
|
|
|
|
|
|
|
if (this.affectedMonitors.length === 0) {
|
2022-01-23 19:33:39 +00:00
|
|
|
|
toast.error(this.$t("atLeastOneMonitor"));
|
2022-01-23 14:22:00 +00:00
|
|
|
|
return this.processing = false;
|
2022-05-08 18:50:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 11:18:24 +00:00
|
|
|
|
/*
|
|
|
|
|
TODO: Temporary disable
|
2022-05-08 18:50:08 +00:00
|
|
|
|
if (this.maintenance.start_date >= this.maintenance.end_date) {
|
|
|
|
|
toast.error(this.$t("maintenanceInvalidDate"));
|
|
|
|
|
return this.processing = false;
|
2022-01-23 14:22:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 15:17:22 +00:00
|
|
|
|
if (!this.showOnAllPages && this.selectedStatusPages.length === 0) {
|
|
|
|
|
toast.error(this.$t("atLeastOneStatusPage"));
|
|
|
|
|
return this.processing = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-24 21:33:15 +00:00
|
|
|
|
this.maintenance.start_date = this.$root.toUTC(this.maintenance.start_date);
|
|
|
|
|
this.maintenance.end_date = this.$root.toUTC(this.maintenance.end_date);
|
2022-09-24 11:18:24 +00:00
|
|
|
|
*/
|
2022-01-24 21:33:15 +00:00
|
|
|
|
|
2022-09-25 11:38:28 +00:00
|
|
|
|
// Use browser's timezone!
|
|
|
|
|
let timezone = dayjs.tz.guess();
|
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
|
if (this.isAdd) {
|
2022-09-25 11:38:28 +00:00
|
|
|
|
this.$root.addMaintenance(this.maintenance, timezone, async (res) => {
|
2022-01-23 14:22:00 +00:00
|
|
|
|
if (res.ok) {
|
2022-04-30 15:17:22 +00:00
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, async () => {
|
|
|
|
|
await this.addMaintenanceStatusPage(res.maintenanceID, () => {
|
|
|
|
|
toast.success(res.msg);
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.getMaintenanceList();
|
2022-09-17 18:02:18 +00:00
|
|
|
|
this.$router.push("/maintenance");
|
2022-04-30 15:17:22 +00:00
|
|
|
|
});
|
2022-01-23 14:22:00 +00:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
this.processing = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2022-09-25 11:38:28 +00:00
|
|
|
|
this.$root.getSocket().emit("editMaintenance", this.maintenance, timezone, async (res) => {
|
2022-01-23 14:22:00 +00:00
|
|
|
|
if (res.ok) {
|
2022-04-30 15:17:22 +00:00
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, async () => {
|
|
|
|
|
await this.addMaintenanceStatusPage(res.maintenanceID, () => {
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
|
this.init();
|
2022-09-17 18:02:18 +00:00
|
|
|
|
this.$router.push("/maintenance");
|
2022-04-30 15:17:22 +00:00
|
|
|
|
});
|
2022-01-23 14:22:00 +00:00
|
|
|
|
});
|
2022-01-24 21:33:15 +00:00
|
|
|
|
} else {
|
2022-01-23 14:22:00 +00:00
|
|
|
|
this.processing = false;
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async addMonitorMaintenance(maintenanceID, callback) {
|
|
|
|
|
await this.$root.addMonitorMaintenance(maintenanceID, this.affectedMonitors, async (res) => {
|
|
|
|
|
if (!res.ok) {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
} else {
|
|
|
|
|
this.$root.getMonitorList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
},
|
2022-04-30 15:17:22 +00:00
|
|
|
|
|
|
|
|
|
async addMaintenanceStatusPage(maintenanceID, callback) {
|
|
|
|
|
await this.$root.addMaintenanceStatusPage(maintenanceID, (this.showOnAllPages) ? this.selectedStatusPagesOptions : this.selectedStatusPages, async (res) => {
|
|
|
|
|
if (!res.ok) {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
} else {
|
|
|
|
|
this.$root.getMaintenanceList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
},
|
2022-01-23 14:22:00 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.shadow-box {
|
|
|
|
|
padding: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textarea {
|
2022-09-18 14:34:05 +00:00
|
|
|
|
min-height: 150px;
|
2022-01-23 14:22:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 15:17:22 +00:00
|
|
|
|
.dark-calendar::-webkit-calendar-picker-indicator {
|
2022-01-23 14:22:00 +00:00
|
|
|
|
filter: invert(1);
|
|
|
|
|
}
|
2022-09-23 18:33:29 +00:00
|
|
|
|
|
|
|
|
|
.weekday-picker {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
|
|
|
|
|
& > div {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
|
|
|
|
.form-check-inline {
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.day-picker {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
|
|
|
|
& > div {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
|
|
|
|
.form-check-inline {
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
|
</style>
|