From 5286e8edf4c086cfc95f4b1a2783be33170280df Mon Sep 17 00:00:00 2001 From: Craig Bassett Date: Fri, 25 Dec 2020 18:38:47 -0600 Subject: [PATCH] feat: draggable dashboard cards --- package-lock.json | 13 ++ package.json | 1 + src/components/AppDrawer.vue | 33 ++++ src/components/cards/CollapsableCard.vue | 92 ++++++++-- src/components/cards/dashboard/CameraCard.vue | 15 +- .../cards/dashboard/ConsoleCard.vue | 15 +- .../cards/dashboard/PrinterLimitsCard.vue | 13 +- src/components/cards/dashboard/StatusCard.vue | 2 +- .../cards/dashboard/TemperatureGraphCard.vue | 15 +- .../dashboard/TemperatureTargetsCard.vue | 17 +- .../cards/dashboard/ToolheadCard.vue | 15 +- src/components/cards/dashboard/ToolsCard.vue | 164 ++++++++---------- .../TemperaturePresetSettingsCard.vue | 1 + src/components/inputs/BtnCollapse.vue | 42 ++++- src/globals.ts | 9 +- src/socketActions.ts | 6 + src/store/config/actions.ts | 16 +- src/store/config/getters.ts | 6 +- src/store/config/index.ts | 15 +- src/store/config/mutations.ts | 33 ++-- src/store/config/types.ts | 24 ++- src/views/Dashboard.vue | 111 +++++++++++- todo.md | 14 +- 23 files changed, 504 insertions(+), 168 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad65e3dc2a..33c6e3b246 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17480,6 +17480,11 @@ "is-plain-obj": "^1.0.0" } }, + "sortablejs": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.10.2.tgz", + "integrity": "sha512-YkPGufevysvfwn5rfdlGyrGjt7/CRHwvRPogD/lC+TnvcN29jDpCifKP+rBqf+LRldfXSTh+0CGLcSg0VIxq3A==" + }, "source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -19737,6 +19742,14 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "vuedraggable": { + "version": "2.24.3", + "resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-2.24.3.tgz", + "integrity": "sha512-6/HDXi92GzB+Hcs9fC6PAAozK1RLt1ewPTLjK0anTYguXLAeySDmcnqE8IC0xa7shvSzRjQXq3/+dsZ7ETGF3g==", + "requires": { + "sortablejs": "1.10.2" + } + }, "vuetify": { "version": "2.3.21", "resolved": "https://registry.npmjs.org/vuetify/-/vuetify-2.3.21.tgz", diff --git a/package.json b/package.json index f9716799ae..5474932b1a 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "vue-prism-editor": "^1.2.2", "vue-property-decorator": "^9.1.2", "vue-router": "^3.2.0", + "vuedraggable": "^2.24.3", "vuetify": "^2.3.21", "vuex": "^3.6.0" }, diff --git a/src/components/AppDrawer.vue b/src/components/AppDrawer.vue index 67b11ebad0..deae018a9a 100644 --- a/src/components/AppDrawer.vue +++ b/src/components/AppDrawer.vue @@ -47,6 +47,30 @@ + + + + + + + + + + + Adjust layout + Adjust dashboard layout + + + + + @@ -69,6 +93,15 @@ export default class AppDrawer extends Mixins(UtilsMixin) { @Prop({ type: Boolean, default: false }) value!: boolean + get layoutMode () { + return this.$store.state.config.layoutMode + } + + set layoutMode (val: boolean) { + this.$store.commit('config/setLayoutMode', val) + this.close() + } + get instanceName () { return this.$store.state.config.fileConfig.general.instanceName } diff --git a/src/components/cards/CollapsableCard.vue b/src/components/cards/CollapsableCard.vue index 0d04c48b6e..279ecdd4cb 100644 --- a/src/components/cards/CollapsableCard.vue +++ b/src/components/cards/CollapsableCard.vue @@ -4,7 +4,28 @@ color="tertiary" :rounded="rounded" :loading="isLoading"> - + +
+ + +
+ + {{ icon }} {{ title }} @@ -12,13 +33,13 @@ -
+
diff --git a/src/components/cards/dashboard/ConsoleCard.vue b/src/components/cards/dashboard/ConsoleCard.vue index 703023647b..c1d58e5da7 100644 --- a/src/components/cards/dashboard/ConsoleCard.vue +++ b/src/components/cards/dashboard/ConsoleCard.vue @@ -5,7 +5,11 @@ cardClasses="mb-2 mb-sm-4 d-flex flex-column" contentClasses="flex-grow-1 flow-shrink-0" :height="450" - :collapsed="true"> + :collapsed="true" + :draggable="true" + :inLayout="inLayout" + :enabled="enabled" + @enabled="$emit('enabled', $event)"> diff --git a/src/components/cards/dashboard/PrinterLimitsCard.vue b/src/components/cards/dashboard/PrinterLimitsCard.vue index 4504b4f3c4..75f8763f85 100644 --- a/src/components/cards/dashboard/PrinterLimitsCard.vue +++ b/src/components/cards/dashboard/PrinterLimitsCard.vue @@ -2,13 +2,17 @@ + :collapsed="true" + :draggable="true" + :inLayout="inLayout" + :enabled="enabled" + @enabled="$emit('enabled', $event)"> diff --git a/src/components/cards/dashboard/StatusCard.vue b/src/components/cards/dashboard/StatusCard.vue index 74281d4b1c..a03a8d1ba5 100644 --- a/src/components/cards/dashboard/StatusCard.vue +++ b/src/components/cards/dashboard/StatusCard.vue @@ -1,7 +1,7 @@