From 22f730499f6e83c4eae048763654322bc8a5caf4 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 3 Apr 2023 02:57:14 +0800 Subject: [PATCH] Improve the database connection string input --- src/pages/EditMonitor.vue | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 0b8e55073..997faf955 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -283,13 +283,13 @@
@@ -301,7 +301,7 @@ @@ -311,7 +311,7 @@
@@ -692,6 +692,13 @@ export default { ipOrHostnameRegexPattern: hostNameRegexPattern(), mqttIpOrHostnameRegexPattern: hostNameRegexPattern(true), gameList: null, + connectionStringTemplates: { + "sqlserver": "Server=,;Database=;User Id=;Password=;Encrypt=;TrustServerCertificate=;Connection Timeout=", + "postgres": "postgres://username:password@host:port/database", + "mysql": "mysql://username:password@host:port/database", + "redis": "redis://user:password@host:port", + "mongodb": "mongodb://username:password@host:port/database", + } }; }, @@ -853,6 +860,24 @@ message HealthCheckResponse { } }); } + + // Set default database connection string if empty or it is a template from another database monitor type + for (let monitorType in this.connectionStringTemplates) { + if (this.monitor.type === monitorType) { + let isTemplate = false; + for (let key in this.connectionStringTemplates) { + if (this.monitor.databaseConnectionString === this.connectionStringTemplates[key]) { + isTemplate = true; + break; + } + } + if (!this.monitor.databaseConnectionString || isTemplate) { + this.monitor.databaseConnectionString = this.connectionStringTemplates[monitorType]; + } + break; + } + } + }, currentGameObject(newGameObject, previousGameObject) { @@ -860,8 +885,7 @@ message HealthCheckResponse { this.monitor.port = newGameObject.options.port; } this.monitor.game = newGameObject.keys[0]; - } - + }, }, mounted() { this.init();