Skip to content

Commit

Permalink
feat: file metadata refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Jun 28, 2023
1 parent 491e863 commit 7913e0c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
11 changes: 10 additions & 1 deletion src/api/socketActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export const SocketActions = {
* Expects the full path including root.
* Optionally pass the just the filename and path.
*/
async serverFilesMetaData (filepath: string) {
async serverFilesMetadata (filepath: string) {
baseEmit(
'server.files.metadata', {
dispatch: 'files/onFileMetaData',
Expand All @@ -538,6 +538,15 @@ export const SocketActions = {
)
},

async serverFilesMetascan (filepath: string) {
baseEmit(
'server.files.metascan', {
dispatch: 'files/onFileMetaData',
params: { filename: filepath }
}
)
},

/**
* This only requires path, but we pass root along too
* for brevity.
Expand Down
19 changes: 14 additions & 5 deletions src/components/widgets/filesystem/FileSystemContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<v-list dense>
<v-list-item
v-if="canPrint"
link
:disabled="!printerReady"
@click="$emit('print', file)"
>
Expand Down Expand Up @@ -74,19 +73,31 @@
@click="$emit('view', file)"
>
<v-list-item-icon>
<v-icon>$magnify</v-icon>
<v-icon>$open</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('app.general.btn.view') }}</v-list-item-title>
</v-list-item-content>
</v-list-item>

<v-list-item
v-if="canPrint"
@click="$emit('refresh-metadata', file)"
>
<v-list-item-icon>
<v-icon>$sync</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('app.general.btn.refresh_metadata') }}</v-list-item-title>
</v-list-item-content>
</v-list-item>

<v-list-item
v-if="canPreviewGcode"
@click="$emit('preview-gcode', file)"
>
<v-list-item-icon>
<v-icon>$magnify</v-icon>
<v-icon>$cubeScan</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('app.general.btn.preview_gcode') }}</v-list-item-title>
Expand All @@ -107,7 +118,6 @@

<v-list-item
v-if="!Array.isArray(file) && file.type !== 'directory'"
link
@click="$emit('download', file)"
>
<v-list-item-icon>
Expand All @@ -132,7 +142,6 @@

<v-list-item
v-if="!Array.isArray(file) && !rootProperties.readonly"
link
@click="$emit('duplicate', file)"
>
<v-list-item-icon>
Expand Down
2 changes: 2 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ import {
mdiFolderArrowUp,
mdiTableColumn,
mdiShape,
mdiSync,
mdiContentDuplicate
} from '@mdi/js'

Expand Down Expand Up @@ -316,6 +317,7 @@ export const Icons = Object.freeze({
download: mdiDownload,
rename: mdiFormTextbox,
duplicate: mdiContentDuplicate,
sync: mdiSync,
delete: mdiDelete,
camera: mdiCamera,
fan: mdiFan,
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ app:
reboot: Reboot
recover: Recover
refresh: Refresh
refresh_metadata: Refresh Metadata
reload: Reload
remove: Remove
remove_all: Remove all
Expand Down
2 changes: 1 addition & 1 deletion src/store/files/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const actions: ActionTree<FilesState, RootState> = {
}

// For gcode files, get the metadata and the meta update will take care of the rest.
SocketActions.serverFilesMetaData(payload.item.path)
SocketActions.serverFilesMetadata(payload.item.path)
} else {
const paths = getFilePaths(payload.item.path, root)
const update: FileUpdate = {
Expand Down
2 changes: 1 addition & 1 deletion src/store/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const handleCurrentFileChange = (payload: any, state: RootState, commit:
// This refreshes the metadata for the current file, which also
// ensures we update the current_file with the latest data via
// the files/onFileUpdate action.
SocketActions.serverFilesMetaData(payload.print_stats.filename)
SocketActions.serverFilesMetadata(payload.print_stats.filename)
}
}
}

0 comments on commit 7913e0c

Please sign in to comment.