Skip to content

Commit

Permalink
Editeur avancé
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvaner committed May 6, 2020
1 parent a3c40c2 commit 5c272ad
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 9 deletions.
40 changes: 37 additions & 3 deletions src/dash/package-lock.json

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

1 change: 1 addition & 0 deletions src/dash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"axios": "^0.19.2",
"core-js": "^3.6.4",
"vue": "^2.6.11",
"vue-json-editor": "^1.4.0",
"vue-router": "^3.1.6",
"vuetify": "^2.2.11",
"vuex": "^3.1.3"
Expand Down
3 changes: 2 additions & 1 deletion src/dash/src/components/Dash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ export default {
this.$store.commit("saveToLocalStorage", this.dashId);
this.$store.commit("initWidgets", result.data.widgetsData);
this.initialized = true;
} else {
this.startWizard();
}
this.startWizard();
},
() => {
this.startWizard();
Expand Down
102 changes: 102 additions & 0 deletions src/dash/src/components/DashEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<div>
<h1>Editeur avancé</h1>
<ConnectDialog v-on:connected="start" />
<vue-json-editor
v-bind:lang="language"
ref="dashEditor"
v-model="dashData"
v-bind:show-btns="true"
v-bind:expandedOnStart="false"
v-on:json-save="dashSave"
></vue-json-editor>
<vue-json-editor
v-bind:lang="language"
ref="widgetsEditor"
v-model="widgetsData"
v-bind:show-btns="true"
v-bind:expandedOnStart="false"
v-on:json-save="widgetsSave"
></vue-json-editor>
</div>
</template>

<script>
import ConnectDialog from "@/components/ConnectDialog";
import Communication from "@/libs/Communication";
import vueJsonEditor from "vue-json-editor";
export default {
props: {
dashId: undefined
},
data: () => ({
language: "en",
dashData: {},
widgetsData: {},
savedDashData: {},
savedWidgetsData: {},
dashError: false,
widgetError: false
}),
mounted() {
this.hackTranslation();
if (Communication.isConnected()) {
this.start();
}
},
components: {
vueJsonEditor,
ConnectDialog
},
methods: {
// Bouton en français
hackTranslation() {
this.$set(this.$refs.dashEditor.$data.locale, "fr", {});
this.$set(this.$refs.dashEditor.$data.locale.fr, "save", "Sauvegarder");
this.$set(this.$refs.widgetsEditor.$data.locale, "fr", {});
this.$set(
this.$refs.widgetsEditor.$data.locale.fr,
"save",
"Sauvegarder"
);
this.language = "fr";
},
start() {
if (this.dashId !== undefined) {
Communication.get(
"/api/dash/" + this.dashId,
result => {
this.dashData = result.data.dashData;
this.savedDashData = JSON.parse(JSON.stringify(this.dashData));
this.widgetsData = result.data.widgetsData;
this.savedWidgetsData = JSON.parse(
JSON.stringify(this.widgetsData)
);
},
error => {
console.log(error);
}
);
}
},
dashSave() {
this.savedDashData = JSON.parse(JSON.stringify(this.dashData));
this.save();
},
widgetsSave() {
this.savedWidgetsData = JSON.parse(JSON.stringify(this.widgetsData));
},
save() {
Communication.postWithOptions("/api/dash/save", {
id: this.dashId,
name: this.dashData.name,
data: JSON.stringify({
dashData: this.savedDashData,
widgetsData: this.savedWidgetsData
})
});
}
}
};
</script>
9 changes: 7 additions & 2 deletions src/dash/src/components/DashPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ Fenêtre de configuration du dash
</v-col>
</v-row>
<v-row>
<v-col cols="6" left>
<v-col cols="4" left>
<v-btn href="/dash/index.html" color="success" dark>
<v-icon left>mdi-plus</v-icon>Nouveau
</v-btn>
</v-col>
<v-col cols="6" right>
<v-col cols="4">
<v-btn v-bind:to="{name: 'dash-editor', params: {dashId: formData.id}}" color="success" dark>
<v-icon left>mdi-plus</v-icon>Editeur avancé
</v-btn>
</v-col>
<v-col cols="4" right>
<v-btn v-on:click="deleteDash" color="red" dark>
<v-icon left>mdi-delete</v-icon>Supprimer
</v-btn>
Expand Down
1 change: 0 additions & 1 deletion src/dash/src/components/GridDash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default {
computed: {
gridData: {
get() {
console.log(this.value);
return this.value;
},
set(newValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/dash/src/libs/Communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default {
callbackFunc(response.data);
})
.catch(error => {
console.log(error);
if (error.response !== undefined && error.response.status === 403) {
localStorage.removeItem("token");
// this.router.push("/login");
} else {
if (errorCallbackFunc !== undefined) {
errorCallbackFunc(error.response);
Expand Down
7 changes: 7 additions & 0 deletions src/dash/src/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Vue from "vue";
import Router from "vue-router";
import Dash from "@/components/Dash"
import DashEditor from "@/components/DashEditor"

Vue.use(Router);

Expand All @@ -11,6 +12,12 @@ export default new Router({
name: "dash",
component: Dash,
props: true
},
{
path: "/editor/:dashId(\\d+)",
name: "dash-editor",
component: DashEditor,
props: true
}
]
});
9 changes: 8 additions & 1 deletion src/dash/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8054,6 +8054,13 @@ vue-hot-reload-api@^2.3.0:
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"
integrity sha512-BXq3jwIagosjgNVae6tkHzzIk6a8MHFtzAdwhnV5VlvPTFxDCvIttgSiHWjdGoTJvXtmRu5HacExfdarRcFhog==

vue-json-editor@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/vue-json-editor/-/vue-json-editor-1.4.0.tgz#becc398f9f101d3775afea7e0dae2fd00dd0d2fd"
integrity sha512-HejLwRk4TYpjehvEWVPpiwg+Wmh2E7XAtiT43PVKElTSaqdyytuyTNrzgJ1xRFhGCnYwyh1xyGsZulcpNF/wwg==
dependencies:
vue "^2.2.6"

vue-loader@^15.9.1:
version "15.9.1"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-15.9.1.tgz#bd2ab8f3d281e51d7b81d15390a58424d142243e"
Expand Down Expand Up @@ -8091,7 +8098,7 @@ vue-template-es2015-compiler@^1.9.0:
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==

vue@^2.6.11:
vue@^2.2.6, vue@^2.6.11:
version "2.6.11"
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.11.tgz#76594d877d4b12234406e84e35275c6d514125c5"
integrity sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==
Expand Down

0 comments on commit 5c272ad

Please sign in to comment.