2021-09-11 08:22:30 +00:00
|
|
|
<template>
|
2021-09-20 08:22:18 +00:00
|
|
|
<div v-if="loadedTheme" class="container mt-3">
|
2021-09-15 10:28:48 +00:00
|
|
|
<!-- Logo & Title -->
|
2021-09-22 07:10:08 +00:00
|
|
|
<h1 class="mb-4">
|
2021-09-15 10:28:48 +00:00
|
|
|
<!-- Logo -->
|
2021-09-22 07:31:15 +00:00
|
|
|
<span class="logo-wrapper" @click="showImageCropUploadMethod">
|
|
|
|
<img :src="logoURL" alt class="logo me-2" :class="logoClass" />
|
2021-09-21 13:22:35 +00:00
|
|
|
<font-awesome-icon v-if="enableEditMode" class="icon-upload" icon="upload" />
|
2021-09-22 07:31:15 +00:00
|
|
|
</span>
|
2021-09-15 10:28:48 +00:00
|
|
|
|
|
|
|
<!-- Uploader -->
|
|
|
|
<!-- url="/api/status-page/upload-logo" -->
|
|
|
|
<ImageCropUpload v-model="showImageCropUpload"
|
|
|
|
field="img"
|
|
|
|
:width="128"
|
|
|
|
:height="128"
|
|
|
|
:langType="$i18n.locale"
|
|
|
|
img-format="png"
|
|
|
|
:noCircle="true"
|
|
|
|
:noSquare="false"
|
|
|
|
@crop-success="cropSuccess"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<!-- Title -->
|
2021-09-15 06:34:30 +00:00
|
|
|
<Editable v-model="config.title" tag="span" :contenteditable="editMode" :noNL="true" />
|
2021-09-14 15:27:11 +00:00
|
|
|
</h1>
|
2021-09-11 11:40:03 +00:00
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
<!-- Admin functions -->
|
2021-09-16 14:48:28 +00:00
|
|
|
<div v-if="hasToken" class="mb-4">
|
2021-09-13 11:21:39 +00:00
|
|
|
<div v-if="!enableEditMode">
|
|
|
|
<button class="btn btn-info me-2" @click="edit">
|
|
|
|
<font-awesome-icon icon="edit" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("Edit Status Page") }}
|
2021-09-13 11:21:39 +00:00
|
|
|
</button>
|
|
|
|
|
2021-09-19 15:24:51 +00:00
|
|
|
<a href="/dashboard" class="btn btn-info">
|
2021-09-13 11:21:39 +00:00
|
|
|
<font-awesome-icon icon="tachometer-alt" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("Go to Dashboard") }}
|
2021-09-19 15:24:51 +00:00
|
|
|
</a>
|
2021-09-13 11:21:39 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-else>
|
2021-09-19 11:04:51 +00:00
|
|
|
<button class="btn btn-success me-2" @click="save">
|
2021-09-13 11:21:39 +00:00
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Save") }}
|
|
|
|
</button>
|
|
|
|
|
2021-09-14 06:12:27 +00:00
|
|
|
<button class="btn btn-danger me-2" @click="discard">
|
2021-09-13 11:21:39 +00:00
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Discard") }}
|
|
|
|
</button>
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
<button class="btn btn-primary btn-add-group me-2" @click="createIncident">
|
2021-09-15 06:34:30 +00:00
|
|
|
<font-awesome-icon icon="bullhorn" />
|
|
|
|
{{ $t("Create Incident") }}
|
|
|
|
</button>
|
|
|
|
|
2021-09-19 11:04:51 +00:00
|
|
|
<!--
|
2021-09-15 06:34:30 +00:00
|
|
|
<button v-if="isPublished" class="btn btn-light me-2" @click="">
|
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Unpublish") }}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button v-if="!isPublished" class="btn btn-info me-2" @click="">
|
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Publish") }}
|
2021-09-19 11:04:51 +00:00
|
|
|
</button>-->
|
2021-09-15 06:34:30 +00:00
|
|
|
|
2021-09-13 11:21:39 +00:00
|
|
|
<!-- Set Default Language -->
|
|
|
|
<!-- Set theme -->
|
2021-09-15 10:28:48 +00:00
|
|
|
<button v-if="theme == 'dark'" class="btn btn-light me-2" @click="changeTheme('light')">
|
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Switch to Light Theme") }}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button v-if="theme == 'light'" class="btn btn-dark me-2" @click="changeTheme('dark')">
|
|
|
|
<font-awesome-icon icon="save" />
|
|
|
|
{{ $t("Switch to Dark Theme") }}
|
|
|
|
</button>
|
2021-10-29 05:19:24 +00:00
|
|
|
|
2021-11-01 00:23:46 +00:00
|
|
|
<button class="btn btn-secondary me-2" @click="changeTagsVisibilty(!tagsVisible)">
|
|
|
|
<template v-if="tagsVisible">
|
|
|
|
<font-awesome-icon icon="eye-slash" />
|
|
|
|
{{ $t("Hide Tags") }}
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<font-awesome-icon icon="eye" />
|
|
|
|
{{ $t("Show Tags") }}
|
|
|
|
</template>
|
2021-10-29 05:19:24 +00:00
|
|
|
</button>
|
2021-12-21 02:27:05 +00:00
|
|
|
|
|
|
|
<button class="btn btn-primary me-2" @click="customizeStatusPage">
|
|
|
|
<font-awesome-icon icon="cog" />
|
|
|
|
{{ $t("Customize") }}
|
|
|
|
</button>
|
2021-09-13 11:21:39 +00:00
|
|
|
</div>
|
2021-09-11 11:40:03 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
<!-- Incident -->
|
2021-09-16 14:48:28 +00:00
|
|
|
<div v-if="incident !== null" class="shadow-box alert mb-4 p-4 incident" role="alert" :class="incidentClass">
|
|
|
|
<strong v-if="editIncidentMode">{{ $t("Title") }}:</strong>
|
2021-09-16 06:37:57 +00:00
|
|
|
<Editable v-model="incident.title" tag="h4" :contenteditable="editIncidentMode" :noNL="true" class="alert-heading" />
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<strong v-if="editIncidentMode">{{ $t("Content") }}:</strong>
|
2021-09-16 06:37:57 +00:00
|
|
|
<Editable v-model="incident.content" tag="div" :contenteditable="editIncidentMode" class="content" />
|
|
|
|
|
2021-09-19 11:04:51 +00:00
|
|
|
<!-- Incident Date -->
|
|
|
|
<div class="date mt-3">
|
2021-11-12 08:54:31 +00:00
|
|
|
{{ $t("Created") }}: {{ $root.datetime(incident.createdDate) }} ({{ dateFromNow(incident.createdDate) }})<br />
|
2021-09-19 11:04:51 +00:00
|
|
|
<span v-if="incident.lastUpdatedDate">
|
2021-11-12 08:54:31 +00:00
|
|
|
{{ $t("Last Updated") }}: {{ $root.datetime(incident.lastUpdatedDate) }} ({{ dateFromNow(incident.lastUpdatedDate) }})
|
2021-09-19 11:04:51 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
<div v-if="editMode" class="mt-3">
|
2021-09-16 14:48:28 +00:00
|
|
|
<button v-if="editIncidentMode" class="btn btn-light me-2" @click="postIncident">
|
2021-09-16 06:37:57 +00:00
|
|
|
<font-awesome-icon icon="bullhorn" />
|
|
|
|
{{ $t("Post") }}
|
|
|
|
</button>
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<button v-if="!editIncidentMode && incident.id" class="btn btn-light me-2" @click="editIncident">
|
2021-09-16 06:37:57 +00:00
|
|
|
<font-awesome-icon icon="edit" />
|
|
|
|
{{ $t("Edit") }}
|
|
|
|
</button>
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<button v-if="editIncidentMode" class="btn btn-light me-2" @click="cancelIncident">
|
|
|
|
<font-awesome-icon icon="times" />
|
|
|
|
{{ $t("Cancel") }}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<div v-if="editIncidentMode" class="dropdown d-inline-block me-2">
|
|
|
|
<button id="dropdownMenuButton1" class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
2021-11-12 08:53:41 +00:00
|
|
|
{{ $t("Style") }}: {{ $t(incident.style) }}
|
2021-09-16 14:48:28 +00:00
|
|
|
</button>
|
|
|
|
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
|
2021-11-11 10:07:48 +00:00
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'info'">{{ $t("info") }}</a></li>
|
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'warning'">{{ $t("warning") }}</a></li>
|
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'danger'">{{ $t("danger") }}</a></li>
|
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'primary'">{{ $t("primary") }}</a></li>
|
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'light'">{{ $t("light") }}</a></li>
|
|
|
|
<li><a class="dropdown-item" href="#" @click="incident.style = 'dark'">{{ $t("dark") }}</a></li>
|
2021-09-16 14:48:28 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button v-if="!editIncidentMode && incident.id" class="btn btn-light me-2" @click="unpinIncident">
|
2021-09-16 06:37:57 +00:00
|
|
|
<font-awesome-icon icon="unlink" />
|
|
|
|
{{ $t("Unpin") }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-12-21 02:27:05 +00:00
|
|
|
<!-- Customize -->
|
|
|
|
<div v-if="editMode && enableEditCustomizeMode" class="mb-4 p-4 alert shadow-box customize" role="alert">
|
|
|
|
<strong v-if="enableEditCustomizeMode">{{ $t("Custom CSS") }}:</strong>
|
|
|
|
<Editable v-model="config.customCSS" tag="div" :contenteditable="enableEditCustomizeMode" class="content p-2" />
|
|
|
|
<br />
|
|
|
|
<strong v-if="enableEditCustomizeMode">{{ $t("Custom Footer") }}:</strong>
|
|
|
|
<Editable v-model="config.poweredBy" tag="h4" :contenteditable="enableEditCustomizeMode" :noNL="true" class="alert-heading p-2" />
|
|
|
|
</div>
|
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
<!-- Overall Status -->
|
2021-09-16 14:48:28 +00:00
|
|
|
<div class="shadow-box list p-4 overall-status mb-4">
|
2021-09-22 07:10:08 +00:00
|
|
|
<div v-if="Object.keys($root.publicMonitorList).length === 0 && loadedData">
|
2021-09-16 14:48:28 +00:00
|
|
|
<font-awesome-icon icon="question-circle" class="ok" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("No Services") }}
|
2021-09-15 06:34:30 +00:00
|
|
|
</div>
|
2021-09-16 14:48:28 +00:00
|
|
|
|
|
|
|
<template v-else>
|
|
|
|
<div v-if="allUp">
|
|
|
|
<font-awesome-icon icon="check-circle" class="ok" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("All Systems Operational") }}
|
2021-09-16 14:48:28 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-20 08:22:18 +00:00
|
|
|
<div v-else-if="partialDown">
|
2021-09-16 14:48:28 +00:00
|
|
|
<font-awesome-icon icon="exclamation-circle" class="warning" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("Partially Degraded Service") }}
|
2021-09-16 14:48:28 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-20 08:22:18 +00:00
|
|
|
<div v-else-if="allDown">
|
2021-09-16 14:48:28 +00:00
|
|
|
<font-awesome-icon icon="times-circle" class="danger" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("Degraded Service") }}
|
2021-09-16 14:48:28 +00:00
|
|
|
</div>
|
2021-09-20 08:22:18 +00:00
|
|
|
|
|
|
|
<div v-else>
|
2021-09-28 06:07:42 +00:00
|
|
|
<font-awesome-icon icon="question-circle" style="color: #efefef;" />
|
2021-09-20 08:22:18 +00:00
|
|
|
</div>
|
2021-09-16 14:48:28 +00:00
|
|
|
</template>
|
2021-09-14 06:12:27 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
<!-- Description -->
|
2021-09-16 14:48:28 +00:00
|
|
|
<strong v-if="editMode">{{ $t("Description") }}:</strong>
|
|
|
|
<Editable v-model="config.description" :contenteditable="editMode" tag="div" class="mb-4 description" />
|
2021-09-14 15:27:11 +00:00
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<div v-if="editMode" class="mb-4">
|
2021-09-14 15:27:11 +00:00
|
|
|
<div>
|
2021-09-15 06:34:30 +00:00
|
|
|
<button class="btn btn-primary btn-add-group me-2" @click="addGroup">
|
|
|
|
<font-awesome-icon icon="plus" />
|
2021-09-23 12:42:33 +00:00
|
|
|
{{ $t("Add Group") }}
|
2021-09-15 06:34:30 +00:00
|
|
|
</button>
|
2021-09-11 11:40:03 +00:00
|
|
|
</div>
|
2021-09-14 15:27:11 +00:00
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
<div class="mt-3">
|
2021-09-22 17:25:33 +00:00
|
|
|
<div v-if="allMonitorList.length > 0 && loadedData">
|
|
|
|
<label>{{ $t("Add a monitor") }}:</label>
|
|
|
|
<select v-model="selectedMonitor" class="form-control">
|
|
|
|
<option v-for="monitor in allMonitorList" :key="monitor.id" :value="monitor">{{ monitor.name }}</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2021-09-24 08:51:53 +00:00
|
|
|
<div v-else class="text-center">
|
|
|
|
{{ $t("No monitors available.") }} <router-link to="/add">{{ $t("Add one") }}</router-link>
|
|
|
|
</div>
|
2021-09-11 15:43:07 +00:00
|
|
|
</div>
|
2021-09-11 11:40:03 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<div class="mb-4">
|
2021-09-22 07:10:08 +00:00
|
|
|
<div v-if="$root.publicGroupList.length === 0 && loadedData" class="text-center">
|
2021-09-23 12:42:33 +00:00
|
|
|
<!-- 👀 Nothing here, please add a group or a monitor. -->
|
2021-09-24 06:42:54 +00:00
|
|
|
👀 {{ $t("statusPageNothing") }}
|
2021-09-15 06:34:30 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
<PublicGroupList :edit-mode="enableEditMode" />
|
2021-09-13 11:21:39 +00:00
|
|
|
</div>
|
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
<footer class="mt-5 mb-4">
|
2021-12-21 02:27:05 +00:00
|
|
|
<p v-if="config.poweredBy">{{ config.poweredBy }}</p>
|
|
|
|
<p v-else>{{ $t("Powered by") }} <a target="_blank" href="https://github.com/louislam/uptime-kuma">{{ $t("Uptime Kuma" ) }}</a></p>
|
2021-09-11 11:40:03 +00:00
|
|
|
</footer>
|
|
|
|
</div>
|
2021-12-21 02:27:05 +00:00
|
|
|
|
|
|
|
<component is="style" v-if="config.customCSS" type="text/css">
|
|
|
|
{{ config.customCSS }}
|
|
|
|
</component>
|
2021-09-11 08:22:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-09-11 15:43:07 +00:00
|
|
|
import axios from "axios";
|
2021-09-16 14:48:28 +00:00
|
|
|
import PublicGroupList from "../components/PublicGroupList.vue";
|
2021-09-15 10:28:48 +00:00
|
|
|
import ImageCropUpload from "vue-image-crop-upload";
|
2021-09-16 14:48:28 +00:00
|
|
|
import { STATUS_PAGE_ALL_DOWN, STATUS_PAGE_ALL_UP, STATUS_PAGE_PARTIAL_DOWN, UP } from "../util.ts";
|
|
|
|
import { useToast } from "vue-toastification";
|
2021-09-19 11:04:51 +00:00
|
|
|
import dayjs from "dayjs";
|
2021-09-16 14:48:28 +00:00
|
|
|
const toast = useToast();
|
2021-09-11 15:43:07 +00:00
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
const leavePageMsg = "Do you really want to leave? you have unsaved changes!";
|
|
|
|
|
2021-09-17 06:42:19 +00:00
|
|
|
let feedInterval;
|
|
|
|
|
2021-09-11 08:22:30 +00:00
|
|
|
export default {
|
2021-09-11 15:43:07 +00:00
|
|
|
components: {
|
2021-09-16 14:48:28 +00:00
|
|
|
PublicGroupList,
|
2021-09-15 10:28:48 +00:00
|
|
|
ImageCropUpload
|
2021-09-11 15:43:07 +00:00
|
|
|
},
|
2021-09-15 06:34:30 +00:00
|
|
|
|
|
|
|
// Leave Page for vue route change
|
|
|
|
beforeRouteLeave(to, from, next) {
|
|
|
|
if (this.editMode) {
|
|
|
|
const answer = window.confirm(leavePageMsg);
|
|
|
|
if (answer) {
|
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
next(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next();
|
|
|
|
},
|
|
|
|
|
2021-09-11 08:22:30 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-09-12 18:26:45 +00:00
|
|
|
enableEditMode: false,
|
2021-09-16 06:37:57 +00:00
|
|
|
enableEditIncidentMode: false,
|
2021-12-21 02:27:05 +00:00
|
|
|
enableEditCustomizeMode: false,
|
2021-09-11 08:22:30 +00:00
|
|
|
hasToken: false,
|
2021-09-11 11:40:03 +00:00
|
|
|
config: {},
|
2021-09-12 18:26:45 +00:00
|
|
|
selectedMonitor: null,
|
2021-09-15 10:28:48 +00:00
|
|
|
incident: null,
|
2021-09-17 06:42:19 +00:00
|
|
|
previousIncident: null,
|
2021-09-15 10:28:48 +00:00
|
|
|
showImageCropUpload: false,
|
|
|
|
imgDataUrl: "/icon.svg",
|
2021-09-20 08:22:18 +00:00
|
|
|
loadedTheme: false,
|
2021-09-22 07:10:08 +00:00
|
|
|
loadedData: false,
|
2021-09-22 07:31:15 +00:00
|
|
|
baseURL: "",
|
2021-09-17 06:42:19 +00:00
|
|
|
};
|
2021-09-11 08:22:30 +00:00
|
|
|
},
|
|
|
|
computed: {
|
2021-09-13 11:21:39 +00:00
|
|
|
|
2021-09-22 07:31:15 +00:00
|
|
|
logoURL() {
|
|
|
|
if (this.imgDataUrl.startsWith("data:")) {
|
|
|
|
return this.imgDataUrl;
|
|
|
|
} else {
|
|
|
|
return this.baseURL + this.imgDataUrl;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-09-14 06:12:27 +00:00
|
|
|
/**
|
|
|
|
* If the monitor is added to public list, which will not be in this list.
|
|
|
|
*/
|
2021-09-12 18:26:45 +00:00
|
|
|
allMonitorList() {
|
2021-09-13 11:21:39 +00:00
|
|
|
let result = [];
|
|
|
|
|
|
|
|
for (let id in this.$root.monitorList) {
|
2021-09-14 06:12:27 +00:00
|
|
|
if (this.$root.monitorList[id] && ! (id in this.$root.publicMonitorList)) {
|
2021-09-13 11:21:39 +00:00
|
|
|
let monitor = this.$root.monitorList[id];
|
|
|
|
result.push(monitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2021-09-12 18:26:45 +00:00
|
|
|
},
|
2021-09-15 06:34:30 +00:00
|
|
|
|
2021-09-14 15:27:11 +00:00
|
|
|
editMode() {
|
2021-09-12 18:26:45 +00:00
|
|
|
return this.enableEditMode && this.$root.socket.connected;
|
2021-09-15 06:34:30 +00:00
|
|
|
},
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
editIncidentMode() {
|
2021-09-16 14:48:28 +00:00
|
|
|
return this.enableEditIncidentMode;
|
2021-09-16 06:37:57 +00:00
|
|
|
},
|
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
isPublished() {
|
|
|
|
return this.config.statusPagePublished;
|
|
|
|
},
|
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
theme() {
|
|
|
|
return this.config.statusPageTheme;
|
|
|
|
},
|
|
|
|
|
2021-10-29 05:19:24 +00:00
|
|
|
tagsVisible() {
|
2021-12-21 02:27:05 +00:00
|
|
|
return this.config.statusPageTags;
|
2021-10-29 05:19:24 +00:00
|
|
|
},
|
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
logoClass() {
|
|
|
|
if (this.editMode) {
|
|
|
|
return {
|
|
|
|
"edit-mode": true,
|
2021-09-17 06:42:19 +00:00
|
|
|
};
|
2021-09-15 10:28:48 +00:00
|
|
|
}
|
|
|
|
return {};
|
2021-09-16 14:48:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
incidentClass() {
|
|
|
|
return "bg-" + this.incident.style;
|
|
|
|
},
|
|
|
|
|
|
|
|
overallStatus() {
|
2021-09-20 08:22:18 +00:00
|
|
|
|
|
|
|
if (Object.keys(this.$root.publicLastHeartbeatList).length === 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
let status = STATUS_PAGE_ALL_UP;
|
|
|
|
let hasUp = false;
|
|
|
|
|
|
|
|
for (let id in this.$root.publicLastHeartbeatList) {
|
|
|
|
let beat = this.$root.publicLastHeartbeatList[id];
|
|
|
|
|
|
|
|
if (beat.status === UP) {
|
|
|
|
hasUp = true;
|
|
|
|
} else {
|
|
|
|
status = STATUS_PAGE_PARTIAL_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! hasUp) {
|
|
|
|
status = STATUS_PAGE_ALL_DOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
},
|
|
|
|
|
|
|
|
allUp() {
|
|
|
|
return this.overallStatus === STATUS_PAGE_ALL_UP;
|
|
|
|
},
|
|
|
|
|
|
|
|
partialDown() {
|
|
|
|
return this.overallStatus === STATUS_PAGE_PARTIAL_DOWN;
|
|
|
|
},
|
|
|
|
|
|
|
|
allDown() {
|
|
|
|
return this.overallStatus === STATUS_PAGE_ALL_DOWN;
|
|
|
|
},
|
2021-09-15 10:28:48 +00:00
|
|
|
|
2021-09-11 08:22:30 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
|
2021-09-13 11:21:39 +00:00
|
|
|
/**
|
|
|
|
* Selected a monitor and add to the list.
|
|
|
|
*/
|
|
|
|
selectedMonitor(monitor) {
|
|
|
|
if (monitor) {
|
|
|
|
if (this.$root.publicGroupList.length === 0) {
|
|
|
|
this.addGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
const firstGroup = this.$root.publicGroupList[0];
|
|
|
|
|
|
|
|
firstGroup.monitorList.push(monitor);
|
|
|
|
this.selectedMonitor = null;
|
|
|
|
}
|
2021-09-15 10:28:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// Set Theme
|
|
|
|
"config.statusPageTheme"() {
|
|
|
|
this.$root.statusPageTheme = this.config.statusPageTheme;
|
2021-09-20 08:22:18 +00:00
|
|
|
this.loadedTheme = true;
|
2021-09-21 15:59:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
"config.title"(title) {
|
|
|
|
document.title = title;
|
2021-09-13 11:21:39 +00:00
|
|
|
}
|
2021-09-15 10:28:48 +00:00
|
|
|
|
2021-09-11 08:22:30 +00:00
|
|
|
},
|
2021-09-11 11:40:03 +00:00
|
|
|
async created() {
|
2021-09-24 07:26:48 +00:00
|
|
|
this.hasToken = ("token" in this.$root.storage());
|
2021-09-11 11:40:03 +00:00
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
// Browser change page
|
|
|
|
// https://stackoverflow.com/questions/7317273/warn-user-before-leaving-web-page-with-unsaved-changes
|
|
|
|
window.addEventListener("beforeunload", (e) => {
|
|
|
|
if (this.editMode) {
|
|
|
|
(e || window.event).returnValue = leavePageMsg;
|
|
|
|
return leavePageMsg;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
2021-09-22 07:31:15 +00:00
|
|
|
|
|
|
|
// Special handle for dev
|
|
|
|
const env = process.env.NODE_ENV;
|
|
|
|
if (env === "development" || localStorage.dev === "dev") {
|
|
|
|
this.baseURL = location.protocol + "//" + location.hostname + ":3001";
|
|
|
|
}
|
2021-09-11 08:22:30 +00:00
|
|
|
},
|
2021-09-11 15:43:07 +00:00
|
|
|
async mounted() {
|
2021-09-16 14:48:28 +00:00
|
|
|
axios.get("/api/status-page/config").then((res) => {
|
|
|
|
this.config = res.data;
|
2021-09-20 08:22:18 +00:00
|
|
|
|
2021-09-21 13:22:35 +00:00
|
|
|
if (this.config.logo) {
|
|
|
|
this.imgDataUrl = this.config.logo;
|
|
|
|
}
|
2021-09-16 14:48:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
axios.get("/api/status-page/incident").then((res) => {
|
|
|
|
if (res.data.ok) {
|
|
|
|
this.incident = res.data.incident;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
axios.get("/api/status-page/monitor-list").then((res) => {
|
2021-09-19 11:04:51 +00:00
|
|
|
this.$root.publicGroupList = res.data;
|
2021-09-16 14:48:28 +00:00
|
|
|
});
|
2021-09-17 06:42:19 +00:00
|
|
|
|
|
|
|
// 5mins a loop
|
2021-09-19 15:24:51 +00:00
|
|
|
this.updateHeartbeatList();
|
2021-09-17 06:42:19 +00:00
|
|
|
feedInterval = setInterval(() => {
|
2021-09-19 15:24:51 +00:00
|
|
|
this.updateHeartbeatList();
|
2021-09-21 16:58:22 +00:00
|
|
|
}, (300 + 10) * 1000);
|
2021-09-19 15:24:51 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
|
|
|
|
updateHeartbeatList() {
|
2021-09-17 06:42:19 +00:00
|
|
|
// If editMode, it will use the data from websocket.
|
|
|
|
if (! this.editMode) {
|
|
|
|
axios.get("/api/status-page/heartbeat").then((res) => {
|
2021-09-19 15:24:51 +00:00
|
|
|
this.$root.heartbeatList = res.data.heartbeatList;
|
2021-09-22 07:10:08 +00:00
|
|
|
this.$root.uptimeList = res.data.uptimeList;
|
|
|
|
this.loadedData = true;
|
2021-09-17 06:42:19 +00:00
|
|
|
});
|
|
|
|
}
|
2021-09-19 15:24:51 +00:00
|
|
|
},
|
2021-09-12 18:26:45 +00:00
|
|
|
|
2021-09-11 08:22:30 +00:00
|
|
|
edit() {
|
|
|
|
this.$root.initSocketIO(true);
|
2021-09-12 18:26:45 +00:00
|
|
|
this.enableEditMode = true;
|
|
|
|
},
|
|
|
|
|
2021-09-19 11:04:51 +00:00
|
|
|
save() {
|
2021-09-20 08:22:18 +00:00
|
|
|
this.$root.getSocket().emit("saveStatusPage", this.config, this.imgDataUrl, this.$root.publicGroupList, (res) => {
|
2021-09-19 11:04:51 +00:00
|
|
|
if (res.ok) {
|
|
|
|
this.enableEditMode = false;
|
|
|
|
this.$root.publicGroupList = res.publicGroupList;
|
2021-09-22 07:10:08 +00:00
|
|
|
location.reload();
|
2021-09-19 11:04:51 +00:00
|
|
|
} else {
|
|
|
|
toast.error(res.msg);
|
|
|
|
}
|
|
|
|
});
|
2021-09-12 18:26:45 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
monitorSelectorLabel(monitor) {
|
|
|
|
return `${monitor.name}`;
|
|
|
|
},
|
|
|
|
|
2021-09-13 11:21:39 +00:00
|
|
|
addGroup() {
|
2021-11-11 09:53:38 +00:00
|
|
|
let groupName = this.$t("Untitled Group");
|
2021-09-15 06:34:30 +00:00
|
|
|
|
|
|
|
if (this.$root.publicGroupList.length === 0) {
|
2021-11-11 09:53:38 +00:00
|
|
|
groupName = this.$t("Services");
|
2021-09-15 06:34:30 +00:00
|
|
|
}
|
|
|
|
|
2021-11-05 10:27:19 +00:00
|
|
|
this.$root.publicGroupList.unshift({
|
2021-09-15 06:34:30 +00:00
|
|
|
name: groupName,
|
2021-09-13 11:21:39 +00:00
|
|
|
monitorList: [],
|
2021-09-17 06:42:19 +00:00
|
|
|
});
|
2021-09-14 06:12:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
discard() {
|
|
|
|
location.reload();
|
2021-09-15 10:28:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
changeTheme(name) {
|
|
|
|
this.config.statusPageTheme = name;
|
|
|
|
},
|
2021-10-29 05:19:24 +00:00
|
|
|
changeTagsVisibilty(newState) {
|
|
|
|
this.config.statusPageTags = newState;
|
|
|
|
|
2021-11-01 09:14:41 +00:00
|
|
|
// On load, the status page will not include tags if it's not enabled for security reasons
|
2021-10-29 05:19:24 +00:00
|
|
|
// Which means if we enable tags, it won't show in the UI until saved
|
|
|
|
// So we have this to enhance UX and load in the tags from the authenticated source instantly
|
2021-11-02 22:46:53 +00:00
|
|
|
this.$root.publicGroupList = this.$root.publicGroupList.map((group) => {
|
2021-10-31 23:52:21 +00:00
|
|
|
return {
|
|
|
|
...group,
|
2021-11-02 22:46:53 +00:00
|
|
|
monitorList: group.monitorList.map((monitor) => {
|
2021-10-29 05:19:24 +00:00
|
|
|
// We only include the tags if visible so we can reuse the logic to hide the tags on disable
|
2021-10-31 23:52:21 +00:00
|
|
|
return {
|
|
|
|
...monitor,
|
2021-11-01 00:23:46 +00:00
|
|
|
tags: newState ? this.$root.monitorList[monitor.id].tags : []
|
2021-12-21 02:27:05 +00:00
|
|
|
};
|
2021-10-29 05:19:24 +00:00
|
|
|
})
|
2021-12-21 02:27:05 +00:00
|
|
|
};
|
2021-10-29 05:19:24 +00:00
|
|
|
});
|
|
|
|
},
|
2021-09-15 10:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2021-09-16 06:37:57 +00:00
|
|
|
* Crop Success
|
2021-09-15 10:28:48 +00:00
|
|
|
*/
|
2021-09-16 06:37:57 +00:00
|
|
|
cropSuccess(imgDataUrl) {
|
2021-09-15 10:28:48 +00:00
|
|
|
this.imgDataUrl = imgDataUrl;
|
|
|
|
},
|
|
|
|
|
|
|
|
showImageCropUploadMethod() {
|
|
|
|
if (this.editMode) {
|
|
|
|
this.showImageCropUpload = true;
|
|
|
|
}
|
2021-09-16 06:37:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
createIncident() {
|
|
|
|
this.enableEditIncidentMode = true;
|
2021-09-17 06:42:19 +00:00
|
|
|
|
|
|
|
if (this.incident) {
|
|
|
|
this.previousIncident = this.incident;
|
|
|
|
}
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
this.incident = {
|
|
|
|
title: "",
|
|
|
|
content: "",
|
2021-09-16 14:48:28 +00:00
|
|
|
style: "primary",
|
2021-09-16 06:37:57 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
postIncident() {
|
2021-09-16 14:48:28 +00:00
|
|
|
if (this.incident.title == "" || this.incident.content == "") {
|
2021-11-12 09:14:23 +00:00
|
|
|
toast.error(this.$t("Please input title and content"));
|
2021-09-16 14:48:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$root.getSocket().emit("postIncident", this.incident, (res) => {
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
this.enableEditIncidentMode = false;
|
|
|
|
this.incident = res.incident;
|
|
|
|
} else {
|
|
|
|
toast.error(res.msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2021-09-16 06:37:57 +00:00
|
|
|
},
|
|
|
|
|
2021-09-16 14:48:28 +00:00
|
|
|
/**
|
|
|
|
* Click Edit Button
|
|
|
|
*/
|
2021-09-16 06:37:57 +00:00
|
|
|
editIncident() {
|
|
|
|
this.enableEditIncidentMode = true;
|
2021-09-17 06:42:19 +00:00
|
|
|
this.previousIncident = Object.assign({}, this.incident);
|
2021-09-16 06:37:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
cancelIncident() {
|
|
|
|
this.enableEditIncidentMode = false;
|
2021-09-17 06:42:19 +00:00
|
|
|
|
|
|
|
if (this.previousIncident) {
|
|
|
|
this.incident = this.previousIncident;
|
|
|
|
this.previousIncident = null;
|
|
|
|
}
|
2021-09-16 06:37:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
unpinIncident() {
|
2021-09-16 14:48:28 +00:00
|
|
|
this.$root.getSocket().emit("unpinIncident", () => {
|
|
|
|
this.incident = null;
|
2021-09-17 06:42:19 +00:00
|
|
|
});
|
2021-09-28 06:07:42 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
dateFromNow(date) {
|
|
|
|
return dayjs.utc(date).fromNow();
|
|
|
|
},
|
|
|
|
|
2021-12-21 02:27:05 +00:00
|
|
|
/** customize status page */
|
|
|
|
customizeStatusPage() {
|
|
|
|
// toggle modal
|
|
|
|
this.enableEditCustomizeMode = !this.enableEditCustomizeMode;
|
|
|
|
},
|
|
|
|
|
2021-09-15 06:34:30 +00:00
|
|
|
}
|
2021-09-17 06:42:19 +00:00
|
|
|
};
|
2021-09-11 08:22:30 +00:00
|
|
|
</script>
|
2021-09-11 11:40:03 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "../assets/vars.scss";
|
|
|
|
|
|
|
|
.overall-status {
|
|
|
|
font-weight: bold;
|
2021-09-14 06:12:27 +00:00
|
|
|
font-size: 25px;
|
2021-09-11 11:40:03 +00:00
|
|
|
|
|
|
|
.ok {
|
|
|
|
color: $primary;
|
|
|
|
}
|
2021-09-14 06:12:27 +00:00
|
|
|
|
|
|
|
.warning {
|
|
|
|
color: $warning;
|
|
|
|
}
|
2021-09-15 06:34:30 +00:00
|
|
|
|
|
|
|
.danger {
|
|
|
|
color: $danger;
|
|
|
|
}
|
2021-09-11 11:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
font-size: 30px;
|
|
|
|
|
|
|
|
img {
|
|
|
|
vertical-align: middle;
|
|
|
|
height: 60px;
|
|
|
|
width: 60px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer {
|
|
|
|
text-align: center;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
2021-09-13 11:21:39 +00:00
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
.description span {
|
|
|
|
min-width: 50px;
|
|
|
|
}
|
|
|
|
|
2021-09-21 13:22:35 +00:00
|
|
|
.logo-wrapper {
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.icon-upload {
|
|
|
|
transform: scale(1.2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon-upload {
|
|
|
|
transition: all $easing-in 0.2s;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 6px;
|
|
|
|
font-size: 20px;
|
|
|
|
left: -14px;
|
|
|
|
background-color: white;
|
|
|
|
padding: 5px;
|
|
|
|
border-radius: 10px;
|
|
|
|
cursor: pointer;
|
|
|
|
box-shadow: 0 15px 70px rgba(0, 0, 0, 0.9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-15 10:28:48 +00:00
|
|
|
.logo {
|
|
|
|
transition: all $easing-in 0.2s;
|
|
|
|
|
|
|
|
&.edit-mode {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
transform: scale(1.2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 02:27:05 +00:00
|
|
|
.incident, .customize {
|
2021-09-16 06:37:57 +00:00
|
|
|
.content {
|
2021-09-19 11:04:51 +00:00
|
|
|
&[contenteditable=true] {
|
|
|
|
min-height: 60px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.date {
|
2021-09-21 13:22:35 +00:00
|
|
|
font-size: 12px;
|
2021-09-16 06:37:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-23 08:31:45 +00:00
|
|
|
.mobile {
|
|
|
|
h1 {
|
|
|
|
font-size: 22px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.overall-status {
|
|
|
|
font-size: 20px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 11:40:03 +00:00
|
|
|
</style>
|