mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 19:32:34 +02:00
Merge branch 'master' into feature/darkmode
This commit is contained in:
commit
0d5e86a793
6 changed files with 76 additions and 28 deletions
|
@ -62,9 +62,6 @@ module.exports = {
|
||||||
exceptAfterSingleLine: true,
|
exceptAfterSingleLine: true,
|
||||||
}],
|
}],
|
||||||
"no-unneeded-ternary": "error",
|
"no-unneeded-ternary": "error",
|
||||||
"no-else-return": ["error", {
|
|
||||||
"allowElseIf": false,
|
|
||||||
}],
|
|
||||||
"array-bracket-newline": ["error", "consistent"],
|
"array-bracket-newline": ["error", "consistent"],
|
||||||
"eol-last": ["error", "always"],
|
"eol-last": ["error", "always"],
|
||||||
//'prefer-template': 'error',
|
//'prefer-template': 'error',
|
||||||
|
|
|
@ -84,40 +84,78 @@ class Notification {
|
||||||
|
|
||||||
} else if (notification.type === "discord") {
|
} else if (notification.type === "discord") {
|
||||||
try {
|
try {
|
||||||
|
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
|
||||||
|
|
||||||
// If heartbeatJSON is null, assume we're testing.
|
// If heartbeatJSON is null, assume we're testing.
|
||||||
if (heartbeatJSON == null) {
|
if (heartbeatJSON == null) {
|
||||||
let data = {
|
let discordtestdata = {
|
||||||
username: "Uptime-Kuma",
|
username: discordDisplayName,
|
||||||
content: msg,
|
content: msg,
|
||||||
}
|
}
|
||||||
await axios.post(notification.discordWebhookUrl, data)
|
await axios.post(notification.discordWebhookUrl, discordtestdata)
|
||||||
return okMsg;
|
return okMsg;
|
||||||
}
|
}
|
||||||
// If heartbeatJSON is not null, we go into the normal alerting loop.
|
// If heartbeatJSON is not null, we go into the normal alerting loop.
|
||||||
if (heartbeatJSON["status"] == 0) {
|
if (heartbeatJSON["status"] == 0) {
|
||||||
var alertColor = "16711680";
|
let discorddowndata = {
|
||||||
|
username: discordDisplayName,
|
||||||
|
embeds: [{
|
||||||
|
title: "❌ One of your services went down. ❌",
|
||||||
|
color: 16711680,
|
||||||
|
timestamp: heartbeatJSON["time"],
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "Service Name",
|
||||||
|
value: monitorJSON["name"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Service URL",
|
||||||
|
value: monitorJSON["url"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Time (UTC)",
|
||||||
|
value: heartbeatJSON["time"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Error",
|
||||||
|
value: heartbeatJSON["msg"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
await axios.post(notification.discordWebhookUrl, discorddowndata)
|
||||||
|
return okMsg;
|
||||||
|
|
||||||
} else if (heartbeatJSON["status"] == 1) {
|
} else if (heartbeatJSON["status"] == 1) {
|
||||||
var alertColor = "65280";
|
let discordupdata = {
|
||||||
|
username: discordDisplayName,
|
||||||
|
embeds: [{
|
||||||
|
title: "✅ Your service " + monitorJSON["name"] + " is up! ✅",
|
||||||
|
color: 65280,
|
||||||
|
timestamp: heartbeatJSON["time"],
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: "Service Name",
|
||||||
|
value: monitorJSON["name"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Service URL",
|
||||||
|
value: "[Visit Service](" + monitorJSON["url"] + ")",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Time (UTC)",
|
||||||
|
value: heartbeatJSON["time"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Ping",
|
||||||
|
value: heartbeatJSON["ping"] + "ms",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
await axios.post(notification.discordWebhookUrl, discordupdata)
|
||||||
|
return okMsg;
|
||||||
}
|
}
|
||||||
let data = {
|
|
||||||
username: "Uptime-Kuma",
|
|
||||||
embeds: [{
|
|
||||||
title: "Uptime-Kuma Alert",
|
|
||||||
color: alertColor,
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: "Time (UTC)",
|
|
||||||
value: heartbeatJSON["time"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Message",
|
|
||||||
value: msg,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
}
|
|
||||||
await axios.post(notification.discordWebhookUrl, data)
|
|
||||||
return okMsg;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throwGeneralAxiosError(error)
|
throwGeneralAxiosError(error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,6 +143,11 @@
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="discord-webhook-url" class="form-label">Discord Webhook URL</label>
|
<label for="discord-webhook-url" class="form-label">Discord Webhook URL</label>
|
||||||
<input id="discord-webhook-url" v-model="notification.discordWebhookUrl" type="text" class="form-control" required autocomplete="false">
|
<input id="discord-webhook-url" v-model="notification.discordWebhookUrl" type="text" class="form-control" required autocomplete="false">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="discord-username" class="form-label">Bot Display Name</label>
|
||||||
|
<input id="discord-username" v-model="notification.discordUsername" type="text" class="form-control" autocomplete="false" :placeholder="$root.appName">
|
||||||
<div class="form-text">
|
<div class="form-text">
|
||||||
You can get this by going to Server Settings -> Integrations -> Create Webhook
|
You can get this by going to Server Settings -> Integrations -> Create Webhook
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,6 +16,7 @@ import Details from "./pages/Details.vue";
|
||||||
import EditMonitor from "./pages/EditMonitor.vue";
|
import EditMonitor from "./pages/EditMonitor.vue";
|
||||||
import Settings from "./pages/Settings.vue";
|
import Settings from "./pages/Settings.vue";
|
||||||
import Setup from "./pages/Setup.vue";
|
import Setup from "./pages/Setup.vue";
|
||||||
|
import { appName } from "./util.ts";
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
@ -79,6 +80,11 @@ const app = createApp({
|
||||||
socket,
|
socket,
|
||||||
theme
|
theme
|
||||||
],
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
appName: appName
|
||||||
|
}
|
||||||
|
},
|
||||||
render: () => h(App),
|
render: () => h(App),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.PENDING = exports.UP = exports.DOWN = void 0;
|
exports.debug = exports.ucfirst = exports.sleep = exports.flipStatus = exports.PENDING = exports.UP = exports.DOWN = exports.appName = void 0;
|
||||||
|
exports.appName = "Uptime Kuma";
|
||||||
exports.DOWN = 0;
|
exports.DOWN = 0;
|
||||||
exports.UP = 1;
|
exports.UP = 1;
|
||||||
exports.PENDING = 2;
|
exports.PENDING = 2;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Frontend uses util.ts
|
// Frontend uses util.ts
|
||||||
// Need to run "tsc" to compile if there are any changes.
|
// Need to run "tsc" to compile if there are any changes.
|
||||||
|
|
||||||
|
export const appName = "Uptime Kuma";
|
||||||
export const DOWN = 0;
|
export const DOWN = 0;
|
||||||
export const UP = 1;
|
export const UP = 1;
|
||||||
export const PENDING = 2;
|
export const PENDING = 2;
|
||||||
|
|
Loading…
Add table
Reference in a new issue