1
0
mirror of https://github.com/louislam/uptime-kuma.git synced 2024-12-12 10:13:46 +02:00

Merge pull request #5 from louislam/master

update
This commit is contained in:
新逸Cary 2021-10-09 09:28:53 +08:00 committed by GitHub
commit 5d617012a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 143 additions and 17 deletions

View File

@ -16,7 +16,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [macos-latest, ubuntu-latest, windows-latest] os: [macos-latest, ubuntu-latest, windows-latest]
node-version: [14.x, 15.x, 16.x] node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps: steps:
@ -27,7 +27,7 @@ jobs:
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'npm' cache: 'npm'
- run: npm ci - run: npm run install-legacy
- run: npm run build - run: npm run build
- run: npm test - run: npm test
env: env:

View File

@ -1,6 +1,5 @@
const { setSetting } = require("./util-server"); const { setSetting } = require("./util-server");
const axios = require("axios"); const axios = require("axios");
const { isDev } = require("../src/util");
exports.version = require("../package.json").version; exports.version = require("../package.json").version;
exports.latestVersion = null; exports.latestVersion = null;

View File

@ -4,6 +4,8 @@
const { TimeLogger } = require("../src/util"); const { TimeLogger } = require("../src/util");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { io } = require("./server"); const { io } = require("./server");
const { setting } = require("./util-server");
const checkVersion = require("./check-version");
async function sendNotificationList(socket) { async function sendNotificationList(socket) {
const timeLogger = new TimeLogger(); const timeLogger = new TimeLogger();
@ -14,10 +16,10 @@ async function sendNotificationList(socket) {
]); ]);
for (let bean of list) { for (let bean of list) {
result.push(bean.export()) result.push(bean.export());
} }
io.to(socket.userID).emit("notificationList", result) io.to(socket.userID).emit("notificationList", result);
timeLogger.print("Send Notification List"); timeLogger.print("Send Notification List");
@ -39,7 +41,7 @@ async function sendHeartbeatList(socket, monitorID, toUser = false, overwrite =
LIMIT 100 LIMIT 100
`, [ `, [
monitorID, monitorID,
]) ]);
let result = list.reverse(); let result = list.reverse();
@ -69,7 +71,7 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove
LIMIT 500 LIMIT 500
`, [ `, [
monitorID, monitorID,
]) ]);
timeLogger.print(`[Monitor: ${monitorID}] sendImportantHeartbeatList`); timeLogger.print(`[Monitor: ${monitorID}] sendImportantHeartbeatList`);
@ -81,8 +83,18 @@ async function sendImportantHeartbeatList(socket, monitorID, toUser = false, ove
} }
async function sendInfo(socket) {
socket.emit("info", {
version: checkVersion.version,
latestVersion: checkVersion.latestVersion,
primaryBaseURL: await setting("primaryBaseURL")
});
}
module.exports = { module.exports = {
sendNotificationList, sendNotificationList,
sendImportantHeartbeatList, sendImportantHeartbeatList,
sendHeartbeatList, sendHeartbeatList,
} sendInfo
};

View File

