2022-01-23 14:22:00 +00:00
|
|
|
<template>
|
|
|
|
<transition name="slide-fade" appear>
|
|
|
|
<div v-if="maintenance">
|
2022-04-30 13:13:13 +00:00
|
|
|
<h1>{{ maintenance.title }}</h1>
|
2022-01-23 14:22:00 +00:00
|
|
|
<p class="url">
|
2022-04-30 12:57:08 +00:00
|
|
|
<span>{{ $t("Start") }}: {{ $root.datetimeMaintenance(maintenance.start_date) }}</span>
|
2022-01-23 14:22:00 +00:00
|
|
|
<br>
|
2022-04-30 12:57:08 +00:00
|
|
|
<span>{{ $t("End") }}: {{ $root.datetimeMaintenance(maintenance.end_date) }}</span>
|
2022-01-23 14:22:00 +00:00
|
|
|
</p>
|
|
|
|
|
2022-04-30 15:17:22 +00:00
|
|
|
<div class="functions" style="margin-top: 10px;">
|
2022-09-17 14:00:11 +00:00
|
|
|
<router-link :to=" '/maintenance/edit/' + maintenance.id " class="btn btn-secondary">
|
2022-01-23 14:22:00 +00:00
|
|
|
<font-awesome-icon icon="edit" /> {{ $t("Edit") }}
|
|
|
|
</router-link>
|
|
|
|
<button class="btn btn-danger" @click="deleteDialog">
|
|
|
|
<font-awesome-icon icon="trash" /> {{ $t("Delete") }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2022-04-30 15:17:22 +00:00
|
|
|
<label for="description" class="form-label" style="margin-top: 20px;">{{ $t("Description") }}</label>
|
2022-04-30 13:13:13 +00:00
|
|
|
<textarea id="description" v-model="maintenance.description" class="form-control" disabled></textarea>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
2022-04-30 15:17:22 +00:00
|
|
|
<label for="affected_monitors" class="form-label" style="margin-top: 20px;">{{ $t("Affected Monitors") }}</label>
|
2022-01-23 14:22:00 +00:00
|
|
|
<br>
|
2022-05-08 18:03:24 +00:00
|
|
|
<button v-for="monitor in affectedMonitors" :key="monitor.id" class="btn btn-monitor" style="margin: 5px; cursor: auto; color: white; font-weight: 500;">
|
2022-01-23 14:22:00 +00:00
|
|
|
{{ monitor }}
|
|
|
|
</button>
|
2022-04-30 15:17:22 +00:00
|
|
|
<br />
|
|
|
|
|
2022-09-17 14:00:11 +00:00
|
|
|
<label for="selected_status_pages" class="form-label" style="margin-top: 20px;">{{ $t("Show this Maintenance Message on which Status Pages") }}</label>
|
2022-04-30 15:17:22 +00:00
|
|
|
<br>
|
2022-05-08 18:03:24 +00:00
|
|
|
<button v-for="statusPage in selectedStatusPages" :key="statusPage.id" class="btn btn-monitor" style="margin: 5px; cursor: auto; color: white; font-weight: 500;">
|
2022-04-30 15:17:22 +00:00
|
|
|
{{ statusPage }}
|
|
|
|
</button>
|
2022-01-23 14:22:00 +00:00
|
|
|
|
|
|
|
<Confirm ref="confirmDelete" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="deleteMaintenance">
|
|
|
|
{{ $t("deleteMaintenanceMsg") }}
|
|
|
|
</Confirm>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
const toast = useToast();
|
|
|
|
import Confirm from "../components/Confirm.vue";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Confirm,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
affectedMonitors: [],
|
2022-04-30 15:17:22 +00:00
|
|
|
selectedStatusPages: [],
|
2022-01-23 14:22:00 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
maintenance() {
|
|
|
|
let id = this.$route.params.id;
|
|
|
|
return this.$root.maintenanceList[id];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.init();
|
|
|
|
},
|
|
|
|
methods: {
|
2023-01-05 22:55:51 +00:00
|
|
|
/** Initialise page */
|
2022-01-23 14:22:00 +00:00
|
|
|
init() {
|
|
|
|
this.$root.getSocket().emit("getMonitorMaintenance", this.$route.params.id, (res) => {
|
|
|
|
if (res.ok) {
|
|
|
|
this.affectedMonitors = Object.values(res.monitors).map(monitor => monitor.name);
|
|
|
|
} 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) {
|
|
|
|
this.selectedStatusPages = Object.values(res.statusPages).map(statusPage => statusPage.title);
|
|
|
|
} else {
|
|
|
|
toast.error(res.msg);
|
|
|
|
}
|
|
|
|
});
|
2022-01-23 14:22:00 +00:00
|
|
|
},
|
2022-04-30 12:57:08 +00:00
|
|
|
|
2023-01-05 22:55:51 +00:00
|
|
|
/** Confirm deletion */
|
2022-01-23 14:22:00 +00:00
|
|
|
deleteDialog() {
|
|
|
|
this.$refs.confirmDelete.show();
|
|
|
|
},
|
|
|
|
|
2023-01-05 22:55:51 +00:00
|
|
|
/** Delete maintenance after showing confirmation */
|
2022-01-23 14:22:00 +00:00
|
|
|
deleteMaintenance() {
|
|
|
|
this.$root.deleteMaintenance(this.maintenance.id, (res) => {
|
|
|
|
if (res.ok) {
|
|
|
|
toast.success(res.msg);
|
2022-09-17 18:02:18 +00:00
|
|
|
this.$router.push("/maintenance");
|
2022-01-23 14:22:00 +00:00
|
|
|
} else {
|
|
|
|
toast.error(res.msg);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "../assets/vars.scss";
|
|
|
|
|
|
|
|
@media (max-width: 550px) {
|
|
|
|
.functions {
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
button, a {
|
|
|
|
margin-left: 10px !important;
|
|
|
|
margin-right: 10px !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 400px) {
|
|
|
|
.btn {
|
|
|
|
display: inline-flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
padding-top: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
a.btn {
|
|
|
|
padding-left: 25px;
|
|
|
|
padding-right: 25px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.url {
|
|
|
|
color: $primary;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
|
|
a {
|
|
|
|
color: $primary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.functions {
|
|
|
|
button, a {
|
|
|
|
margin-right: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
min-height: 100px;
|
|
|
|
resize: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-monitor {
|
|
|
|
background-color: #5cdd8b;
|
|
|
|
}
|
|
|
|
|
2022-05-08 18:03:24 +00:00
|
|
|
.dark .btn-monitor {
|
|
|
|
color: #020b05 !important;
|
|
|
|
}
|
|
|
|
|
2022-01-23 14:22:00 +00:00
|
|
|
</style>
|