Skip to content

Commit 5b528e7

Browse files
committed
Edition, correction de la grille
1 parent 8a338e1 commit 5b528e7

23 files changed

+438
-291
lines changed

src/dash/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"vuex": "^3.1.3"
1919
},
2020
"devDependencies": {
21+
"@mdi/font": "^5.1.45",
2122
"@vue/cli-plugin-babel": "~4.3.0",
2223
"@vue/cli-plugin-eslint": "~4.3.0",
2324
"@vue/cli-service": "~4.3.0",

src/dash/src/components/Dash.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Composant global du Dash
1010
<Tools v-if="initialized" />
1111
<AddDashWizard v-on:endOfWizard="endOfWizard" v-bind:showWizard="showWizard" />
1212
<SelectItemToAddWizard />
13-
<AddItemWizard />
13+
<ItemWizard />
1414
</div>
1515
</template>
1616

@@ -22,7 +22,7 @@ import Communication from "@/libs/Communication";
2222
import DashPreferences from "@/components/DashPreferences";
2323
import Tools from "@/components/Tools";
2424
import SelectItemToAddWizard from "@/components/Wizards/SelectItemToAddWizard";
25-
import AddItemWizard from "@/components/Wizards/AddItemWizard";
25+
import ItemWizard from "@/components/Wizards/ItemWizard";
2626
import AddDashWizard from "@/components/Wizards/AddDashWizard";
2727
import EventsManager from "@/libs/EventsManager.js";
2828

@@ -35,7 +35,7 @@ export default {
3535
DashPreferences,
3636
Tools,
3737
SelectItemToAddWizard,
38-
AddItemWizard,
38+
ItemWizard,
3939
AddDashWizard
4040
},
4141
props: {

src/dash/src/components/GridContainer.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</v-hover>
2323
</span>
2424
<template v-else-if="gridData.children.length === 1">
25-
<Widget v-bind:widgetData="gridData.children[0].widgetData" />
25+
<Widget v-bind:widgetData="$store.getters.widgets[gridData.children[0].widgetId]" v-on:remove="widgetRemoved" />
2626
</template>
2727
<template v-else-if="gridData.children.length === 2">
2828
<GridContainer
@@ -65,7 +65,7 @@ export default {
6565
children: [],
6666
orientation: "",
6767
type: "widget",
68-
widgetData: this.$store.getters.widgets[widgetId]
68+
widgetId: widgetId
6969
});
7070
}
7171
});
@@ -145,6 +145,9 @@ export default {
145145
},
146146
setDeletePreviewState(state) {
147147
this.deletePreviewState = state;
148+
},
149+
widgetRemoved() {
150+
this.gridData.children = [];
148151
}
149152
}
150153
};

src/dash/src/components/Widgets/Widget.vue

+21-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
v-on:dragend="dragEndEvent"
88
>
99
<component class="widget-content" v-bind:is="widgetData.type" v-bind:widgetData="widgetData" />
10-
<v-btn v-if="$store.getters.editMode" right absolute color="red theme--dark" small v-on:click="remove">
11-
<v-icon>mdi-delete</v-icon>
12-
</v-btn>
10+
<div v-if="$store.getters.editMode" class="widget-tools">
11+
<v-btn right color="grey theme--dark" small v-on:click="edit">
12+
<v-icon>mdi-pencil</v-icon>
13+
</v-btn>
14+
<v-btn right color="red theme--dark" small v-on:click="remove">
15+
<v-icon>mdi-delete</v-icon>
16+
</v-btn>
17+
</div>
1318
</v-card>
1419
</template>
1520

