From dfac38a2577e9725d1aaf534906b58739b261519 Mon Sep 17 00:00:00 2001 From: patrykb0802 Date: Thu, 20 Jul 2023 15:59:34 +0200 Subject: [PATCH 01/22] #2384 Added test script in Meta Data Source on new UI In point.vue: - Added validateScript() method - Added 'Run script' button to Meta Data Point editing - Added alert that shows result of working script - Modified script textarea to run validateScript method - Added new rule that is checking if script is correct - Added script.runScript translation key to en.json --- .../datasources/MetaDataSource/point.vue | 34 +++++++++++++++++-- scadalts-ui/src/locales/en.json | 4 +-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index fc2077d6fa..d95f877ad3 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -317,14 +317,26 @@ - - + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+

!!v || this.$t('validation.rule.notNull'), + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -535,6 +550,21 @@ export default { return; } }, + + async validateScript() { + try { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + this.$t(resp); + } catch (e) { + console.log('error:' + e); + } + }, }, }; diff --git a/scadalts-ui/src/locales/en.json b/scadalts-ui/src/locales/en.json index a527ea9021..2fb915ea1d 100644 --- a/scadalts-ui/src/locales/en.json +++ b/scadalts-ui/src/locales/en.json @@ -333,7 +333,6 @@ "event.audit.recip.list.9": "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}", "event.audit.recip.mailingList": "mailing list '{0}'", "event.audit.recip.user": "user '{0}'", - "event.audit.scheduledEvent": "Scheduled event", "event.bacnet.covFailed": "COV subscription failed at {0}, point disabled: {1}", "event.bacnet.deviceError": "No response from device at {0}, point init failed", "event.bacnet.iamError": "IAm broadcast failure: {0}", @@ -1053,5 +1052,6 @@ "systemsettings.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen", "userDetails.view.forceAdminTitle": "The function is enforced by the Admin", "userDetails.view.enableFullScreen": "Enable full screen mode", - "userDetails.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen" + "userDetails.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen", + "script.runScript": "Run script" } From 23d8dbfab2fc619d7b4c176193b7bf484b9c2e5f Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Mon, 24 Jul 2023 18:36:55 +0200 Subject: [PATCH 02/22] #2384 Added test script in Meta Data Source on new UI - Added correct error message when creating new data point and script field is empty - Added delayed validation, so requests for validation are not send every letter typed - Added handling of error when field for script is empty and you press "run script", now when field is empty and you press "run script" nothing happens - Deleted duplicated property key dox.newUISettings --- .../datasources/MetaDataSource/point.vue | 34 +++++++++++-------- scadalts-ui/src/locales/en.json | 3 +- .../api/datasources/meta/MetaController.java | 22 +++++++++--- test/messages_en.properties | 2 +- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d95f877ad3..c998b6f4af 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -318,22 +318,25 @@ {{ $t('script.runScript') }} -
+
- Script results: {{this.resultMessage}} +
{{$t('script.Results')}} {{this.resultMessage}}

