Skip to content

Commit

Permalink
feat: Use new PathNavigation in GCodes & Config explorers
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Dziekoński <[email protected]>
  • Loading branch information
mdziekon committed Nov 18, 2023
1 parent 8d089fe commit cc1af28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/components/panels/GcodefilesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@
<v-row>
<v-col class="col-12 py-2 d-flex align-center">
<span>
<b>{{ $t('Files.CurrentPath') }}:</b>
{{ currentPath || '/' }}
<b class="mr-1">{{ $t('Files.CurrentPath') }}:</b>
<path-navigation :path="currentPath" :on-segment-click="clickPathNavGoToDirectory">
<template #rootElement>{{ '/gcodes' }}</template>
</path-navigation>
</span>
<v-spacer></v-spacer>
<template v-if="disk_usage !== null">
Expand Down Expand Up @@ -652,6 +654,7 @@ import {
} from '@mdi/js'
import StartPrintDialog from '@/components/dialogs/StartPrintDialog.vue'
import ControlMixin from '@/components/mixins/control'
import PathNavigation from '@/components/ui/PathNavigation.vue'
interface contextMenu {
shown: boolean
Expand Down Expand Up @@ -694,7 +697,7 @@ interface tableColumnSetting {
}
@Component({
components: { StartPrintDialog, Panel, SettingsRow, draggable },
components: { StartPrintDialog, Panel, SettingsRow, PathNavigation, draggable },
})
export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
mdiChevronDown = mdiChevronDown
Expand Down Expand Up @@ -1255,6 +1258,10 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
this.currentPath = this.currentPath.slice(0, this.currentPath.lastIndexOf('/'))
}
clickPathNavGoToDirectory(segment: { location: string }) {
this.currentPath = segment.location
}
async addToQueue(item: FileStateGcodefile) {
let filename = [this.currentPath, item.filename].join('/')
if (filename.startsWith('/')) filename = filename.slice(1)
Expand Down
13 changes: 10 additions & 3 deletions src/components/panels/Machine/ConfigFilesPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@
<v-row>
<v-col class="col-12 py-2 d-flex align-center">
<span>
<b>{{ $t('Machine.ConfigFilesPanel.CurrentPath') }}:</b>
{{ absolutePath }}
<b class="mr-1">{{ $t('Machine.ConfigFilesPanel.CurrentPath') }}:</b>
<path-navigation :path="currentPath" :on-segment-click="clickPathNavGoToDirectory">
<template #rootElement>{{ '/' + root }}</template>
</path-navigation>
</span>
<v-spacer></v-spacer>
<template v-if="disk_usage !== null && !showMissingConfigRootWarning">
Expand Down Expand Up @@ -537,6 +539,7 @@ import { formatFilesize, sortFiles } from '@/plugins/helpers'
import { FileStateFile, FileStateGcodefile } from '@/store/files/types'
import axios from 'axios'
import Panel from '@/components/ui/Panel.vue'
import PathNavigation from '@/components/ui/PathNavigation.vue'
import { hiddenRootDirectories } from '@/store/variables'
import {
mdiFilePlus,
Expand Down Expand Up @@ -607,7 +610,7 @@ interface draggingFile {
}
@Component({
components: { Panel },
components: { Panel, PathNavigation },
})
export default class ConfigFilesPanel extends Mixins(BaseMixin) {
mdiInformation = mdiInformation
Expand Down Expand Up @@ -1009,6 +1012,10 @@ export default class ConfigFilesPanel extends Mixins(BaseMixin) {
this.currentPath = this.currentPath.slice(0, this.currentPath.lastIndexOf('/'))
}
clickPathNavGoToDirectory(segment: { location: string }) {
this.currentPath = segment.location
}
showContextMenu(e: any, item: FileStateFile) {
if (!this.contextMenu.shown) {
e?.preventDefault()
Expand Down

0 comments on commit cc1af28

Please sign in to comment.