Merge branch 'master' of https://github.com/meteyou/mainsail into LanguageChange

# Conflicts:
#	package.json
#	src/App.vue
#	src/components/ConnectingDialog.vue
#	src/components/SelectPrinterDialog.vue
#	src/components/panels/ControlPanel.vue
#	src/components/panels/ExtruderPanel.vue
#	src/components/panels/Settings/ConfigFilesPanel.vue
#	src/components/panels/Settings/ControlPanel.vue
#	src/components/panels/Settings/EndstopPanel.vue
#	src/components/panels/Settings/GeneralPanel.vue
#	src/components/panels/Settings/LimitsPanel.vue
#	src/components/panels/Settings/UpdatePanel.vue
#	src/components/panels/StatusPanel.vue
#	src/components/panels/ToolsPanel.vue
#	src/components/panels/WebcamPanel.vue
#	src/components/panels/ZOffsetPanel.vue
#	src/main.js
#	src/pages/Files.vue
#	src/store/gui/actions.js
#	src/store/gui/index.js
This commit is contained in:
winbin committed 2021-03-15 16:17:56 +08:00
commit ef732ebc87
91 files changed
+3530 -1162

No files matched your search

@@ -29,7 +29,7 @@
<v-col>
<v-card>
<v-card-title>
{{ $t('Setting.ConfigFiles') }}
{{ $t('Settings.ConfigFilesPanel.ConfigFiles') }}
<v-spacer class="d-none d-sm-block"></v-spacer>
<input type="file" ref="fileUpload" style="display: none" multiple @change="uploadFile" />
<v-item-group class="v-btn-toggle my-5 my-sm-0 col-12 col-sm-auto px-0 py-0">
@@ -37,19 +37,19 @@
<v-btn v-if="currentPath !== '' && currentPath !== '/config_examples'" class="flex-grow-1" @click="createFile"><v-icon>mdi-file-plus</v-icon></v-btn>
<v-btn v-if="currentPath !== '' && currentPath !== '/config_examples'" class="flex-grow-1" @click="createFolder"><v-icon>mdi-folder-plus</v-icon></v-btn>
<v-btn class="flex-grow-1" @click="refreshFileList"><v-icon>mdi-refresh</v-icon></v-btn>
<v-menu :offset-y="true" title="Setup current list">
<v-menu :offset-y="true" :title="$t('Settings.ConfigFilesPanel.SetupCurrentList')">
<template v-slot:activator="{ on, attrs }">
<v-btn class="flex-grow-1" v-bind="attrs" v-on="on"><v-icon class="">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('Setting.HiddenFiles')"></v-checkbox>
<v-checkbox class="mt-0" hide-details v-model="showHiddenFiles" :label="$t('Settings.ConfigFilesPanel.HiddenFiles')"></v-checkbox>
</v-list-item>
</v-list>
</v-menu>
</v-item-group>
</v-card-title>
<v-card-subtitle>{{ $t('Setting.CurrentPath') }} {{ this.currentPath === "" ? "/" : this.currentPath }}</v-card-subtitle>
<v-card-subtitle>{{ $t('Settings.ConfigFilesPanel.CurrentPath') }} {{ this.currentPath === "" ? "/" : this.currentPath }}</v-card-subtitle>
<v-data-table
:items="files"
class="files-table"
@@ -61,13 +61,13 @@
:sort-desc.sync="sortDesc"
:items-per-page.sync="countPerPage"
:footer-props="{
itemsPerPageText: $t('Setting.Files')
itemsPerPageText: $t('Settings.ConfigFilesPanel.Files')
}"
mobile-breakpoint="0"
item-key="name">
<template #no-data>
<div class="text-center">{{ $t('Setting.Empty') }}</div>
<div class="text-center">{{ $t('Settings.ConfigFilesPanel.Empty') }}</div>
</template>
<template slot="body.prepend" v-if="(currentPath !== '')">
@@ -81,9 +81,10 @@
<template #item="{ item }">
<tr
v-longpress:600="(e) => showContextMenu(e, item)"
@contextmenu="showContextMenu($event, item)"
@click="clickRow(item)"
class="file-list-cursor"
class="file-list-cursor user-select-none"
:data-name="item.filename">
<td class="pr-0 text-center" style="width: 32px;">
<v-icon v-if="item.isDirectory">mdi-folder</v-icon>
@@ -98,27 +99,27 @@
</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)" v-if="!contextMenu.item.isDirectory">
<v-icon class="mr-1">mdi-file-document-edit-outline</v-icon> {{ $t('Setting.EditFile') }}
<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> {{ $t('Settings.ConfigFilesPanel.EditFile') }}
</v-list-item>
<v-list-item @click="downloadFile" v-if="!contextMenu.item.isDirectory">
<v-icon class="mr-1">mdi-cloud-download</v-icon> {{ $t('Setting.Download') }}
<v-icon class="mr-1">mdi-cloud-download</v-icon> {{ $t('Settings.ConfigFilesPanel.Download') }}
</v-list-item>
<v-list-item @click="renameFile(contextMenu.item)" v-if="!contextMenu.item.isDirectory && currentPath !== '/config_examples'">
<v-icon class="mr-1">mdi-rename-box</v-icon> {{ $t('Setting.Rename') }}
<v-icon class="mr-1">mdi-rename-box</v-icon> {{ $t('Settings.ConfigFilesPanel.Rename') }}
</v-list-item>
<v-list-item @click="removeFile" v-if="!contextMenu.item.isDirectory && currentPath !== '/config_examples'">
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Setting.Delete') }}
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Settings.ConfigFilesPanel.Delete') }}
</v-list-item>
<v-list-item @click="deleteDirectoryAction" v-if="contextMenu.item.isDirectory && currentPath !== '' && currentPath !== '/config_examples'">
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Setting.Delete') }}
<v-icon class="mr-1">mdi-delete</v-icon> {{ $t('Settings.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('Setting.PleaseStandBy') }}
{{ $t('Settings.ConfigFilesPanel.PleaseStandBy') }}
<v-progress-linear indeterminate color="white" class="mb-0" ></v-progress-linear>
</v-card-text>
</v-card>
@@ -132,11 +133,11 @@
<v-toolbar-title>{{ editor.item.filename }}</v-toolbar-title>
<v-spacer></v-spacer>
<v-toolbar-items>
<v-btn dark text href="https://www.klipper3d.org/Config_Reference.html" target="_blank" class="d-none d-md-flex"><v-icon small class="mr-1">mdi-help</v-icon>{{ $t('Setting.ConfigReference') }}</v-btn>
<v-btn dark text href="https://www.klipper3d.org/Config_Reference.html" target="_blank" class="d-none d-md-flex"><v-icon small class="mr-1">mdi-help</v-icon>{{ $t('Settings.ConfigFilesPanel.ConfigReference') }}</v-btn>
<v-divider white vertical v-if="currentPath !== '/config_examples'" class="d-none d-md-flex"></v-divider>
<v-btn dark text @click="saveFile(false)" v-if="currentPath !== '/config_examples'"><v-icon small class="mr-1">mdi-content-save</v-icon><span class="d-none d-sm-inline">{{ $t('Setting.Save') }}</span></v-btn>
<v-btn dark text @click="saveFile(false)" v-if="currentPath !== '/config_examples'"><v-icon small class="mr-1">mdi-content-save</v-icon><span class="d-none d-sm-inline">{{ $t('Settings.ConfigFilesPanel.Save') }}</span></v-btn>
<v-divider white vertical v-if="currentPath !== '/config_examples' && !['printing', 'paused'].includes(printer_state)" class="d-none d-sm-flex"></v-divider>
<v-btn dark text @click="saveFile(true)" v-if="currentPath !== '/config_examples' && !['printing', 'paused'].includes(printer_state)" class="d-none d-sm-flex"><v-icon small class="mr-1">mdi-restart</v-icon>{{ $t('Setting.SaveRestart') }}</v-btn>
<v-btn dark text @click="saveFile(true)" v-if="currentPath !== '/config_examples' && !['printing', 'paused'].includes(printer_state)" class="d-none d-sm-flex"><v-icon small class="mr-1">mdi-restart</v-icon>{{ $t('Settings.ConfigFilesPanel.SaveRestart') }}</v-btn>
</v-toolbar-items>
</v-toolbar>
<prism-editor class="my-editor" v-model="editor.sourcecode" :readonly="editor.readonly" :highlight="highlighter" line-numbers></prism-editor>
@@ -144,40 +145,40 @@
</v-dialog>
<v-dialog v-model="dialogRenameFile.show" max-width="400">
<v-card>
<v-card-title class="headline">{{ $t('Setting.RenameFile') }}</v-card-title>
<v-card-title class="headline">{{ $t('Settings.ConfigFilesPanel.RenameFile') }}</v-card-title>
<v-card-text>
<v-text-field :label="$t('Setting.Name')" required v-model="dialogRenameFile.newName"></v-text-field>
<v-text-field :label="$t('Settings.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('Setting.Cancel') }}</v-btn>
<v-btn color="primary" text @click="renameFileAction">{{ $t('Setting.Rename') }}</v-btn>
<v-btn color="" text @click="dialogRenameFile.show = false">{{ $t('Settings.ConfigFilesPanel.Cancel') }}</v-btn>
<v-btn color="primary" text @click="renameFileAction">{{ $t('Settings.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('Setting.CreateFile') }}</v-card-title>
<v-card-title class="headline">{{ $t('Settings.ConfigFilesPanel.CreateFile') }}</v-card-title>
<v-card-text>
<v-text-field :label="$t('Setting.Name')" required v-model="dialogCreateFile.name"></v-text-field>
<v-text-field :label="$t('Settings.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('Setting.Cancel') }}</v-btn>
<v-btn color="primary" text @click="createFileAction">{{ $t('Setting.Create') }}</v-btn>
<v-btn color="" text @click="dialogCreateFile.show = false">{{ $t('Settings.ConfigFilesPanel.Cancel') }}</v-btn>
<v-btn color="primary" text @click="createFileAction">{{ $t('Settings.ConfigFilesPanel.Create') }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-dialog v-model="dialogCreateFolder.show" max-width="400">
<v-card>
<v-card-title class="headline">{{ $t('Setting.CreateFolder') }}</v-card-title>
<v-card-title class="headline">{{ $t('Settings.ConfigFilesPanel.CreateFolder') }}</v-card-title>
<v-card-text>
<v-text-field :label="$t('Setting.Name')" required v-model="dialogCreateFolder.name"></v-text-field>
<v-text-field :label="$t('Settings.ConfigFilesPanel.Name')" required v-model="dialogCreateFolder.name"></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="" text @click="dialogCreateFolder.show = false">{{ $t('Setting.Cancel') }}</v-btn>
<v-btn color="primary" text @click="createFolderAction">{{ $t('Setting.Create') }}</v-btn>
<v-btn color="" text @click="dialogCreateFolder.show = false">{{ $t('Settings.ConfigFilesPanel.Cancel') }}</v-btn>
<v-btn color="primary" text @click="createFolderAction">{{ $t('Settings.ConfigFilesPanel.Create') }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
@@ -190,7 +191,7 @@
dark
v-model="uploadSnackbar.status"
>
<span v-if="uploadSnackbar.max > 1" class="mr-1">({{ uploadSnackbar.number }}/{{ uploadSnackbar.max }})</span><strong>{{ $t('Setting.Uploading') }} {{ uploadSnackbar.filename }}</strong><br />
<span v-if="uploadSnackbar.max > 1" class="mr-1">({{ uploadSnackbar.number }}/{{ uploadSnackbar.max }})</span><strong>{{ $t('Settings.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 }">
@@ -234,9 +235,9 @@
selected: [],
headers: [
{ text: '', value: '', },
{ text: this.$t('Setting.Name'), value: 'filename', },
{ text: this.$t('Setting.Filesize'), value: 'size', align: 'right', },
{ text: this.$t('Setting.LastModified'), value: 'modified', align: 'right', },
{ text: this.$t('Settings.ConfigFilesPanel.Name'), value: 'filename', },
{ text: this.$t('Settings.ConfigFilesPanel.Filesize'), value: 'size', align: 'right', },
{ text: this.$t('Settings.ConfigFilesPanel.LastModified'), value: 'modified', align: 'right', },
],
options: {
},
@@ -321,7 +322,7 @@
highlighter(code) {
return highlight(code, languages.ini); //returns html
},
refreshFileList: function() {
refreshFileList() {
if (this.currentPath === "") {
this.$socket.sendObj('server.files.get_directory', { path: 'config' }, 'files/getDirectory');
this.$socket.sendObj('server.files.get_directory', { path: 'config_examples' }, 'files/getDirectory');
@@ -377,7 +378,7 @@
}
return items;
},
loadPath: function() {
loadPath() {
let dirArray = this.currentPath.substring(1).split("/");
this.files = findDirectory(this.filetree, dirArray);
@@ -389,30 +390,35 @@
this.files = this.files.filter(file => file.filename.substr(0, 1) !== ".");
}
},
clickRow: function(item) {
if (!item.isDirectory) {
this.editor.showLoader = true;
this.editor.sourcecode = "";
this.editor.item = item;
clickRow(item, force = false) {
if (!this.contextMenu.shown || force) {
if (force) {
this.contextMenu.shown = false;
}
if (!item.isDirectory) {
this.editor.showLoader = true;
this.editor.sourcecode = "";
this.editor.item = item;
let url = '//'+this.hostname+':'+this.port+'/server/files'+this.currentPath+'/'+item.filename+'?time='+Date.now();
fetch(url, { cache: "no-cache" }).then(res => res.text()).then(file => {
this.editor.sourcecode = file;
this.editor.show = true;
this.editor.showLoader = false;
this.editor.readonly = false;
if (this.currentPath === '/config_examples') this.editor.readonly = true;
});
let url = '//' + this.hostname + ':' + this.port + '/server/files' + this.currentPath + '/' + item.filename + '?time=' + Date.now();
fetch(url, {cache: "no-cache"}).then(res => res.text()).then(file => {
this.editor.sourcecode = file;
this.editor.show = true;
this.editor.showLoader = false;
this.editor.readonly = false;
if (this.currentPath === '/config_examples') this.editor.readonly = true;
});
} else {
this.currentPath += "/"+item.filename;
this.currentPage = 1;
} else {
this.currentPath += "/" + item.filename;
this.currentPage = 1;
}
}
},
clickRowGoBack: function() {
clickRowGoBack() {
this.currentPath = this.currentPath.substr(0, this.currentPath.lastIndexOf("/"));
},
saveFile: function(boolRestart = false) {
saveFile(boolRestart = false) {
let file = new File([this.editor.sourcecode], this.editor.item.filename);
let formData = new FormData();
@@ -440,14 +446,16 @@
});
},
showContextMenu (e, item) {
e.preventDefault();
this.contextMenu.shown = true;
this.contextMenu.x = e.clientX;
this.contextMenu.y = e.clientY;
this.contextMenu.item = item;
this.$nextTick(() => {
this.contextMenu.shown = true
});
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() {
let filename = (this.currentPath+"/"+this.contextMenu.item.filename);
@@ -507,10 +515,10 @@
removeFile() {
this.$socket.sendObj('server.files.delete_file', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteFile');
},
deleteDirectoryAction: function() {
deleteDirectoryAction() {
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteDir');
},
uploadFileButton: function() {
uploadFileButton() {
this.$refs.fileUpload.click()
},
async uploadFile() {
@@ -533,7 +541,7 @@
this.$refs.fileUpload.value = ''
}
},
doUploadFile: function(file) {
doUploadFile(file) {
let toast = this.$toast;
let formData = new FormData();
let filename = file.name.replace(" ", "_");
@@ -579,7 +587,7 @@
})
})
},
cancelUpload: function() {
cancelUpload() {
this.uploadSnackbar.cancelTokenSource.cancel()
this.uploadSnackbar.status = false
},