@@ -423,6 +426,7 @@ export default { DataTypes: DataTypes, DataChangeTypes: DataChangeTypes, multistateValue: 0, + timer: null, booleanSelectBox: [ { text: 'False', @@ -458,7 +462,6 @@ export default { validScript: false, resultMessage: "", ruleNotNull: (v) => !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -557,14 +560,17 @@ export default { url: `/datapoint/meta/test`, data: this.datapoint.pointLocator }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - this.$t(resp); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); } catch (e) { console.log('error:' + e); } }, + delayedValidateScript(){ + clearTimeout(this.timer); + this.timer = setTimeout(this.validateScript,1400); + } }, }; diff --git a/scadalts-ui/src/locales/en.json b/scadalts-ui/src/locales/en.json index 2fb915ea1d..886d17f7a8 100644 --- a/scadalts-ui/src/locales/en.json +++ b/scadalts-ui/src/locales/en.json @@ -1053,5 +1053,6 @@ "userDetails.view.forceAdminTitle": "The function is enforced by the Admin", "userDetails.view.enableFullScreen": "Enable full screen mode", "userDetails.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen", - "script.runScript": "Run script" + "script.runScript": "Run script", + "script.Results": "Script results: " } diff --git a/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java b/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java index ba2a536945..d7d1162090 100644 --- a/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java +++ b/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java @@ -50,13 +50,27 @@ public void validateScript(String script, List context, int dataTy PointValueTime pvt = executor.execute(script, convertedContext, System.currentTimeMillis(), dataTypeId, -1); if(pvt.getTime() == -1) { - response.put("success", true); + if (script == "") { + response.put("success", false); + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.failure", pvt.getValue())); + } + else { + response.put("success", true); + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.success", pvt.getValue())); + } response.put("result", pvt.getStringValue()); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.success", pvt.getValue())); + } else { - response.put("success", true); + if (script == "") { + response.put("success", false); + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.failure", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); + } + else { + response.put("success", true); + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.successTs", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); + } response.put("result", pvt.getStringValue()); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.successTs", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); + } } catch (DataPointStateException | ResultTypeException e) { response.put("success", false); diff --git a/test/messages_en.properties b/test/messages_en.properties index 17ff46f6f9..7be732c294 100644 --- a/test/messages_en.properties +++ b/test/messages_en.properties @@ -779,6 +779,7 @@ dsEdit.meta.test.context=One or more points are disabled or missing dsEdit.meta.test.scriptError=Script error: {0} dsEdit.meta.test.success=Success. result={0} dsEdit.meta.test.successTs=Success. result={0}, timestamp={1} +dsEdit.meta.test.failure=Failure. result={0} dsEdit.meta.validate=Validate script dsEdit.meta.var=Var dsEdit.modbus.addPoint=Add point @@ -3246,7 +3247,6 @@ dox.newUISettings=Settings to set in the new UI logo.for=for logo.powered=Powered by systemSettings.valuesLimitForPurge=Default values limit for purge -dox.newUISettings=Settings to set in the new UI dox.dataRetentionSettings=Data retention settings dsEdit.httpRetriever.credentials=Credentials dsEdit.httpRetriever.password=Password From 032e8e15dfdad7ad099d2c24afad737937466c32 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Tue, 8 Aug 2023 13:25:17 +0200 Subject: [PATCH 03/22] #2384 Added test script in Meta Data Source on new UI --- .../datasources/MetaDataSource/point.vue | 78 +++++++++---------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index c998b6f4af..cddc5b70b8 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -317,29 +317,28 @@ - - - {{ $t('script.runScript') }} - - -
- -
{{$t('script.Results')}} {{this.resultMessage}}
-
-
-

+ + {{ $t('script.runScript') }} + + +
+ +
{{$t('script.Results')}} {{this.resultMessage}}
+
+
+

!!v || this.$t('validation.rule.notNull'), }; }, @@ -554,23 +553,20 @@ export default { } }, - async validateScript() { - try { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator + async validateScript() { + try { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - } catch (e) { - console.log('error:' + e); - } - }, - delayedValidateScript(){ - clearTimeout(this.timer); - this.timer = setTimeout(this.validateScript,1400); - } + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } catch (e) { + console.log('error:' + e); + } + }, + }, }; From 0c9146090e84b1d78c3775da6c04f5a6d8f5b174 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Wed, 9 Aug 2023 12:33:49 +0200 Subject: [PATCH 04/22] Revert "#2384 Added test script in Meta Data Source on new UI" This reverts commit 032e8e15dfdad7ad099d2c24afad737937466c32. --- .../datasources/MetaDataSource/point.vue | 78 ++++++++++--------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index cddc5b70b8..c998b6f4af 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -317,28 +317,29 @@ - - - - {{ $t('script.runScript') }} - - -
- -
{{$t('script.Results')}} {{this.resultMessage}}
-
-
-

+ + {{ $t('script.runScript') }} + + +
+ +
{{$t('script.Results')}} {{this.resultMessage}}
+
+
+

