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");
const { allowDevAllOrigin, getSettings, setting } = require("../util-server");
const { R } = require("redbean-node");
const server = require("../server");
let router = express.Router();
router.get("/api/entry-page", async (_, response) => {
allowDevAllOrigin(response);
response.json(server.entryPage);
});
// Status Page Config
router.get("/api/status-page/config", async (_request, response) => {
allowDevAllOrigin(response);

View file

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

View file

@ -35,7 +35,7 @@
<div class="row">
<div class="col-6 col-md-8 small-padding">
<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)" />
<Uptime :monitor="monitor.element" type="24" :pill="true" />
@ -94,10 +94,6 @@ export default {
removeMonitor(groupIndex, index) {
this.$root.publicGroupList[groupIndex].monitorList.splice(index, 1);
},
showMonitorDrag(groupIndex) {
return this.$root.publicGroupList[groupIndex].monitorList.length >= 2
}
}
}
</script>

View file

@ -78,6 +78,7 @@
<script>
import Login from "../components/Login.vue";
import compareVersions from "compare-versions";
import axios from "axios";
export default {
@ -120,9 +121,16 @@ export default {
},
methods: {
init() {
async init() {
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 {
data() {
return {

View file

@ -83,6 +83,24 @@
</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>
<button class="btn btn-primary" type="submit">
{{ $t("Save") }}
@ -180,17 +198,14 @@
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
{{ $t("Setup Notification") }}
</button>
</div>
</div>
</div>
<footer>
<div class="container-fluid">
Uptime Kuma -
{{ $t("Version") }}: {{ $root.info.version }} -
<h2 class="mt-5">Info</h2>
{{ $t("Version") }}: {{ $root.info.version }} <br />
<a href="https://github.com/louislam/uptime-kuma/releases" target="_blank" rel="noopener">{{ $t("Check Update On GitHub") }}</a>
</div>
</footer>
</div>
</div>
<NotificationDialog ref="notificationDialog" />
<TwoFADialog ref="TwoFADialog" />
@ -360,6 +375,10 @@ export default {
this.settings.searchEngineIndex = false;
}
if (this.settings.entryPage === undefined) {
this.settings.entryPage = "dashboard";
}
this.loaded = true;
})
},

View file

@ -150,13 +150,6 @@ import axios from "axios";
import GroupList from "../components/GroupList.vue";
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!";
export default {