@@ -81,8 +86,12 @@ export default {
8186
dragEndEvent() {
8287
this.dragStarted = false;
8388
},
89+
edit() {
90+
this.$eventBus.$emit("WizardEditItem", this.widgetData.id);
91+
},
8492
remove() {
8593
this.$store.commit("removeWidget", this.widgetData.id);
94+
this.$emit("remove");
8695
}
8796
}
8897
};
@@ -97,4 +106,13 @@ export default {
97106
.v-card.hide-border {
98107
box-shadow: none !important;
99108
}
109+
</style>
110+
111+
<style>
112+
.widget-tools {
113+
width: 100%;
114+
text-align: right;
115+
position: relative;
116+
z-index: 1;
117+
}
100118
</style>

src/dash/src/components/Wizards/BaseWizard.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export default {
88
stateUpdater: null
99
}),
1010
methods: {
11+
resetData() {
12+
this.previewData = JSON.parse(JSON.stringify(this.baseData));
13+
},
1114
startStateUpdater() {
1215
this.stateUpdater = setInterval(() => {
1316
this.previewData.state = !this.previewData.state;
@@ -21,7 +24,9 @@ export default {
2124
endOfWizard() {
2225
this.stopStateUpdater();
2326
this.$store.commit("setEditMode", true);
24-
this.previewData.id = this.genFakeGuid();
27+
if (this.previewData.id === -1) {
28+
this.previewData.id = this.genFakeGuid();
29+
}
2530
// Clone de l'objet
2631
this.$store.commit(
2732
"addWidget",

src/dash/src/components/Wizards/Helpers/FilteredCommands.vue

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export default {
3939
type: String,
4040
default: "Commande"
4141
},
42+
default: {
43+
type: Number,
44+
default: -1
45+
},
4246
type: String,
4347
subType: String,
4448
eqLogicId: Number,
@@ -63,7 +67,6 @@ export default {
6367
},
6468
watch: {
6569
type: function() {
66-
console.log("UPDATE");
6770
if (this.dataLoaded) {
6871
this.updateCommandsList();
6972
}
@@ -108,15 +111,19 @@ export default {
108111
this.mustBeShowed(cmdData) &&
109112
!(this.hideUseless && this.isUselessCommand(cmdData["name"]))
110113
) {
111-
this.commandsList.push({
114+
const commandData = {
112115
room: this.commandsTree[roomId]["name"],
113116
eqLogic: this.commandsTree[roomId]["eqLogics"][eqLogicIndex][
114117
"name"
115118
],
116119
cmd: cmdData["name"],
117120
id: cmdData["id"],
118121
data: cmdData
119-
});
122+
};
123+
if (this.default == commandData.id) {
124+
this.command = [commandData];
125+
}
126+
this.commandsList.push(commandData);
120127
}
121128
}
122129
}

src/dash/src/components/Wizards/Helpers/FilteredDashs.vue

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
v-bind:loading="Object.keys(rawDashs).length === 0"
1616
loading-text="Chargement..."
1717
class="elevation-10"
18-
v-model="scenario"
18+
v-model="dash"
1919
v-bind:search="search"
2020
></v-data-table>
2121
</v-card>
@@ -31,6 +31,10 @@ export default {
3131
type: Array,
3232
default: () => []
3333
},
34+
default: {
35+
type: Number,
36+
default: -1
37+
},
3438
type: {}
3539
},
3640
data: () => ({
@@ -42,18 +46,21 @@ export default {
4246
{ text: "Nom", value: "name" }
4347
]
4448
}),
45-
created() {
49+
mounted() {
4650
Communication.get("/api/dash/all", result => {
4751
this.rawDashs = result;
4852
this.dashsList = result;
53+
if (this.default !== -1) {
54+
this.dash = [{ id: this.default }];
55+
}
4956
// this.updateDashsList();
5057
});
5158
},
5259
computed: {
5360
dataLoaded() {
5461
return !(Object.keys(this.rawDashs).length === 0);
5562
},
56-
scenario: {
63+
dash: {
5764
get() {
5865
return this.value;
5966
},

src/dash/src/components/Wizards/Helpers/FilteredEqLogics.vue

+13-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export default {
3131
type: Array,
3232
default: () => []
3333
},
34+
default: {
35+
type: Number,
36+
default: -1
37+
},
3438
type: String
3539
},
3640
data: () => ({
@@ -43,6 +47,9 @@ export default {
4347
]
4448
}),
4549
created() {
50+
this.updateEqLogicssList();
51+
},
52+
mounted() {
4653
Communication.get("/api/summary/all", result => {
4754
this.eqLogicsTree = result;
4855
this.updateEqLogicssList();
@@ -80,14 +87,18 @@ export default {
8087
this.type
8188
)
8289
) {
83-
this.eqLogicsList.push({
90+
const eqLogicData = {
8491
room: this.eqLogicsTree[roomId]["name"],
8592
eqLogic: this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]["name"],
8693
id: parseInt(
8794
this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]["id"]
8895
),
8996
eqLogicData: this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]
90-
});
97+
};
98+
if (this.default == eqLogicData.id) {
99+
this.eqLogic = [eqLogicData];
100+
}
101+
this.eqLogicsList.push(eqLogicData);
91102
}
92103
}
93104
}

src/dash/src/components/Wizards/Helpers/FilteredScenarios.vue

+16-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
<v-card-title>
44
Scénarios
55
<v-spacer />
6-
<v-text-field
7-
v-model="search"
8-
append-icon="mdi-magnify"
9-
label="Filtrer"
10-
single-line
11-
hide-details
12-
></v-text-field>
6+
<v-text-field v-model="search" append-icon="mdi-magnify" label="Filtrer" single-line hide-details></v-text-field>
137
</v-card-title>
148
<v-data-table
159
v-bind:headers="headers"
@@ -24,11 +18,7 @@
2418
v-model="scenario"
2519
v-bind:search="search"
2620
></v-data-table>
27-
<v-checkbox
28-
label="Cacher les scénarios désactivés"
29-
v-model="hideInactives"
30-
v-on:change="updateScenariosList"
31-
/>
21+
<v-checkbox label="Cacher les scénarios désactivés" v-model="hideInactives" v-on:change="updateScenariosList" />
3222
</v-card>
3323
</template>
3424

@@ -42,6 +32,10 @@ export default {
4232
type: Array,
4333
default: () => []
4434
},
35+
default: {
36+
type: Number,
37+
default: -1
38+
},
4539
type: {}
4640
},
4741
data: () => ({
@@ -54,10 +48,13 @@ export default {
5448
{ text: "Scenario", value: "name" }
5549
]
5650
}),
57-
created() {
51+
mounted() {
5852
Communication.get("/api/scenario/all", result => {
5953
this.rawScenarios = result;
6054
this.updateScenariosList();
55+
if (this.default !== -1) {
56+
this.scenario = [{ id: this.default }];
57+
}
6158
});
6259
},
6360
computed: {
@@ -79,12 +76,16 @@ export default {
7976
for (let scenarioIndex in this.rawScenarios) {
8077
const scenario = this.rawScenarios[scenarioIndex];
8178
if (!(!scenario.active && this.hideInactives)) {
82-
this.scenariosList.push({
79+
const scenarioData = {
8380
scenario: scenario,
8481
id: scenario.id,
8582
name: scenario.name,
8683
group: scenario.group
87-
});
84+
};
85+
if (this.default == scenario.id) {
86+
this.scenario = [scenarioData];
87+
}
88+
this.scenariosList.push();
8889
}
8990
}
9091
}

src/dash/src/components/Wizards/AddItemWizard.vue src/dash/src/components/Wizards/ItemWizard.vue

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Dialog de base d'ajout d'un élément
33
-->
44
<template>
55
<v-dialog v-model="showed">
6-
<component v-if="currentWizard !== null" v-bind:is="currentWizard" v-on:hide="showed = false" />
6+
<component v-if="currentWizard !== null" v-bind:is="currentWizard" v-on:hide="showed = false" v-bind="editAttr" />
77
</v-dialog>
88
</template>
99

@@ -20,7 +20,7 @@ import EqLogicActionWizard from "@/components/Wizards/Items/EqLogicActionWizard"
2020
import LinkToDashWizard from "@/components/Wizards/Items/LinkToDashWizard";
2121

2222
export default {
23-
name: "AddItemWizard",
23+
name: "ItemWizard",
2424
components: {
2525
CameraWizard,
2626
InfoBinaryWizard,
@@ -35,12 +35,22 @@ export default {
3535
},
3636
data: () => ({
3737
showed: false,
38-
currentWizard: null
38+
currentWizard: null,
39+
editAttr: {}
3940
}),
4041
mounted() {
4142
this.$eventBus.$on("WizardAddItem", component => {
42-
this.showed = true;
43+
this.editAttr = {};
4344
this.currentWizard = component + "Wizard";
45+
this.showed = true;
46+
});
47+
this.$eventBus.$on("WizardEditItem", widgetId => {
48+
this.editAttr = {
49+
baseData: this.$store.getters.widgets[widgetId]
50+
};
51+
this.currentWizard =
52+
this.$store.getters.widgets[widgetId].type + "Wizard";
53+
this.showed = true;
4454
});
4555
}
4656
};

0 commit comments

Comments
 (0)