From f5ad932b12705425bde0d6072636ad16cabaf93d Mon Sep 17 00:00:00 2001 From: marcsello Date: Tue, 8 Dec 2020 01:31:56 +0100 Subject: [PATCH] Added some basic form checks --- .../components/FlowchartNode.vue | 51 +++++++++++++++---- src/views/Dashboard.vue | 8 +-- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/simple-flowchart/components/FlowchartNode.vue b/src/simple-flowchart/components/FlowchartNode.vue index bd8a65b..2ea5737 100644 --- a/src/simple-flowchart/components/FlowchartNode.vue +++ b/src/simple-flowchart/components/FlowchartNode.vue @@ -3,8 +3,8 @@ {{ capitalizedType }} preferences +
-
@@ -30,16 +30,25 @@ + + report_problem + + + report_problem + + + report_problem + @@ -49,6 +58,7 @@ + report_problem @@ -61,11 +71,11 @@ - - {{ discardButtonLabel }} - Save + {{ discardButtonLabel }} + Save +
Apply first! - URL: {{this.data.url}} + URL: {{ this.data.url }}
@@ -185,7 +195,8 @@ export default { return { show: { delete: false, - editor: false + editor: false, + mistakes: false }, editorData: {} } @@ -218,6 +229,15 @@ export default { } else { return "DISCARD"; } + }, + restreamerValid() { + let pattern = new RegExp('^((https?|rtmp):\\/\\/)?' + // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator + return !!pattern.test(this.editorData.url); } }, @@ -247,9 +267,22 @@ export default { this.show.editor = true; }, saveEdit() { - this.show.editor = false; - this.$emit('update:data', this.editorData); - this.$emit("dataUpdated", this.data); + let form_valid = true; + if (this.type === 'encoder') { + form_valid = this.editorData.width && this.editorData.height && this.editorData.bitrate && + (this.editorData.width > 0) && (this.editorData.height > 0) && (this.editorData.bitrate > 0); + } else if (this.type === 'restreamer') { + form_valid = this.restreamerValid; + } + + if (form_valid) { + this.show.editor = false; + this.show.mistakes = false; + this.$emit('update:data', this.editorData); + this.$emit("dataUpdated", this.data); + } else { + this.show.mistakes = true; + } } } } diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index d021d78..2689265 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -80,14 +80,14 @@ export default { case "ingest": newNode.data = { url: "", - streamkey: "demokey" + streamkey: "" } break; case "encoder": newNode.data = { - bitrate: 0, - width: 0, - height: 0 + bitrate: 2500, + width: 1280, + height: 720 } break; case "restreamer":