mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-28 01:04:05 +00:00
Default friendly name i18n and auto increase
This commit is contained in:
parent
8c941b1d56
commit
601204ae77
2 changed files with 19 additions and 3 deletions
|
@ -108,15 +108,15 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
"notification.type"(to, from) {
|
"notification.type"(to, from) {
|
||||||
let oldName;
|
let oldName;
|
||||||
|
console.log(this.$root.notificationList)
|
||||||
if (from) {
|
if (from) {
|
||||||
oldName = `My ${ucfirst(from)} Alert (1)`;
|
oldName = this.getUniqueDefaultName(from);
|
||||||
} else {
|
} else {
|
||||||
oldName = "";
|
oldName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! this.notification.name || this.notification.name === oldName) {
|
if (! this.notification.name || this.notification.name === oldName) {
|
||||||
this.notification.name = `My ${ucfirst(to)} Alert (1)`
|
this.notification.name = this.getUniqueDefaultName(to);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -192,6 +192,21 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @param {string} notificationKey
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
getUniqueDefaultName(notificationKey) {
|
||||||
|
let index = 1
|
||||||
|
let name = ""
|
||||||
|
do {
|
||||||
|
name = this.$t("defaultNotificationName", [
|
||||||
|
this.$t(notificationKey).replace(/\(.+\)/, ""),
|
||||||
|
index++
|
||||||
|
]);
|
||||||
|
} while (this.$root.notificationList.find(it => it.name === name))
|
||||||
|
return name
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -169,6 +169,7 @@ export default {
|
||||||
"Avg. Ping": "Avg. Ping",
|
"Avg. Ping": "Avg. Ping",
|
||||||
"Avg. Response": "Avg. Response",
|
"Avg. Response": "Avg. Response",
|
||||||
// Start notification form
|
// Start notification form
|
||||||
|
defaultNotificationName: "My {0} Alert ({1})",
|
||||||
here: "here",
|
here: "here",
|
||||||
"Required": "Required",
|
"Required": "Required",
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue