Merge pull request #287 from Ponkhy/dns-monitor

[Before 1.5.0] Show latest dns result in Details.vue
This commit is contained in:
Louis Lam 2021-08-29 11:17:35 +08:00 committed by GitHub
commit fd1ba46d3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 4 deletions

View File

@ -7,4 +7,7 @@ ALTER TABLE monitor
ALTER TABLE monitor ALTER TABLE monitor
ADD dns_resolve_server VARCHAR(255); ADD dns_resolve_server VARCHAR(255);
ALTER TABLE monitor
ADD dns_last_result VARCHAR(255);
COMMIT; COMMIT;

7
db/patch8.sql Normal file
View 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 monitor
ADD dns_last_result VARCHAR(255);
COMMIT;

View File

@ -6,7 +6,7 @@ class Database {
static templatePath = "./db/kuma.db" static templatePath = "./db/kuma.db"
static path = "./data/kuma.db"; static path = "./data/kuma.db";
static latestVersion = 7; static latestVersion = 8;
static noReject = true; static noReject = true;
static sqliteInstance = null; static sqliteInstance = null;

View File

@ -50,6 +50,7 @@ class Monitor extends BeanModel {
accepted_statuscodes: this.getAcceptedStatuscodes(), accepted_statuscodes: this.getAcceptedStatuscodes(),
dns_resolve_type: this.dns_resolve_type, dns_resolve_type: this.dns_resolve_type,
dns_resolve_server: this.dns_resolve_server, dns_resolve_server: this.dns_resolve_server,
dns_last_result: this.dns_last_result,
notificationIDList, notificationIDList,
}; };
} }
@ -207,6 +208,13 @@ class Monitor extends BeanModel {
dnsMessage = dnsMessage.slice(0, -2) dnsMessage = dnsMessage.slice(0, -2)
} }
if (this.dnsLastResult !== dnsMessage) {
R.exec("UPDATE `monitor` SET dns_last_result = ? WHERE id = ? ", [
dnsMessage,
this.id
]);
}
bean.msg = dnsMessage; bean.msg = dnsMessage;
bean.status = UP; bean.status = UP;
} }

View File

@ -102,4 +102,6 @@ export default {
resoverserverDescription: "Cloudflare ist der Standardserver, dieser kann jederzeit geändern werden.", resoverserverDescription: "Cloudflare ist der Standardserver, dieser kann jederzeit geändern werden.",
"Resolver Server": "Auflösungsserver", "Resolver Server": "Auflösungsserver",
rrtypeDescription: "Wähle den RR-Typ aus, welchen du überwachen möchtest.", 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?",
} }

View File

@ -15,4 +15,5 @@ export default {
deleteNotificationMsg: "Are you sure want to delete this notification for all monitors?", 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.", 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?",
} }

View File

@ -10,7 +10,10 @@
<br> <br>
<span>{{ $t("Keyword") }}:</span> <span class="keyword">{{ monitor.keyword }}</span> <span>{{ $t("Keyword") }}:</span> <span class="keyword">{{ monitor.keyword }}</span>
</span> </span>
<span v-if="monitor.type === 'dns'">[{{ monitor.dns_resolve_type }}] {{ monitor.hostname }}</span> <span v-if="monitor.type === 'dns'">[{{ monitor.dns_resolve_type }}] {{ monitor.hostname }}
<br>
<span>{{ $t("Last Result") }}:</span> <span class="keyword">{{ monitor.dns_last_result }}</span>
</span>
</p> </p>
<div class="functions"> <div class="functions">
@ -162,8 +165,8 @@
</div> </div>
</div> </div>
<Confirm ref="confirmPause" @yes="pauseMonitor"> <Confirm ref="confirmPause" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="pauseMonitor">
Are you sure want to pause? {{ $t("pauseMonitorMsg") }}
</Confirm> </Confirm>
<Confirm ref="confirmDelete" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="deleteMonitor"> <Confirm ref="confirmDelete" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="deleteMonitor">