|
|
|
@ -54,22 +54,63 @@
|
|
|
|
|
|
|
|
|
|
<!-- Start Date Time -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="start_date" class="form-label">{{ $t("Start of maintenance") }} ({{ $root.timezone }})</label>
|
|
|
|
|
<label for="start_date" class="form-label">{{ $t("Start of maintenance") }}
|
|
|
|
|
({{ $root.timezone }})</label>
|
|
|
|
|
<input
|
|
|
|
|
id="start_date" v-model="maintenance.start_date" :type="'datetime-local'"
|
|
|
|
|
class="form-control" :class="{'darkCalendar': dark }" required
|
|
|
|
|
class="form-control" :class="{'dark-calendar': dark }" required
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- End Date Time -->
|
|
|
|
|
<div class="my-3">
|
|
|
|
|
<label for="end_date" class="form-label">{{ $t("Expected end of maintenance") }} ({{ $root.timezone }})</label>
|
|
|
|
|
<label for="end_date" class="form-label">{{ $t("Expected end of maintenance") }}
|
|
|
|
|
({{ $root.timezone }})</label>
|
|
|
|
|
<input
|
|
|
|
|
id="end_date" v-model="maintenance.end_date" :type="'datetime-local'"
|
|
|
|
|
class="form-control" :class="{'darkCalendar': dark }" required
|
|
|
|
|
class="form-control" :class="{'dark-calendar': dark }" required
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Show on all pages -->
|
|
|
|
|
<div class="my-3 form-check">
|
|
|
|
|
<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("Show on all pages")
|
|
|
|
|
}}</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Status pages to display maintenance info on -->
|
|
|
|
|
<div v-if="!showOnAllPages" class="my-3">
|
|
|
|
|
<label for="selected_status_pages" class="form-label">{{
|
|
|
|
|
$t("Selected status pages")
|
|
|
|
|
}}</label>
|
|
|
|
|
|
|
|
|
|
<VueMultiselect
|
|
|
|
|
id="selected_status_pages"
|
|
|
|
|
v-model="selectedStatusPages"
|
|
|
|
|
:options="selectedStatusPagesOptions"
|
|
|
|
|
track-by="id"
|
|
|
|
|
label="name"
|
|
|
|
|
:multiple="true"
|
|
|
|
|
:allow-empty="false"
|
|
|
|
|
: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>
|
|
|
|
|
|
|
|
|
|
<div class="form-text">
|
|
|
|
|
{{ $t("selectedStatusPagesDescription") }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mt-5 mb-1">
|
|
|
|
|
<button
|
|
|
|
|
id="monitor-submit-btn" class="btn btn-primary" type="submit"
|
|
|
|
@ -104,6 +145,9 @@ export default {
|
|
|
|
|
maintenance: {},
|
|
|
|
|
affectedMonitors: [],
|
|
|
|
|
affectedMonitorsOptions: [],
|
|
|
|
|
showOnAllPages: true,
|
|
|
|
|
selectedStatusPages: [],
|
|
|
|
|
selectedStatusPagesOptions: [],
|
|
|
|
|
dark: (this.$root.theme === "dark"),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
@ -150,10 +194,18 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.values(this.$root.statusPageList).map(statusPage => {
|
|
|
|
|
this.selectedStatusPagesOptions.push({
|
|
|
|
|
id: statusPage.id,
|
|
|
|
|
name: statusPage.title
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
init() {
|
|
|
|
|
this.affectedMonitors = [];
|
|
|
|
|
this.selectedStatusPages = [];
|
|
|
|
|
|
|
|
|
|
if (this.isAdd) {
|
|
|
|
|
this.maintenance = {
|
|
|
|
@ -178,6 +230,21 @@ export default {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
|
}
|
|
|
|
@ -193,17 +260,24 @@ export default {
|
|
|
|
|
return this.processing = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.showOnAllPages && this.selectedStatusPages.length === 0) {
|
|
|
|
|
toast.error(this.$t("atLeastOneStatusPage"));
|
|
|
|
|
return this.processing = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.maintenance.start_date = this.$root.toUTC(this.maintenance.start_date);
|
|
|
|
|
this.maintenance.end_date = this.$root.toUTC(this.maintenance.end_date);
|
|
|
|
|
|
|
|
|
|
if (this.isAdd) {
|
|
|
|
|
this.$root.addMaintenance(this.maintenance, async (res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, () => {
|
|
|
|
|
toast.success(res.msg);
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.getMaintenanceList();
|
|
|
|
|
this.$router.push("/dashboard/maintenance/" + res.maintenanceID);
|
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, async () => {
|
|
|
|
|
await this.addMaintenanceStatusPage(res.maintenanceID, () => {
|
|
|
|
|
toast.success(res.msg);
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.getMaintenanceList();
|
|
|
|
|
this.$router.push("/dashboard/maintenance/" + res.maintenanceID);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
toast.error(res.msg);
|
|
|
|
@ -214,10 +288,12 @@ export default {
|
|
|
|
|
} else {
|
|
|
|
|
this.$root.getSocket().emit("editMaintenance", this.maintenance, async (res) => {
|
|
|
|
|
if (res.ok) {
|
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, () => {
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
|
this.init();
|
|
|
|
|
await this.addMonitorMaintenance(res.maintenanceID, async () => {
|
|
|
|
|
await this.addMaintenanceStatusPage(res.maintenanceID, () => {
|
|
|
|
|
this.processing = false;
|
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
|
this.init();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.processing = false;
|
|
|
|
@ -238,6 +314,18 @@ export default {
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
@ -251,7 +339,7 @@ textarea {
|
|
|
|
|
min-height: 200px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.darkCalendar::-webkit-calendar-picker-indicator {
|
|
|
|
|
.dark-calendar::-webkit-calendar-picker-indicator {
|
|
|
|
|
filter: invert(1);
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|