Skip to content

Commit

Permalink
Link to dash and multi dash
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvaner committed May 6, 2020
1 parent 54f4291 commit a3c40c2
Show file tree
Hide file tree
Showing 23 changed files with 325 additions and 15 deletions.
1 change: 1 addition & 0 deletions dash/css/app.5be19580.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dash/css/app.7eddb38a.css

This file was deleted.

2 changes: 1 addition & 1 deletion dash/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/dash/favicon.ico><title>dash</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href=/dash/css/app.7eddb38a.css rel=preload as=style><link href=/dash/css/chunk-vendors.ad854b7a.css rel=preload as=style><link href=/dash/js/app.46e18992.js rel=preload as=script><link href=/dash/js/chunk-vendors.4e70bf30.js rel=preload as=script><link href=/dash/css/chunk-vendors.ad854b7a.css rel=stylesheet><link href=/dash/css/app.7eddb38a.css rel=stylesheet></head><body><noscript><strong>We're sorry but dash doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/dash/js/chunk-vendors.4e70bf30.js></script><script src=/dash/js/app.46e18992.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/dash/favicon.ico><title>dash</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href=/dash/css/app.5be19580.css rel=preload as=style><link href=/dash/css/chunk-vendors.ad854b7a.css rel=preload as=style><link href=/dash/js/app.269155a6.js rel=preload as=script><link href=/dash/js/chunk-vendors.4e70bf30.js rel=preload as=script><link href=/dash/css/chunk-vendors.ad854b7a.css rel=stylesheet><link href=/dash/css/app.5be19580.css rel=stylesheet></head><body><noscript><strong>We're sorry but dash doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/dash/js/chunk-vendors.4e70bf30.js></script><script src=/dash/js/app.269155a6.js></script></body></html>
2 changes: 2 additions & 0 deletions dash/js/app.269155a6.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dash/js/app.269155a6.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dash/js/app.46e18992.js

This file was deleted.

1 change: 0 additions & 1 deletion dash/js/app.46e18992.js.map

This file was deleted.

14 changes: 14 additions & 0 deletions src/Rest/DashRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ public static function delete(int $dashId)
return false;
}

public static function all()
{
$result = [];
/** @var Dash[] $dashs */
$dashs = DashManager::all();
foreach ($dashs as $dash) {
$result[] = [
'id' => $dash->getId(),
'name' => $dash->getName()
];
}
return $result;
}

