From afc991af03fb5b373ac657532b9ebfd8bd36f291 Mon Sep 17 00:00:00 2001 From: Sylvaner Date: Sat, 9 May 2020 23:41:54 +0200 Subject: [PATCH] Edition, correction de la grille --- src/dash/package.json | 1 + src/dash/src/components/Dash.vue | 6 +- src/dash/src/components/GridContainer.vue | 69 +++++++------- src/dash/src/components/Widgets/Widget.vue | 24 ++++- .../src/components/Wizards/BaseWizard.vue | 7 +- .../Wizards/Helpers/FilteredCommands.vue | 13 ++- .../Wizards/Helpers/FilteredDashs.vue | 13 ++- .../Wizards/Helpers/FilteredEqLogics.vue | 15 ++- .../Wizards/Helpers/FilteredScenarios.vue | 31 ++++--- .../{AddItemWizard.vue => ItemWizard.vue} | 18 +++- .../components/Wizards/Items/CameraWizard.vue | 53 ++++++----- .../Wizards/Items/CmdActionWizard.vue | 54 ++++++----- .../Wizards/Items/EqLogicActionWizard.vue | 91 ++++++++++++------- .../Wizards/Items/InfoBinaryImgWizard.vue | 54 ++++++----- .../Wizards/Items/InfoBinaryWizard.vue | 54 ++++++----- .../Wizards/Items/InfoNumericImgWizard.vue | 65 ++++++------- .../Wizards/Items/InfoNumericWizard.vue | 56 +++++++----- .../Wizards/Items/LinkToDashWizard.vue | 53 ++++++----- .../Wizards/Items/ScenarioActionImgWizard.vue | 54 ++++++----- .../Wizards/Items/ScenarioActionWizard.vue | 52 ++++++----- src/dash/src/libs/Store.js | 2 +- src/dash/src/main.js | 1 + src/dash/yarn.lock | 5 + 23 files changed, 471 insertions(+), 320 deletions(-) rename src/dash/src/components/Wizards/{AddItemWizard.vue => ItemWizard.vue} (78%) diff --git a/src/dash/package.json b/src/dash/package.json index 65eaf2c7b..33bd44bc3 100644 --- a/src/dash/package.json +++ b/src/dash/package.json @@ -18,6 +18,7 @@ "vuex": "^3.1.3" }, "devDependencies": { + "@mdi/font": "^5.1.45", "@vue/cli-plugin-babel": "~4.3.0", "@vue/cli-plugin-eslint": "~4.3.0", "@vue/cli-service": "~4.3.0", diff --git a/src/dash/src/components/Dash.vue b/src/dash/src/components/Dash.vue index e19991860..48b2b9cfe 100644 --- a/src/dash/src/components/Dash.vue +++ b/src/dash/src/components/Dash.vue @@ -10,7 +10,7 @@ Composant global du Dash - + @@ -22,7 +22,7 @@ import Communication from "@/libs/Communication"; import DashPreferences from "@/components/DashPreferences"; import Tools from "@/components/Tools"; import SelectItemToAddWizard from "@/components/Wizards/SelectItemToAddWizard"; -import AddItemWizard from "@/components/Wizards/AddItemWizard"; +import ItemWizard from "@/components/Wizards/ItemWizard"; import AddDashWizard from "@/components/Wizards/AddDashWizard"; import EventsManager from "@/libs/EventsManager.js"; @@ -35,7 +35,7 @@ export default { DashPreferences, Tools, SelectItemToAddWizard, - AddItemWizard, + ItemWizard, AddDashWizard }, props: { diff --git a/src/dash/src/components/GridContainer.vue b/src/dash/src/components/GridContainer.vue index ee9730f96..440eb6602 100644 --- a/src/dash/src/components/GridContainer.vue +++ b/src/dash/src/components/GridContainer.vue @@ -1,5 +1,5 @@ @@ -42,6 +32,10 @@ export default { type: Array, default: () => [] }, + default: { + type: Number, + default: -1 + }, type: {} }, data: () => ({ @@ -54,10 +48,13 @@ export default { { text: "Scenario", value: "name" } ] }), - created() { + mounted() { Communication.get("/api/scenario/all", result => { this.rawScenarios = result; this.updateScenariosList(); + if (this.default !== -1) { + this.scenario = [{ id: this.default }]; + } }); }, computed: { @@ -79,12 +76,16 @@ export default { for (let scenarioIndex in this.rawScenarios) { const scenario = this.rawScenarios[scenarioIndex]; if (!(!scenario.active && this.hideInactives)) { - this.scenariosList.push({ + const scenarioData = { scenario: scenario, id: scenario.id, name: scenario.name, group: scenario.group - }); + }; + if (this.default == scenario.id) { + this.scenario = [scenarioData]; + } + this.scenariosList.push(); } } } diff --git a/src/dash/src/components/Wizards/AddItemWizard.vue b/src/dash/src/components/Wizards/ItemWizard.vue similarity index 78% rename from src/dash/src/components/Wizards/AddItemWizard.vue rename to src/dash/src/components/Wizards/ItemWizard.vue index a729777a7..8d411f797 100644 --- a/src/dash/src/components/Wizards/AddItemWizard.vue +++ b/src/dash/src/components/Wizards/ItemWizard.vue @@ -3,7 +3,7 @@ Dialog de base d'ajout d'un élément --> @@ -20,7 +20,7 @@ import EqLogicActionWizard from "@/components/Wizards/Items/EqLogicActionWizard" import LinkToDashWizard from "@/components/Wizards/Items/LinkToDashWizard"; export default { - name: "AddItemWizard", + name: "ItemWizard", components: { CameraWizard, InfoBinaryWizard, @@ -35,12 +35,22 @@ export default { }, data: () => ({ showed: false, - currentWizard: null + currentWizard: null, + editAttr: {} }), mounted() { this.$eventBus.$on("WizardAddItem", component => { - this.showed = true; + this.editAttr = {}; this.currentWizard = component + "Wizard"; + this.showed = true; + }); + this.$eventBus.$on("WizardEditItem", widgetId => { + this.editAttr = { + baseData: this.$store.getters.widgets[widgetId] + }; + this.currentWizard = + this.$store.getters.widgets[widgetId].type + "Wizard"; + this.showed = true; }); } }; diff --git a/src/dash/src/components/Wizards/Items/CameraWizard.vue b/src/dash/src/components/Wizards/Items/CameraWizard.vue index 953f0b4d0..d11d04652 100644 --- a/src/dash/src/components/Wizards/Items/CameraWizard.vue +++ b/src/dash/src/components/Wizards/Items/CameraWizard.vue @@ -7,7 +7,7 @@ - + @@ -46,6 +46,29 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + cmdId: -1, + type: "Camera", + pos: { top: 0, left: 0 }, + eqLogicId: -1, + localApiKey: "", + refreshInterval: 0, + title: "Camera", + quality: true, + style: { + border: false, + width: "auto", + height: "auto", + transparent: true, + titleSize: 20 + } + }) + } + }, data: () => ({ eqLogic: [], previewData: {} @@ -62,7 +85,9 @@ export default { } break; case 2: - this.previewData.title = this.eqLogic[0].eqLogic; + if (this.previewData.id === -1) { + this.previewData.title = this.eqLogic[0].eqLogic; + } this.previewData.eqLogicId = this.eqLogic[0].id; this.previewData.refreshInterval = this.eqLogic[0].eqLogicData.configuration[ "thumbnail::refresh" @@ -76,29 +101,13 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - cmdId: -1, - type: "Camera", - pos: { top: 0, left: 0 }, - eqLogicId: -1, - localApiKey: "", - refreshInterval: 0, - title: "Camera", - quality: true, - style: { - border: false, - width: "auto", - height: "auto", - transparent: true, - titleSize: 20 - } - }) - ); + this.previewData = JSON.parse(JSON.stringify(this.baseData)); }, finish() { this.endOfWizard(); diff --git a/src/dash/src/components/Wizards/Items/CmdActionWizard.vue b/src/dash/src/components/Wizards/Items/CmdActionWizard.vue index 5221a8d56..cea73d67e 100644 --- a/src/dash/src/components/Wizards/Items/CmdActionWizard.vue +++ b/src/dash/src/components/Wizards/Items/CmdActionWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,6 +43,29 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "CmdAction", + cmdId: -1, + pos: { top: 0, left: 0 }, + icon: "play-circle", + title: "", + state: true, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ command: [], stateUpdater: null @@ -58,7 +81,9 @@ export default { this.previewData.state = !this.previewData.state; }, 2000); if (this.command.length > 0) { - this.previewData.title = this.command[0]["eqLogic"]; + if (this.previewData.id === -1) { + this.previewData.title = this.command[0]["eqLogic"]; + } this.previewData.cmdId = parseInt(this.command[0]["id"]); } break; @@ -67,30 +92,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "CmdAction", - cmdId: -1, - pos: { top: 0, left: 0 }, - icon: "play-circle", - title: "", - state: true, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/EqLogicActionWizard.vue b/src/dash/src/components/Wizards/Items/EqLogicActionWizard.vue index 396fa36f7..cd72bd55f 100644 --- a/src/dash/src/components/Wizards/Items/EqLogicActionWizard.vue +++ b/src/dash/src/components/Wizards/Items/EqLogicActionWizard.vue @@ -13,19 +13,37 @@ - + - + - + - + @@ -63,6 +81,31 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "EqLogicAction", + cmdId: -1, + pos: { top: 0, left: 0 }, + icon: "lamp", + title: "", + state: true, + onCommandId: -1, + offCommandId: -1, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ eqLogic: [], eqLogicId: undefined, @@ -74,22 +117,18 @@ export default { step: function(newStep) { switch (newStep) { case 1: + this.resetData(); this.stopStateUpdater(); - this.eqLogic = []; break; case 2: this.eqLogicId = this.eqLogic[0].id; - this.stateCommand = []; - break; - case 3: - this.onCommand = []; - break; - case 4: - this.offCommand = []; break; case 5: this.startStateUpdater(); - this.previewData.title = this.eqLogic[0].eqLogic; + this.previewData.eqLogicId = this.eqLogicId; + if (this.previewData.id === -1) { + this.previewData.title = this.eqLogic[0].eqLogic; + } this.previewData.state = this.stateCommand[0].data.state; this.previewData.cmdId = parseInt(this.stateCommand[0].id); this.previewData.onCommandId = parseInt(this.onCommand[0].id); @@ -100,31 +139,13 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 5; + } }, methods: { resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "EqLogicAction", - cmdId: -1, - pos: { top: 0, left: 0 }, - icon: "lamp", - title: "", - state: true, - onCommandId: -1, - offCommandId: -1, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); + this.previewData = JSON.parse(JSON.stringify(this.baseData)); }, finish() { this.endOfWizard(); diff --git a/src/dash/src/components/Wizards/Items/InfoBinaryImgWizard.vue b/src/dash/src/components/Wizards/Items/InfoBinaryImgWizard.vue index d1f9a185c..9dc6812e2 100644 --- a/src/dash/src/components/Wizards/Items/InfoBinaryImgWizard.vue +++ b/src/dash/src/components/Wizards/Items/InfoBinaryImgWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,6 +43,29 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "InfoBinaryImg", + cmdId: -1, + pos: { top: 0, left: 0 }, + picture: "v1", + title: "", + state: true, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ command: [] }), @@ -56,7 +79,9 @@ export default { case 2: this.startStateUpdater(); if (this.command.length > 0) { - this.previewData.title = this.command[0]["eqLogic"]; + if (this.previewData.id === -1) { + this.previewData.title = this.command[0]["eqLogic"]; + } this.previewData.state = this.command[0]["data"]["state"]; this.previewData.cmdId = parseInt(this.command[0]["id"]); } @@ -66,30 +91,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "InfoBinaryImg", - cmdId: -1, - pos: { top: 0, left: 0 }, - picture: "v1", - title: "", - state: true, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/InfoBinaryWizard.vue b/src/dash/src/components/Wizards/Items/InfoBinaryWizard.vue index a5de3186a..ddc9f00e8 100644 --- a/src/dash/src/components/Wizards/Items/InfoBinaryWizard.vue +++ b/src/dash/src/components/Wizards/Items/InfoBinaryWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,6 +43,29 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "InfoBinary", + cmdId: -1, + pos: { top: 0, left: 0 }, + icon: "door", + title: "", + state: true, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ command: [] }), @@ -56,7 +79,9 @@ export default { case 2: this.startStateUpdater(); if (this.command.length > 0) { - this.previewData.title = this.command[0]["eqLogic"]; + if (this.previewData.id === -1) { + this.previewData.title = this.command[0]["eqLogic"]; + } this.previewData.state = this.command[0]["data"]["state"]; this.previewData.cmdId = parseInt(this.command[0]["id"]); } @@ -66,30 +91,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "InfoBinary", - cmdId: -1, - pos: { top: 0, left: 0 }, - icon: "door", - title: "", - state: true, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/InfoNumericImgWizard.vue b/src/dash/src/components/Wizards/Items/InfoNumericImgWizard.vue index d9f3d790d..03c8d72f1 100644 --- a/src/dash/src/components/Wizards/Items/InfoNumericImgWizard.vue +++ b/src/dash/src/components/Wizards/Items/InfoNumericImgWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,14 +43,38 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "InfoNumericImg", + cmdId: -1, + pos: { top: 0, left: 0 }, + picture: { name: "shutter", values: [0, 100] }, + title: "", + unit: "%", + percent: false, + min: 0, + max: 100, + state: 100, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 60 + } + }) + } + }, data: () => ({ command: [], previewData: {} }), watch: { - previewData: function(newData) { - console.log(newData); - }, step: function(newStep) { switch (newStep) { case 1: @@ -58,7 +82,9 @@ export default { break; case 2: if (this.command.length > 0) { - this.previewData.title = this.command[0]["eqLogic"]; + if (this.previewData.id === -1) { + this.previewData.title = this.command[0]["eqLogic"]; + } if (this.command[0]["data"]["unite"] === "%") { this.previewData.percent = true; this.previewData.unit = "%"; @@ -76,6 +102,9 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { filterCmd(cmd) { @@ -90,32 +119,6 @@ export default { } return false; }, - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "InfoNumericImg", - cmdId: -1, - pos: { top: 0, left: 0 }, - picture: { name: "shutter", values: [0, 100] }, - title: "", - unit: "%", - percent: false, - min: 0, - max: 100, - state: 100, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 60 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/InfoNumericWizard.vue b/src/dash/src/components/Wizards/Items/InfoNumericWizard.vue index 3513195f3..adbadb291 100644 --- a/src/dash/src/components/Wizards/Items/InfoNumericWizard.vue +++ b/src/dash/src/components/Wizards/Items/InfoNumericWizard.vue @@ -7,7 +7,7 @@ - + @@ -44,6 +44,30 @@ export default { StepperButtons, WidgetPreview }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "InfoNumeric", + cmdId: -1, + pos: { top: 0, left: 0 }, + icon: "", + title: "", + unit: "", + state: 20, + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 20 + } + }) + } + }, data: () => ({ command: [] }), @@ -55,7 +79,9 @@ export default { break; case 2: if (this.command.length > 0) { - this.previewData.title = this.command[0]["eqLogic"]; + if (this.previewData.id === -1) { + this.previewData.title = this.command[0]["eqLogic"]; + } this.previewData.unit = this.command[0]["data"]["unite"]; this.previewData.state = this.command[0]["data"]["state"]; this.previewData.cmdId = parseInt(this.command[0]["id"]); @@ -66,31 +92,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "InfoNumeric", - cmdId: -1, - pos: { top: 0, left: 0 }, - icon: "", - title: "", - unit: "", - state: 20, - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 20 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/LinkToDashWizard.vue b/src/dash/src/components/Wizards/Items/LinkToDashWizard.vue index ff5a06478..db5d849c4 100644 --- a/src/dash/src/components/Wizards/Items/LinkToDashWizard.vue +++ b/src/dash/src/components/Wizards/Items/LinkToDashWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,6 +43,29 @@ export default { WidgetPreview, StepperButtons }, + props: { + baseData: { + type: Object, + default: () => ({ + id: 0, + type: "LinkToDash", + target: 0, + pos: { top: 0, left: 0 }, + title: "", + hideBorder: true, + picture: "on-off/play-on.png", + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ dash: [] }), @@ -54,7 +77,9 @@ export default { break; case 2: if (this.dash.length > 0) { - this.previewData.title = this.dash[0].name; + if (this.previewData.id === -1) { + this.previewData.title = this.dash[0].name; + } this.previewData.target = parseInt(this.dash[0].id); } break; @@ -63,29 +88,13 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: 0, - type: "LinkToDash", - target: 0, - pos: { top: 0, left: 0 }, - title: "", - hideBorder: true, - picture: "on-off/play-on.png", - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); + this.previewData = JSON.parse(JSON.stringify(this.baseData)); }, finish() { this.endOfWizard(); diff --git a/src/dash/src/components/Wizards/Items/ScenarioActionImgWizard.vue b/src/dash/src/components/Wizards/Items/ScenarioActionImgWizard.vue index b13d2a6cb..6791ee944 100644 --- a/src/dash/src/components/Wizards/Items/ScenarioActionImgWizard.vue +++ b/src/dash/src/components/Wizards/Items/ScenarioActionImgWizard.vue @@ -7,7 +7,7 @@ - + @@ -43,6 +43,29 @@ export default { WidgetPreview, StepperButtons }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "ScenarioActionImg", + scenarioId: -1, + pos: { top: 0, left: 0 }, + title: "", + state: "stop", + picture: "on-off/play-on.png", + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ scenario: [] }), @@ -54,7 +77,9 @@ export default { break; case 2: if (this.scenario.length > 0) { - this.previewData.title = this.scenario[0].name; + if (this.previewData.id === -1) { + this.previewData.title = this.scenario[0].name; + } this.previewData.scenarioId = parseInt(this.scenario[0].id); } break; @@ -63,30 +88,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "ScenarioActionImg", - scenarioId: -1, - pos: { top: 0, left: 0 }, - title: "", - state: "stop", - picture: "on-off/play-on.png", - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/components/Wizards/Items/ScenarioActionWizard.vue b/src/dash/src/components/Wizards/Items/ScenarioActionWizard.vue index 1c27e7b67..8ae03c3d9 100644 --- a/src/dash/src/components/Wizards/Items/ScenarioActionWizard.vue +++ b/src/dash/src/components/Wizards/Items/ScenarioActionWizard.vue @@ -7,7 +7,7 @@ - + @@ -40,6 +40,28 @@ export default { WidgetPreview, StepperButtons }, + props: { + baseData: { + type: Object, + default: () => ({ + id: -1, + type: "ScenarioAction", + scenarioId: -1, + pos: { top: 0, left: 0 }, + title: "", + state: "stop", + style: { + border: true, + width: 280, + height: 150, + transparent: false, + backgroundColor: "#FFFFFFFF", + titleSize: 20, + contentSize: 40 + } + }) + } + }, data: () => ({ scenario: [] }), @@ -51,7 +73,9 @@ export default { break; case 2: if (this.scenario.length > 0) { - this.previewData.title = this.scenario[0].name; + if (this.previewData.id === -1) { + this.previewData.title = this.scenario[0].name; + } this.previewData.scenarioId = parseInt(this.scenario[0].id); } break; @@ -60,29 +84,11 @@ export default { }, created() { this.resetData(); + if (this.previewData.id !== -1) { + this.step = 2; + } }, methods: { - resetData() { - this.previewData = JSON.parse( - JSON.stringify({ - id: -1, - type: "ScenarioAction", - scenarioId: -1, - pos: { top: 0, left: 0 }, - title: "", - state: "stop", - style: { - border: true, - width: 280, - height: 150, - transparent: false, - backgroundColor: "#FFFFFFFF", - titleSize: 20, - contentSize: 40 - } - }) - ); - }, finish() { this.endOfWizard(); this.resetData(); diff --git a/src/dash/src/libs/Store.js b/src/dash/src/libs/Store.js index 59d8db925..7775d3714 100644 --- a/src/dash/src/libs/Store.js +++ b/src/dash/src/libs/Store.js @@ -44,7 +44,7 @@ export const store = new Vuex.Store({ */ updateCmd(state, payload) { for (let widget in state.widgets) { - if (state.widgets[widget].cmdId === payload.cmdId) { + if (state.widgets[widget].cmdId == payload.cmdId) { state.widgets[widget].state = payload.newState; } } diff --git a/src/dash/src/main.js b/src/dash/src/main.js index a4af328ae..51fc212d5 100644 --- a/src/dash/src/main.js +++ b/src/dash/src/main.js @@ -1,4 +1,5 @@ import '@fortawesome/fontawesome-free/css/all.css' +import '@mdi/font/css/materialdesignicons.css' import '@/assets/global.css' import Vue from 'vue' import App from '@/App.vue' diff --git a/src/dash/yarn.lock b/src/dash/yarn.lock index 790922328..566151551 100644 --- a/src/dash/yarn.lock +++ b/src/dash/yarn.lock @@ -842,6 +842,11 @@ cssnano-preset-default "^4.0.0" postcss "^7.0.0" +"@mdi/font@^5.1.45": + version "5.1.45" + resolved "https://registry.yarnpkg.com/@mdi/font/-/font-5.1.45.tgz#58edff65985cc5a350eb95ff2974273a285ea9ad" + integrity sha512-7H1UMwUpEp8mthdPlpAi7bhEyvTbvtK1TlA89scc0cXMpQy0UFygdkaf+6fveIxpBcRNgw0gnGSEonlsfYocXg== + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"