* test vue-echarts and dataset>source instead of series>data Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix disposed state of chart & delete update interval of settings page Signed-off-by: Stefan Dej <meteyou@gmail.com> * init TS migation & dashboard Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: dashbaord console Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: add "disabled" status to the filament runout sensor on the dashboard Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix klipper restart process Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix status panel during a print Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert g-code files to typescript Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert history files to typescript Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert machine limits to typescript Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert update manager to typescript Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert endstops & logfiles to typescript Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix temp display in tools panel Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert machine > config files to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert select printer dialog to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert select printer menu to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert farm page to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix debug output of farm printer getters Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix import webcam streams in farm view Signed-off-by: Stefan Dej <meteyou@gmail.com> * better handling when changing printers Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert heightmap to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert heightmap to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * Console QOL (#300) * CHORE Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * NEW: console ts refactor, linux autocomplete, gui helplist, multiline Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * FIX: console autocomplete flood fix Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * fix merged console Signed-off-by: Stefan Dej <meteyou@gmail.com> * fixed return of ConsoleTable.vue isCommand Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: add toast after creating file in ConfigFilesPanel.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: file upload message Signed-off-by: Stefan Dej <meteyou@gmail.com> * add toolbar to files panels Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: disable scrollbars in TempChart.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: sidebar z-index and farm printer toolbar Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: sidebar & topbar z-index and farm printer toolbar Signed-off-by: Stefan Dej <meteyou@gmail.com> * update toolbars in gcode-files and history Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: new settings dialog (#302) * create settings dialog and integrate general, console, control, marcos, presets, webcams Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: renamed webcam gui state variable Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: temperature_fan chamber in farm printers dashboard Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: only display RPM in tools panel, when its available Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: reading empty remote printers list Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: loading additionalSensors in temp panel Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix: bed_mesh loading rework heightmap settings save heightmap settings in moonraker db Signed-off-by: Stefan Dej <meteyou@gmail.com> * add remote printers to settings Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix types Signed-off-by: Stefan Dej <meteyou@gmail.com> * add beforeDestroy to echarts Signed-off-by: Stefan Dej <meteyou@gmail.com> * add heightmap visualMap scaling and format tooltip Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: logo & primary color customizing Signed-off-by: Stefan Dej <meteyou@gmail.com> * remove keep-alive in app.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * round tempchart data Signed-off-by: Stefan Dej <meteyou@gmail.com> * normalize toolbar buttons Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix series attributes & update echarts-gl Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix hostname in sidebar Signed-off-by: Stefan Dej <meteyou@gmail.com> * rework websocket loadings Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix rework websocket loadings Signed-off-by: Stefan Dej <meteyou@gmail.com> * Fixes for console QOL PR (#301) * FIX: command help dialog added Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * FIX: console fixes Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * rework events store Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: check customFilters if string or array Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: edit preset dont work (existing name check) Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: save webcam with index 0 Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: tool combobox input dont work Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: tooltip position & z-index Signed-off-by: Stefan Dej <meteyou@gmail.com> * rework console Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix output name of filament sensor Signed-off-by: Stefan Dej <meteyou@gmail.com> * store performance updates and StatusPanel.vue optimizing Signed-off-by: Stefan Dej <meteyou@gmail.com> * console bugfixes Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix icon-rotate in temperatures panel Signed-off-by: Stefan Dej <meteyou@gmail.com> * add auto-grow to console input fields Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix dialog action button colors Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix refreshMetadata of gcocde files Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: add multi fileupload to drag&drop upload Signed-off-by: Stefan Dej <meteyou@gmail.com> * convert SystemPanel to TS Signed-off-by: Stefan Dej <meteyou@gmail.com> * add init and getters for system panels Signed-off-by: Stefan Dej <meteyou@gmail.com> * add init and getters for system panels Signed-off-by: Stefan Dej <meteyou@gmail.com> * finish SystemPanel.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: raspberry throttled flags in topbar Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: fix type in TheThrottledStates.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: add new editor (#307) * init test Signed-off-by: Stefan Dej <meteyou@gmail.com> * theme test Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: switch to codemirror editor Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: fix type in TheThrottledStates.vue Signed-off-by: Stefan Dej <meteyou@gmail.com> * reformat flags output and deactivate debug output Signed-off-by: Stefan Dej <meteyou@gmail.com> * add types to throttle states Signed-off-by: Stefan Dej <meteyou@gmail.com> * display "dirty" in the board firmware version string Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix mini console array cut Signed-off-by: Stefan Dej <meteyou@gmail.com> * delete old comment Signed-off-by: Stefan Dej <meteyou@gmail.com> * fix config files on small devices Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: display macro description in settings tab Signed-off-by: Stefan Dej <meteyou@gmail.com> * change settings icons Signed-off-by: Stefan Dej <meteyou@gmail.com> * rename dashboard panel & change slider text in settings Signed-off-by: Stefan Dej <meteyou@gmail.com> * responsive optimations for settings Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix throttled state flags filter Signed-off-by: Stefan Dej <meteyou@gmail.com> * Code highlighting for codemirror (#309) * init test Signed-off-by: Stefan Dej <meteyou@gmail.com> * theme test Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: switch to codemirror editor Signed-off-by: Stefan Dej <meteyou@gmail.com> * NEW: klipper_config editor theme Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> * NEW: code highlighting for codemirror Signed-off-by: Eike Ahmels <eike.ahmels@tu-dortmund.de> Co-authored-by: Stefan Dej <meteyou@gmail.com> * feature: hide/show jobs with special print status Signed-off-by: Stefan Dej <meteyou@gmail.com> * redesign console help modal Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: default state of sidebar was wrong on mobile devices Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: mobile view interface settings Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: optimize mobile view interface settings Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: block empty console commands Signed-off-by: Stefan Dej <meteyou@gmail.com> * push version number Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: add current / max flow in status panel Signed-off-by: Stefan Dej <meteyou@gmail.com> * feature: add big gcode thumbnail to status panel Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: fix favicon and setting tab names Signed-off-by: Stefan Dej <meteyou@gmail.com> * cleanup old editor Signed-off-by: Stefan Dej <meteyou@gmail.com> * bugfix: add redirect for updates from 1.6.0 to 2.0.0 Signed-off-by: Stefan Dej <meteyou@gmail.com> Co-authored-by: Eike Ahmels <hui_buh-@gmx.net>
821 lines
32 KiB
Vue
821 lines
32 KiB
Vue
<style scoped>
|
|
|
|
</style>
|
|
|
|
<template>
|
|
<div>
|
|
<v-card>
|
|
<v-toolbar flat dense>
|
|
<v-toolbar-title>
|
|
<span class="subheading align-baseline"><v-icon left>mdi-information</v-icon>{{ $t('Machine.ConfigFilesPanel.ConfigFiles') }}</span>
|
|
</v-toolbar-title>
|
|
</v-toolbar>
|
|
<v-card-text>
|
|
<v-row>
|
|
<v-col class="col-12 col-lg pr-lg-0">
|
|
<v-select
|
|
v-model="root"
|
|
:items="registeredDirectories"
|
|
label="Root"
|
|
outlined
|
|
hide-details
|
|
dense
|
|
@change="changeRoot"
|
|
></v-select>
|
|
</v-col>
|
|
<v-col class="col col-lg-auto pl-lg-0 text-right">
|
|
<input type="file" ref="fileUpload" style="display: none" multiple @change="uploadFile" />
|
|
<v-btn
|
|
v-for="button in filteredToolbarButtons"
|
|
v-bind:key="button.loadingName"
|
|
class="px-2 minwidth-0 ml-3"
|
|
:color="button.color"
|
|
@click="button.click"
|
|
:loading="button.loadingName !== null && loadings.includes(button.loadingName)"
|
|
>
|
|
<v-tooltip top>
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<v-icon v-bind="attrs" v-on="on">{{ button.icon }}</v-icon>
|
|
</template>
|
|
<span>{{ button.text }}</span>
|
|
</v-tooltip>
|
|
</v-btn>
|
|
<v-menu :offset-y="true" :title="$t('Machine.ConfigFilesPanel.SetupCurrentList')">
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<v-btn class="px-2 minwidth-0 ml-3" color="grey darken-3" v-bind="attrs" v-on="on"><v-icon>mdi-cog</v-icon></v-btn>
|
|
</template>
|
|
<v-list>
|
|
<v-list-item class="minHeight36">
|
|
<v-checkbox class="mt-0" hide-details v-model="showHiddenFiles" :label="$t('Machine.ConfigFilesPanel.HiddenFiles')"></v-checkbox>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-menu>
|
|
</v-col>
|
|
</v-row>
|
|
</v-card-text>
|
|
<v-card-text>
|
|
<v-row>
|
|
<v-col class="col-12 py-2 d-flex align-center">
|
|
<span><b>{{ $t('Machine.ConfigFilesPanel.CurrentPath') }}:</b> {{ this.absolutePath }}</span>
|
|
<v-spacer></v-spacer>
|
|
<template v-if="disk_usage !== null">
|
|
<v-tooltip top>
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<span v-bind="attrs" v-on="on">
|
|
<b>{{ $t('Machine.ConfigFilesPanel.FreeDisk') }}:</b> {{ formatFilesize(disk_usage.free) }}
|
|
</span>
|
|
</template>
|
|
<span>
|
|
{{ $t('Machine.ConfigFilesPanel.Used') }}: {{ formatFilesize(disk_usage.used) }}<br />
|
|
{{ $t('Machine.ConfigFilesPanel.Free') }}: {{ formatFilesize(disk_usage.free) }}<br />
|
|
{{ $t('Machine.ConfigFilesPanel.Total') }}: {{ formatFilesize(disk_usage.total) }}
|
|
</span>
|
|
</v-tooltip>
|
|
</template>
|
|
</v-col>
|
|
</v-row>
|
|
</v-card-text>
|
|
<v-divider></v-divider>
|
|
<v-data-table
|
|
:items="files"
|
|
class="files-table"
|
|
:headers="headers"
|
|
:options="options"
|
|
:page.sync="currentPage"
|
|
:custom-sort="sortFiles"
|
|
:sort-by.sync="sortBy"
|
|
:sort-desc.sync="sortDesc"
|
|
:items-per-page.sync="countPerPage"
|
|
:footer-props="{
|
|
itemsPerPageText: $t('Machine.ConfigFilesPanel.Files'),
|
|
itemsPerPageAllText: $t('Machine.ConfigFilesPanel.AllFiles'),
|
|
itemsPerPageOptions: [10,25,50,100,-1]
|
|
}"
|
|
mobile-breakpoint="0"
|
|
item-key="name">
|
|
|
|
<template #no-data>
|
|
<div class="text-center">{{ $t('Machine.ConfigFilesPanel.Empty') }}</div>
|
|
</template>
|
|
|
|
<template slot="body.prepend" v-if="(currentPath !== '')">
|
|
<tr
|
|
class="file-list-cursor"
|
|
@click="clickRowGoBack"
|
|
@dragover="dragOverFilelist($event, {isDirectory: true, filename: '..'})"
|
|
@dragleave="dragLeaveFilelist"
|
|
@drop.prevent.stop="dragDropFilelist($event, {isDirectory: true, filename: '..'})"
|
|
>
|
|
<td class="pr-0 text-center" style="width: 32px;"><v-icon>mdi-folder-upload</v-icon></td>
|
|
<td class=" " colspan="4">..</td>
|
|
</tr>
|
|
</template>
|
|
|
|
<template #item="{ index, item }">
|
|
<tr
|
|
:key="`${index} ${item.filename}`"
|
|
v-longpress:600="(e) => showContextMenu(e, item)"
|
|
@contextmenu="showContextMenu($event, item)"
|
|
@click="clickRow(item)"
|
|
class="file-list-cursor user-select-none"
|
|
:data-name="item.filename"
|
|
draggable="true"
|
|
@drag="dragFile($event, item)"
|
|
@dragend="dragendFile($event)"
|
|
@dragover="dragOverFilelist($event, item)" @dragleave="dragLeaveFilelist" @drop.prevent.stop="dragDropFilelist($event, item)"
|
|
>
|
|
<td class="pr-0 text-center" style="width: 32px;">
|
|
<v-icon v-if="item.isDirectory">mdi-folder</v-icon>
|
|
<v-icon v-if="!item.isDirectory">mdi-file</v-icon>
|
|
</td>
|
|
<td class=" ">{{ item.filename }}</td>
|
|
<td class="text-no-wrap text-right">{{ item.isDirectory ? '--' : formatFilesize(item.size) }}</td>
|
|
<td class="text-right">{{ formatDate(item.modified) }}</td>
|
|
</tr>
|
|
</template>
|
|
</v-data-table>
|
|
</v-card>
|
|
<v-menu v-model="contextMenu.shown" :position-x="contextMenu.x" :position-y="contextMenu.y" absolute offset-y>
|
|
<v-list>
|
|
<v-list-item @click="clickRow(contextMenu.item, true)" v-if="!contextMenu.item.isDirectory">
|
|
<v-icon class="mr-1">mdi-file-document-edit-outline</v-icon> {{ isDirWriteable ? $t('Machine.ConfigFilesPanel.EditFile') : $t('Machine.ConfigFilesPanel.ShowFile') }}
|
|
</v-list-item>
|
|
<v-list-item @click="downloadFile" v-if="!contextMenu.item.isDirectory">
|
|
<v-icon class="mr-1">mdi-cloud-download</v-icon> {{ $t('Machine.ConfigFilesPanel.Download') }}
|
|
</v-list-item>
|
|
<v-list-item @click="renameFile(contextMenu.item)" v-if="!contextMenu.item.isDirectory && isDirWriteable">
|
|
<v-icon class="mr-1">mdi-rename-box</v-icon> {{ $t('Machine.ConfigFilesPanel.Rename') }}
|
|
</v-list-item>
|
|
<v-list-item @click="renameDirectory(contextMenu.item)" v-if="contextMenu.item.isDirectory && isDirWriteable">
|
|
<v-icon class="mr-1">mdi-rename-box</v-icon> {{ $t('Machine.ConfigFilesPanel.Rename') }}
|
|
</v-list-item>
|
|
<v-list-item @click="removeFile" v-if="!contextMenu.item.isDirectory && isDirWriteable">
|
|
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Machine.ConfigFilesPanel.Delete') }}
|
|
</v-list-item>
|
|
<v-list-item @click="deleteDirectory(contextMenu.item)" v-if="contextMenu.item.isDirectory && isDirWriteable">
|
|
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Machine.ConfigFilesPanel.Delete') }}
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-menu>
|
|
<!-- <v-dialog v-model="editor.showLoader" hide-overlay persistent width="300">
|
|
<v-card color="primary" dark >
|
|
<v-card-text>
|
|
{{ $t('Machine.ConfigFilesPanel.PleaseStandBy') }}
|
|
<v-progress-linear indeterminate color="white" class="mb-0" ></v-progress-linear>
|
|
</v-card-text>
|
|
</v-card>
|
|
</v-dialog>-->
|
|
<v-dialog v-model="dialogImage.show" hide-overlay fullscreen @keydown.esc="dialogImage.show = false; dialogImage.item.url = null; dialogImage.item.svg = null;" class="fill-height">
|
|
<v-card style="position: relative;">
|
|
<v-toolbar dark color="primary">
|
|
<v-btn icon dark @click="dialogImage.show = false; dialogImage.item.url = null; dialogImage.item.svg = null;">
|
|
<v-icon>mdi-close</v-icon>
|
|
</v-btn>
|
|
</v-toolbar>
|
|
<div class="d-flex justify-center" style="max-height: calc(100vh - 64px); overflow: auto;">
|
|
<img v-if="dialogImage.item.url" :src="dialogImage.item.url" style="max-height: 100%; width: auto;" alt="image" />
|
|
<div v-else-if="dialogImage.item.svg"
|
|
class="fill-width"
|
|
v-html="dialogImage.item.svg"></div>
|
|
</div>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-dialog v-model="dialogRenameFile.show" max-width="400">
|
|
<v-card>
|
|
<v-card-title class="headline">{{ $t('Machine.ConfigFilesPanel.RenameFile') }}</v-card-title>
|
|
<v-card-text>
|
|
<v-text-field :label="$t('Machine.ConfigFilesPanel.Name')" required v-model="dialogRenameFile.newName"></v-text-field>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="" text @click="dialogRenameFile.show = false">{{ $t('Machine.ConfigFilesPanel.Cancel') }}</v-btn>
|
|
<v-btn color="primary" text @click="renameFileAction">{{ $t('Machine.ConfigFilesPanel.Rename') }}</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-dialog v-model="dialogCreateFile.show" max-width="400">
|
|
<v-card>
|
|
<v-card-title class="headline">{{ $t('Machine.ConfigFilesPanel.CreateFile') }}</v-card-title>
|
|
<v-card-text>
|
|
<v-text-field :label="$t('Machine.ConfigFilesPanel.Name')" required v-model="dialogCreateFile.name"></v-text-field>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="" text @click="dialogCreateFile.show = false">{{ $t('Machine.ConfigFilesPanel.Cancel') }}</v-btn>
|
|
<v-btn color="primary" text @click="createFileAction">{{ $t('Machine.ConfigFilesPanel.Create') }}</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-dialog v-model="dialogCreateDirectory.show" max-width="400">
|
|
<v-card>
|
|
<v-card-title class="headline">{{ $t('Machine.ConfigFilesPanel.CreateDirectory') }}</v-card-title>
|
|
<v-card-text>
|
|
<v-text-field :label="$t('Machine.ConfigFilesPanel.Name')" required v-model="dialogCreateDirectory.name"></v-text-field>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="" text @click="dialogCreateDirectory.show = false">{{ $t('Machine.ConfigFilesPanel.Cancel') }}</v-btn>
|
|
<v-btn color="primary" text @click="createDirectoryAction">{{ $t('Machine.ConfigFilesPanel.Create') }}</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-dialog v-model="dialogRenameDirectory.show" max-width="400">
|
|
<v-card>
|
|
<v-card-title class="headline">{{ $t('Machine.ConfigFilesPanel.RenameDirectory') }}</v-card-title>
|
|
<v-card-text>
|
|
<v-text-field :label="$t('Machine.ConfigFilesPanel.Name')" required v-model="dialogRenameDirectory.newName"></v-text-field>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="" text @click="dialogRenameDirectory.show = false">{{ $t('Machine.ConfigFilesPanel.Cancel') }}</v-btn>
|
|
<v-btn color="primary" text @click="renameDirectoryAction">{{ $t('Machine.ConfigFilesPanel.Rename') }}</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-dialog v-model="dialogDeleteDirectory.show" max-width="400">
|
|
<v-card>
|
|
<v-card-title class="headline">{{ $t('Machine.ConfigFilesPanel.DeleteDirectory') }}</v-card-title>
|
|
<v-card-text>
|
|
<p class="mb-0">{{ $t('Machine.ConfigFilesPanel.DeleteDirectoryQuestion', { name: dialogDeleteDirectory.item.filename } )}}</p>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<v-btn color="" text @click="dialogDeleteDirectory.show = false">{{ $t('Machine.ConfigFilesPanel.Cancel') }}</v-btn>
|
|
<v-btn color="error" text @click="deleteDirectoryAction">{{ $t('Machine.ConfigFilesPanel.Delete') }}</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
<v-snackbar v-model="uploadSnackbar.status" :timeout="-1" :value="true" fixed right bottom dark>
|
|
<span v-if="uploadSnackbar.max > 1" class="mr-1">({{ uploadSnackbar.number }}/{{ uploadSnackbar.max }})</span><strong>{{ $t('Machine.ConfigFilesPanel.Uploading') }} {{ uploadSnackbar.filename }}</strong><br />
|
|
{{ Math.round(uploadSnackbar.percent) }} % @ {{ formatFilesize(Math.round(uploadSnackbar.speed)) }}/s<br />
|
|
<v-progress-linear class="mt-2" :value="uploadSnackbar.percent"></v-progress-linear>
|
|
<template v-slot:action="{ attrs }">
|
|
<v-btn
|
|
color="red"
|
|
text
|
|
v-bind="attrs"
|
|
@click="cancelUpload"
|
|
style="min-width: auto;"
|
|
>
|
|
<v-icon class="0">mdi-close</v-icon>
|
|
</v-btn>
|
|
</template>
|
|
</v-snackbar>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import {Component, Mixins, Watch} from "vue-property-decorator";
|
|
import BaseMixin from "@/components/mixins/base";
|
|
import {readOnlyRoots} from "@/store/variables";
|
|
import {findDirectory, formatDate, formatFilesize, sortFiles} from "@/plugins/helpers";
|
|
import {FileStateFile} from "@/store/files/types";
|
|
import axios from "axios";
|
|
|
|
interface contextMenu {
|
|
shown: boolean
|
|
isDirectory: boolean
|
|
touchTimer: number | null
|
|
x: number
|
|
y: number
|
|
item: FileStateFile
|
|
}
|
|
|
|
|
|
interface dialogImageObject {
|
|
show: boolean
|
|
item: {
|
|
url: string | null,
|
|
svg: string | null
|
|
}
|
|
}
|
|
|
|
interface dialogRenameObject {
|
|
show: boolean
|
|
newName: string
|
|
item: FileStateFile
|
|
}
|
|
|
|
interface dialogDeleteObject {
|
|
show: boolean
|
|
item: FileStateFile
|
|
}
|
|
|
|
interface uploadSnackbar {
|
|
status: boolean
|
|
filename: string
|
|
percent: number
|
|
speed: number
|
|
total: number
|
|
number: number
|
|
max: number
|
|
cancelTokenSource: any
|
|
lastProgress: {
|
|
time: number
|
|
loaded: number
|
|
}
|
|
}
|
|
|
|
interface draggingFile {
|
|
status: boolean
|
|
item: FileStateFile
|
|
}
|
|
|
|
@Component
|
|
export default class ConfigFilesPanel extends Mixins(BaseMixin) {
|
|
sortFiles = sortFiles
|
|
formatFilesize = formatFilesize
|
|
formatDate = formatDate
|
|
|
|
$refs!: {
|
|
fileUpload: HTMLInputElement,
|
|
}
|
|
|
|
private selected = []
|
|
private options = { }
|
|
private currentPage = 1
|
|
private files: FileStateFile[] = []
|
|
private currentPath = ''
|
|
private root = 'config'
|
|
private contextMenu: contextMenu = {
|
|
shown: false,
|
|
isDirectory: false,
|
|
touchTimer: null,
|
|
x: 0,
|
|
y: 0,
|
|
item: {
|
|
isDirectory: false,
|
|
filename: '',
|
|
modified: new Date()
|
|
}
|
|
}
|
|
private dialogImage: dialogImageObject = {
|
|
show: false,
|
|
item: {
|
|
url: null,
|
|
svg: null
|
|
}
|
|
}
|
|
private dialogRenameFile: dialogRenameObject = {
|
|
show: false,
|
|
newName: "",
|
|
item: {
|
|
isDirectory: false,
|
|
filename: '',
|
|
modified: new Date()
|
|
}
|
|
}
|
|
private dialogCreateFile = {
|
|
show: false,
|
|
name: "",
|
|
}
|
|
private dialogCreateDirectory = {
|
|
show: false,
|
|
name: "",
|
|
}
|
|
private dialogRenameDirectory: dialogRenameObject = {
|
|
show: false,
|
|
newName: "",
|
|
item: {
|
|
isDirectory: false,
|
|
filename: '',
|
|
modified: new Date()
|
|
}
|
|
}
|
|
private dialogDeleteDirectory: dialogDeleteObject = {
|
|
show: false,
|
|
item: {
|
|
isDirectory: false,
|
|
filename: '',
|
|
modified: new Date()
|
|
}
|
|
}
|
|
private uploadSnackbar: uploadSnackbar = {
|
|
status: false,
|
|
filename: "",
|
|
percent: 0,
|
|
speed: 0,
|
|
total: 0,
|
|
number: 0,
|
|
max: 0,
|
|
cancelTokenSource: {},
|
|
lastProgress: {
|
|
time: 0,
|
|
loaded: 0
|
|
}
|
|
}
|
|
private draggingFile: draggingFile = {
|
|
status: false,
|
|
item: {
|
|
isDirectory: false,
|
|
filename: "",
|
|
modified: new Date()
|
|
}
|
|
}
|
|
|
|
get toolbarButtons() {
|
|
return [
|
|
{
|
|
text: this.$t("Machine.ConfigFilesPanel.UploadFile"),
|
|
color: "grey darken-3",
|
|
icon: "mdi-file-upload",
|
|
loadingName: null,
|
|
onlyWriteable: true,
|
|
click: this.uploadFileButton
|
|
}, {
|
|
text: this.$t("Machine.ConfigFilesPanel.CreateFile"),
|
|
color: "grey darken-3",
|
|
icon: "mdi-file-plus",
|
|
loadingName: null,
|
|
onlyWriteable: true,
|
|
click: this.createFile
|
|
}, {
|
|
text: this.$t("Machine.ConfigFilesPanel.CreateDirectory"),
|
|
color: "grey darken-3",
|
|
icon: "mdi-folder-plus",
|
|
loadingName: null,
|
|
onlyWriteable: true,
|
|
click: this.createDirecotry
|
|
}, {
|
|
text: this.$t("Machine.ConfigFilesPanel.RefreshDirectory"),
|
|
color: "grey darken-3",
|
|
icon: "mdi-refresh",
|
|
loadingName: null,
|
|
onlyWriteable: false,
|
|
click: this.refreshFileList
|
|
},
|
|
]
|
|
}
|
|
|
|
get filteredToolbarButtons() {
|
|
return this.toolbarButtons.filter((button) => {
|
|
return (this.isDirWriteable && button.onlyWriteable) || !button.onlyWriteable
|
|
})
|
|
}
|
|
|
|
get filetree() {
|
|
return this.$store.state.files.filetree
|
|
}
|
|
|
|
get headers() {
|
|
return [
|
|
{ text: '', value: '', },
|
|
{ text: this.$t('Machine.ConfigFilesPanel.Name'), value: 'filename', },
|
|
{ text: this.$t('Machine.ConfigFilesPanel.Filesize'), value: 'size', align: 'right', },
|
|
{ text: this.$t('Machine.ConfigFilesPanel.LastModified'), value: 'modified', align: 'right', },
|
|
]
|
|
}
|
|
|
|
get countPerPage() {
|
|
return this.$store.state.gui.settings.configfiles.countPerPage
|
|
}
|
|
|
|
set countPerPage(newVal) {
|
|
this.$store.dispatch("gui/saveSetting", { name: 'settings.configfiles.countPerPage', value: newVal })
|
|
}
|
|
|
|
get showHiddenFiles() {
|
|
return this.$store.state.gui.settings.configfiles.showHiddenFiles
|
|
}
|
|
|
|
set showHiddenFiles(newVal) {
|
|
this.$store.dispatch("gui/saveSetting", { name: 'settings.configfiles.showHiddenFiles', value: newVal })
|
|
}
|
|
|
|
get sortBy() {
|
|
return this.$store.state.gui.settings.configfiles.sortBy
|
|
}
|
|
|
|
set sortBy(newVal) {
|
|
this.$store.dispatch("gui/saveSetting", { name: 'settings.configfiles.sortBy', value: newVal })
|
|
}
|
|
|
|
get sortDesc() {
|
|
return this.$store.state.gui.settings.configfiles.sortDesc
|
|
}
|
|
|
|
set sortDesc(newVal) {
|
|
this.$store.dispatch("gui/saveSetting", { name: 'settings.configfiles.sortDesc', value: newVal })
|
|
}
|
|
|
|
get registeredDirectories() {
|
|
return this.$store.state.server.registered_directories.filter((dir: string) => dir !== 'gcodes').sort()
|
|
}
|
|
|
|
get availableServices() {
|
|
return this.$store.state.server.system_info.available_services
|
|
}
|
|
|
|
get absolutePath() {
|
|
let path = "/"+this.root
|
|
if (this.currentPath) path += this.currentPath
|
|
|
|
return path
|
|
}
|
|
|
|
get disk_usage() {
|
|
return this.$store.getters["files/getDiskUsage"](this.absolutePath)
|
|
}
|
|
|
|
get isDirWriteable() {
|
|
return !readOnlyRoots.includes(this.root)
|
|
}
|
|
|
|
refreshFileList() {
|
|
this.$socket.emit('server.files.get_directory', { path: this.absolutePath.substring(1) }, { action: 'files/getDirectory' })
|
|
}
|
|
|
|
changeRoot() {
|
|
this.currentPath = ""
|
|
this.loadPath()
|
|
}
|
|
|
|
loadPath() {
|
|
let dirArray = this.absolutePath.substring(1).split("/")
|
|
this.files = findDirectory(this.filetree, dirArray) ?? []
|
|
|
|
if (!this.showHiddenFiles) {
|
|
this.files = this.files.filter(file => file.filename.substr(0, 1) !== ".");
|
|
}
|
|
}
|
|
|
|
clickRow(item: FileStateFile, force = false) {
|
|
if (!this.contextMenu.shown || force) {
|
|
if (force) this.contextMenu.shown = false
|
|
|
|
if (!item.isDirectory) {
|
|
if (['png', 'jpeg', 'jpg', 'gif', 'bmp', 'tif', 'svg'].includes(item.filename.split('.').pop()?.toLowerCase() ?? '')) {
|
|
const url = `${this.apiUrl}/server/files${this.absolutePath}/${item.filename}?t=${Date.now()}`;
|
|
if (['svg'].includes(item.filename.split('.').pop()?.toLowerCase() ?? '')) {
|
|
fetch(url)
|
|
.then(res => res.text())
|
|
.then(svg => {
|
|
this.dialogImage.show = true;
|
|
this.dialogImage.item.svg = svg;
|
|
});
|
|
} else {
|
|
this.dialogImage.show = true;
|
|
this.dialogImage.item.url = url;
|
|
}
|
|
} else {
|
|
this.$store.dispatch('editor/openFile', {
|
|
root: this.root,
|
|
path: this.currentPath,
|
|
filename: item.filename
|
|
});
|
|
}
|
|
} else {
|
|
this.currentPath += "/" + item.filename;
|
|
this.currentPage = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
clickRowGoBack() {
|
|
this.currentPath = this.currentPath.substr(0, this.currentPath.lastIndexOf("/"))
|
|
}
|
|
|
|
showContextMenu (e: any, item: FileStateFile) {
|
|
if (!this.contextMenu.shown) {
|
|
e?.preventDefault()
|
|
this.contextMenu.shown = true
|
|
this.contextMenu.x = e?.clientX || e?.pageX || window.screenX / 2
|
|
this.contextMenu.y = e?.clientY || e?.pageY || window.screenY / 2
|
|
this.contextMenu.item = item
|
|
|
|
this.$nextTick(() => {
|
|
this.contextMenu.shown = true
|
|
})
|
|
}
|
|
}
|
|
|
|
downloadFile() {
|
|
const filename = (this.absolutePath+"/"+this.contextMenu.item.filename)
|
|
const href = this.apiUrl + '/server/files' + filename
|
|
window.open(href)
|
|
}
|
|
|
|
createDirecotry() {
|
|
this.dialogCreateDirectory.name = ""
|
|
this.dialogCreateDirectory.show = true
|
|
}
|
|
|
|
createDirectoryAction() {
|
|
this.dialogCreateDirectory.show = false;
|
|
|
|
this.$socket.emit('server.files.post_directory', {
|
|
path: this.absolutePath.substring(1)+"/"+this.dialogCreateDirectory.name
|
|
}, { action: 'files/getCreateDir' })
|
|
}
|
|
|
|
renameDirectory(item: FileStateFile) {
|
|
this.dialogRenameDirectory.item = item;
|
|
this.dialogRenameDirectory.newName = item.filename;
|
|
this.dialogRenameDirectory.show = true;
|
|
}
|
|
|
|
renameDirectoryAction() {
|
|
this.dialogRenameDirectory.show = false;
|
|
this.$socket.emit('server.files.move', {
|
|
source: this.absolutePath+"/"+this.dialogRenameDirectory.item.filename,
|
|
dest: this.absolutePath+"/"+this.dialogRenameDirectory.newName
|
|
}, { action: 'files/getMove' });
|
|
}
|
|
|
|
deleteDirectory(item: FileStateFile) {
|
|
this.dialogDeleteDirectory.item = item
|
|
this.dialogDeleteDirectory.show = true
|
|
}
|
|
|
|
deleteDirectoryAction() {
|
|
this.dialogDeleteDirectory.show = false
|
|
this.$socket.emit('server.files.delete_directory', { path: this.absolutePath+"/"+this.dialogDeleteDirectory.item.filename, force: true }, { action: 'files/getDeleteDir' })
|
|
}
|
|
|
|
createFile() {
|
|
this.dialogCreateFile.name = ""
|
|
this.dialogCreateFile.show = true
|
|
}
|
|
|
|
createFileAction() {
|
|
const file = new File([""], this.dialogCreateFile.name)
|
|
|
|
let formData = new FormData()
|
|
formData.append('file', file)
|
|
formData.append('root', this.root)
|
|
if(this.currentPath.length) formData.append('path', this.currentPath.slice(1))
|
|
|
|
axios.post(this.apiUrl + '/server/files/upload',
|
|
formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' }
|
|
}
|
|
).then(() => {
|
|
this.$toast.success(this.$t('Files.SuccessfullyCreated', { filename: this.dialogCreateFile.name }).toString())
|
|
this.dialogCreateFile.show = false
|
|
this.dialogCreateFile.name = ""
|
|
}).catch(() => {
|
|
window.console.error("Error create file: "+this.dialogCreateFile.name)
|
|
})
|
|
}
|
|
|
|
renameFile(item: FileStateFile) {
|
|
this.dialogRenameFile.item = item
|
|
this.dialogRenameFile.newName = item.filename
|
|
this.dialogRenameFile.show = true
|
|
}
|
|
|
|
renameFileAction() {
|
|
this.dialogRenameFile.show = false
|
|
this.$socket.emit('server.files.move', {
|
|
source: this.absolutePath+"/"+this.dialogRenameFile.item.filename,
|
|
dest: this.absolutePath+"/"+this.dialogRenameFile.newName
|
|
}, { action: 'files/getMove' })
|
|
}
|
|
|
|
removeFile() {
|
|
this.$socket.emit('server.files.delete_file', { path: this.absolutePath+"/"+this.contextMenu.item.filename }, { action: 'files/getDeleteFile' })
|
|
}
|
|
|
|
uploadFileButton() {
|
|
this.$refs.fileUpload.click()
|
|
}
|
|
|
|
async uploadFile() {
|
|
if (this.$refs.fileUpload.files?.length) {
|
|
this.$store.dispatch('socket/addLoading', { name: 'configFileUpload' })
|
|
let successFiles = []
|
|
this.uploadSnackbar.number = 0
|
|
this.uploadSnackbar.max = this.$refs.fileUpload.files.length
|
|
for (const file of this.$refs.fileUpload.files) {
|
|
this.uploadSnackbar.number++
|
|
const result = await this.doUploadFile(file)
|
|
successFiles.push(result)
|
|
}
|
|
|
|
this.$store.dispatch('socket/removeLoading', { name: 'configFileUpload' })
|
|
for(const file of successFiles) {
|
|
this.$toast.success("Upload of "+file+" successful!")
|
|
}
|
|
|
|
this.$refs.fileUpload.value = ''
|
|
}
|
|
}
|
|
|
|
doUploadFile(file: File) {
|
|
let toast = this.$toast;
|
|
let formData = new FormData();
|
|
let filename = file.name.replace(" ", "_");
|
|
|
|
this.uploadSnackbar.filename = filename
|
|
this.uploadSnackbar.status = true
|
|
this.uploadSnackbar.percent = 0
|
|
this.uploadSnackbar.speed = 0
|
|
this.uploadSnackbar.lastProgress.loaded = 0
|
|
this.uploadSnackbar.lastProgress.time = 0
|
|
|
|
formData.append('root', this.root)
|
|
formData.append('file', file, this.currentPath+"/"+filename)
|
|
this.$store.dispatch('socket/addLoading', { name: 'configFileUpload' })
|
|
|
|
return new Promise(resolve => {
|
|
this.uploadSnackbar.cancelTokenSource = axios.CancelToken.source()
|
|
axios.post(this.apiUrl + '/server/files/upload',
|
|
formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
cancelToken: this.uploadSnackbar.cancelTokenSource.token,
|
|
onUploadProgress: (progressEvent) => {
|
|
this.uploadSnackbar.percent = (progressEvent.loaded * 100) / progressEvent.total
|
|
if (this.uploadSnackbar.lastProgress.time) {
|
|
const time = progressEvent.timeStamp - this.uploadSnackbar.lastProgress.time
|
|
const data = progressEvent.loaded - this.uploadSnackbar.lastProgress.loaded
|
|
|
|
if (time) this.uploadSnackbar.speed = data / (time / 1000)
|
|
}
|
|
|
|
this.uploadSnackbar.lastProgress.time = progressEvent.timeStamp
|
|
this.uploadSnackbar.lastProgress.loaded = progressEvent.loaded
|
|
this.uploadSnackbar.total = progressEvent.total
|
|
}
|
|
}
|
|
).then((result) => {
|
|
const filename = result.data.item.path.substr(result.data.item.path.indexOf("/")+1)
|
|
this.uploadSnackbar.status = false
|
|
resolve(filename)
|
|
}).catch(() => {
|
|
this.uploadSnackbar.status = false
|
|
this.$store.dispatch('socket/removeLoading', { name: 'configFileUpload' })
|
|
toast.error("Cannot upload the file!")
|
|
})
|
|
})
|
|
}
|
|
|
|
cancelUpload() {
|
|
this.uploadSnackbar.cancelTokenSource.cancel()
|
|
this.uploadSnackbar.status = false
|
|
}
|
|
|
|
dragFile(e: Event, item: FileStateFile) {
|
|
e.preventDefault();
|
|
this.draggingFile.status = true;
|
|
this.draggingFile.item = item;
|
|
}
|
|
|
|
dragendFile(e: Event) {
|
|
e.preventDefault();
|
|
this.draggingFile.status = false
|
|
this.draggingFile.item = {
|
|
isDirectory: false,
|
|
filename: "",
|
|
modified: new Date()
|
|
}
|
|
}
|
|
|
|
dragOverFilelist(e: any, row: any) {
|
|
if (this.draggingFile.status) {
|
|
e.preventDefault()
|
|
//e.stopPropagation()
|
|
|
|
if (row.isDirectory) e.target.parentElement.style.backgroundColor = '#43A04720'
|
|
}
|
|
}
|
|
|
|
dragLeaveFilelist(e: any) {
|
|
if (this.draggingFile.status) {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
|
|
e.target.parentElement.style.backgroundColor = 'transparent'
|
|
}
|
|
}
|
|
|
|
async dragDropFilelist(e: any, row: any) {
|
|
if (this.draggingFile.status) {
|
|
e.preventDefault()
|
|
e.target.parentElement.style.backgroundColor = 'transparent'
|
|
|
|
let dest = "";
|
|
if (row.filename === '..') {
|
|
dest = this.absolutePath.slice(1, this.absolutePath.lastIndexOf("/")+1)+this.draggingFile.item.filename
|
|
} else dest = this.absolutePath+"/"+row.filename+"/"+this.draggingFile.item.filename
|
|
|
|
this.$socket.emit('server.files.move', {
|
|
source: this.absolutePath.slice(1)+"/"+this.draggingFile.item.filename,
|
|
dest: dest
|
|
}, { action: 'files/getMove' })
|
|
}
|
|
}
|
|
|
|
created() { this.loadPath() }
|
|
|
|
@Watch('filetree', { deep: true })
|
|
filetreeChanged() { this.loadPath() }
|
|
|
|
@Watch('currentPath')
|
|
currentPathChanged() { this.loadPath() }
|
|
|
|
@Watch('showHiddenFiles')
|
|
showHiddenFilesChanged() { this.loadPath() }
|
|
}
|
|
</script>
|