!!v || this.$t('validation.rule.notNull'), }; }, @@ -553,20 +554,23 @@ export default { } }, - async validateScript() { - try { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator + async validateScript() { + try { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - } catch (e) { - console.log('error:' + e); - } - }, - + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } catch (e) { + console.log('error:' + e); + } + }, + delayedValidateScript(){ + clearTimeout(this.timer); + this.timer = setTimeout(this.validateScript,1400); + } }, }; From ca049d22bfd37802d4f6c2c7a16f9d50d1470f2a Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Wed, 9 Aug 2023 12:34:14 +0200 Subject: [PATCH 05/22] Revert "#2384 Added test script in Meta Data Source on new UI" This reverts commit 23d8dbfab2fc619d7b4c176193b7bf484b9c2e5f. --- .../datasources/MetaDataSource/point.vue | 34 ++++++++----------- scadalts-ui/src/locales/en.json | 3 +- .../api/datasources/meta/MetaController.java | 22 +++--------- test/messages_en.properties | 2 +- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index c998b6f4af..d95f877ad3 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -318,25 +318,22 @@ {{ $t('script.runScript') }} -
+
-
{{$t('script.Results')}} {{this.resultMessage}}
+ Script results: {{this.resultMessage}}

@@ -426,7 +423,6 @@ export default { DataTypes: DataTypes, DataChangeTypes: DataChangeTypes, multistateValue: 0, - timer: null, booleanSelectBox: [ { text: 'False', @@ -462,6 +458,7 @@ export default { validScript: false, resultMessage: "", ruleNotNull: (v) => !!v || this.$t('validation.rule.notNull'), + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -560,17 +557,14 @@ export default { url: `/datapoint/meta/test`, data: this.datapoint.pointLocator }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + this.$t(resp); } catch (e) { console.log('error:' + e); } }, - delayedValidateScript(){ - clearTimeout(this.timer); - this.timer = setTimeout(this.validateScript,1400); - } }, }; diff --git a/scadalts-ui/src/locales/en.json b/scadalts-ui/src/locales/en.json index 886d17f7a8..2fb915ea1d 100644 --- a/scadalts-ui/src/locales/en.json +++ b/scadalts-ui/src/locales/en.json @@ -1053,6 +1053,5 @@ "userDetails.view.forceAdminTitle": "The function is enforced by the Admin", "userDetails.view.enableFullScreen": "Enable full screen mode", "userDetails.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen", - "script.runScript": "Run script", - "script.Results": "Script results: " + "script.runScript": "Run script" } diff --git a/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java b/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java index d7d1162090..ba2a536945 100644 --- a/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java +++ b/src/org/scada_lts/web/mvc/api/datasources/meta/MetaController.java @@ -50,27 +50,13 @@ public void validateScript(String script, List context, int dataTy PointValueTime pvt = executor.execute(script, convertedContext, System.currentTimeMillis(), dataTypeId, -1); if(pvt.getTime() == -1) { - if (script == "") { - response.put("success", false); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.failure", pvt.getValue())); - } - else { - response.put("success", true); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.success", pvt.getValue())); - } + response.put("success", true); response.put("result", pvt.getStringValue()); - + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.success", pvt.getValue())); } else { - if (script == "") { - response.put("success", false); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.failure", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); - } - else { - response.put("success", true); - response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.successTs", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); - } + response.put("success", true); response.put("result", pvt.getStringValue()); - + response.put("message", LocalizableMessage.getMessage(Common.getBundle(request), "dsEdit.meta.test.successTs", pvt.getValue(), DateFunctions.getTime(pvt.getTime()))); } } catch (DataPointStateException | ResultTypeException e) { response.put("success", false); diff --git a/test/messages_en.properties b/test/messages_en.properties index 7be732c294..17ff46f6f9 100644 --- a/test/messages_en.properties +++ b/test/messages_en.properties @@ -779,7 +779,6 @@ dsEdit.meta.test.context=One or more points are disabled or missing dsEdit.meta.test.scriptError=Script error: {0} dsEdit.meta.test.success=Success. result={0} dsEdit.meta.test.successTs=Success. result={0}, timestamp={1} -dsEdit.meta.test.failure=Failure. result={0} dsEdit.meta.validate=Validate script dsEdit.meta.var=Var dsEdit.modbus.addPoint=Add point @@ -3247,6 +3246,7 @@ dox.newUISettings=Settings to set in the new UI logo.for=for logo.powered=Powered by systemSettings.valuesLimitForPurge=Default values limit for purge +dox.newUISettings=Settings to set in the new UI dox.dataRetentionSettings=Data retention settings dsEdit.httpRetriever.credentials=Credentials dsEdit.httpRetriever.password=Password From c56c68a375a38fa44c7ce2f4a29a8895cb7fa418 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 10 Aug 2023 13:11:44 +0200 Subject: [PATCH 06/22] #2384 added test script in meta data source on new UI - Added validation in validateScript() method for empty text area of script - Added script validation when focusing out of the script text area - Added script validation when changing data point type so there is no possibility of saving with incorrect script --- .../datasources/MetaDataSource/point.vue | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d95f877ad3..a72fd401fe 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,6 +11,7 @@ @@ -317,13 +318,12 @@ - @@ -550,17 +550,22 @@ export default { return; } }, - async validateScript() { try { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - this.$t(resp); + if (this.datapoint.pointLocator.script === ""){ + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + this.$refs.scriptBodyTextarea.validate(); + } + else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } } catch (e) { console.log('error:' + e); } From 6372fd791e8dfc1974bafa0d040736ad4c5f885f Mon Sep 17 00:00:00 2001 From: Kamil Jarmusik <35842300+Limraj@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:02:31 +0200 Subject: [PATCH 07/22] Update en.json corrected en.json --- scadalts-ui/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scadalts-ui/src/locales/en.json b/scadalts-ui/src/locales/en.json index f76249bda1..73cc3eb914 100644 --- a/scadalts-ui/src/locales/en.json +++ b/scadalts-ui/src/locales/en.json @@ -1053,7 +1053,7 @@ "userDetails.view.forceAdminTitle": "The function is enforced by the Admin", "userDetails.view.enableFullScreen": "Enable full screen mode", "userDetails.view.hideShortcutDisableFullScreen": "Hide shortcut to disable full screen", - "script.runScript": "Run script" + "script.runScript": "Run script", "systemsettings.event.pendingLimit": "Event Pending Limit", "systemsettings.event.pendingCacheEnabled": "Enabled Event Pending Cache" } From 4f82adebad78d4c7c1ebd964afce3f4e7e2fbc96 Mon Sep 17 00:00:00 2001 From: "pbartyzel@student.agh.edu.pl" Date: Fri, 18 Aug 2023 14:57:23 +0200 Subject: [PATCH 08/22] #2384 added test script in meta data source on new UI - Added validation after adding context datapoint for script - Added validation after editing text fields like data point name, datapoint export ID and description --- .../src/components/datasources/DataPointCreation.vue | 6 ++++++ .../src/components/datasources/MetaDataSource/point.vue | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scadalts-ui/src/components/datasources/DataPointCreation.vue b/scadalts-ui/src/components/datasources/DataPointCreation.vue index bd314b4076..b52d6632cc 100644 --- a/scadalts-ui/src/components/datasources/DataPointCreation.vue +++ b/scadalts-ui/src/components/datasources/DataPointCreation.vue @@ -27,6 +27,7 @@ label="Data Point Name" :rules="[ruleNotNull]" required + @focusout = 'handleFocusOut' > @@ -36,6 +37,7 @@ @input="checkXidUnique" :rules="[ruleNotNull, ruleXidUnique]" required + @focusout = 'handleFocusOut' > @@ -49,6 +51,7 @@ @@ -129,6 +132,9 @@ export default { console.error('Failed to fetch data'); } }, + async handleFocusOut(){ + this.$emit('textarea-focusout'); + } }, }; diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index a72fd401fe..f2381cdc0b 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -6,6 +6,7 @@ :datapoint="datapoint" @cancel="cancel()" @accept="save()" + @textarea-focusout="validateScript" > @@ -556,7 +558,6 @@ export default { }, async validateScript() { try { - console.log("validation happened"); if (this.datapoint.pointLocator.script === ""){ this.validScript = false; this.resultMessage = this.$t('validation.rule.notNull'); From 9f2fc03e02566bd1ec4173ef143f4d1c6d34378c Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Wed, 6 Sep 2023 16:08:13 +0200 Subject: [PATCH 13/22] Revert "Repaired formatting" This reverts commit f44805285da566e5c6194d2dd5421fcfc7c57638. --- .../datasources/MetaDataSource/point.vue | 183 +++++++++--------- 1 file changed, 91 insertions(+), 92 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d647de9009..7bd9b17acc 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -286,98 +286,96 @@ - - - - - - - - - - - -
{{ p.dataPointXid }} - - - mdi-close -
-
-
- - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - - - - - - - - - - - - - - - - + + + + + + + + + + + +
{{ p.dataPointXid }} + + + mdi-close + +
+
+
+ + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + + + + + + + + + + + + + + +
@@ -558,6 +556,7 @@ export default { }, async validateScript() { try { + console.log("validation happened"); if (this.datapoint.pointLocator.script === ""){ this.validScript = false; this.resultMessage = this.$t('validation.rule.notNull'); From 3df9a435ad2f93128b537794c20779cd146c8aa4 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Wed, 6 Sep 2023 16:08:21 +0200 Subject: [PATCH 14/22] Revert "- Removed unnecessary script validation" This reverts commit 6b415b3c9867519c18ca90f3875ef9c00d28b562. --- .../datasources/MetaDataSource/point.vue | 183 +++++++++--------- 1 file changed, 92 insertions(+), 91 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 7bd9b17acc..32ab562cb2 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -286,96 +286,98 @@ - - - - - - - - - - - -
{{ p.dataPointXid }} - - - mdi-close - -
-
-
- - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - - - - - - - - + + + + + + + + + + + +
{{ p.dataPointXid }} + + + mdi-close +
+
+
+ - - - - + {{ $t('script.runScript') }} + -
+
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + + + + + + + + + + + + + + + +
@@ -387,7 +389,7 @@ export default { DataPointCreation, }, async mounted() { - this.$refs.scriptBodyTextarea.validate(); + this.validateScript(); this.fetchScriptList(); this.datapoints = await this.$store.dispatch('getAllDatapoints'); }, @@ -458,7 +460,7 @@ export default { executionDelayPeriodType: "SECONDS" } }, - validScript: true, + validScript: false, resultMessage: "", ruleNotNull: (v) => !!v || this.$t('validation.rule.notNull'), ruleValidScript: () => this.validScript || this.resultMessage, @@ -556,7 +558,6 @@ export default { }, async validateScript() { try { - console.log("validation happened"); if (this.datapoint.pointLocator.script === ""){ this.validScript = false; this.resultMessage = this.$t('validation.rule.notNull'); From b7917f266dd6d147818aa166dc6541b12b778e1c Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Tue, 5 Sep 2023 18:11:12 +0200 Subject: [PATCH 15/22] latest version --- .../datasources/MetaDataSource/point.vue | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 32ab562cb2..d2f93d409b 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -326,21 +326,21 @@ required error-count="0" > - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + !!v || this.$t('validation.rule.notNull'), ruleValidScript: () => this.validScript || this.resultMessage, @@ -561,7 +560,6 @@ export default { if (this.datapoint.pointLocator.script === ""){ this.validScript = false; this.resultMessage = this.$t('validation.rule.notNull'); - this.$refs.scriptBodyTextarea.validate(); } else { let resp = await this.$store.dispatch('requestPost', { @@ -570,7 +568,6 @@ export default { }); this.validScript = resp.success; this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); } } catch (e) { console.log('error:' + e); From 787144a096d37dfa5d889a7aad850573a0e9abc2 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 10:36:58 +0200 Subject: [PATCH 16/22] - Added validation on Update/Create button --- .../datasources/MetaDataSource/point.vue | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d2f93d409b..7add6873d3 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,9 +11,9 @@ - + @@ -316,31 +316,31 @@ - - + + {{ $t('script.runScript') }} - -
+ +
- Script results: {{this.resultMessage}} + Script results: {{ this.resultMessage }} -
- - - Script error: {{this.resultMessage}} +
+ + + Script error: {{ this.resultMessage }} - + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,11 +530,12 @@ export default { this.$emit('canceled'); }, - save() { + async save() { console.debug('VirtualDataSource.point.vue::save()'); - if (this.validScript) - this.$emit('saved', this.datapoint); - }, + await this.validateScript(); + if (this.validScript) + this.$emit('saved', this.datapoint); + }, addMsValue(array) { array.push(this.multistateValue); @@ -555,24 +556,24 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === ""){ - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } - else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === "") { + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } + } catch (e) { + console.log('error:' + e); + } + }, }, }; From 5caf2934a96169d30c82b1f09109cba678a36dcc Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 10:39:30 +0200 Subject: [PATCH 17/22] Revert "- Added validation on Update/Create button" This reverts commit 787144a096d37dfa5d889a7aad850573a0e9abc2. --- .../datasources/MetaDataSource/point.vue | 93 +++++++++---------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 7add6873d3..d2f93d409b 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,9 +11,9 @@ - + @@ -316,31 +316,31 @@ - - + + {{ $t('script.runScript') }} - -
+ +
- Script results: {{ this.resultMessage }} + Script results: {{this.resultMessage}} -
- - - Script error: {{ this.resultMessage }} +
+ + + Script error: {{this.resultMessage}} - + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,12 +530,11 @@ export default { this.$emit('canceled'); }, - async save() { + save() { console.debug('VirtualDataSource.point.vue::save()'); - await this.validateScript(); - if (this.validScript) - this.$emit('saved', this.datapoint); - }, + if (this.validScript) + this.$emit('saved', this.datapoint); + }, addMsValue(array) { array.push(this.multistateValue); @@ -556,24 +555,24 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === "") { - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === ""){ + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } + else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + } + } catch (e) { + console.log('error:' + e); + } + }, }, }; From 55f59cbe18914d4e886fe7e05f6c2b72cc14522d Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 11:05:55 +0200 Subject: [PATCH 18/22] - Added validation on Update/Create button --- .../datasources/MetaDataSource/point.vue | 88 ++++++++++--------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d2f93d409b..691e36fed8 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,7 +11,7 @@ @@ -321,26 +321,26 @@ :label="$t('scriptList.script')" v-model="datapoint.pointLocator.script" rows=3 - @focusout="validateScript" + @focusout="validateScript" ref="scriptBodyTextarea" - required - error-count="0" + required + error-count="0" > - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,10 +530,11 @@ export default { this.$emit('canceled'); }, - save() { + async save() { console.debug('VirtualDataSource.point.vue::save()'); - if (this.validScript) - this.$emit('saved', this.datapoint); + await this.validateScript(); + if (this.validScript) + this.$emit('saved', this.datapoint); }, addMsValue(array) { @@ -555,24 +556,25 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === ""){ - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } - else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === ""){ + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } + else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } + } catch (e) { + console.log('error:' + e); + } + }, }, }; From 2ed265fe45040a3454eb1ee5aa88e6b689569875 Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 11:21:01 +0200 Subject: [PATCH 19/22] Revert "- Added validation on Update/Create button" This reverts commit 55f59cbe18914d4e886fe7e05f6c2b72cc14522d. --- .../datasources/MetaDataSource/point.vue | 88 +++++++++---------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 691e36fed8..d2f93d409b 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,7 +11,7 @@ @@ -321,26 +321,26 @@ :label="$t('scriptList.script')" v-model="datapoint.pointLocator.script" rows=3 - @focusout="validateScript" + @focusout="validateScript" ref="scriptBodyTextarea" - required - error-count="0" + required + error-count="0" > - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,11 +530,10 @@ export default { this.$emit('canceled'); }, - async save() { + save() { console.debug('VirtualDataSource.point.vue::save()'); - await this.validateScript(); - if (this.validScript) - this.$emit('saved', this.datapoint); + if (this.validScript) + this.$emit('saved', this.datapoint); }, addMsValue(array) { @@ -556,25 +555,24 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === ""){ - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } - else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - this.$refs.scriptBodyTextarea.validate(); - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === ""){ + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } + else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + } + } catch (e) { + console.log('error:' + e); + } + }, }, }; From 7cb4ad963c4f6ac114dfd67b9d5b23f3b20aaa2d Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 11:30:30 +0200 Subject: [PATCH 20/22] - Added validation on Update/Create button --- scadalts-ui/src/components/datasources/MetaDataSource/point.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index d2f93d409b..1a1a6f561b 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -321,7 +321,7 @@ :label="$t('scriptList.script')" v-model="datapoint.pointLocator.script" rows=3 - @focusout="validateScript" + @focusout="validateScript" ref="scriptBodyTextarea" required error-count="0" From 5f42350c915380d7a35a7c80bc723484ee1d523c Mon Sep 17 00:00:00 2001 From: Patrykb0802 Date: Thu, 7 Sep 2023 11:47:45 +0200 Subject: [PATCH 21/22] - Formatting repairment --- .../src/components/datasources/MetaDataSource/point.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 1a1a6f561b..5b66b5ae18 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -321,10 +321,10 @@ :label="$t('scriptList.script')" v-model="datapoint.pointLocator.script" rows=3 - @focusout="validateScript" + @focusout="validateScript" ref="scriptBodyTextarea" - required - error-count="0" + required + error-count="0" > Date: Thu, 7 Sep 2023 12:20:11 +0200 Subject: [PATCH 22/22] - Code formatting repair --- .../datasources/MetaDataSource/point.vue | 82 ++++++++++--------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue index 5b66b5ae18..b488890843 100644 --- a/scadalts-ui/src/components/datasources/MetaDataSource/point.vue +++ b/scadalts-ui/src/components/datasources/MetaDataSource/point.vue @@ -11,7 +11,7 @@ @@ -326,21 +326,21 @@ required error-count="0" > - - {{ $t('script.runScript') }} - - -
- - Script results: {{this.resultMessage}} - -
- - - Script error: {{this.resultMessage}} - - + + {{ $t('script.runScript') }} + + +
+ + Script results: {{this.resultMessage}} + +
+ + + Script error: {{this.resultMessage}} + + !!v || this.$t('validation.rule.notNull'), - ruleValidScript: () => this.validScript || this.resultMessage, + ruleValidScript: () => this.validScript || this.resultMessage, }; }, @@ -530,10 +530,11 @@ export default { this.$emit('canceled'); }, - save() { + async save() { console.debug('VirtualDataSource.point.vue::save()'); - if (this.validScript) - this.$emit('saved', this.datapoint); + await this.validateScript(); + if (this.validScript) + this.$emit('saved', this.datapoint); }, addMsValue(array) { @@ -555,24 +556,25 @@ export default { return; } }, - async validateScript() { - try { - if (this.datapoint.pointLocator.script === ""){ - this.validScript = false; - this.resultMessage = this.$t('validation.rule.notNull'); - } - else { - let resp = await this.$store.dispatch('requestPost', { - url: `/datapoint/meta/test`, - data: this.datapoint.pointLocator - }); - this.validScript = resp.success; - this.resultMessage = resp.message; - } - } catch (e) { - console.log('error:' + e); - } - }, + async validateScript() { + try { + if (this.datapoint.pointLocator.script === ""){ + this.validScript = false; + this.resultMessage = this.$t('validation.rule.notNull'); + } + else { + let resp = await this.$store.dispatch('requestPost', { + url: `/datapoint/meta/test`, + data: this.datapoint.pointLocator + }); + this.validScript = resp.success; + this.resultMessage = resp.message; + this.$refs.scriptBodyTextarea.validate(); + } + } catch (e) { + console.log('error:' + e); + } + }, }, };