/**
* @param string $path
* @return array
Expand Down
4 changes: 4 additions & 0 deletions src/Rest/rest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ dash_get:
methods: GET
requirements:
dashId: \d+
dash_all:
path: '/dash/all'
controller: NextDom\Rest\DashRest::all
methods: GET
dash_save:
path: '/dash/save'
controller: NextDom\Rest\DashRest::save
Expand Down
26 changes: 25 additions & 1 deletion src/dash/src/components/Dash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Composant global du Dash
<ConnectDialog v-on:connected="start" />
<DashPreferences v-model="dashData" v-on:startWizard="startWizard" />
<ManualDash v-if="dashData !== undefined && dashData.positioning === 'manual'" />
<GridDash v-else-if="dashData !== undefined && dashData.positioning === 'grid'" />
<GridDash v-else-if="dashData !== undefined && dashData.positioning === 'grid'" v-model="dashData.grid" />
<Tools v-if="initialized" />
<AddDashWizard v-on:endOfWizard="endOfWizard" v-bind:showWizard="showWizard" />
<SelectItemToAddWizard />
Expand Down Expand Up @@ -50,6 +50,12 @@ export default {
title: "Dash",
width: 640,
height: 480,
grid: {
id: "0",
children: [],
orientation: "horizontal",
type: "grid"
},
positioning: "manual",
size: "fix"
}
Expand All @@ -59,6 +65,14 @@ export default {
this.start();
}
},
watch: {
/**
* Détection changement de dash
*/
dashId: function() {
this.start();
}
},
computed: {
/**
* Taille de l'écran
Expand Down Expand Up @@ -101,6 +115,10 @@ export default {
if (result.id == this.dashId) {
// La première fois, l'objet n'a pas d'identifiant au moment de l'enregistrement
result.data.dashData.id = this.dashId;
if (Array.isArray(result.data.widgetsData)) {
result.data.widgetsData = {};
}
this.dashData = result.data.dashData;
this.$store.commit("initDash", result.data.dashData);
this.$store.commit("saveToLocalStorage", this.dashId);
this.$store.commit("initWidgets", result.data.widgetsData);
Expand All @@ -127,6 +145,12 @@ export default {
name: "Dash",
width: 640,
height: 480,
grid: {
id: "0",
children: [],
orientation: "horizontal",
type: "grid"
},
positioning: "manual",
size: "fix"
};
Expand Down
16 changes: 16 additions & 0 deletions src/dash/src/components/GridDash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,33 @@ export default {
components: {
GridContainer
},
props: {
value: Object
},
data: () => ({
/*
gridData: {
id: "0",
children: [],
orientation: "horizontal",
type: "grid"
},
*/
parentId: "0"
}),
mounted() {
this.$store.commit("setDashType", "grid");
},
computed: {
gridData: {
get() {
console.log(this.value);
return this.value;
},
set(newValue) {
this.$emit("input", newValue);
}
}
}
};
</script>
9 changes: 8 additions & 1 deletion src/dash/src/components/Tools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,24 @@ export default {
this.$eventBus.$emit("showDashPreferences");
},
save() {
const newDash = this.$store.getters.dashData.id === undefined;
Communication.postWithOptions(
"/api/dash/save",
{
id: this.$store.getters.dashData.id,
name: "Dash",
name: this.$store.getters.dashData.name,
data: JSON.stringify({
dashData: this.$store.getters.dashData,
widgetsData: this.$store.getters.widgets
})
},
result => {
if (newDash) {
this.$router.push({
name: "dash",
params: { dashId: result.data }
});
}
this.$store.commit("setDashId", parseInt(result.data));
this.$store.commit("saveToLocalStorage", result.data);
this.message = "Sauvegarde réussie";
Expand Down
32 changes: 32 additions & 0 deletions src/dash/src/components/Widgets/LinkToDash.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div>
<v-card-title v-if="widgetData.title !== ''" v-bind:style="{ fontSize: widgetData.style.titleSize + 'px' }">{{ widgetData.title }}</v-card-title>
<v-card-text class="text-center">
<v-content>
<v-btn text v-bind:to="{name: 'dash', params: {dashId: widgetData.target }}">
<img v-bind:style="{height: widgetData.style.contentSize + 'px'}" v-bind:src="picture" />
</v-btn>
</v-content>
</v-card-text>
</div>
</template>

<script>
export default {
name: "LinkToDash",
props: {
widgetData: {}
},
computed: {
picture() {
return "/data/pictures/" + this.widgetData.picture;
}
}
};
</script>

<style scoped>
.v-card__title {
justify-content: center;
}
</style>
18 changes: 16 additions & 2 deletions src/dash/src/components/Wizards/AddDashWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Assistant de création d'un nouveau dash
<v-divider />
<v-stepper-step v-bind:complete="step > 2" step="2">Dimensions</v-stepper-step>
<v-divider />
<v-stepper-step step="3">Thème</v-stepper-step>
<v-stepper-step step="3">Personnalisation</v-stepper-step>
</v-stepper-header>
<v-stepper-items>
<v-stepper-content step="1">
Expand Down Expand Up @@ -66,6 +66,12 @@ Assistant de création d'un nouveau dash
<StepperButtons v-model="step" />
</v-stepper-content>
<v-stepper-content step="3">
<v-card color="blue-grey lighten-5">
<v-card-title>Personnalisation</v-card-title>
<v-card-text>
<v-text-field v-model="title" label="Nom" />
</v-card-text>
</v-card>
<StepperButtons v-model="step" last v-on:next="endOfWizard" />
</v-stepper-content>
</v-stepper-items>
Expand All @@ -86,6 +92,7 @@ export default {
},
data: () => ({
step: 1,
title: "Mon Dash",
positioning: "manual",
size: "fix",
width: 1280,
Expand All @@ -104,9 +111,16 @@ export default {
endOfWizard() {
this.$emit("endOfWizard", {
positioning: this.positioning,
name: this.title,
size: this.size,
width: this.width,
height: this.height
height: this.height,
grid: {
id: "0",
children: [],
orientation: "horizontal",
type: "grid"
}
});
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/dash/src/components/Wizards/AddItemWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CmdActionWizard from "@/components/Wizards/Items/CmdActionWizard";
import ScenarioActionWizard from "@/components/Wizards/Items/ScenarioActionWizard";
import ScenarioActionImgWizard from "@/components/Wizards/Items/ScenarioActionImgWizard";
import EqLogicActionWizard from "@/components/Wizards/Items/EqLogicActionWizard";
import LinkToDashWizard from "@/components/Wizards/Items/LinkToDashWizard";

export default {
name: "AddItemWizard",
Expand All @@ -29,7 +30,8 @@ export default {
CmdActionWizard,
ScenarioActionWizard,
ScenarioActionImgWizard,
EqLogicActionWizard
EqLogicActionWizard,
LinkToDashWizard
},
data: () => ({
showed: false,
Expand Down
84 changes: 84 additions & 0 deletions src/dash/src/components/Wizards/Helpers/FilteredDashs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<template>
<v-card color="blue-grey lighten-5">
<v-card-title>
Dashs
<v-spacer />
<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"
v-bind:items="dashsList"
single-select
show-select
item-key="id"
v-bind:items-per-page="5"
v-bind:loading="Object.keys(rawDashs).length === 0"
loading-text="Chargement..."
class="elevation-10"
v-model="scenario"
v-bind:search="search"
></v-data-table>
</v-card>
</template>

<script>
import Communication from "@/libs/Communication";
export default {
name: "FilteredDashs",
props: {
value: {
type: Array,
default: () => []
},
type: {}
},
data: () => ({
rawDashs: {},
dashsList: [],
search: "",
headers: [
{ text: "ID", value: "id" },
{ text: "Nom", value: "name" }
]
}),
created() {
Communication.get("/api/dash/all", result => {
this.rawDashs = result;
this.dashsList = result;
// this.updateDashsList();
});
},
computed: {
dataLoaded() {
return !(Object.keys(this.rawDashs).length === 0);
},
scenario: {
get() {
return this.value;
},
set(newValue) {
this.$emit("input", newValue);
}
}
},
methods: {
/*
updateScenariosList() {
this.dashsList = [];
for (let scenarioIndex in this.rawScenarios) {
const scenario = this.rawScenarios[scenarioIndex];
if (!(!scenario.active && this.hideInactives)) {
this.scenariosList.push({
scenario: scenario,
id: scenario.id,
name: scenario.name,
group: scenario.group
});
}
}
}
*/
}
};
</script>
Loading

0 comments on commit a3c40c2

Please sign in to comment.