Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add facility to Scan Metadata from G-code Files #1316

Merged
merged 5 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1376,6 +1383,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 @@ -216,6 +216,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