diff --git a/src/components/panels/GcodefilesPanel.vue b/src/components/panels/GcodefilesPanel.vue
index 23d07213..17b0846b 100644
--- a/src/components/panels/GcodefilesPanel.vue
+++ b/src/components/panels/GcodefilesPanel.vue
@@ -374,12 +374,16 @@
v-model="dialogCreateDirectory.name"
:label="$t('Files.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keypress.enter="createDirectoryAction">
{{ $t('Files.Cancel') }}
- {{ $t('Files.Create') }}
+
+ {{ $t('Files.Create') }}
+
@@ -399,12 +403,16 @@
v-model="dialogRenameFile.newName"
:label="$t('Files.Name').toString()"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameFileAction">
{{ $t('Files.Cancel') }}
- {{ $t('Files.Rename') }}
+
+ {{ $t('Files.Rename') }}
+
@@ -424,12 +432,16 @@
v-model="dialogRenameDirectory.newName"
:label="$t('Files.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameDirectoryAction">
{{ $t('Files.Cancel') }}
- {{ $t('Files.Rename') }}
+
+ {{ $t('Files.Rename') }}
+
@@ -647,6 +659,16 @@ export default class GcodefilesPanel extends Mixins(BaseMixin, ControlMixin) {
private deleteSelectedDialog = false
+ private isInvalidName = true
+ private nameInputRules = [
+ (value: string) => !!value || this.$t('Files.InvalidNameEmpty'),
+ (value: string) => !this.existsFilename(value) || this.$t('Files.InvalidNameAlreadyExists'),
+ ]
+
+ existsFilename(name: string) {
+ return this.files.findIndex((file) => file.filename === name) >= 0
+ }
+
get currentPath() {
const path = this.$store.state.gui.view.gcodefiles.currentPath
if (path === 'gcodes') return ''
diff --git a/src/components/panels/Machine/ConfigFilesPanel.vue b/src/components/panels/Machine/ConfigFilesPanel.vue
index ef25fd6f..218046cd 100644
--- a/src/components/panels/Machine/ConfigFilesPanel.vue
+++ b/src/components/panels/Machine/ConfigFilesPanel.vue
@@ -277,6 +277,8 @@
v-model="dialogCreateFile.name"
:label="$t('Machine.ConfigFilesPanel.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="createFileAction">
@@ -284,7 +286,7 @@
{{ $t('Machine.ConfigFilesPanel.Cancel') }}
-
+
{{ $t('Machine.ConfigFilesPanel.Create') }}
@@ -306,6 +308,8 @@
v-model="dialogRenameFile.newName"
:label="$t('Machine.ConfigFilesPanel.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameFileAction">
@@ -313,7 +317,7 @@
{{ $t('Machine.ConfigFilesPanel.Cancel') }}
-
+
{{ $t('Machine.ConfigFilesPanel.Rename') }}
@@ -335,6 +339,8 @@
v-model="dialogCreateDirectory.name"
:label="$t('Machine.ConfigFilesPanel.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="createDirectoryAction">
@@ -342,7 +348,7 @@
{{ $t('Machine.ConfigFilesPanel.Cancel') }}
-
+
{{ $t('Machine.ConfigFilesPanel.Create') }}
@@ -364,6 +370,8 @@
v-model="dialogRenameDirectory.newName"
:label="$t('Machine.ConfigFilesPanel.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameDirectoryAction">
@@ -371,7 +379,7 @@
{{ $t('Machine.ConfigFilesPanel.Cancel') }}
-
+
{{ $t('Machine.ConfigFilesPanel.Rename') }}
@@ -639,6 +647,16 @@ export default class ConfigFilesPanel extends Mixins(BaseMixin) {
private deleteSelectedDialog = false
+ private isInvalidName = true
+ private nameInputRules = [
+ (value: string) => !!value || this.$t('Files.InvalidNameEmpty'),
+ (value: string) => !this.existsFilename(value) || this.$t('Files.InvalidNameAlreadyExists'),
+ ]
+
+ existsFilename(name: string) {
+ return this.files.findIndex((file) => file.filename === name) >= 0
+ }
+
get blockFileUpload() {
return this.$store.state.gui.view.blockFileUpload ?? false
}
diff --git a/src/components/panels/Timelapse/TimelapseFilesPanel.vue b/src/components/panels/Timelapse/TimelapseFilesPanel.vue
index 6edac070..9f42fc63 100644
--- a/src/components/panels/Timelapse/TimelapseFilesPanel.vue
+++ b/src/components/panels/Timelapse/TimelapseFilesPanel.vue
@@ -237,12 +237,16 @@
v-model="dialogRenameFile.newName"
:label="$t('Timelapse.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keypress.enter="renameFileAction">
{{ $t('Timelapse.Cancel') }}
- {{ $t('Timelapse.Rename') }}
+
+ {{ $t('Timelapse.Rename') }}
+
@@ -261,8 +265,9 @@
ref="inputFieldCreateDirectory"
v-model="dialogCreateDirectory.name"
:label="$t('Timelapse.Name')"
- :rules="input_rules"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keypress.enter="createDirectoryAction">
@@ -270,7 +275,9 @@
{{ $t('Timelapse.Cancel') }}
- {{ $t('Timelapse.Create') }}
+
+ {{ $t('Timelapse.Create') }}
+
@@ -290,6 +297,8 @@
v-model="dialogRenameDirectory.newName"
:label="$t('Timelapse.Name')"
required
+ :rules="nameInputRules"
+ @update:error="isInvalidName = !isInvalidName"
@keyup.enter="renameDirectoryAction">
@@ -297,7 +306,9 @@
{{ $t('Timelapse.Cancel') }}
- {{ $t('Timelapse.Rename') }}
+
+ {{ $t('Timelapse.Rename') }}
+
@@ -496,7 +507,15 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) {
private deleteSelectedDialog = false
- private input_rules = [(value: string) => value.indexOf(' ') === -1 || 'Name contains spaces!']
+ private isInvalidName = true
+ private nameInputRules = [
+ (value: string) => !!value || this.$t('Files.InvalidNameEmpty'),
+ (value: string) => !this.existsFilename(value) || this.$t('Files.InvalidNameAlreadyExists'),
+ ]
+
+ existsFilename(name: string) {
+ return this.files.findIndex((file) => file.filename === name) >= 0
+ }
get headers() {
return [
@@ -593,14 +612,15 @@ export default class TimelapseFilesPanel extends Mixins(BaseMixin) {
}
createDirectoryAction() {
- if (this.dialogCreateDirectory.name.length && this.dialogCreateDirectory.name.indexOf(' ') === -1) {
- this.dialogCreateDirectory.show = false
- this.$socket.emit(
- 'server.files.post_directory',
- { path: this.currentPath + '/' + this.dialogCreateDirectory.name },
- { action: 'files/getCreateDir' }
- )
- }
+ this.dialogCreateDirectory.show = false
+
+ this.$socket.emit(
+ 'server.files.post_directory',
+ {
+ path: this.currentPath + '/' + this.dialogCreateDirectory.name,
+ },
+ { action: 'files/getCreateDir' }
+ )
}
refreshFileList() {
diff --git a/src/locales/de.json b/src/locales/de.json
index 12643a47..f2f363f0 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -181,6 +181,8 @@
"GCodeFiles": "G-Code Dateien",
"GcodesRootDirectoryDoesntExists": "Keinen G-Code Ordner gefunden. Bitte überprüfe die Option \"path\" im Abschnitt [virtual_sdcard] in der Klipper Konfiguration.",
"HiddenFiles": "Versteckte Dateien",
+ "InvalidNameEmpty": "Feld darf nicht leer sein!",
+ "InvalidNameAlreadyExists": "Name existiert bereits, bitte wähle einen anderen Namen.",
"LastEndTime": "Letzte Endzeit",
"LastFilamentUsed": "Letzter Filamentverbrauch",
"LastModified": "Zuletzt geändert",
diff --git a/src/locales/en.json b/src/locales/en.json
index c243288f..7f71c470 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -181,6 +181,8 @@
"GCodeFiles": "G-Code Files",
"GcodesRootDirectoryDoesntExists": "No G-Code directory found. Please check option \"path\" in the [virtual_sdcard] section of the Klipper configuration.",
"HiddenFiles": "Hidden files",
+ "InvalidNameEmpty": "Input must not be empty!",
+ "InvalidNameAlreadyExists": "Name already exists, please choose another name.",
"LastEndTime": "Last End Time",
"LastFilamentUsed": "Last Filament Used",
"LastModified": "Last modified",