From 303adbf9b13975636f48d9d33b1962e2685a28c9 Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sat, 28 Aug 2021 21:20:25 +0200 Subject: [PATCH 1/5] Show latest dns result in Details.vue --- db/patch7.sql | 3 +++ server/model/monitor.js | 12 ++++++++++++ src/pages/Details.vue | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/db/patch7.sql b/db/patch7.sql index 2e8eba15c..4085daf3f 100644 --- a/db/patch7.sql +++ b/db/patch7.sql @@ -7,4 +7,7 @@ ALTER TABLE monitor ALTER TABLE monitor ADD dns_resolve_server VARCHAR(255); +ALTER TABLE monitor + ADD dns_last_result VARCHAR(255); + COMMIT; diff --git a/server/model/monitor.js b/server/model/monitor.js index f5efadc1f..a01dd6142 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -50,6 +50,7 @@ class Monitor extends BeanModel { accepted_statuscodes: this.getAcceptedStatuscodes(), dns_resolve_type: this.dns_resolve_type, dns_resolve_server: this.dns_resolve_server, + dns_last_result: this.dns_last_result, notificationIDList, }; } @@ -207,6 +208,17 @@ class Monitor extends BeanModel { dnsMessage = dnsMessage.slice(0, -2) } + let dnsLastResult = await R.findOne("monitor", "id = ?", [ + this.id, + ]); + + if (dnsLastResult.dnsLastResult !== dnsMessage) { + R.exec("UPDATE `monitor` SET dns_last_result = ? WHERE id = ? ", [ + dnsMessage, + this.id + ]); + } + bean.msg = dnsMessage; bean.status = UP; } diff --git a/src/pages/Details.vue b/src/pages/Details.vue index f06f9e138..8da1112b6 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -10,7 +10,7 @@
{{ $t("Keyword") }}: {{ monitor.keyword }} - [{{ monitor.dns_resolve_type }}] {{ monitor.hostname }} + [{{ monitor.dns_resolve_type }}] {{ monitor.hostname }} [ {{ monitor.dns_last_result }} ]

From 858affa8089f5e0da98be8aa80538b55d2eafe4f Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sat, 28 Aug 2021 21:29:24 +0200 Subject: [PATCH 2/5] Removed useless database query --- server/model/monitor.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index a01dd6142..6d0d812bd 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -208,11 +208,7 @@ class Monitor extends BeanModel { dnsMessage = dnsMessage.slice(0, -2) } - let dnsLastResult = await R.findOne("monitor", "id = ?", [ - this.id, - ]); - - if (dnsLastResult.dnsLastResult !== dnsMessage) { + if (this.dnsLastResult !== dnsMessage) { R.exec("UPDATE `monitor` SET dns_last_result = ? WHERE id = ? ", [ dnsMessage, this.id From 93edb8817dae96a35fa60c5a42e008a56bab52ef Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sun, 29 Aug 2021 03:57:26 +0200 Subject: [PATCH 3/5] More uniform look --- src/languages/de-DE.js | 1 + src/pages/Details.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/languages/de-DE.js b/src/languages/de-DE.js index 93d3da1d1..a4d84e76d 100644 --- a/src/languages/de-DE.js +++ b/src/languages/de-DE.js @@ -102,4 +102,5 @@ export default { resoverserverDescription: "Cloudflare ist der Standardserver, dieser kann jederzeit geändern werden.", "Resolver Server": "Auflösungsserver", rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.", + "Last Result": "Letztes Ergebnis", } diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 8da1112b6..10a27a9a3 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -10,7 +10,10 @@
{{ $t("Keyword") }}: {{ monitor.keyword }} - [{{ monitor.dns_resolve_type }}] {{ monitor.hostname }} [ {{ monitor.dns_last_result }} ] + [{{ monitor.dns_resolve_type }}] {{ monitor.hostname }} +
+ {{ $t("Last Result") }}: {{ monitor.dns_last_result }} +

From dd877cfc7043cb87fc91900ead911e615d1a048a Mon Sep 17 00:00:00 2001 From: Ponkhy Date: Sun, 29 Aug 2021 04:03:55 +0200 Subject: [PATCH 4/5] Added translation to pause monitor confirmation --- src/languages/de-DE.js | 1 + src/languages/en.js | 1 + src/pages/Details.vue | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/languages/de-DE.js b/src/languages/de-DE.js index a4d84e76d..ba852cf32 100644 --- a/src/languages/de-DE.js +++ b/src/languages/de-DE.js @@ -103,4 +103,5 @@ export default { "Resolver Server": "Auflösungsserver", rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.", "Last Result": "Letztes Ergebnis", + pauseMonitorMsg: "Bist du sicher das du den Monitor pausieren möchtest?", } diff --git a/src/languages/en.js b/src/languages/en.js index ebacfac8e..75c25dd57 100644 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -15,4 +15,5 @@ export default { deleteNotificationMsg: "Are you sure want to delete this notification for all monitors?", resoverserverDescription: "Cloudflare is the default server, you can change the resolver server anytime.", rrtypeDescription: "Select the RR-Type you want to monitor", + pauseMonitorMsg: "Are you sure want to pause?", } diff --git a/src/pages/Details.vue b/src/pages/Details.vue index 10a27a9a3..cc45e4034 100644 --- a/src/pages/Details.vue +++ b/src/pages/Details.vue @@ -165,8 +165,8 @@
- - Are you sure want to pause? + + {{ $t("pauseMonitorMsg") }} From ada660621786e259af299c7532154a938d583030 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Sun, 29 Aug 2021 11:16:06 +0800 Subject: [PATCH 5/5] move the new sql to patch8.sql --- db/patch8.sql | 7 +++++++ server/database.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/patch8.sql diff --git a/db/patch8.sql b/db/patch8.sql new file mode 100644 index 000000000..d63a59476 --- /dev/null +++ b/db/patch8.sql @@ -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 monitor + ADD dns_last_result VARCHAR(255); + +COMMIT; diff --git a/server/database.js b/server/database.js index 2b9b715cf..7ce81be11 100644 --- a/server/database.js +++ b/server/database.js @@ -6,7 +6,7 @@ class Database { static templatePath = "./db/kuma.db" static path = "./data/kuma.db"; - static latestVersion = 7; + static latestVersion = 8; static noReject = true; static sqliteInstance = null;