Skip to content

Commit

Permalink
Edition, correction de la grille
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvaner committed May 9, 2020
1 parent 8a338e1 commit 5b528e7
Show file tree
Hide file tree
Showing 23 changed files with 438 additions and 291 deletions.
1 change: 1 addition & 0 deletions src/dash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/dash/src/components/Dash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Composant global du Dash
<Tools v-if="initialized" />
<AddDashWizard v-on:endOfWizard="endOfWizard" v-bind:showWizard="showWizard" />
<SelectItemToAddWizard />
<AddItemWizard />
<ItemWizard />
</div>
</template>

Expand All @@ -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";

Expand All @@ -35,7 +35,7 @@ export default {
DashPreferences,
Tools,
SelectItemToAddWizard,
AddItemWizard,
ItemWizard,
AddDashWizard
},
props: {
Expand Down
7 changes: 5 additions & 2 deletions src/dash/src/components/GridContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</v-hover>
</span>
<template v-else-if="gridData.children.length === 1">
<Widget v-bind:widgetData="gridData.children[0].widgetData" />
<Widget v-bind:widgetData="$store.getters.widgets[gridData.children[0].widgetId]" v-on:remove="widgetRemoved" />
</template>
<template v-else-if="gridData.children.length === 2">
<GridContainer
Expand Down Expand Up @@ -65,7 +65,7 @@ export default {
children: [],
orientation: "",
type: "widget",
widgetData: this.$store.getters.widgets[widgetId]
widgetId: widgetId
});
}
});
Expand Down Expand Up @@ -145,6 +145,9 @@ export default {
},
setDeletePreviewState(state) {
this.deletePreviewState = state;
},
widgetRemoved() {
this.gridData.children = [];
}
}
};
Expand Down
24 changes: 21 additions & 3 deletions src/dash/src/components/Widgets/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
v-on:dragend="dragEndEvent"
>
<component class="widget-content" v-bind:is="widgetData.type" v-bind:widgetData="widgetData" />
<v-btn v-if="$store.getters.editMode" right absolute color="red theme--dark" small v-on:click="remove">
<v-icon>mdi-delete</v-icon>
</v-btn>
<div v-if="$store.getters.editMode" class="widget-tools">
<v-btn right color="grey theme--dark" small v-on:click="edit">
<v-icon>mdi-pencil</v-icon>
</v-btn>
<v-btn right color="red theme--dark" small v-on:click="remove">
<v-icon>mdi-delete</v-icon>
</v-btn>
</div>
</v-card>
</template>

