|
|
@ -1,10 +1,31 @@ |
|
|
|
<template> |
|
|
|
<div class="container mt-3"> |
|
|
|
<!-- Logo & Title --> |
|
|
|
<h1> |
|
|
|
<img src="/icon.svg" alt class="me-2" /> |
|
|
|
<!-- Logo --> |
|
|
|
<img :src="imgDataUrl" alt class="logo me-2" :class="logoClass" @click="showImageCropUploadMethod" /> |
|
|
|
|
|
|
|
<!-- Uploader --> |
|
|
|
<!-- url="/api/status-page/upload-logo" --> |
|
|
|
<ImageCropUpload v-model="showImageCropUpload" |
|
|
|
field="img" |
|
|
|
:width="128" |
|
|
|
:height="128" |
|
|
|
:langType="$i18n.locale" |
|
|
|
:headers="uploadHeader" |
|
|
|
img-format="png" |
|
|
|
:noCircle="true" |
|
|
|
:noSquare="false" |
|
|
|
@crop-success="cropSuccess" |
|
|
|
@crop-upload-success="cropUploadSuccess" |
|
|
|
@crop-upload-fail="cropUploadFail" |
|
|
|
/> |
|
|
|
|
|
|
|
<!-- Title --> |
|
|
|
<Editable v-model="config.title" tag="span" :contenteditable="editMode" :noNL="true" /> |
|
|
|
</h1> |
|
|
|
|
|
|
|
<!-- Admin functions --> |
|
|
|
<div v-if="hasToken" class="mt-3" style="height: 38px;"> |
|
|
|
<div v-if="!enableEditMode"> |
|
|
|
<button class="btn btn-info me-2" @click="edit"> |
|
|
@ -46,9 +67,19 @@ |
|
|
|
|
|
|
|
<!-- Set Default Language --> |
|
|
|
<!-- Set theme --> |
|
|
|
<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> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- Overall Status --> |
|
|
|
<div class="shadow-box list p-4 overall-status mt-4"> |
|
|
|
<div v-if="false"> |
|
|
|
<font-awesome-icon icon="check-circle" class="ok" /> |
|
|
@ -64,10 +95,10 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="mt-4"> |
|
|
|
<Editable v-model="config.description" :contenteditable="editMode" tag="span" /> |
|
|
|
</div> |
|
|
|
<!-- Description --> |
|
|
|
<Editable v-model="config.description" :contenteditable="editMode" tag="div" class="mt-4 description" /> |
|
|
|
|
|
|
|
<!-- Incident --> |
|
|
|
<div class="shadow-box alert alert-success mt-4 p-4" role="alert"> |
|
|
|
<h4 class="alert-heading">Well done!</h4> |
|
|
|
<p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p> |
|
|
@ -117,6 +148,7 @@ |
|
|
|
import VueMultiselect from "vue-multiselect" |
|
|
|
import axios from "axios"; |
|
|
|
import GroupList from "../components/GroupList.vue"; |
|
|
|
import ImageCropUpload from "vue-image-crop-upload"; |
|
|
|
|
|
|
|
const env = process.env.NODE_ENV || "production"; |
|
|
|
|
|
|
@ -131,6 +163,7 @@ export default { |
|
|
|
components: { |
|
|
|
GroupList, |
|
|
|
VueMultiselect, |
|
|
|
ImageCropUpload |
|
|
|
}, |
|
|
|
|
|
|
|
// Leave Page for vue route change |
|
|
@ -152,6 +185,9 @@ export default { |
|
|
|
hasToken: false, |
|
|
|
config: {}, |
|
|
|
selectedMonitor: null, |
|
|
|
incident: null, |
|
|
|
showImageCropUpload: false, |
|
|
|
imgDataUrl: "/icon.svg", |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -180,6 +216,25 @@ export default { |
|
|
|
return this.config.statusPagePublished; |
|
|
|
}, |
|
|
|
|
|
|
|
theme() { |
|
|
|
return this.config.statusPageTheme; |
|
|
|
}, |
|
|
|
|
|
|
|
uploadHeader() { |
|
|
|
return { |
|
|
|
Authorization: "Bearer " + localStorage.token, |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
logoClass() { |
|
|
|
if (this.editMode) { |
|
|
|
return { |
|
|
|
"edit-mode": true, |
|
|
|
} |
|
|
|
} |
|
|
|
return {}; |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
watch: { |
|
|
|
|
|
|
@ -197,15 +252,18 @@ export default { |
|
|
|
firstGroup.monitorList.push(monitor); |
|
|
|
this.selectedMonitor = null; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// Set Theme |
|
|
|
"config.statusPageTheme"() { |
|
|
|
this.$root.statusPageTheme = this.config.statusPageTheme; |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
async created() { |
|
|
|
this.hasToken = ("token" in localStorage); |
|
|
|
this.config = (await axios.get("/api/status-page/config")).data; |
|
|
|
|
|
|
|
// Set Theme |
|
|
|
this.$root.statusPageTheme = this.config.statusPageTheme; |
|
|
|
|
|
|
|
// Browser change page |
|
|
|
// https://stackoverflow.com/questions/7317273/warn-user-before-leaving-web-page-with-unsaved-changes |
|
|
|
window.addEventListener("beforeunload", (e) => { |
|
|
@ -250,6 +308,24 @@ export default { |
|
|
|
|
|
|
|
discard() { |
|
|
|
location.reload(); |
|
|
|
}, |
|
|
|
|
|
|
|
changeTheme(name) { |
|
|
|
this.config.statusPageTheme = name; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Crop success |
|
|
|
*/ |
|
|
|
cropSuccess(imgDataUrl, field) { |
|
|
|
console.log("-------- crop success --------"); |
|
|
|
this.imgDataUrl = imgDataUrl; |
|
|
|
}, |
|
|
|
|
|
|
|
showImageCropUploadMethod() { |
|
|
|
if (this.editMode) { |
|
|
|
this.showImageCropUpload = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -290,4 +366,20 @@ footer { |
|
|
|
font-size: 14px; |
|
|
|
} |
|
|
|
|
|
|
|
.description span { |
|
|
|
min-width: 50px; |
|
|
|
} |
|
|
|
|
|
|
|
.logo { |
|
|
|
transition: all $easing-in 0.2s; |
|
|
|
|
|
|
|
&.edit-mode { |
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
&:hover { |
|
|
|
transform: scale(1.2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|