From 8bbd5bdb0f2ea26b57e1b4977b222c023f7ffa44 Mon Sep 17 00:00:00 2001 From: siparker Date: Sat, 6 May 2023 22:09:46 +0100 Subject: [PATCH] feat: add facility to Scan Metadata from G-code Files (#1316) Co-authored-by: Stefan Dej --- src/components/panels/GcodefilesPanel.vue | 13 +++++++++++++ src/locales/de.json | 2 ++ src/locales/en.json | 2 ++ src/store/files/actions.ts | 22 ++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index 816d30b3..02d833b7 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -345,6 +345,13 @@ {{ mdiVideo3d }} {{ $t('Files.View3D') }} + + {{ mdiMagnify }} + {{ $t('Files.ScanMeta') }} + {{ mdiCloudDownload }} {{ $t('Files.Download') }} @@ -1436,6 +1443,12 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) { this.$router.push({ path: '/viewer', query: { filename: 'gcodes' + this.currentPath + '/' + item.filename } }) } + scanMeta(item: FileStateFile) { + this.$store.dispatch('files/scanMetadata', { + filename: 'gcodes' + this.currentPath + '/' + item.filename, + }) + } + deleteSelectedFiles() { this.selectedFiles.forEach((item: FileStateGcodefile) => { if (item.isDirectory) { diff --git a/src/locales/de.json b/src/locales/de.json index 76755026..26d353f3 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -216,6 +216,8 @@ "Rename": "Umbenennen", "RenameDirectory": "Verzeichnis umbenennen", "RenameFile": "Datei umbenennen", + "ScanMeta": "Metadaten scannen", + "ScanMetaSuccess": "Metadaten von {filename} wurden erfolgreich gescannt.", "Search": "Suchen", "SetupCurrentList": "Einstellungen", "Slicer": "Slicer", diff --git a/src/locales/en.json b/src/locales/en.json index a529c7ea..a25d5e67 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -218,6 +218,8 @@ "Rename": "Rename", "RenameDirectory": "Rename Directory", "RenameFile": "Rename File", + "ScanMeta": "Scan Metadata", + "ScanMetaSuccess": "Successfully scanned metadata from: {filename}.", "Search": "Search", "SetupCurrentList": "Setup current list", "Slicer": "Slicer", diff --git a/src/store/files/actions.ts b/src/store/files/actions.ts index 80957b17..a67e1f11 100644 --- a/src/store/files/actions.ts +++ b/src/store/files/actions.ts @@ -137,6 +137,28 @@ export const actions: ActionTree = { } }, + scanMetadata({ commit }, payload: { filename: string }) { + const rootPath = payload.filename.slice(0, payload.filename.indexOf('/')) + if (rootPath === 'gcodes') { + const requestFilename = payload.filename.slice(7) + commit('setMetadataRequested', { filename: requestFilename }) + Vue.$socket.emit( + 'server.files.metascan', + { filename: requestFilename }, + { action: 'files/getScanMetadata' } + ) + } + }, + + getScanMetadata({ dispatch }, payload: { filename: string }) { + if (payload !== undefined && payload.filename !== '') { + dispatch('getMetadata', payload) + + const filename = payload.filename + Vue.$toast.success(i18n.t('Files.ScanMetaSuccess', { filename }).toString()) + } + }, + requestMetadata({ commit }, payload: { filename: string }) { const rootPath = payload.filename.slice(0, payload.filename.indexOf('/')) if (rootPath === 'gcodes') {