Initial support for setting a server identifier

This commit is contained in:
Nathan Neulinger 2024-12-27 14:21:18 -06:00
parent be2faf64ce
commit afd0ae6428
8 changed files with 60 additions and 5 deletions

View file

@ -160,6 +160,7 @@ async function sendInfo(socket, hideVersion = false) {
isContainer,
dbType,
primaryBaseURL: await setting("primaryBaseURL"),
serverIdentifier: await setting("serverIdentifier"),
serverTimezone: await server.getTimezone(),
serverTimezoneOffset: server.getTimezoneOffset(),
});

View file

@ -142,8 +142,12 @@ class Slack extends NotificationProvider {
}
const baseURL = await setting("primaryBaseURL");
const serverIdentifier = await setting("serverIdentifier");
const title = "Uptime Kuma Alert";
if (serverIdentifier) {
title = title + " (" + serverIdentifier + ")"
}
let data = {
"channel": notification.slackchannel,
"username": notification.slackusername,

View file

@ -46,6 +46,11 @@ class SMTP extends NotificationProvider {
let body = msg;
if (heartbeatJSON) {
body = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
const serverIdentifier = await setting("serverIdentifier");
if (serverIdentifier) {
body = body + `\nServer Identifier: ${serverIdentifier}`
}
}
// subject and body are templated
if ((monitorJSON && heartbeatJSON) || msg.endsWith("Testing")) {

View file

@ -132,6 +132,27 @@
<div class="form-text"></div>
</div>
<!-- Server Identifier -->
<div class="mb-4">
<label class="form-label" for="serverIdentifier">
{{ $t("Server Identifier") }}
</label>
<div class="input-group mb-3">
<input
id="serverIdentifier"
v-model="settings.serverIdentifier"
class="form-control"
name="serverIdentifier"
placeholder=""
pattern=".+"
autocomplete="new-password"
/>
</div>
<div class="form-text"></div>
</div>
<!-- Steam API Key -->
<div class="mb-4">
<label class="form-label" for="steamAPIKey">

View file

@ -13,7 +13,7 @@
<header v-if="! $root.isMobile" class="d-flex flex-wrap justify-content-center py-3 mb-3 border-bottom">
<router-link to="/dashboard" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-dark text-decoration-none">
<object class="bi me-2 ms-4" width="40" height="40" data="/icon.svg" />
<span class="fs-4 title">{{ $t("Uptime Kuma") }}</span>
<span class="fs-4 title">{{ $t("Uptime Kuma") }}{{ $root.serverIdentifierSuffix }}</span>
</router-link>
<a v-if="hasNewVersion" target="_blank" href="https://github.com/louislam/uptime-kuma/releases" class="btn btn-info me-3">
@ -85,7 +85,7 @@
<header v-else class="d-flex flex-wrap justify-content-center pt-2 pb-2 mb-3">
<router-link to="/dashboard" class="d-flex align-items-center text-dark text-decoration-none">
<object class="bi" width="40" height="40" data="/icon.svg" />
<span class="fs-4 title ms-2">Uptime Kuma</span>
<span class="fs-4 title ms-2">{{ $t("Uptime Kuma") }}{{ $root.serverIdentifierSuffix }}</span>
</router-link>
</header>
@ -170,7 +170,11 @@ export default {
},
watch: {
$route(to) {
if (this.serverIdentifierSuffix) {
this.updateTitle("Uptime Kuma" + this.$root.serverIdentifierSuffix);
}
}
},
mounted() {
@ -188,6 +192,10 @@ export default {
if (this.toastContainer != null) {
this.toastContainerObserver.observe(this.toastContainer, { childList: true });
}
if (this.$root.serverIdentifierSuffix) {
this.updateTitle("Uptime Kuma" + this.$root.serverIdentifierSuffix);
}
},
beforeUnmount() {
@ -201,6 +209,10 @@ export default {
*/
clearToasts() {
toast.clear();
},
updateTitle(title) {
document.title = title;
}
},

View file

@ -51,5 +51,17 @@ export default {
return location.protocol + "//" + location.host;
}
},
serverIdentifierSuffix() {
if (this.$root.info.serverIdentifier) {
return " (" + this.$root.info.serverIdentifier + ")";
}
if (env === "development" || localStorage.dev === "dev") {
return " (dev)";
} else {
return "";
}
},
}
};

View file

@ -5,7 +5,7 @@
<div>
<object width="64" height="64" data="/icon.svg" />
<div style="font-size: 28px; font-weight: bold; margin-top: 5px;">
Uptime Kuma
{{ $t("Uptime Kuma") }}
</div>
</div>

View file

@ -4,7 +4,7 @@
<div>
<object width="64" height="64" data="/icon.svg" />
<div style="font-size: 28px; font-weight: bold; margin-top: 5px;">
Uptime Kuma
{{ $t("Uptime Kuma") }}
</div>
</div>