Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Initial support for setting a server identifier #5479

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down
6 changes: 5 additions & 1 deletion server/notification-providers/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ class Slack extends NotificationProvider {
}

const baseURL = await setting("primaryBaseURL");
const serverIdentifier = await setting("serverIdentifier");

const title = "Uptime Kuma Alert";
let title = "Uptime Kuma Alert";
if (serverIdentifier) {
title = title + " (" + serverIdentifier + ")";
}
let data = {
"channel": notification.slackchannel,
"username": notification.slackusername,
Expand Down
6 changes: 6 additions & 0 deletions server/notification-providers/smtp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const nodemailer = require("nodemailer");
const NotificationProvider = require("./notification-provider");
const { setting } = require("../util-server");
const { DOWN } = require("../../src/util");
const { Liquid } = require("liquidjs");

Expand Down Expand Up @@ -46,6 +47,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")) {
Expand Down
23 changes: 23 additions & 0 deletions src/components/settings/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@
<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">
{{ $t("serverIdentifierDescription") }}
</div>
</div>

<!-- Steam API Key -->
<div class="mb-4">
<label class="form-label" for="steamAPIKey">
Expand Down
2 changes: 2 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"General": "General",
"Game": "Game",
"Primary Base URL": "Primary Base URL",
"serverIdentifier": "Server Identifier",
"serverIdentifierDescription": "If provided, this will be appended in parentheses after Uptime Kuma in UI and notifications",
"Version": "Version",
"Check Update On GitHub": "Check Update On GitHub",
"List": "List",
Expand Down
18 changes: 15 additions & 3 deletions src/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -170,7 +170,11 @@ export default {
},

watch: {

$route(to) {
if (this.serverIdentifierSuffix) {
this.updateTitle("Uptime Kuma" + this.$root.serverIdentifierSuffix);
}
}
},

mounted() {
Expand All @@ -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() {
Expand All @@ -201,6 +209,10 @@ export default {
*/
clearToasts() {
toast.clear();
},

updateTitle(title) {
document.title = title;
}
},

Expand Down
12 changes: 12 additions & 0 deletions src/mixins/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
},
}
};
2 changes: 1 addition & 1 deletion src/pages/Setup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/SetupDatabase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Loading