From a00259f81ad4d1e99942e51ff69c4f4e7b3bb8c6 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 30 Aug 2023 23:08:36 +0200 Subject: [PATCH 01/32] feat: add first init process of spoolman Signed-off-by: Stefan Dej --- src/store/server/index.ts | 2 + src/store/server/spoolman/actions.ts | 56 ++++++++++++++++++++++++++ src/store/server/spoolman/getters.ts | 5 +++ src/store/server/spoolman/index.ts | 32 +++++++++++++++ src/store/server/spoolman/mutations.ts | 22 ++++++++++ src/store/server/spoolman/types.ts | 25 ++++++++++++ src/store/variables.ts | 10 ++++- 7 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 src/store/server/spoolman/actions.ts create mode 100644 src/store/server/spoolman/getters.ts create mode 100644 src/store/server/spoolman/index.ts create mode 100644 src/store/server/spoolman/mutations.ts create mode 100644 src/store/server/spoolman/types.ts diff --git a/src/store/server/index.ts b/src/store/server/index.ts index 95717ac7c..643e9ce4c 100644 --- a/src/store/server/index.ts +++ b/src/store/server/index.ts @@ -11,6 +11,7 @@ import { history } from '@/store/server/history' import { timelapse } from '@/store/server/timelapse' import { jobQueue } from '@/store/server/jobQueue' import { announcements } from '@/store/server/announcements' +import { spoolman } from '@/store/server/spoolman' // create getDefaultState export const getDefaultState = (): ServerState => { @@ -59,5 +60,6 @@ export const server: Module = { timelapse, jobQueue, announcements, + spoolman, }, } diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts new file mode 100644 index 000000000..b8b3d53c7 --- /dev/null +++ b/src/store/server/spoolman/actions.ts @@ -0,0 +1,56 @@ +import Vue from 'vue' +import { ActionTree } from 'vuex' +import { RootState } from '@/store/types' +import { ServerSpoolmanState } from './types' + +export const actions: ActionTree = { + reset({ commit }) { + commit('reset') + }, + + init({ dispatch }) { + Vue.$socket.emit('server.spoolman.get_spool_id', {}, { action: 'server/spoolman/getSpoolId' }) + Vue.$socket.emit( + 'server.spoolman.proxy', + { + request_method: 'GET', + path: '/v1/info', + }, + { action: 'server/spoolman/getInfo' } + ) + Vue.$socket.emit( + 'server.spoolman.proxy', + { + request_method: 'GET', + path: '/v1/vendor', + }, + { action: 'server/spoolman/getVendors' } + ) + + dispatch('socket/addInitModule', 'server/spoolman/getSpoolId', { root: true }) + dispatch('socket/addInitModule', 'server/spoolman/getInfo', { root: true }) + dispatch('socket/addInitModule', 'server/spoolman/getVendors', { root: true }) + + dispatch('socket/removeInitModule', 'server/spoolman/init', { root: true }) + }, + + getSpoolId({ commit, dispatch }, payload) { + commit('setSpoolId', payload.spool_id) + dispatch('socket/removeInitModule', 'server/spoolman/getSpoolId', { root: true }) + }, + + getInfo({ commit, dispatch }, payload) { + delete payload.requestParams + commit('setInfo', payload) + dispatch('socket/removeInitModule', 'server/spoolman/getInfo', { root: true }) + }, + + getVendors({ commit, dispatch }, payload) { + delete payload.requestParams + commit( + 'setVendors', + Object.entries(payload).map((value) => value) + ) + dispatch('socket/removeInitModule', 'server/spoolman/getVendors', { root: true }) + }, +} diff --git a/src/store/server/spoolman/getters.ts b/src/store/server/spoolman/getters.ts new file mode 100644 index 000000000..0cdbc7858 --- /dev/null +++ b/src/store/server/spoolman/getters.ts @@ -0,0 +1,5 @@ +import { GetterTree } from 'vuex' +import { ServerSpoolmanState } from './types' + +// eslint-disable-next-line +export const getters: GetterTree = {} diff --git a/src/store/server/spoolman/index.ts b/src/store/server/spoolman/index.ts new file mode 100644 index 000000000..4d7d280f3 --- /dev/null +++ b/src/store/server/spoolman/index.ts @@ -0,0 +1,32 @@ +import { Module } from 'vuex' +import { ServerSpoolmanState } from '@/store/server/spoolman/types' +import { actions } from '@/store/server/spoolman/actions' +import { mutations } from '@/store/server/spoolman/mutations' +import { getters } from '@/store/server/spoolman/getters' + +export const getDefaultState = (): ServerSpoolmanState => { + return { + info: { + automatic_backups: false, + backups_dir: '', + data_dir: '', + debug_mode: false, + version: '', + }, + spool_id: null, + vendors: [], + feeds: [], + } +} + +// initial state +const state = getDefaultState() + +// eslint-disable-next-line +export const spoolman: Module = { + namespaced: true, + state, + getters, + actions, + mutations, +} diff --git a/src/store/server/spoolman/mutations.ts b/src/store/server/spoolman/mutations.ts new file mode 100644 index 000000000..bf8575c4e --- /dev/null +++ b/src/store/server/spoolman/mutations.ts @@ -0,0 +1,22 @@ +import { getDefaultState } from './index' +import { MutationTree } from 'vuex' +import { ServerSpoolmanState } from './types' +import Vue from 'vue' + +export const mutations: MutationTree = { + reset(state) { + Object.assign(state, getDefaultState()) + }, + + setSpoolId(state, payload) { + Vue.set(state, 'spool_id', payload) + }, + + setInfo(state, payload) { + Vue.set(state, 'info', payload) + }, + + setVendors(state, payload) { + Vue.set(state, 'vendors', payload) + }, +} diff --git a/src/store/server/spoolman/types.ts b/src/store/server/spoolman/types.ts new file mode 100644 index 000000000..e8c6bfaf0 --- /dev/null +++ b/src/store/server/spoolman/types.ts @@ -0,0 +1,25 @@ +export interface ServerSpoolmanState { + info: { + automatic_backups: boolean + backups_dir: string + data_dir: string + debug_mode: boolean + version: string + } + spool_id: number | null + vendors: ServerSpoolmanStateVendor[] + feeds: string[] +} + +export interface ServerSpoolmanStateVendor { + id: number + registered: string + name: string +} + +export interface ServerSpoolmanStateFilament { + id: number + registered: string + name: string + comment?: string +} diff --git a/src/store/variables.ts b/src/store/variables.ts index d2a847be4..950b9e3d7 100644 --- a/src/store/variables.ts +++ b/src/store/variables.ts @@ -24,7 +24,15 @@ export const validGcodeExtensions = ['.gcode', '.g', '.gco', '.ufp', '.nc'] /* * List of initable server components */ -export const initableServerComponents = ['history', 'power', 'updateManager', 'timelapse', 'jobQueue', 'announcements'] +export const initableServerComponents = [ + 'history', + 'power', + 'updateManager', + 'timelapse', + 'jobQueue', + 'announcements', + 'spoolman', +] /* * List of required klipper config modules From d8bffe6f9ba9456995e6a2f651e200ea54ed6e8c Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Wed, 30 Aug 2023 23:25:11 +0200 Subject: [PATCH 02/32] feat: add spoolman panel on dashboard if moonraker component exists Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 30 +++++++++++++++++++++++++ src/pages/Dashboard.vue | 2 ++ src/store/gui/getters.ts | 5 +++++ src/store/server/spoolman/actions.ts | 15 +++++++++++++ src/store/server/spoolman/index.ts | 1 + src/store/server/spoolman/mutations.ts | 4 ++++ src/store/server/spoolman/types.ts | 1 + src/store/variables.ts | 1 + 8 files changed, 59 insertions(+) create mode 100644 src/components/panels/SpoolmanPanel.vue diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue new file mode 100644 index 000000000..2d7435fc9 --- /dev/null +++ b/src/components/panels/SpoolmanPanel.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/pages/Dashboard.vue b/src/pages/Dashboard.vue index 86fdd025b..6d8d7d326 100644 --- a/src/pages/Dashboard.vue +++ b/src/pages/Dashboard.vue @@ -91,6 +91,7 @@ import MacrosPanel from '@/components/panels/MacrosPanel.vue' import MiniconsolePanel from '@/components/panels/MiniconsolePanel.vue' import MinSettingsPanel from '@/components/panels/MinSettingsPanel.vue' import MiscellaneousPanel from '@/components/panels/MiscellaneousPanel.vue' +import SpoolmanPanel from '@/components/panels/SpoolmanPanel.vue' import StatusPanel from '@/components/panels/StatusPanel.vue' import ToolheadControlPanel from '@/components/panels/ToolheadControlPanel.vue' import TemperaturePanel from '@/components/panels/TemperaturePanel.vue' @@ -106,6 +107,7 @@ import WebcamPanel from '@/components/panels/WebcamPanel.vue' MiniconsolePanel, MinSettingsPanel, MiscellaneousPanel, + SpoolmanPanel, StatusPanel, ToolheadControlPanel, TemperaturePanel, diff --git a/src/store/gui/getters.ts b/src/store/gui/getters.ts index 039b9846c..c26e42a90 100644 --- a/src/store/gui/getters.ts +++ b/src/store/gui/getters.ts @@ -72,6 +72,11 @@ export const getters: GetterTree = { allPanels = allPanels.filter((name) => name !== 'webcam') } + // remove spoolman panel, if no spoolman component exists in moonraker + if (!rootState.server.components.includes('spoolman')) { + allPanels = allPanels.filter((name) => name !== 'spoolman') + } + return allPanels }, diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index b8b3d53c7..1a6970575 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -18,6 +18,14 @@ export const actions: ActionTree = { }, { action: 'server/spoolman/getInfo' } ) + Vue.$socket.emit( + 'server.spoolman.proxy', + { + request_method: 'GET', + path: '/v1/health', + }, + { action: 'server/spoolman/getHealth' } + ) Vue.$socket.emit( 'server.spoolman.proxy', { @@ -28,6 +36,7 @@ export const actions: ActionTree = { ) dispatch('socket/addInitModule', 'server/spoolman/getSpoolId', { root: true }) + dispatch('socket/addInitModule', 'server/spoolman/getHealth', { root: true }) dispatch('socket/addInitModule', 'server/spoolman/getInfo', { root: true }) dispatch('socket/addInitModule', 'server/spoolman/getVendors', { root: true }) @@ -39,6 +48,12 @@ export const actions: ActionTree = { dispatch('socket/removeInitModule', 'server/spoolman/getSpoolId', { root: true }) }, + getHealth({ commit, dispatch }, payload) { + delete payload.requestParams + commit('setHealth', payload.status) + dispatch('socket/removeInitModule', 'server/spoolman/getHealth', { root: true }) + }, + getInfo({ commit, dispatch }, payload) { delete payload.requestParams commit('setInfo', payload) diff --git a/src/store/server/spoolman/index.ts b/src/store/server/spoolman/index.ts index 4d7d280f3..1cd4fdb76 100644 --- a/src/store/server/spoolman/index.ts +++ b/src/store/server/spoolman/index.ts @@ -6,6 +6,7 @@ import { getters } from '@/store/server/spoolman/getters' export const getDefaultState = (): ServerSpoolmanState => { return { + health: '', info: { automatic_backups: false, backups_dir: '', diff --git a/src/store/server/spoolman/mutations.ts b/src/store/server/spoolman/mutations.ts index bf8575c4e..c91d97742 100644 --- a/src/store/server/spoolman/mutations.ts +++ b/src/store/server/spoolman/mutations.ts @@ -12,6 +12,10 @@ export const mutations: MutationTree = { Vue.set(state, 'spool_id', payload) }, + setHealth(state, payload) { + Vue.set(state, 'health', payload) + }, + setInfo(state, payload) { Vue.set(state, 'info', payload) }, diff --git a/src/store/server/spoolman/types.ts b/src/store/server/spoolman/types.ts index e8c6bfaf0..6337a67bd 100644 --- a/src/store/server/spoolman/types.ts +++ b/src/store/server/spoolman/types.ts @@ -1,4 +1,5 @@ export interface ServerSpoolmanState { + health: string info: { automatic_backups: boolean backups_dir: string diff --git a/src/store/variables.ts b/src/store/variables.ts index 950b9e3d7..b7f6f8b54 100644 --- a/src/store/variables.ts +++ b/src/store/variables.ts @@ -85,6 +85,7 @@ export const allDashboardPanels = [ 'machine-settings', 'miniconsole', 'miscellaneous', + 'spoolman', 'temperature', 'webcam', ] From 818be405b6204939921caa4a83cb03626b6c17c9 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 2 Sep 2023 15:05:15 +0200 Subject: [PATCH 03/32] feat: add icon for spool Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 8 ++++- src/components/ui/SpoolIcon.vue | 42 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/components/ui/SpoolIcon.vue diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 2d7435fc9..5a8349fe0 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -1,6 +1,12 @@ diff --git a/src/components/ui/SpoolIcon.vue b/src/components/ui/SpoolIcon.vue new file mode 100644 index 000000000..6741ecb47 --- /dev/null +++ b/src/components/ui/SpoolIcon.vue @@ -0,0 +1,42 @@ + + + From 215aea8f7f491fe21b03d09d3bf251cc96bfea90 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 5 Sep 2023 07:20:04 +0200 Subject: [PATCH 04/32] WIP Signed-off-by: Stefan Dej --- .../Spoolman/SpoolmanChangeSpoolDialog.vue | 67 +++++++++++++++++++ src/components/panels/SpoolmanPanel.vue | 30 ++++++--- 2 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue diff --git a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue new file mode 100644 index 000000000..dbfc62480 --- /dev/null +++ b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue @@ -0,0 +1,67 @@ + + + diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 5a8349fe0..e1ff6d0e6 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -1,12 +1,21 @@ @@ -14,12 +23,17 @@ import { Component, Mixins } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' -import { mdiAdjust } from '@mdi/js' +import { mdiAdjust, mdiSync } from '@mdi/js' +import SpoolmanChangeSpoolDialog from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue' + @Component({ - components: { Panel }, + components: { Panel, SpoolmanChangeSpoolDialog }, }) export default class SpoolmanPanel extends Mixins(BaseMixin) { mdiAdjust = mdiAdjust + mdiSync = mdiSync + + showChangeSpoolDialog = false get health() { return this.$store.state.server.spoolman.health ?? '' From 2c0ccb078f0276b6f15a1fc26512e3894ffc4487 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 7 Sep 2023 07:36:59 +0200 Subject: [PATCH 05/32] WIP Signed-off-by: Stefan Dej --- .../Spoolman/SpoolmanChangeSpoolDialog.vue | 28 +++++++++++++++---- src/store/server/spoolman/actions.ts | 19 +++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue index dbfc62480..f1da3f7a5 100644 --- a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue +++ b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue @@ -14,14 +14,23 @@ - + + :search="search"> + + + + @@ -30,7 +39,7 @@ diff --git a/src/components/ui/SpoolIcon.vue b/src/components/ui/SpoolIcon.vue index 6741ecb47..730da9111 100644 --- a/src/components/ui/SpoolIcon.vue +++ b/src/components/ui/SpoolIcon.vue @@ -24,11 +24,11 @@ import BaseMixin from '../mixins/base' @Component export default class SpoolIcon extends Mixins(BaseMixin) { - @Prop({ required: false, default: '' }) + @Prop({ required: false, default: '#ff0' }) declare readonly color: string get styleCircle1() { - return { fill: '#ff0' } + return { fill: this.color } } get styleCircle2() { diff --git a/src/locales/en.json b/src/locales/en.json index b7234078d..58ced7e10 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -620,6 +620,15 @@ "On": "On", "PowerControl": "Power Control" }, + "Spoolman": { + "ChangeSpool": "Change Spool", + "Filament": "Filament", + "LastUsed": "Last Used", + "Location": "Location", + "Material": "Material", + "Never": "Never", + "Weight": "Weight" + }, "StatusPanel": { "CancelPrint": "Cancel print", "ClearPrintStats": "Clear print stats", diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index b877be630..4262f5c40 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -1,7 +1,7 @@ import Vue from 'vue' import { ActionTree } from 'vuex' import { RootState } from '@/store/types' -import { ServerSpoolmanState } from './types' +import { ServerSpoolmanState } from '@/store/server/spoolman/types' export const actions: ActionTree = { reset({ commit }) { @@ -69,7 +69,7 @@ export const actions: ActionTree = { dispatch('socket/removeInitModule', 'server/spoolman/getVendors', { root: true }) }, - refreshSpools({ commit, dispatch }) { + refreshSpools({ dispatch }) { Vue.$socket.emit( 'server.spoolman.proxy', { @@ -82,8 +82,10 @@ export const actions: ActionTree = { dispatch('socket/addLoading', 'refreshSpools', { root: true }) }, - getSpools({ dispatch }, payload) { - window.console.log(payload) + getSpools({ commit, dispatch }, payload) { + if ('requestParams' in payload) delete payload.requestParams + const spools = Object.entries(payload).map((value) => value[1]) + commit('setSpools', spools) dispatch('socket/removeLoading', 'refreshSpools', { root: true }) }, diff --git a/src/store/server/spoolman/mutations.ts b/src/store/server/spoolman/mutations.ts index c91d97742..fbffbd0e7 100644 --- a/src/store/server/spoolman/mutations.ts +++ b/src/store/server/spoolman/mutations.ts @@ -23,4 +23,8 @@ export const mutations: MutationTree = { setVendors(state, payload) { Vue.set(state, 'vendors', payload) }, + + setSpools(state, payload) { + Vue.set(state, 'spools', payload) + }, } diff --git a/src/store/server/spoolman/types.ts b/src/store/server/spoolman/types.ts index 6337a67bd..959e1ee87 100644 --- a/src/store/server/spoolman/types.ts +++ b/src/store/server/spoolman/types.ts @@ -23,4 +23,29 @@ export interface ServerSpoolmanStateFilament { registered: string name: string comment?: string + color_hex: string + density: number + diameter: number + material: string + price: number + settings_bed_temp: number + settings_extruder_temp: number + spool_weight: number + weight: number + vendor: ServerSpoolmanStateVendor +} + +export interface ServerSpoolmanStateSpool { + id: number + registered: string + archived: boolean + filament: ServerSpoolmanStateFilament + first_used: string + last_used: string + remaining_length: number + remaining_weight: number + used_length: number + used_weight: number + location?: string + comment?: string } From 475e31eb7168d292f4a3c6e52d9e679a06297497 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 10 Sep 2023 23:27:57 +0200 Subject: [PATCH 07/32] WIP Signed-off-by: Stefan Dej --- .../Spoolman/SpoolmanChangeSpoolDialog.vue | 89 ++++++++++++++++--- .../Spoolman/SpoolmanChangeSpoolDialogRow.vue | 40 ++++++--- src/components/panels/SpoolmanPanel.vue | 88 +++++++++++++++++- src/locales/en.json | 15 +++- src/store/server/spoolman/actions.ts | 37 ++++++-- src/store/server/spoolman/index.ts | 3 +- src/store/server/spoolman/mutations.ts | 8 +- src/store/server/spoolman/types.ts | 3 +- src/store/socket/actions.ts | 4 + 9 files changed, 250 insertions(+), 37 deletions(-) diff --git a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue index f6ba8d0d9..caaf8ff5f 100644 --- a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue +++ b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue @@ -12,21 +12,47 @@ - + + + + {{ mdiRefresh }} + + + {{ mdiDatabase }} + + :search="search" + :custom-filter="customFilter" + :disable-sort="true"> + @@ -40,7 +66,7 @@ import Component from 'vue-class-component' import { Mixins, Prop } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' -import { mdiCloseThick, mdiAdjust } from '@mdi/js' +import { mdiCloseThick, mdiAdjust, mdiDatabase, mdiMagnify, mdiRefresh } from '@mdi/js' import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' import SpoolmanChangeSpoolDialogRow from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialogRow.vue' @Component({ @@ -49,40 +75,55 @@ import SpoolmanChangeSpoolDialogRow from '@/components/panels/Spoolman/SpoolmanC export default class SpoolmanChangeSpoolDialog extends Mixins(BaseMixin) { mdiAdjust = mdiAdjust mdiCloseThick = mdiCloseThick + mdiDatabase = mdiDatabase + mdiMagnify = mdiMagnify + mdiRefresh = mdiRefresh @Prop({ required: true }) declare readonly showDialog: boolean search = '' get spools(): ServerSpoolmanStateSpool[] { - return this.$store.state.server.spoolman.spools ?? [] + const spools = this.$store.state.server.spoolman.spools ?? [] + + return spools.filter((spool: ServerSpoolmanStateSpool) => { + return spool.filament !== null + }) } get headers() { return [ + { + text: ' ', + align: 'start', + }, { text: this.$t('Panels.Spoolman.Filament'), align: 'start', - filterable: false, }, { text: this.$t('Panels.Spoolman.Material'), align: 'center', - filterable: false, }, { text: this.$t('Panels.Spoolman.LastUsed'), align: 'end', - filterable: false, }, { text: this.$t('Panels.Spoolman.Weight'), align: 'end', - filterable: false, }, ] } + get spoolManagerUrl() { + return this.$store.state.server.config.config?.spoolman?.server ?? null + } + + openSpoolManager() { + window.open(this.spoolManagerUrl, '_blank') + } + mounted() { this.refresh() } @@ -94,5 +135,33 @@ export default class SpoolmanChangeSpoolDialog extends Mixins(BaseMixin) { close() { this.$emit('close') } + + refreshSpools() { + this.$store.dispatch('server/spoolman/refreshSpools') + } + + customFilter(value: any, search: string, item: ServerSpoolmanStateSpool): boolean { + const querySplits = search.toLowerCase().split(' ') + const searchArray = [ + item.comment, + item.filament.name, + item.filament.vendor.name, + item.filament.material, + item.location, + ] + + for (const query of querySplits) { + const result = searchArray.some((q) => q?.toLowerCase().includes(query)) + + if (!result) return false + } + + return true + } + + setSpool(spool: ServerSpoolmanStateSpool) { + this.$store.dispatch('server/spoolman/setActiveSpool', spool.id) + this.close() + } } diff --git a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialogRow.vue b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialogRow.vue index c83f5925a..a4596a3f0 100644 --- a/src/components/panels/Spoolman/SpoolmanChangeSpoolDialogRow.vue +++ b/src/components/panels/Spoolman/SpoolmanChangeSpoolDialogRow.vue @@ -1,18 +1,18 @@ - + - - + +