Expand Down Expand Up @@ -81,8 +86,12 @@ export default {
dragEndEvent() {
this.dragStarted = false;
},
edit() {
this.$eventBus.$emit("WizardEditItem", this.widgetData.id);
},
remove() {
this.$store.commit("removeWidget", this.widgetData.id);
this.$emit("remove");
}
}
};
Expand All @@ -97,4 +106,13 @@ export default {
.v-card.hide-border {
box-shadow: none !important;
}
</style>

<style>
.widget-tools {
width: 100%;
text-align: right;
position: relative;
z-index: 1;
}
</style>
7 changes: 6 additions & 1 deletion src/dash/src/components/Wizards/BaseWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export default {
stateUpdater: null
}),
methods: {
resetData() {
this.previewData = JSON.parse(JSON.stringify(this.baseData));
},
startStateUpdater() {
this.stateUpdater = setInterval(() => {
this.previewData.state = !this.previewData.state;
Expand All @@ -21,7 +24,9 @@ export default {
endOfWizard() {
this.stopStateUpdater();
this.$store.commit("setEditMode", true);
this.previewData.id = this.genFakeGuid();
if (this.previewData.id === -1) {
this.previewData.id = this.genFakeGuid();
}
// Clone de l'objet
this.$store.commit(
"addWidget",
Expand Down
13 changes: 10 additions & 3 deletions src/dash/src/components/Wizards/Helpers/FilteredCommands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default {
type: String,
default: "Commande"
},
default: {
type: Number,
default: -1
},
type: String,
subType: String,
eqLogicId: Number,
Expand All @@ -63,7 +67,6 @@ export default {
},
watch: {
type: function() {
console.log("UPDATE");
if (this.dataLoaded) {
this.updateCommandsList();
}
Expand Down Expand Up @@ -108,15 +111,19 @@ export default {
this.mustBeShowed(cmdData) &&
!(this.hideUseless && this.isUselessCommand(cmdData["name"]))
) {
this.commandsList.push({
const commandData = {
room: this.commandsTree[roomId]["name"],
eqLogic: this.commandsTree[roomId]["eqLogics"][eqLogicIndex][
"name"
],
cmd: cmdData["name"],
id: cmdData["id"],
data: cmdData
});
};
if (this.default == commandData.id) {
this.command = [commandData];
}
this.commandsList.push(commandData);
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/dash/src/components/Wizards/Helpers/FilteredDashs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
v-bind:loading="Object.keys(rawDashs).length === 0"
loading-text="Chargement..."
class="elevation-10"
v-model="scenario"
v-model="dash"
v-bind:search="search"
></v-data-table>
</v-card>
Expand All @@ -31,6 +31,10 @@ export default {
type: Array,
default: () => []
},
default: {
type: Number,
default: -1
},
type: {}
},
data: () => ({
Expand All @@ -42,18 +46,21 @@ export default {
{ text: "Nom", value: "name" }
]
}),
created() {
mounted() {
Communication.get("/api/dash/all", result => {
this.rawDashs = result;
this.dashsList = result;
if (this.default !== -1) {
this.dash = [{ id: this.default }];
}
// this.updateDashsList();
});
},
computed: {
dataLoaded() {
return !(Object.keys(this.rawDashs).length === 0);
},
scenario: {
dash: {
get() {
return this.value;
},
Expand Down
15 changes: 13 additions & 2 deletions src/dash/src/components/Wizards/Helpers/FilteredEqLogics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default {
type: Array,
default: () => []
},
default: {
type: Number,
default: -1
},
type: String
},
data: () => ({
Expand All @@ -43,6 +47,9 @@ export default {
]
}),
created() {
this.updateEqLogicssList();
},
mounted() {
Communication.get("/api/summary/all", result => {
this.eqLogicsTree = result;
this.updateEqLogicssList();
Expand Down Expand Up @@ -80,14 +87,18 @@ export default {
this.type
)
) {
this.eqLogicsList.push({
const eqLogicData = {
room: this.eqLogicsTree[roomId]["name"],
eqLogic: this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]["name"],
id: parseInt(
this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]["id"]
),
eqLogicData: this.eqLogicsTree[roomId]["eqLogics"][eqLogicId]
});
};
if (this.default == eqLogicData.id) {
this.eqLogic = [eqLogicData];
}
this.eqLogicsList.push(eqLogicData);
}
}
}
Expand Down
31 changes: 16 additions & 15 deletions src/dash/src/components/Wizards/Helpers/FilteredScenarios.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@
<v-card-title>
Scénarios
<v-spacer />
<v-text-field
v-model="search"
append-icon="mdi-magnify"
label="Filtrer"
single-line
hide-details
></v-text-field>
<v-text-field v-model="search" append-icon="mdi-magnify" label="Filtrer" single-line hide-details></v-text-field>
</v-card-title>
<v-data-table
v-bind:headers="headers"
Expand All @@ -24,11 +18,7 @@
v-model="scenario"
v-bind:search="search"
></v-data-table>
<v-checkbox
label="Cacher les scénarios désactivés"
v-model="hideInactives"
v-on:change="updateScenariosList"
/>
<v-checkbox label="Cacher les scénarios désactivés" v-model="hideInactives" v-on:change="updateScenariosList" />
</v-card>
</template>

Expand All @@ -42,6 +32,10 @@ export default {
type: Array,
default: () => []
},
default: {
type: Number,
default: -1
},
type: {}
},
data: () => ({
Expand All @@ -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: {
Expand All @@ -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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Dialog de base d'ajout d'un élément
-->
<template>
<v-dialog v-model="showed">
<component v-if="currentWizard !== null" v-bind:is="currentWizard" v-on:hide="showed = false" />
<component v-if="currentWizard !== null" v-bind:is="currentWizard" v-on:hide="showed = false" v-bind="editAttr" />
</v-dialog>
</template>

Expand All @@ -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,
Expand All @@ -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;
});
}
};
Expand Down
Loading

0 comments on commit 5b528e7

Please sign in to comment.