@ -0,0 +1,41 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class PromoSMS extends NotificationProvider {
name = "promosms";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
let config = {
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + Buffer.from(notification.promosmsLogin + ":" + notification.promosmsPassword).toString('base64'),
"Accept": "text/json",
}
};
let data = {
"recipients": [ notification.promosmsPhoneNumber ],
//Lets remove non ascii char
"text": msg.replace(/[^\x00-\x7F]/g, ""),
"type": Number(notification.promosmsSMSType),
"sender": notification.promosmsSenderName
};
let resp = await axios.post("https://promosms.com/api/rest/v3_2/sms", data, config);
if (resp.data.response.status !== 0) {
let error = "Something gone wrong. Api returned " + resp.data.response.status + ".";
this.throwGeneralAxiosError(error);
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = PromoSMS;

View File

@ -7,6 +7,7 @@ const LunaSea = require("./notification-providers/lunasea");
const Mattermost = require("./notification-providers/mattermost"); const Mattermost = require("./notification-providers/mattermost");
const Matrix = require("./notification-providers/matrix"); const Matrix = require("./notification-providers/matrix");
const Octopush = require("./notification-providers/octopush"); const Octopush = require("./notification-providers/octopush");
const PromoSMS = require("./notification-providers/promosms");
const Pushbullet = require("./notification-providers/pushbullet"); const Pushbullet = require("./notification-providers/pushbullet");
const Pushover = require("./notification-providers/pushover"); const Pushover = require("./notification-providers/pushover");
const Pushy = require("./notification-providers/pushy"); const Pushy = require("./notification-providers/pushy");
@ -37,6 +38,7 @@ class Notification {
new Mattermost(), new Mattermost(),
new Matrix(), new Matrix(),
new Octopush(), new Octopush(),
new PromoSMS(),
new Pushbullet(), new Pushbullet(),
new Pushover(), new Pushover(),
new Pushy(), new Pushy(),

View File

@ -90,7 +90,7 @@ const io = new Server(server);
module.exports.io = io; module.exports.io = io;
// Must be after io instantiation // Must be after io instantiation
const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList } = require("./client"); const { sendNotificationList, sendHeartbeatList, sendImportantHeartbeatList, sendInfo } = require("./client");
const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler"); const { statusPageSocketHandler } = require("./socket-handlers/status-page-socket-handler");
app.use(express.json()); app.use(express.json());
@ -180,10 +180,7 @@ exports.entryPage = "dashboard";
console.log("Adding socket handler"); console.log("Adding socket handler");
io.on("connection", async (socket) => { io.on("connection", async (socket) => {
socket.emit("info", { sendInfo(socket);
version: checkVersion.version,
latestVersion: checkVersion.latestVersion,
});
totalClient++; totalClient++;
@ -870,6 +867,8 @@ exports.entryPage = "dashboard";
msg: "Saved" msg: "Saved"
}); });
sendInfo(socket);
} catch (e) { } catch (e) {
callback({ callback({
ok: false, ok: false,

View File

@ -3,7 +3,7 @@
@import "node_modules/bootstrap/scss/bootstrap"; @import "node_modules/bootstrap/scss/bootstrap";
#app { #app {
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji; font-family: BlinkMacSystemFont, segoe ui, Roboto, helvetica neue, Arial, noto sans, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol, noto color emoji;
} }
h1 { h1 {

View File

@ -0,0 +1,39 @@
<template>
<div class="mb-3">
<label for="promosms-login" class="form-label">API LOGIN</label>
<input id="promosms-login" v-model="$parent.notification.promosmsLogin" type="text" class="form-control" required>
<label for="promosms-key" class="form-label">API PASSWORD</label>
<HiddenInput id="promosms-key" v-model="$parent.notification.promosmsPassword" :required="true" autocomplete="one-time-code"></HiddenInput>
</div>
<div class="mb-3">
<label for="promosms-type-sms" class="form-label">{{ $t("SMS Type") }}</label>
<select id="promosms-type-sms" v-model="$parent.notification.promosmsSMSType" class="form-select">
<option value="0">{{ $t("promosmsTypeFlash") }}</option>
<option value="1">{{ $t("promosmsTypeEco") }}</option>
<option value="2">{{ $t("promosmsTypeFull") }}</option>
<option value="3">{{ $t("promosmsTypeSpeed") }}</option>
</select>
<i18n-t tag="div" keypath="Check PromoSMS prices" class="form-text">
<a href="https://promosms.com/cennik/" target="_blank">https://promosms.com/cennik/</a>
</i18n-t>
</div>
<div class="mb-3">
<label for="promosms-phone-number" class="form-label">{{ $t("promosmsPhoneNumber") }}</label>
<input id="promosms-phone-number" v-model="$parent.notification.promosmsPhoneNumber" type="text" class="form-control" required>
</div>
<div class="mb-3">
<label for="promosms-sender-name" class="form-label">{{ $t("promosmsSMSSender") }}</label>
<input id="promosms-sender-name" v-model="$parent.notification.promosmsSenderName" type="text" minlength="3" maxlength="11" class="form-control">
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>

View File

@ -10,6 +10,7 @@ import Teams from "./Teams.vue";
import Pushover from "./Pushover.vue"; import Pushover from "./Pushover.vue";
import Pushy from "./Pushy.vue"; import Pushy from "./Pushy.vue";
import Octopush from "./Octopush.vue"; import Octopush from "./Octopush.vue";
import PromoSMS from "./PromoSMS.vue";
import LunaSea from "./LunaSea.vue"; import LunaSea from "./LunaSea.vue";
import Apprise from "./Apprise.vue"; import Apprise from "./Apprise.vue";
import Pushbullet from "./Pushbullet.vue"; import Pushbullet from "./Pushbullet.vue";
@ -35,6 +36,7 @@ const NotificationFormList = {
"pushover": Pushover, "pushover": Pushover,
"pushy": Pushy, "pushy": Pushy,
"octopush": Octopush, "octopush": Octopush,
"promosms": PromoSMS,
"lunasea": LunaSea, "lunasea": LunaSea,
"apprise": Apprise, "apprise": Apprise,
"pushbullet": Pushbullet, "pushbullet": Pushbullet,

View File

@ -190,6 +190,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Поддържа 50+ услуги за инвестяване)", apprise: "Apprise (Поддържа 50+ услуги за инвестяване)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -191,6 +191,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -235,6 +235,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",
@ -273,5 +274,11 @@ export default {
aboutIconURL: "You can provide a link to a picture in \"Icon URL\" to override the default profile picture. Will not be used if Icon Emoji is set.", aboutIconURL: "You can provide a link to a picture in \"Icon URL\" to override the default profile picture. Will not be used if Icon Emoji is set.",
aboutMattermostChannelName: "You can override the default channel that webhook posts to by entering the channel name into \"Channel Name\" field. This needs to be enabled in Mattermost webhook settings. Ex: #other-channel", aboutMattermostChannelName: "You can override the default channel that webhook posts to by entering the channel name into \"Channel Name\" field. This needs to be enabled in Mattermost webhook settings. Ex: #other-channel",
"matrix": "Matrix", "matrix": "Matrix",
promosmsTypeEco: "SMS ECO - cheap but slow and often overloaded. Limited only to Polish recipients.",
promosmsTypeFlash: "SMS FLASH - Message will automatically show on recipient device. Limited only to Polish recipients.",
promosmsTypeFull: "SMS FULL - Premium tier of SMS, You can use Your Sender Name (You need to register name first). Reliable for alerts.",
promosmsTypeFull: "SMS SPEED - Highest priority in system. Very quick and reliable but costly (about twice of SMS FULL price).",
promosmsPhoneNumber: "Phone number (for Polish recipient You can skip area codes)",
promosmsSMSSender: "SMS Sender Name : Pre-registred name or one of defaults: InfoSMS, SMS Info, MaxSMS, INFO, SMS",
// End notification form // End notification form
}; };

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -191,6 +191,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (vahendab üle 65 teavitusteenust)", apprise: "Apprise (vahendab üle 65 teavitusteenust)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -199,6 +199,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -190,6 +190,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -191,6 +191,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (obsługuje 50+ usług powiadamiania)", apprise: "Apprise (obsługuje 50+ usług powiadamiania)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -191,6 +191,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -196,6 +196,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -191,6 +191,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (Support 50+ Notification services)", apprise: "Apprise (Support 50+ Notification services)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -192,6 +192,7 @@ export default {
pushover: "Pushover", pushover: "Pushover",
pushy: "Pushy", pushy: "Pushy",
octopush: "Octopush", octopush: "Octopush",
promosms: "PromoSMS",
lunasea: "LunaSea", lunasea: "LunaSea",
apprise: "Apprise (支援 50 多種通知)", apprise: "Apprise (支援 50 多種通知)",
pushbullet: "Pushbullet", pushbullet: "Pushbullet",

View File

@ -38,11 +38,15 @@ export default {
}, },
baseURL() { baseURL() {
if (this.$root.info.primaryBaseURL) {
return this.$root.info.primaryBaseURL;
}
if (env === "development" || localStorage.dev === "dev") { if (env === "development" || localStorage.dev === "dev") {
return axios.defaults.baseURL; return axios.defaults.baseURL;
} else { } else {
return location.protocol + "//" + location.host; return location.protocol + "//" + location.host;
} }
} },
} }
}; };

View File

@ -131,7 +131,7 @@
<input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required min="20" step="1"> <input id="retry-interval" v-model="monitor.retryInterval" type="number" class="form-control" required min="20" step="1">
</div> </div>
<h2 class="mt-5 mb-2">{{ $t("Advanced") }}</h2> <h2 v-if="monitor.type !== 'push'" class="mt-5 mb-2">{{ $t("Advanced") }}</h2>
<div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check"> <div v-if="monitor.type === 'http' || monitor.type === 'keyword' " class="my-3 form-check">
<input id="ignore-tls" v-model="monitor.ignoreTls" class="form-check-input" type="checkbox" value=""> <input id="ignore-tls" v-model="monitor.ignoreTls" class="form-check-input" type="checkbox" value="">
@ -140,7 +140,7 @@
</label> </label>
</div> </div>
<div class="my-3 form-check"> <div v-if="monitor.type !== 'push'" class="my-3 form-check">
<input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox"> <input id="upside-down" v-model="monitor.upsideDown" class="form-check-input" type="checkbox">
<label class="form-check-label" for="upside-down"> <label class="form-check-label" for="upside-down">
{{ $t("Upside Down Mode") }} {{ $t("Upside Down Mode") }}