From 4d7ffbe090611fb82e1524c8428ea3fc4290c410 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sat, 6 May 2023 23:01:38 +0200 Subject: [PATCH] feat: add function to duplicate gcode files (#1321) --- src/components/panels/GcodefilesPanel.vue | 60 +++++++++++++++++ .../panels/Machine/ConfigFilesPanel.vue | 66 +++++++++++++++++++ src/locales/en.json | 4 ++ 3 files changed, 130 insertions(+) diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue index f5180ad1..816d30b3 100644 --- a/src/components/panels/GcodefilesPanel.vue +++ b/src/components/panels/GcodefilesPanel.vue @@ -361,6 +361,10 @@ {{ mdiRenameBox }} {{ $t('Files.Rename') }} + + {{ mdiContentCopy }} + {{ $t('Files.Duplicate') }} + {{ mdiDelete }} {{ $t('Files.Delete') }} @@ -432,6 +436,35 @@ + + + + + + + + + {{ $t('Files.Cancel') }} + + {{ $t('Files.Duplicate') }} + + + + { + this.$refs.inputFieldDuplicateFile?.focus() + }, 200) + } + + duplicateFileAction() { + this.dialogDuplicateFile.show = false + this.$socket.emit('server.files.copy', { + source: 'gcodes' + this.currentPath + '/' + this.dialogDuplicateFile.item.filename, + dest: 'gcodes' + this.currentPath + '/' + this.dialogDuplicateFile.newName, + }) + } + renameDirectory(item: FileStateGcodefile) { this.dialogRenameDirectory.item = item this.dialogRenameDirectory.newName = item.filename diff --git a/src/components/panels/Machine/ConfigFilesPanel.vue b/src/components/panels/Machine/ConfigFilesPanel.vue index 16cae98a..03349425 100644 --- a/src/components/panels/Machine/ConfigFilesPanel.vue +++ b/src/components/panels/Machine/ConfigFilesPanel.vue @@ -203,6 +203,10 @@ {{ mdiRenameBox }} {{ $t('Machine.ConfigFilesPanel.Rename') }} + + {{ mdiContentCopy }} + {{ $t('Machine.ConfigFilesPanel.Duplicate') }} + @@ -323,6 +327,37 @@ + + + + + + + + + + {{ $t('Machine.ConfigFilesPanel.Cancel') }} + + + {{ $t('Machine.ConfigFilesPanel.Duplicate') }} + + + + { + this.$refs.inputDialogDuplicateFileName?.focus() + }, 200) + } + + duplicateFileAction() { + this.dialogDuplicateFile.show = false + this.$socket.emit('server.files.copy', { + source: (this.absolutePath + '/' + this.dialogDuplicateFile.item.filename).slice(1), + dest: (this.absolutePath + '/' + this.dialogDuplicateFile.newName).slice(1), + }) + } + removeFile() { this.$socket.emit( 'server.files.delete_file', diff --git a/src/locales/en.json b/src/locales/en.json index 759b51f8..68b2e04c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -180,6 +180,8 @@ "DeleteDirectoryQuestion": "Do you really want to delete the \"{name}\" directory with all its contents?", "DeleteSelectedQuestion": "Do you really want to delete {count} selected files?", "Download": "Download", + "Duplicate": "Duplicate", + "DuplicateFile": "Duplicate File", "EditFile": "Edit File", "Empty": "Empty", "ExtruderTemp": "Extruder Temp.", @@ -400,6 +402,8 @@ "DeleteDirectoryQuestion": "Delete directory \"{name}\" and all its contents?", "DeleteSelectedQuestion": "Delete {count} selected elements?", "Download": "Download", + "Duplicate": "Duplicate", + "DuplicateFile": "Duplicate File", "EditFile": "Edit file", "Empty": "Empty", "Files": "Files",