mirror of
https://github.com/koichixD/uptime-kuma.git
synced 2026-09-04 09:13:21 +00:00
fix: noisy domain expiry checks in monitor editor and missing debuggability (#6637)
Co-authored-by: Frank Elsinga <frank@elsinga.de> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Frank Elsinga
autofix-ci[bot]
parent
e31ef63b01
commit
0eca301181
@@ -1261,6 +1261,13 @@
|
||||
"labelDomainExpiry": "Domain Exp.",
|
||||
"labelDomainNameExpiryNotification": "Domain Name Expiry Notification",
|
||||
"domainExpiryDescription": "Trigger notification when domain names expires in:",
|
||||
"domain_expiry_unsupported_monitor_type": "Domain expiry monitoring is not supported for this monitor type",
|
||||
"domain_expiry_unsupported_missing_target": "No valid domain or hostname is configured for this monitor",
|
||||
"domain_expiry_unsupported_invalid_domain": "The configured value \"{hostname}\" is not a valid domain name",
|
||||
"domain_expiry_public_suffix_too_short": "\".{publicSuffix}\" is too short for a top level domain",
|
||||
"domain_expiry_unsupported_public_suffix": "The domain \"{domain}\" does not have a valid public suffix",
|
||||
"domain_expiry_unsupported_is_ip": "\"{hostname}\" is an IP address. Domain expiry monitoring requires a domain name",
|
||||
"domain_expiry_unsupported_unsupported_tld_no_rdap_endpoint": "Domain expiry monitoring is not available for \".{publicSuffix}\" because no RDAP service is listed by IANA",
|
||||
"minimumIntervalWarning": "Intervals below 20 seconds may result in poor performance.",
|
||||
"lowIntervalWarning": "Are you sure want to set the interval value below 20 seconds? Performance may be degraded, particularly if there are a large number of monitors.",
|
||||
"imageResetConfirmation": "Image reset to default",
|
||||
|
||||
+17
-9
@@ -346,25 +346,33 @@ export default {
|
||||
return socket;
|
||||
},
|
||||
|
||||
/**
|
||||
* Apply translation to a message if possible
|
||||
* @param {string | {key: string, values: object}} msg Message to translate
|
||||
* @returns {string} Translated message
|
||||
*/
|
||||
applyTranslation(msg) {
|
||||
if (msg != null && typeof msg === "object") {
|
||||
return this.$t(msg.key, msg.values);
|
||||
} else {
|
||||
return this.$t(msg);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show success or error toast dependent on response status code
|
||||
* @param {object} res Response object
|
||||
* @param {{ok:boolean, msg: string, msgi18n: false} | {ok:boolean, msg: string|{key: string, values: object}, msgi18n: true}} res Response object
|
||||
* @returns {void}
|
||||
*/
|
||||
toastRes(res) {
|
||||
let msg = res.msg;
|
||||
if (res.msgi18n) {
|
||||
if (msg != null && typeof msg === "object") {
|
||||
msg = this.$t(msg.key, msg.values);
|
||||
} else {
|
||||
msg = this.$t(msg);
|
||||
}
|
||||
res.msg = this.applyTranslation(res.msg);
|
||||
}
|
||||
|
||||
if (res.ok) {
|
||||
toast.success(msg);
|
||||
toast.success(res.msg);
|
||||
} else {
|
||||
toast.error(msg);
|
||||
toast.error(res.msg);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -817,12 +817,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasDomain" class="my-3 form-check">
|
||||
<input id="domain-expiry-notification" v-model="monitor.domainExpiryNotification" class="form-check-input" type="checkbox">
|
||||
<div v-if="showDomainExpiryNotification" class="my-3 form-check">
|
||||
<input id="domain-expiry-notification" v-model="monitor.domainExpiryNotification" class="form-check-input" type="checkbox" :disabled="!hasDomain">
|
||||
<label class="form-check-label" for="domain-expiry-notification">
|
||||
{{ $t("labelDomainNameExpiryNotification") }}
|
||||
</label>
|
||||
<div class="form-text">
|
||||
<div v-if="!hasDomain && domainExpiryUnsupportedReason" class="form-text">
|
||||
{{ domainExpiryUnsupportedReason }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="monitor.type === 'websocket-upgrade' " class="my-3 form-check">
|
||||
@@ -1442,6 +1443,8 @@ export default {
|
||||
// Do not add default value here, please check init() method
|
||||
},
|
||||
hasDomain: false,
|
||||
domainExpiryUnsupportedReason: null,
|
||||
checkMonitorDebounce: null,
|
||||
acceptedStatusCodeOptions: [],
|
||||
acceptedWebsocketCodeOptions: [],
|
||||
dnsresolvetypeOptions: [],
|
||||
@@ -1517,6 +1520,18 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
showDomainExpiryNotification() {
|
||||
// NOTE: Keep this list in sync with `excludeTypes` in `server/model/domain_expiry.js`.
|
||||
const excludedTypes = [ "docker", "group", "push", "manual", "rabbitmq", "redis" ];
|
||||
const type = this.monitor.type;
|
||||
|
||||
if (!type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !excludedTypes.includes(type) && !type.match(/sql$/);
|
||||
},
|
||||
|
||||
pageName() {
|
||||
let name = "Add New Monitor";
|
||||
if (this.isClone) {
|
||||
@@ -1795,12 +1810,22 @@ message HealthCheckResponse {
|
||||
},
|
||||
|
||||
"monitorTypeUrlHost"(data) {
|
||||
this.$root.getSocket().emit("checkMointor", data, (res) => {
|
||||
this.hasDomain = !!res?.domain;
|
||||
if (!res?.domain) {
|
||||
this.monitor.domainExpiryNotification = false;
|
||||
}
|
||||
});
|
||||
if (this.checkMonitorDebounce != null) {
|
||||
clearTimeout(this.checkMonitorDebounce);
|
||||
}
|
||||
|
||||
if (!this.showDomainExpiryNotification) {
|
||||
this.hasDomain = false;
|
||||
this.domainExpiryUnsupportedReason = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.checkMonitorDebounce = setTimeout(() => {
|
||||
this.$root.getSocket().emit("checkMointor", data, (res) => {
|
||||
this.hasDomain = !!res?.ok;
|
||||
this.domainExpiryUnsupportedReason = res.msgi18n ? this.$t(res.msg, res.meta) : res.msg;
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
|
||||
"monitor.type"(newType, oldType) {
|
||||
|
||||
Reference in New Issue
Block a user