Skip to content

Commit

Permalink
feat: add facility to Scan Metadata from G-code Files (#1316)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Dej <[email protected]>
  • Loading branch information
siparker and meteyou authored May 6, 2023
1 parent 74816c5 commit 8bbd5bd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/panels/GcodefilesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@
<v-icon class="mr-1">{{ mdiVideo3d }}</v-icon>
{{ $t('Files.View3D') }}
</v-list-item>
<v-list-item
v-if="!contextMenu.item.isDirectory"
:disabled="!isGcodeFile(contextMenu.item)"
@click="scanMeta(contextMenu.item)">
<v-icon class="mr-1">{{ mdiMagnify }}</v-icon>
{{ $t('Files.ScanMeta') }}
</v-list-item>
<v-list-item v-if="!contextMenu.item.isDirectory" @click="downloadFile">
<v-icon class="mr-1">{{ mdiCloudDownload }}</v-icon>
{{ $t('Files.Download') }}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 22 additions & 0 deletions src/store/files/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ export const actions: ActionTree<FileState, RootState> = {
}
},

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') {
Expand Down

0 comments on commit 8bbd5bd

Please sign in to comment.