uptime-kuma/src/pages/Settings.vue

192 lines
5.1 KiB
Vue
Raw Normal View History

2021-06-25 09:55:49 -04:00
<template>
2021-08-19 14:37:59 -04:00
<transition name="slide-fade" appear>
<div>
<h1 v-show="show" class="mb-3">
2021-08-24 04:44:58 -04:00
{{ $t("Settings") }}
2021-08-19 14:37:59 -04:00
</h1>
<div class="shadow-box">
<div class="row">
2021-10-20 06:54:20 -04:00
<div class="settings-menu">
<div v-for="(item, key) in subMenus"
:key="key"
class="menu-item"
:class="{ active: currentSubMenu == key }"
@click="currentSubMenu = key"
>
{{ item.title }}
2021-08-24 04:44:58 -04:00
</div>
2021-06-25 09:55:49 -04:00
</div>
2021-10-20 06:54:20 -04:00
<div class="settings-content">
<div class="settings-content-header">
{{ subMenus[currentSubMenu].title }}
</div>
<div class="mx-3">
<component :is="subMenus[currentSubMenu].component" />
2021-10-07 04:30:16 -04:00
</div>
2021-08-19 14:37:59 -04:00
</div>
</div>
2021-06-25 09:55:49 -04:00
</div>
2021-08-19 14:37:59 -04:00
</div>
</transition>
2021-06-25 09:55:49 -04:00
</template>
<script>
2021-10-20 06:54:20 -04:00
import { markRaw } from "vue";
2021-10-20 06:54:20 -04:00
import Appearance from "../components/settings/Appearance.vue";
import General from "../components/settings/General.vue";
import Notifications from "../components/settings/Notifications.vue";
import MonitorHistory from "../components/settings/MonitorHistory.vue";
import Security from "../components/settings/Security.vue";
import Backup from "../components/settings/Backup.vue";
import About from "../components/settings/About.vue";
2021-06-25 09:55:49 -04:00
export default {
2021-06-25 09:55:49 -04:00
data() {
return {
2021-10-20 06:54:20 -04:00
2021-08-19 14:37:59 -04:00
show: true,
2021-07-31 09:57:58 -04:00
2021-10-20 06:54:20 -04:00
settings: {},
settingsLoaded: false,
subMenus: {
general: {
title: this.$t("General"),
component: markRaw(General),
},
appearance: {
title: this.$t("Appearance"),
component: markRaw(Appearance),
},
notifications: {
title: this.$t("Notifications"),
component: markRaw(Notifications),
},
monitorHistory: {
title: this.$t("Monitor History"),
component: markRaw(MonitorHistory),
},
security: {
title: this.$t("Security"),
component: markRaw(Security),
},
backup: {
title: this.$t("Backup"),
component: markRaw(Backup),
},
about: {
title: this.$t("About"),
component: markRaw(About),
}
2021-07-31 11:41:24 -04:00
},
2021-10-20 06:54:20 -04:00
currentSubMenu: "general",
};
2021-06-25 09:55:49 -04:00
},
2021-07-01 09:47:14 -04:00
mounted() {
2021-07-31 09:57:58 -04:00
this.loadSettings();
2021-07-01 09:47:14 -04:00
},
2021-06-25 09:55:49 -04:00
methods: {
2021-07-31 09:57:58 -04:00
loadSettings() {
this.$root.getSocket().emit("getSettings", (res) => {
this.settings = res.data;
2021-08-09 06:46:57 -04:00
if (this.settings.searchEngineIndex === undefined) {
this.settings.searchEngineIndex = false;
}
2021-09-15 08:40:26 -04:00
if (this.settings.entryPage === undefined) {
this.settings.entryPage = "dashboard";
}
if (this.settings.keepDataPeriodDays === undefined) {
2021-10-12 11:28:21 -04:00
this.settings.keepDataPeriodDays = 180;
}
2021-10-20 06:54:20 -04:00
this.settingsLoaded = true;
});
2021-07-31 09:57:58 -04:00
},
saveSettings() {
this.$root.getSocket().emit("setSettings", this.settings, (res) => {
this.$root.toastRes(res);
this.loadSettings();
});
2021-07-31 09:57:58 -04:00
},
2021-06-25 09:55:49 -04:00
},
};
2021-06-25 09:55:49 -04:00
</script>
<style lang="scss" scoped>
@import "../assets/vars.scss";
.shadow-box {
padding: 20px;
2021-10-20 06:54:20 -04:00
min-height: calc(100vh - 155px);
max-height: calc(100vh - 30px);
}
2021-10-20 06:54:20 -04:00
footer {
color: #aaa;
font-size: 13px;
margin-top: 20px;
padding-bottom: 30px;
text-align: center;
}
2021-10-20 06:54:20 -04:00
.settings-menu {
flex: 0 0 auto;
width: 300px;
2021-10-20 06:54:20 -04:00
.menu-item {
border-radius: 10px;
margin: 0.5em;
padding: 0.7em 1em;
cursor: pointer;
}
2021-09-01 11:09:32 -04:00
2021-10-20 06:54:20 -04:00
.menu-item:hover {
background: $highlight-white;
.dark & {
background: $dark-header-bg;
}
2021-10-20 06:54:20 -04:00
}
2021-09-01 11:09:32 -04:00
2021-10-20 06:54:20 -04:00
.menu-item.active {
background: $highlight-white;
border-left: 4px solid $primary;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
.dark & {
background: $dark-header-bg;
}
2021-09-01 11:09:32 -04:00
}
}
2021-08-29 14:22:49 -04:00
2021-10-20 06:54:20 -04:00
.settings-content {
flex: 0 0 auto;
width: calc(100% - 300px);
.settings-content-header {
width: calc(100% + 20px);
border-bottom: 1px solid #dee2e6;
border-radius: 0 10px 0 0;
margin-top: -20px;
margin-right: -20px;
padding: 12.5px 1em;
font-size: 26px;
.dark & {
background: $dark-header-bg;
border-bottom: 0;
}
}
2021-08-29 14:22:49 -04:00
}
2021-06-25 09:55:49 -04:00
</style>