set entry page

This commit is contained in:
LouisLam 2021-09-15 20:40:26 +08:00
parent e8f4fabcd0
commit 512ff09cca
7 changed files with 62 additions and 26 deletions

View File

@ -1,8 +1,14 @@
let express = require("express"); let express = require("express");
const { allowDevAllOrigin, getSettings, setting } = require("../util-server"); const { allowDevAllOrigin, getSettings, setting } = require("../util-server");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const server = require("../server");
let router = express.Router(); let router = express.Router();
router.get("/api/entry-page", async (_, response) => {
allowDevAllOrigin(response);
response.json(server.entryPage);
});
// Status Page Config // Status Page Config
router.get("/api/status-page/config", async (_request, response) => { router.get("/api/status-page/config", async (_request, response) => {
allowDevAllOrigin(response); allowDevAllOrigin(response);

View File

@ -131,10 +131,14 @@ let needSetup = false;
*/ */
let indexHTML = fs.readFileSync("./dist/index.html").toString(); let indexHTML = fs.readFileSync("./dist/index.html").toString();
exports.entryPage = "dashboard";
(async () => { (async () => {
await initDatabase(); await initDatabase();
console.log("Adding route") exports.entryPage = await setting("entryPage");
console.log("Adding route");
// *************************** // ***************************
// Normal Router here // Normal Router here
@ -846,7 +850,8 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
try { try {
checkLogin(socket) checkLogin(socket)
await setSettings("general", data) await setSettings("general", data);
exports.entryPage = data.entryPage;
callback({ callback({
ok: true, ok: true,

View File

@ -35,7 +35,7 @@
<div class="row"> <div class="row">
<div class="col-6 col-md-8 small-padding"> <div class="col-6 col-md-8 small-padding">
<div class="info"> <div class="info">
<font-awesome-icon v-if="editMode && showMonitorDrag(group.index)" icon="arrows-alt-v" class="action drag me-3" /> <font-awesome-icon v-if="editMode" icon="arrows-alt-v" class="action drag me-3" />
<font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" /> <font-awesome-icon v-if="editMode" icon="times" class="action remove me-3" @click="removeMonitor(group.index, monitor.index)" />
<Uptime :monitor="monitor.element" type="24" :pill="true" /> <Uptime :monitor="monitor.element" type="24" :pill="true" />
@ -94,10 +94,6 @@ export default {
removeMonitor(groupIndex, index) { removeMonitor(groupIndex, index) {
this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1); this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1);
}, },
showMonitorDrag(groupIndex) {
return this.$root.publicGroupList[groupIndex].monitorList.length >= 2
}
} }
} }
</script> </script>

View File

@ -78,6 +78,7 @@
<script> <script>
import Login from "../components/Login.vue"; import Login from "../components/Login.vue";
import compareVersions from "compare-versions"; import compareVersions from "compare-versions";
import axios from "axios";
export default { export default {
@ -120,9 +121,16 @@ export default {
}, },
methods: { methods: {
init() { async init() {
if (this.$route.name === "root") { if (this.$route.name === "root") {
this.$router.push("/dashboard")
let entryPage = (await axios.get("/api/entry-page")).data;
if (entryPage === "statusPage") {
this.$router.push("/status-page");
} else {
this.$router.push("/dashboard");
}
} }
}, },
}, },

View File

@ -1,3 +1,12 @@
import axios from "axios";
const env = process.env.NODE_ENV || "production";
// change the axios base url for development
if (env === "development" || localStorage.dev === "dev") {
axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
}
export default { export default {
data() { data() {
return { return {

View File

@ -83,6 +83,24 @@
</div> </div>
</div> </div>
<div class="mb-3">
<label class="form-label">{{ $t("Entry Page") }}</label>
<div class="form-check">
<input id="entryPageYes" v-model="settings.entryPage" class="form-check-input" type="radio" name="statusPage" value="dashboard" required>
<label class="form-check-label" for="entryPageYes">
{{ $t("Dashboard") }}
</label>
</div>
<div class="form-check">
<input id="entryPageNo" v-model="settings.entryPage" class="form-check-input" type="radio" name="statusPage" value="statusPage" required>
<label class="form-check-label" for="entryPageNo">
{{ $t("Status Page") }}
</label>
</div>
</div>
<div> <div>
<button class="btn btn-primary" type="submit"> <button class="btn btn-primary" type="submit">
{{ $t("Save") }} {{ $t("Save") }}
@ -180,17 +198,14 @@
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()"> <button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
{{ $t("Setup Notification") }} {{ $t("Setup Notification") }}
</button> </button>
</div>
</div>
</div>
<footer> <h2 class="mt-5">Info</h2>
<div class="container-fluid">
Uptime Kuma - {{ $t("Version") }}: {{ $root.info.version }} <br />
{{ $t("Version") }}: {{ $root.info.version }} -
<a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">{{ $t("Check Update On GitHub") }}</a> <a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">{{ $t("Check Update On GitHub") }}</a>
</div> </div>
</footer> </div>
</div>
<NotificationDialog ref="notificationDialog" /> <NotificationDialog ref="notificationDialog" />
<TwoFADialog ref="TwoFADialog" /> <TwoFADialog ref="TwoFADialog" />
@ -360,6 +375,10 @@ export default {
this.settings.searchEngineIndex = false; this.settings.searchEngineIndex = false;
} }
if (this.settings.entryPage === undefined) {
this.settings.entryPage = "dashboard";
}
this.loaded = true; this.loaded = true;
}) })
}, },

View File

@ -150,13 +150,6 @@ import axios from "axios";
import GroupList from "../components/GroupList.vue"; import GroupList from "../components/GroupList.vue";
import ImageCropUpload from "vue-image-crop-upload"; import ImageCropUpload from "vue-image-crop-upload";
const env = process.env.NODE_ENV || "production";
// change the axios base url for development
if (env === "development" || localStorage.dev === "dev") {
axios.defaults.baseURL = location.protocol + "//" + location.hostname + ":3001";
}
const leavePageMsg = "Do you really want to leave? you have unsaved changes!"; const leavePageMsg = "Do you really want to leave? you have unsaved changes!";
export default { export default {