2021-06-25 13:55:49 +00:00
|
|
|
<template>
|
2021-07-27 17:47:13 +00:00
|
|
|
<h1 class="mb-3">
|
|
|
|
Settings
|
|
|
|
</h1>
|
2021-06-25 13:55:49 +00:00
|
|
|
|
|
|
|
<div class="shadow-box">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6">
|
|
|
|
<h2>General</h2>
|
2021-07-01 13:47:14 +00:00
|
|
|
<form class="mb-3" @submit.prevent="saveGeneral">
|
2021-06-25 13:55:49 +00:00
|
|
|
<div class="mb-3">
|
|
|
|
<label for="timezone" class="form-label">Timezone</label>
|
2021-07-27 17:47:13 +00:00
|
|
|
<select id="timezone" v-model="$root.userTimezone" class="form-select">
|
|
|
|
<option value="auto">
|
|
|
|
Auto: {{ guessTimezone }}
|
|
|
|
</option>
|
|
|
|
<option v-for="(timezone, index) in timezoneList" :key="index" :value="timezone.value">
|
|
|
|
{{ timezone.name }}
|
|
|
|
</option>
|
2021-06-25 13:55:49 +00:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
2021-07-27 17:47:13 +00:00
|
|
|
<button class="btn btn-primary" type="submit">
|
|
|
|
Save
|
|
|
|
</button>
|
2021-06-25 13:55:49 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
2021-07-31 15:41:24 +00:00
|
|
|
<template v-if="loaded">
|
|
|
|
<template v-if="! settings.disableAuth">
|
|
|
|
<h2>Change Password</h2>
|
|
|
|
<form class="mb-3" @submit.prevent="savePassword">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="current-password" class="form-label">Current Password</label>
|
|
|
|
<input id="current-password" v-model="password.currentPassword" type="password" class="form-control" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="new-password" class="form-label">New Password</label>
|
|
|
|
<input id="new-password" v-model="password.newPassword" type="password" class="form-control" required>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="repeat-new-password" class="form-label">Repeat New Password</label>
|
|
|
|
<input id="repeat-new-password" v-model="password.repeatNewPassword" type="password" class="form-control" :class="{ 'is-invalid' : invalidPassword }" required>
|
|
|
|
<div class="invalid-feedback">
|
|
|
|
The repeat password does not match.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<button class="btn btn-primary" type="submit">
|
|
|
|
Update Password
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<h2>Advanced</h2>
|
2021-06-25 13:55:49 +00:00
|
|
|
|
|
|
|
<div class="mb-3">
|
2021-07-31 15:41:24 +00:00
|
|
|
<button v-if="settings.disableAuth" class="btn btn-outline-primary me-1" @click="enableAuth">Enable Auth</button>
|
|
|
|
<button v-if="! settings.disableAuth" class="btn btn-primary me-1" @click="confirmDisableAuth">Disable Auth</button>
|
|
|
|
<button v-if="! settings.disableAuth" class="btn btn-danger me-1" @click="$root.logout">Logout</button>
|
2021-06-25 13:55:49 +00:00
|
|
|
</div>
|
2021-07-31 15:41:24 +00:00
|
|
|
</template>
|
2021-06-25 13:55:49 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-6">
|
2021-07-27 17:47:13 +00:00
|
|
|
<div v-if="$root.isMobile" class="mt-3" />
|
2021-07-11 07:23:28 +00:00
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
<h2>Notifications</h2>
|
2021-07-27 17:47:13 +00:00
|
|
|
<p v-if="$root.notificationList.length === 0">
|
|
|
|
Not available, please setup.
|
|
|
|
</p>
|
|
|
|
<p v-else>
|
|
|
|
Please assign a notification to monitor(s) to get it to work.
|
|
|
|
</p>
|
2021-07-09 09:55:48 +00:00
|
|
|
|
2021-07-10 04:04:40 +00:00
|
|
|
<ul class="list-group mb-3" style="border-radius: 1rem;">
|
2021-07-27 17:47:13 +00:00
|
|
|
<li v-for="(notification, index) in $root.notificationList" :key="index" class="list-group-item">
|
|
|
|
{{ notification.name }}<br>
|
2021-07-09 09:55:48 +00:00
|
|
|
<a href="#" @click="$refs.notificationDialog.show(notification.id)">Edit</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2021-07-27 17:47:13 +00:00
|
|
|
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
|
|
|
|
Setup Notification
|
|
|
|
</button>
|
2021-06-25 13:55:49 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-07-09 09:55:48 +00:00
|
|
|
<NotificationDialog ref="notificationDialog" />
|
2021-07-31 13:57:58 +00:00
|
|
|
|
|
|
|
<Confirm ref="confirmDisableAuth" btn-style="btn-danger" yes-text="I understand, please disable" no-text="Leave" @yes="disableAuth">
|
|
|
|
<p>Are you sure want to <strong>disable auth</strong>?</p>
|
|
|
|
<p>It is for <strong>someone who have 3rd-party auth</strong> in front of Uptime Kuma such as Cloudflare Access.</p>
|
|
|
|
<p>Please use it carefully.</p>
|
|
|
|
</Confirm>
|
2021-06-25 13:55:49 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-07-31 13:57:58 +00:00
|
|
|
import Confirm from "../components/Confirm.vue";
|
2021-06-30 18:02:54 +00:00
|
|
|
import dayjs from "dayjs";
|
2021-07-27 17:47:13 +00:00
|
|
|
import utc from "dayjs/plugin/utc"
|
|
|
|
import timezone from "dayjs/plugin/timezone"
|
2021-07-09 09:55:48 +00:00
|
|
|
import NotificationDialog from "../components/NotificationDialog.vue";
|
2021-06-30 18:02:54 +00:00
|
|
|
dayjs.extend(utc)
|
|
|
|
dayjs.extend(timezone)
|
2021-07-31 13:57:58 +00:00
|
|
|
|
2021-07-27 17:47:13 +00:00
|
|
|
import { timezoneList } from "../util-frontend";
|
|
|
|
import { useToast } from "vue-toastification"
|
2021-07-01 13:47:14 +00:00
|
|
|
const toast = useToast()
|
2021-06-25 13:55:49 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2021-07-27 17:47:13 +00:00
|
|
|
NotificationDialog,
|
2021-07-31 13:57:58 +00:00
|
|
|
Confirm,
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-06-30 18:02:54 +00:00
|
|
|
timezoneList: timezoneList(),
|
|
|
|
guessTimezone: dayjs.tz.guess(),
|
2021-07-01 13:47:14 +00:00
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
invalidPassword: false,
|
|
|
|
password: {
|
|
|
|
currentPassword: "",
|
|
|
|
newPassword: "",
|
|
|
|
repeatNewPassword: "",
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
2021-07-31 13:57:58 +00:00
|
|
|
settings: {
|
|
|
|
|
2021-07-31 15:41:24 +00:00
|
|
|
},
|
|
|
|
loaded: false,
|
2021-06-25 13:55:49 +00:00
|
|
|
}
|
|
|
|
},
|
2021-07-27 17:47:13 +00:00
|
|
|
watch: {
|
|
|
|
"password.repeatNewPassword"() {
|
|
|
|
this.invalidPassword = false;
|
|
|
|
},
|
|
|
|
},
|
2021-07-01 13:47:14 +00:00
|
|
|
|
|
|
|
mounted() {
|
2021-07-31 13:57:58 +00:00
|
|
|
this.loadSettings();
|
2021-07-01 13:47:14 +00:00
|
|
|
},
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
methods: {
|
2021-07-01 13:47:14 +00:00
|
|
|
|
|
|
|
saveGeneral() {
|
|
|
|
localStorage.timezone = this.$root.userTimezone;
|
|
|
|
toast.success("Saved.")
|
|
|
|
},
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
savePassword() {
|
|
|
|
if (this.password.newPassword !== this.password.repeatNewPassword) {
|
|
|
|
this.invalidPassword = true;
|
|
|
|
} else {
|
|
|
|
this.$root.getSocket().emit("changePassword", this.password, (res) => {
|
|
|
|
this.$root.toastRes(res)
|
|
|
|
if (res.ok) {
|
|
|
|
this.password.currentPassword = ""
|
|
|
|
this.password.newPassword = ""
|
|
|
|
this.password.repeatNewPassword = ""
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2021-07-31 13:57:58 +00:00
|
|
|
|
|
|
|
loadSettings() {
|
|
|
|
this.$root.getSocket().emit("getSettings", (res) => {
|
|
|
|
this.settings = res.data;
|
2021-07-31 15:41:24 +00:00
|
|
|
this.loaded = true;
|
2021-07-31 13:57:58 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
saveSettings() {
|
|
|
|
this.$root.getSocket().emit("setSettings", this.settings, (res) => {
|
|
|
|
this.$root.toastRes(res);
|
|
|
|
this.loadSettings();
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
confirmDisableAuth() {
|
|
|
|
this.$refs.confirmDisableAuth.show();
|
|
|
|
},
|
|
|
|
|
|
|
|
disableAuth() {
|
|
|
|
this.settings.disableAuth = true;
|
|
|
|
this.saveSettings();
|
|
|
|
},
|
|
|
|
|
|
|
|
enableAuth() {
|
|
|
|
this.settings.disableAuth = false;
|
|
|
|
this.saveSettings();
|
2021-07-31 15:41:24 +00:00
|
|
|
this.$root.storage().token = null;
|
2021-07-31 13:57:58 +00:00
|
|
|
},
|
|
|
|
|
2021-06-25 13:55:49 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.shadow-box {
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
</style>
|