{{ $t('Panels.Spoolman.NoActiveSpool') }}

+ + {{ $t('Panels.Spoolman.SelectSpool') }} +
- bla
+ + +
{{ vendor }}
+ + {{ name }} + + {{ subtitle }} +
+ + + + +
@@ -25,6 +40,7 @@ import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' import { mdiAdjust, mdiSync } from '@mdi/js' import SpoolmanChangeSpoolDialog from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue' +import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' @Component({ components: { Panel, SpoolmanChangeSpoolDialog }, @@ -44,6 +60,70 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { return `Spoolman (${this.health})` } + + get active_spool(): ServerSpoolmanStateSpool | null { + return this.$store.state.server.spoolman.active_spool ?? null + } + + get color() { + const color = this.active_spool?.filament.color_hex ?? null + if (color === null) return '#000' + + return `#${color}` + } + + get vendor() { + return this.active_spool?.filament?.vendor?.name ?? 'Unknown' + } + + get name() { + return this.active_spool?.filament.name ?? 'Unknown' + } + + get materialOutput() { + const material = this.active_spool?.filament.material ?? null + if (material === null) return null + + return this.$t('Panels.Spoolman.MaterialOutput', { material }) + } + + get weightOutput() { + const remaining = this.active_spool?.remaining_weight ?? null + const total = this.active_spool?.filament.weight ?? null + + if (remaining === null || total === null) return null + + return this.$t('Panels.Spoolman.WeightOutput', { remaining, total }) + } + + get firstUsedString() { + const first_used = this.active_spool?.first_used ?? null + if (first_used === null) return null + + const date = new Date(first_used) + const now = new Date() + const diff = now.getTime() - date.getTime() + + if (diff <= 1000 * 60 * 60 * 24) return this.$t('Panels.Spoolman.Today') + if (diff <= 1000 * 60 * 60 * 24 * 2) return this.$t('Panels.Spoolman.Yesterday') + if (diff <= 1000 * 60 * 60 * 24 * 14) { + const days = Math.floor(diff / (1000 * 60 * 60 * 24)) + + return this.$t('Panels.Spoolman.DaysAgo', { days }) + } + + return date.toLocaleDateString() + } + + get firstUsedOutput() { + if (this.firstUsedString === null) return null + + return this.$t('Panels.Spoolman.FirstUsedOutput', { firstUsed: this.firstUsedString }) + } + + get subtitle() { + return [this.materialOutput, this.weightOutput, this.firstUsedOutput].filter((v) => v !== null).join(', ') + } } diff --git a/src/locales/en.json b/src/locales/en.json index 58ced7e10..0dba3b40d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -622,12 +622,25 @@ }, "Spoolman": { "ChangeSpool": "Change Spool", + "DaysAgo": "{days} days ago", "Filament": "Filament", + "FirstUsedOutput": "First used: {firstUsed}", "LastUsed": "Last Used", "Location": "Location", "Material": "Material", + "MaterialOutput": "Material: {material}", "Never": "Never", - "Weight": "Weight" + "NoActiveSpool": "Filament tracking is inactive. To get started, please select a spool.", + "NoResults": "No spool found with the current search criteria.", + "NoSpools": "No spools available", + "OpenSpoolManager": "open Spool Manager", + "Refresh": "refresh", + "Search": "Search", + "SelectSpool": "Select Spool", + "Today": "Today", + "Weight": "Weight", + "WeightOutput": "Weight: {remaining} / {total} g", + "Yesterday": "Yesterday" }, "StatusPanel": { "CancelPrint": "Cancel print", diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index 4262f5c40..1bc7980a2 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -9,7 +9,7 @@ export const actions: ActionTree = { }, init({ dispatch }) { - Vue.$socket.emit('server.spoolman.get_spool_id', {}, { action: 'server/spoolman/getSpoolId' }) + Vue.$socket.emit('server.spoolman.get_spool_id', {}, { action: 'server/spoolman/getActiveSpoolId' }) Vue.$socket.emit( 'server.spoolman.proxy', { @@ -35,7 +35,7 @@ export const actions: ActionTree = { { action: 'server/spoolman/getVendors' } ) - dispatch('socket/addInitModule', 'server/spoolman/getSpoolId', { root: true }) + dispatch('socket/addInitModule', 'server/spoolman/getActiveSpoolId', { root: true }) dispatch('socket/addInitModule', 'server/spoolman/getHealth', { root: true }) dispatch('socket/addInitModule', 'server/spoolman/getInfo', { root: true }) dispatch('socket/addInitModule', 'server/spoolman/getVendors', { root: true }) @@ -43,9 +43,30 @@ export const actions: ActionTree = { dispatch('socket/removeInitModule', 'server/spoolman/init', { root: true }) }, - getSpoolId({ commit, dispatch }, payload) { - commit('setSpoolId', payload.spool_id) - dispatch('socket/removeInitModule', 'server/spoolman/getSpoolId', { root: true }) + getActiveSpoolId({ commit, dispatch }, payload) { + commit('setActiveSpoolId', payload.spool_id) + dispatch('socket/removeInitModule', 'server/spoolman/getActiveSpoolId', { root: true }) + + // also set active spool to null, if spool_id is null + if (payload.spool_id === null) { + commit('setActiveSpool', null) + return + } + + Vue.$socket.emit( + 'server.spoolman.proxy', + { + request_method: 'GET', + path: `/v1/spool/${payload.spool_id}`, + }, + { action: 'server/spoolman/getActiveSpool' } + ) + }, + + getActiveSpool({ commit }, payload) { + if ('requestParams' in payload) delete payload.requestParams + + commit('setActiveSpool', payload) }, getHealth({ commit, dispatch }, payload) { @@ -89,4 +110,10 @@ export const actions: ActionTree = { dispatch('socket/removeLoading', 'refreshSpools', { root: true }) }, + + setActiveSpool(_, id: number | null) { + Vue.$socket.emit('server.spoolman.post_spool_id', { + spool_id: id, + }) + }, } diff --git a/src/store/server/spoolman/index.ts b/src/store/server/spoolman/index.ts index 1cd4fdb76..8c894c942 100644 --- a/src/store/server/spoolman/index.ts +++ b/src/store/server/spoolman/index.ts @@ -14,7 +14,8 @@ export const getDefaultState = (): ServerSpoolmanState => { debug_mode: false, version: '', }, - spool_id: null, + active_spool_id: null, + active_spool: null, vendors: [], feeds: [], } diff --git a/src/store/server/spoolman/mutations.ts b/src/store/server/spoolman/mutations.ts index fbffbd0e7..f1a9f4093 100644 --- a/src/store/server/spoolman/mutations.ts +++ b/src/store/server/spoolman/mutations.ts @@ -8,8 +8,12 @@ export const mutations: MutationTree = { Object.assign(state, getDefaultState()) }, - setSpoolId(state, payload) { - Vue.set(state, 'spool_id', payload) + setActiveSpoolId(state, payload) { + Vue.set(state, 'active_spool_id', payload) + }, + + setActiveSpool(state, payload) { + Vue.set(state, 'active_spool', payload) }, setHealth(state, payload) { diff --git a/src/store/server/spoolman/types.ts b/src/store/server/spoolman/types.ts index 959e1ee87..11f8cf77e 100644 --- a/src/store/server/spoolman/types.ts +++ b/src/store/server/spoolman/types.ts @@ -7,7 +7,8 @@ export interface ServerSpoolmanState { debug_mode: boolean version: string } - spool_id: number | null + active_spool_id: number | null + active_spool: number | null vendors: ServerSpoolmanStateVendor[] feeds: string[] } diff --git a/src/store/socket/actions.ts b/src/store/socket/actions.ts index a231fa051..a58a016d1 100644 --- a/src/store/socket/actions.ts +++ b/src/store/socket/actions.ts @@ -128,6 +128,10 @@ export const actions: ActionTree = { dispatch('gui/webcams/initStore', payload.params[0], { root: true }) break + case 'notify_active_spool_set': + dispatch('server/spoolman/getActiveSpoolId', payload.params[0], { root: true }) + break + default: window.console.debug(payload) } From 9bf10c6d0b2a374576231dd615cead7b1b653652 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 12 Sep 2023 00:43:38 +0200 Subject: [PATCH 08/32] WIP Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 48 ++++++++++++------------- src/locales/en.json | 2 -- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index eff3b2d6e..3f693d7a2 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -18,7 +18,7 @@
-
{{ vendor }}
+
#{{ id }} | {{ vendor }}
{{ name }} @@ -56,7 +56,7 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { } get title() { - if (this.health === '') return 'Spoolman' + if (this.health === '' || this.health === 'healthy') return 'Spoolman' return `Spoolman (${this.health})` } @@ -72,6 +72,10 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { return `#${color}` } + get id() { + return this.active_spool?.id ?? 'XX' + } + get vendor() { return this.active_spool?.filament?.vendor?.name ?? 'Unknown' } @@ -84,45 +88,39 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { const material = this.active_spool?.filament.material ?? null if (material === null) return null - return this.$t('Panels.Spoolman.MaterialOutput', { material }) + return material } get weightOutput() { const remaining = this.active_spool?.remaining_weight ?? null - const total = this.active_spool?.filament.weight ?? null + let total = this.active_spool?.filament.weight ?? null + let unit = 'g' if (remaining === null || total === null) return null + let totalRound = Math.floor(total / 1000) - return this.$t('Panels.Spoolman.WeightOutput', { remaining, total }) - } - - get firstUsedString() { - const first_used = this.active_spool?.first_used ?? null - if (first_used === null) return null + if (total >= 1000) { + if (totalRound !== total / 1000) { + totalRound = Math.round(total / 100) / 10 + } - const date = new Date(first_used) - const now = new Date() - const diff = now.getTime() - date.getTime() - - if (diff <= 1000 * 60 * 60 * 24) return this.$t('Panels.Spoolman.Today') - if (diff <= 1000 * 60 * 60 * 24 * 2) return this.$t('Panels.Spoolman.Yesterday') - if (diff <= 1000 * 60 * 60 * 24 * 14) { - const days = Math.floor(diff / (1000 * 60 * 60 * 24)) - - return this.$t('Panels.Spoolman.DaysAgo', { days }) + return `${remaining} g / ${totalRound} kg` } - return date.toLocaleDateString() + return `${remaining} / ${total} ${unit}` } - get firstUsedOutput() { - if (this.firstUsedString === null) return null + get lengthOutput() { + let remaining = this.active_spool?.remaining_length ?? null + + if (remaining === null) return null + remaining = Math.round(remaining / 1000) - return this.$t('Panels.Spoolman.FirstUsedOutput', { firstUsed: this.firstUsedString }) + return `${remaining} m` } get subtitle() { - return [this.materialOutput, this.weightOutput, this.firstUsedOutput].filter((v) => v !== null).join(', ') + return [this.materialOutput, this.weightOutput, this.lengthOutput].filter((v) => v !== null).join(' | ') } } diff --git a/src/locales/en.json b/src/locales/en.json index 0dba3b40d..45e2c2c94 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -628,7 +628,6 @@ "LastUsed": "Last Used", "Location": "Location", "Material": "Material", - "MaterialOutput": "Material: {material}", "Never": "Never", "NoActiveSpool": "Filament tracking is inactive. To get started, please select a spool.", "NoResults": "No spool found with the current search criteria.", @@ -639,7 +638,6 @@ "SelectSpool": "Select Spool", "Today": "Today", "Weight": "Weight", - "WeightOutput": "Weight: {remaining} / {total} g", "Yesterday": "Yesterday" }, "StatusPanel": { From 0026126f10ef563bdd10a17a248dc11b190b710a Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 12 Sep 2023 21:28:23 +0200 Subject: [PATCH 09/32] refactor: change format for spool details format Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 3f693d7a2..47af4518b 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -104,10 +104,10 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { totalRound = Math.round(total / 100) / 10 } - return `${remaining} g / ${totalRound} kg` + return `${remaining}g / ${totalRound}kg` } - return `${remaining} / ${total} ${unit}` + return `${remaining} / ${total}${unit}` } get lengthOutput() { @@ -116,7 +116,7 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { if (remaining === null) return null remaining = Math.round(remaining / 1000) - return `${remaining} m` + return `${remaining}m` } get subtitle() { From 9bd4787c93a32b3b186e18a94bb7a4e8a4492c1b Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 12 Sep 2023 23:15:44 +0200 Subject: [PATCH 10/32] feat: add option to remove spool Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 42 ++++++++++++++++++++++--- src/locales/en.json | 1 + src/store/server/spoolman/actions.ts | 4 +-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 47af4518b..9b4f98767 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -2,9 +2,37 @@
@@ -38,7 +66,7 @@ import { Component, Mixins } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' -import { mdiAdjust, mdiSync } from '@mdi/js' +import { mdiAdjust, mdiDotsVertical, mdiMinusCircleOutline, mdiSync } from '@mdi/js' import SpoolmanChangeSpoolDialog from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue' import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' @@ -47,6 +75,8 @@ import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' }) export default class SpoolmanPanel extends Mixins(BaseMixin) { mdiAdjust = mdiAdjust + mdiDotsVertical = mdiDotsVertical + mdiMinusCircleOutline = mdiMinusCircleOutline mdiSync = mdiSync showChangeSpoolDialog = false @@ -122,6 +152,10 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { get subtitle() { return [this.materialOutput, this.weightOutput, this.lengthOutput].filter((v) => v !== null).join(' | ') } + + removeSpool() { + this.$store.dispatch('server/spoolman/setActiveSpool', 0) + } } diff --git a/src/locales/en.json b/src/locales/en.json index 45e2c2c94..78478fbb0 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -634,6 +634,7 @@ "NoSpools": "No spools available", "OpenSpoolManager": "open Spool Manager", "Refresh": "refresh", + "RemoveSpool": "Remove spool", "Search": "Search", "SelectSpool": "Select Spool", "Today": "Today", diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index 1bc7980a2..30d4c57ae 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -47,8 +47,8 @@ export const actions: ActionTree = { commit('setActiveSpoolId', payload.spool_id) dispatch('socket/removeInitModule', 'server/spoolman/getActiveSpoolId', { root: true }) - // also set active spool to null, if spool_id is null - if (payload.spool_id === null) { + // also set active spool to null, if spool_id is 0 + if (payload.spool_id === 0) { commit('setActiveSpool', null) return } From 093dc21d4743b14a1ca28917b3a3bf22846a16fd Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 14 Sep 2023 23:01:57 +0200 Subject: [PATCH 11/32] refactor: remove submenu for change/eject spool and add a prompt to eject spove Signed-off-by: Stefan Dej --- .../Spoolman/SpoolmanEjectSpoolDialog.vue | 53 ++++++++++++++++ src/components/panels/SpoolmanPanel.vue | 60 +++++++------------ src/locales/en.json | 4 +- 3 files changed, 76 insertions(+), 41 deletions(-) create mode 100644 src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue diff --git a/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue b/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue new file mode 100644 index 000000000..9a0381990 --- /dev/null +++ b/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue @@ -0,0 +1,53 @@ + + + diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 9b4f98767..9a1173a2e 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -2,37 +2,19 @@
@@ -59,6 +41,7 @@ +
@@ -66,20 +49,21 @@ import { Component, Mixins } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' -import { mdiAdjust, mdiDotsVertical, mdiMinusCircleOutline, mdiSync } from '@mdi/js' +import { mdiAdjust, mdiEject, mdiSwapVertical } from '@mdi/js' import SpoolmanChangeSpoolDialog from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue' +import SpoolmanEjectSpoolDialog from '@/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue' import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' @Component({ - components: { Panel, SpoolmanChangeSpoolDialog }, + components: { Panel, SpoolmanChangeSpoolDialog, SpoolmanEjectSpoolDialog }, }) export default class SpoolmanPanel extends Mixins(BaseMixin) { mdiAdjust = mdiAdjust - mdiDotsVertical = mdiDotsVertical - mdiMinusCircleOutline = mdiMinusCircleOutline - mdiSync = mdiSync + mdiEject = mdiEject + mdiSwapVertical = mdiSwapVertical showChangeSpoolDialog = false + showEjectSpoolDialog = false get health() { return this.$store.state.server.spoolman.health ?? '' @@ -152,10 +136,6 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { get subtitle() { return [this.materialOutput, this.weightOutput, this.lengthOutput].filter((v) => v !== null).join(' | ') } - - removeSpool() { - this.$store.dispatch('server/spoolman/setActiveSpool', 0) - } } diff --git a/src/locales/en.json b/src/locales/en.json index 78478fbb0..cb12cd896 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -621,8 +621,11 @@ "PowerControl": "Power Control" }, "Spoolman": { + "Cancel": "Cancel", "ChangeSpool": "Change Spool", "DaysAgo": "{days} days ago", + "EjectSpool": "Eject spool", + "EjectSpoolQuestion": "Are you sure to eject the filament spool?", "Filament": "Filament", "FirstUsedOutput": "First used: {firstUsed}", "LastUsed": "Last Used", @@ -634,7 +637,6 @@ "NoSpools": "No spools available", "OpenSpoolManager": "open Spool Manager", "Refresh": "refresh", - "RemoveSpool": "Remove spool", "Search": "Search", "SelectSpool": "Select Spool", "Today": "Today", From 11370b5e6b686421282eab354aea3e1ec8c075d4 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Thu, 14 Sep 2023 23:03:15 +0200 Subject: [PATCH 12/32] refactor: remove div in SpoolmanEjectSpoolDialog.vue Signed-off-by: Stefan Dej --- .../Spoolman/SpoolmanEjectSpoolDialog.vue | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue b/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue index 9a0381990..4c82f17ca 100644 --- a/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue +++ b/src/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue @@ -1,29 +1,27 @@ diff --git a/src/components/panels/Spoolman/SpoolmanPanelActiveSpool.vue b/src/components/panels/Spoolman/SpoolmanPanelActiveSpool.vue new file mode 100644 index 000000000..02cb9eccb --- /dev/null +++ b/src/components/panels/Spoolman/SpoolmanPanelActiveSpool.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index 93d72ff03..fdd1fc4ef 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -2,19 +2,30 @@
@@ -26,19 +37,7 @@ - - -
#{{ id }} | {{ vendor }}
- - {{ name }} - - {{ subtitle }} -
- - - - -
+
@@ -49,17 +48,20 @@ import { Component, Mixins } from 'vue-property-decorator' import BaseMixin from '@/components/mixins/base' import Panel from '@/components/ui/Panel.vue' -import { mdiAdjust, mdiEject, mdiSwapVertical } from '@mdi/js' -import SpoolmanChangeSpoolDialog from '@/components/panels/Spoolman/SpoolmanChangeSpoolDialog.vue' -import SpoolmanEjectSpoolDialog from '@/components/panels/Spoolman/SpoolmanEjectSpoolDialog.vue' +import { mdiAdjust, mdiDotsVertical, mdiEject, mdiOpenInNew, mdiSwapVertical } from '@mdi/js' +import SpoolmanChangeSpoolDialog from '@/components/dialogs/SpoolmanChangeSpoolDialog.vue' +import SpoolmanEjectSpoolDialog from '@/components/dialogs/SpoolmanEjectSpoolDialog.vue' import { ServerSpoolmanStateSpool } from '@/store/server/spoolman/types' +import SpoolmanPanelActiveSpool from '@/components/panels/Spoolman/SpoolmanPanelActiveSpool.vue' @Component({ - components: { Panel, SpoolmanChangeSpoolDialog, SpoolmanEjectSpoolDialog }, + components: { SpoolmanPanelActiveSpool, Panel, SpoolmanChangeSpoolDialog, SpoolmanEjectSpoolDialog }, }) export default class SpoolmanPanel extends Mixins(BaseMixin) { mdiAdjust = mdiAdjust + mdiDotsVertical = mdiDotsVertical mdiEject = mdiEject + mdiOpenInNew = mdiOpenInNew mdiSwapVertical = mdiSwapVertical showChangeSpoolDialog = false @@ -75,6 +77,12 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { return `Spoolman (${this.health})` } + get changeSpoolTooltip(): string { + if (this.active_spool === null) return this.$t('Panels.Spoolman.SelectSpool') as string + + return this.$t('Panels.Spoolman.ChangeSpool') as string + } + get active_spool(): ServerSpoolmanStateSpool | null { return this.$store.state.server.spoolman.active_spool ?? null } @@ -137,6 +145,14 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { get subtitle() { return [this.materialOutput, this.weightOutput, this.lengthOutput].filter((v) => v !== null).join(' | ') } + + get spoolManagerUrl() { + return this.$store.state.server.config.config?.spoolman?.server ?? null + } + + openSpoolManager() { + window.open(this.spoolManagerUrl, '_blank') + } } diff --git a/src/locales/en.json b/src/locales/en.json index 427cfdf5a..84f5f9d2b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -144,8 +144,9 @@ "StartPrint": { "Cancel": "Cancel", "DoYouWantToStartFilename": "Do you want to start {filename}?", - "DoYouWantToStartFilenameFilament": "Do you want to start {filename} with the filament {filament}?", + "DoYouWantToStartFilenameFilament": "Do you want to start {filename} with the following filament?", "Headline": "Start Job", + "NoSpoolSelected": "No spool selected. Please select a spool or this print will not be tracked.", "Print": "print", "Timelapse": "Timelapse" } From d069329be7201a66937ba9bb49a7e098237ca59e Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 17 Sep 2023 10:54:14 +0200 Subject: [PATCH 18/32] locale: add headline to locale Signed-off-by: Stefan Dej --- src/components/panels/SpoolmanPanel.vue | 6 ++++-- src/locales/en.json | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/panels/SpoolmanPanel.vue b/src/components/panels/SpoolmanPanel.vue index fdd1fc4ef..b6335ba95 100644 --- a/src/components/panels/SpoolmanPanel.vue +++ b/src/components/panels/SpoolmanPanel.vue @@ -72,9 +72,11 @@ export default class SpoolmanPanel extends Mixins(BaseMixin) { } get title() { - if (this.health === '' || this.health === 'healthy') return 'Spoolman' + const headline = this.$t('Panels.Spoolman.Headline') as string - return `Spoolman (${this.health})` + if (this.health === '' || this.health === 'healthy') return headline + + return `${headline} (${this.health})` } get changeSpoolTooltip(): string { diff --git a/src/locales/en.json b/src/locales/en.json index 84f5f9d2b..d6bba7759 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -630,6 +630,7 @@ "EjectSpoolQuestion": "Are you sure to eject the filament spool?", "Filament": "Filament", "FirstUsedOutput": "First used: {firstUsed}", + "Headline": "Spoolman", "LastUsed": "Last Used", "Location": "Location", "Material": "Material", From b6fc06824a9f3eaf75713e67431421b43e653750 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 17 Sep 2023 23:07:07 +0200 Subject: [PATCH 19/32] locale: fix locale Signed-off-by: Stefan Dej --- .../dialogs/SpoolmanChangeSpoolDialog.vue | 20 +++++++++---------- .../dialogs/SpoolmanChangeSpoolDialogRow.vue | 10 +++++----- .../dialogs/SpoolmanEjectSpoolDialog.vue | 8 ++++---- src/components/panels/SpoolmanPanel.vue | 14 ++++++------- src/locales/en.json | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/components/dialogs/SpoolmanChangeSpoolDialog.vue b/src/components/dialogs/SpoolmanChangeSpoolDialog.vue index 38a195cc8..7c51d32f5 100644 --- a/src/components/dialogs/SpoolmanChangeSpoolDialog.vue +++ b/src/components/dialogs/SpoolmanChangeSpoolDialog.vue @@ -2,7 +2,7 @@
@@ -15,21 +15,21 @@ {{ mdiRefresh }} {{ mdiDatabase }} @@ -45,10 +45,10 @@ :custom-filter="customFilter" :disable-sort="true">