mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-18 12:14:41 -05:00
Merge pull request #340 from Ponkhy/default-notification
Added the option for default notifications
This commit is contained in:
commit
d761d54d0e
7
db/patch9.sql
Normal file
7
db/patch9.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- You should not modify if this have pushed to Github, unless it does serious wrong with the db.
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
|
||||||
|
ALTER TABLE notification
|
||||||
|
ADD is_default BOOLEAN default 0 NOT NULL;
|
||||||
|
|
||||||
|
COMMIT;
|
@ -7,7 +7,7 @@ class Database {
|
|||||||
static templatePath = "./db/kuma.db"
|
static templatePath = "./db/kuma.db"
|
||||||
static dataDir;
|
static dataDir;
|
||||||
static path;
|
static path;
|
||||||
static latestVersion = 8;
|
static latestVersion = 9;
|
||||||
static noReject = true;
|
static noReject = true;
|
||||||
static sqliteInstance = null;
|
static sqliteInstance = null;
|
||||||
|
|
||||||
|
@ -92,8 +92,13 @@ class Notification {
|
|||||||
|
|
||||||
bean.name = notification.name;
|
bean.name = notification.name;
|
||||||
bean.user_id = userID;
|
bean.user_id = userID;
|
||||||
bean.config = JSON.stringify(notification)
|
bean.config = JSON.stringify(notification);
|
||||||
|
bean.is_default = notification.isDefault;
|
||||||
await R.store(bean)
|
await R.store(bean)
|
||||||
|
|
||||||
|
if (notification.applyExisting) {
|
||||||
|
await applyNotificationEveryMonitor(bean.id, userID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async delete(notificationID, userID) {
|
static async delete(notificationID, userID) {
|
||||||
@ -117,6 +122,26 @@ class Notification {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function applyNotificationEveryMonitor(notificationID, userID) {
|
||||||
|
let monitors = await R.getAll("SELECT id FROM monitor WHERE user_id = ?", [
|
||||||
|
userID
|
||||||
|
]);
|
||||||
|
|
||||||
|
for (let i = 0; i < monitors.length; i++) {
|
||||||
|
let checkNotification = await R.findOne("monitor_notification", " monitor_id = ? AND notification_id = ? ", [
|
||||||
|
monitors[i].id,
|
||||||
|
notificationID,
|
||||||
|
])
|
||||||
|
|
||||||
|
if (! checkNotification) {
|
||||||
|
let relation = R.dispense("monitor_notification");
|
||||||
|
relation.monitor_id = monitors[i].id;
|
||||||
|
relation.notification_id = notificationID;
|
||||||
|
await R.store(relation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Notification,
|
Notification,
|
||||||
}
|
}
|
||||||
|
@ -436,6 +436,25 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- DEPRECATED! Please create vue component in "./src/components/notifications/{notification name}.vue" -->
|
<!-- DEPRECATED! Please create vue component in "./src/components/notifications/{notification name}.vue" -->
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<hr class="dropdown-divider">
|
||||||
|
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input v-model="notification.isDefault" class="form-check-input" type="checkbox">
|
||||||
|
<label class="form-check-label">{{ $t("Default enabled") }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-text">
|
||||||
|
{{ $t("enableDefaultNotificationDescription") }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input v-model="notification.applyExisting" class="form-check-input" type="checkbox">
|
||||||
|
<label class="form-check-label">{{ $t("Also apply to existing monitors") }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm">
|
<button v-if="id" type="button" class="btn btn-danger" :disabled="processing" @click="deleteConfirm">
|
||||||
@ -445,6 +464,7 @@
|
|||||||
{{ $t("Test") }}
|
{{ $t("Test") }}
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="btn btn-primary" :disabled="processing">
|
<button type="submit" class="btn btn-primary" :disabled="processing">
|
||||||
|
<div v-if="processing" class="spinner-border spinner-border-sm me-1"></div>
|
||||||
{{ $t("Save") }}
|
{{ $t("Save") }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -485,6 +505,7 @@ export default {
|
|||||||
name: "",
|
name: "",
|
||||||
type: null,
|
type: null,
|
||||||
gotifyPriority: 8,
|
gotifyPriority: 8,
|
||||||
|
isDefault: false,
|
||||||
},
|
},
|
||||||
appriseInstalled: false,
|
appriseInstalled: false,
|
||||||
}
|
}
|
||||||
@ -534,6 +555,7 @@ export default {
|
|||||||
this.notification = {
|
this.notification = {
|
||||||
name: "",
|
name: "",
|
||||||
type: null,
|
type: null,
|
||||||
|
isDefault: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default set to Telegram
|
// Default set to Telegram
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,9 @@ export default {
|
|||||||
"Resource Record Type": "Resource Record Type",
|
"Resource Record Type": "Resource Record Type",
|
||||||
respTime: "Antw. Zeit (ms)",
|
respTime: "Antw. Zeit (ms)",
|
||||||
notAvailableShort: "N/A",
|
notAvailableShort: "N/A",
|
||||||
|
"Default enabled": "Standardmäßig aktiviert",
|
||||||
|
"Also apply to existing monitors": "Auch für alle existierenden Monitore aktivieren",
|
||||||
|
enableDefaultNotificationDescription: "Für jeden neuen Monitor wird diese Benachrichtigung standardmäßig aktiviert. Die Benachrichtigung kann weiterhin für jeden Monitor separat deaktiviert werden.",
|
||||||
Create: "Erstellen",
|
Create: "Erstellen",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get"
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ export default {
|
|||||||
resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.",
|
resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.",
|
||||||
rrtypeDescription: "Select the RR-Type you want to monitor",
|
rrtypeDescription: "Select the RR-Type you want to monitor",
|
||||||
pauseMonitorMsg: "Are you sure want to pause?",
|
pauseMonitorMsg: "Are you sure want to pause?",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
clearEventsMsg: "Are you sure want to delete all events for this monitor?",
|
clearEventsMsg: "Are you sure want to delete all events for this monitor?",
|
||||||
clearHeartbeatsMsg: "Are you sure want to delete all heartbeats for this monitor?",
|
clearHeartbeatsMsg: "Are you sure want to delete all heartbeats for this monitor?",
|
||||||
confirmClearStatisticsMsg: "Are you sure want to delete ALL statistics?",
|
confirmClearStatisticsMsg: "Are you sure want to delete ALL statistics?",
|
||||||
@ -112,6 +113,8 @@ export default {
|
|||||||
"Repeat Password": "Repeat Password",
|
"Repeat Password": "Repeat Password",
|
||||||
respTime: "Resp. Time (ms)",
|
respTime: "Resp. Time (ms)",
|
||||||
notAvailableShort: "N/A",
|
notAvailableShort: "N/A",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors",
|
||||||
Create: "Create",
|
Create: "Create",
|
||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "Clear Data",
|
"Clear Data": "Clear Data",
|
||||||
Events: "Events",
|
Events: "Events",
|
||||||
Heartbeats: "Heartbeats",
|
Heartbeats: "Heartbeats",
|
||||||
"Auto Get": "Auto Get"
|
"Auto Get": "Auto Get",
|
||||||
|
enableDefaultNotificationDescription: "For every new monitor this notification will be enabled by default. You can still disable the notification separately for each monitor.",
|
||||||
|
"Default enabled": "Default enabled",
|
||||||
|
"Also apply to existing monitors": "Also apply to existing monitors"
|
||||||
}
|
}
|
||||||
|
@ -116,5 +116,8 @@ export default {
|
|||||||
"Clear Data": "清除資料",
|
"Clear Data": "清除資料",
|
||||||
Events: "事件",
|
Events: "事件",
|
||||||
Heartbeats: "脈搏",
|
Heartbeats: "脈搏",
|
||||||
"Auto Get": "自動獲取"
|
"Auto Get": "自動獲取",
|
||||||
|
enableDefaultNotificationDescription: "新增監測器時這個通知會預設啟用,當然每個監測器亦可分別控制開關。",
|
||||||
|
"Default enabled": "預設通知",
|
||||||
|
"Also apply to existing monitors": "同時取用至目前所有監測器"
|
||||||
}
|
}
|
||||||
|
@ -178,6 +178,8 @@
|
|||||||
{{ notification.name }}
|
{{ notification.name }}
|
||||||
<a href="#" @click="$refs.notificationDialog.show(notification.id)">{{ $t("Edit") }}</a>
|
<a href="#" @click="$refs.notificationDialog.show(notification.id)">{{ $t("Edit") }}</a>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<span v-if="notification.isDefault == true" class="badge bg-primary ms-2">Default</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
|
<button class="btn btn-primary me-2" type="button" @click="$refs.notificationDialog.show()">
|
||||||
@ -296,6 +298,12 @@ export default {
|
|||||||
dns_resolve_type: "A",
|
dns_resolve_type: "A",
|
||||||
dns_resolve_server: "1.1.1.1",
|
dns_resolve_server: "1.1.1.1",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < this.$root.notificationList.length; i++) {
|
||||||
|
if (this.$root.notificationList[i].isDefault == true) {
|
||||||
|
this.monitor.notificationIDList[this.$root.notificationList[i].id] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (this.isEdit) {
|
} else if (this.isEdit) {
|
||||||
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => {
|
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
Loading…
Reference in New Issue
Block a user