Compare commits

...
15 Commits
Author SHA1 Message Date
Stefan Dej aaf934eaae push to v0.4.1
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-31 01:41:22 +01:00
Stefan Dej e44e3bc540 feature: add multi file upload in gcode-files & config-files
feature: add upload status in config-files

Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-31 01:37:58 +01:00
Stefan Dej 6856c9a99f bugfix: delete files with special chars in ConfigFilesPanel
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 22:53:42 +01:00
Stefan Dej d74e38d0ba bugfix: delete files with special chars (fix #149)
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 22:31:15 +01:00
Stefan Dej 4ec5ab0f53 change UpdateDialog to dark mode
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 21:44:42 +01:00
Stefan Dej 8226c32bb3 exclude sourceMaps to build release
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 05:22:41 +01:00
Stefan Dej 99f963df26 feature: gcode files fileupload progress
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 04:32:14 +01:00
Stefan Dej 07072ce2a1 feature: add customizing favicons
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-30 00:50:03 +01:00
Stefan Dej 983c5c9bda feature: add customizing sidebar logo
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-29 23:40:40 +01:00
Stefan Dej a8ea45d53c feature: add log during a update
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-29 23:20:14 +01:00
Stefan Dej 595e5bb4a0 upload customize guide
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-29 17:36:09 +01:00
Stefan Dej 2e7290210f upload customize guide
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-29 17:12:22 +01:00
Stefan Dej 9152934f9d update mainsail setup guide
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-28 23:59:49 +01:00
Stefan Dej 02eab15fe5 bugfix: first column width of gcode files & config files and centering the icons
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-28 17:02:58 +01:00
Stefan Dej 8d12bac8c8 bugfix: update manager > update mainsail button show the wrong state
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2020-12-27 22:02:22 +01:00
27 changed files with 541 additions and 97 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
---
layout: default
title: Additional Support
nav_order: 5
nav_order: 6
has_children: true
permalink: /additional
---
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+16
View File
@@ -0,0 +1,16 @@
---
layout: default
title: Custom CSS
parent: Customizing
nav_order: 99
permalink: /customizing/custom-css
---
## Custom-CSS
The custom.css file allows you to customize the appearance of Mainsail
without the need of rebuilding it. All you need to do is to place a file
named "custom.css" into the configuration directory ".theme" and define
your css rules in there.
![screenshot](../assets/img/customizing/screenshot-custom-css.png)
+15
View File
@@ -0,0 +1,15 @@
---
layout: default
title: Favicons
parent: Customizing
nav_order: 3
permalink: /customizing/favicons
---
## Custom favicon
Upload the images with the name "favicon-16x16.png" and "favicon-32x32.png"
to the .theme folder. Allowed extension is only .png. The "favicon-32x32.png"
is required. The "favicon-16x16.png" is optional. Maybe a hard refresh is
necessary (CTRL+SHIFT+F5 on windows or CMD+SHIFT+R on mac).
![screenshot](../assets/img/customizing/screenshot-favicons.png)
+22
View File
@@ -0,0 +1,22 @@
---
layout: default
title: Customizing
nav_order: 5
has_children: true
permalink: /customizing
---
# Customizing
Feel free to customize Mainsail to your preferences. At the moment there
are not many possibilities, but i will expand them continuously. If some features
are not yet listed below, please create a FR (feature request) on Github.
### currently supported functions
- [change sidebar logo](sidebar.md)
- [change sidebar background](sidebar.md)
- [change favicon](favicon.md)
- [upload custom.css](custom-css.md)
### cooming soon
- change primary color (all blue buttons atm)
+16
View File
@@ -0,0 +1,16 @@
---
layout: default
title: Prepare
parent: Customizing
nav_order: 1
permalink: /customizing/prepare
---
## Prepare theme
To prepare mainsail to use themes, you only have to create the ".theme" directory. Go into
"Settings" > "Machine" and check if you have enabled "Hidden files". Then you can create a
directory with the name ".theme". Important is the "." on the beginning. All further customizing
files, will be placed in this directory.
![screenshot](../assets/img/customizing/screenshot-display-hidden-files.png)
+22
View File
@@ -0,0 +1,22 @@
---
layout: default
title: Sidebar
parent: Customizing
nav_order: 2
permalink: /customizing/sidebar
---
## Sidebar customizing
### Change sidebar logo
Upload an image with the name "sidebar-logo" to the .theme folder.
Allowed file extensions for the image are: .svg, .jpg, .png and .gif.
![screenshot](../assets/img/customizing/screenshot-sidebar-logo.png)
### Change sidebar background image
Upload an image with the name "sidebar-background" to the .theme folder.
Allowed file extensions for the image are: .jpg, .png and .gif. The
recommended image size is 300x1000px.
![screenshot](../assets/img/customizing/screenshot-sidebar-background.png)
+3 -3
View File
@@ -31,13 +31,13 @@ Each file can be filled with the following content:
# /etc/nginx/conf.d/upstreams.conf
upstream apiserver {
#edit your api port here
#if you need to change your api port, edit it here
ip_hash;
server 127.0.0.1:7125;
}
upstream mjpgstreamer {
#edit your webcam port here
#if you need to change your webcam port, edit it here
ip_hash;
server 127.0.0.1:8081;
}
@@ -159,7 +159,7 @@ sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/
sudo service nginx restart
```
Now you can check again the API if it works with the reverse proxy. Open the url http://<printer-ip>/printer/info in your browser. if you see a content like this:
Now you can check again the API if it works with the reverse proxy. Open the url http://\<printer-ip\>/printer/info in your browser. if you see a content like this:
```
{"result": {"hostname": "voron250", "error_detected": false, "version": "v0.8.0-479-gd586fb06", "is_ready": true, "message": "Printer is ready", "cpu": "4 core ARMv7 Processor rev 4 (v7l)"}}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "mainsail",
"version": "0.4.0",
"version": "0.4.1",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
File renamed without changes.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

+24 -17
View File
@@ -25,7 +25,7 @@
:src="sidebarBackground"
>
<div id="nav-header">
<img :src="require('./assets/logo.svg')" />
<img :src="sidebarLogo" />
<v-toolbar-title>{{ printername !== "" ? printername : hostname }}</v-toolbar-title>
</div>
<ul class="navi" :expand="$vuetify.breakpoint.mdAndUp">
@@ -90,28 +90,24 @@
</v-card>
</v-dialog>
<v-dialog :value="!updateStatus" persistent width="500">
<v-card color="primary" dark >
<v-card-text class="pt-2">
{{ updateMessage}}
<v-progress-linear indeterminate color="white" class="mb-0 mt-2"></v-progress-linear>
</v-card-text>
</v-card>
</v-dialog>
<update-dialog></update-dialog>
</v-app>
</template>
<script>
import routes from './routes'
import { mapState, mapGetters } from 'vuex'
import TopCornerMenu from "@/components/TopCornerMenu";
import TopCornerMenu from "@/components/TopCornerMenu"
import UpdateDialog from "@/components/UpdateDialog"
export default {
props: {
source: String,
},
components: {
TopCornerMenu
UpdateDialog,
TopCornerMenu,
},
data: () => ({
overlayDisconnect: true,
@@ -144,9 +140,6 @@ export default {
save_config_pending: state => state.printer.configfile.save_config_pending,
klipperVersion: state => state.printer.software_version,
updateStatus: state => state.server.updateManager.updateResponse.complete,
updateMessage: state => state.server.updateManager.updateResponse.message,
}),
...mapGetters([
'getTitle',
@@ -157,6 +150,16 @@ export default {
return this.$store.getters["printer/getPrintPercent"]
}
},
defaultFavicons: {
get() {
return this.$store.getters["files/getFavicons"]
}
},
sidebarLogo: {
get() {
return this.$store.getters["files/getSidebarLogo"]
}
},
sidebarBackground: {
get() {
return this.$store.getters["files/getSidebarBackground"]
@@ -220,11 +223,12 @@ export default {
context.fillStyle = "#e41313";
context.fill();
favicon16.href = canvas.toDataURL('image/png')
//favicon16.href = canvas.toDataURL('image/png')
favicon32.href = canvas.toDataURL('image/png')
} else {
favicon16.href = "/img/icons/favicon-16x16.png"
favicon32.href = "/img/icons/favicon-32x32.png"
const [favicon16Default, favicon32Default] = this.defaultFavicons
favicon16.href = favicon16Default
favicon32.href = favicon32Default
}
}
},
@@ -259,6 +263,9 @@ export default {
let style = document.getElementById("customStylesheet")
if (style) style.remove()
}
},
defaultFavicons() {
this.drawFavicon(this.print_percent);
}
},
}
+139
View File
@@ -0,0 +1,139 @@
<style scoped>
.updaterLog {
height: 350px;
max-height: 350px;
overflow-y: auto;
}
.updaterLog .title-cell {
white-space: nowrap;
}
.updaterLog.v-data-table > .v-data-table__wrapper > table > tbody > tr > td {
height: auto;
}
</style>
<template>
<v-dialog :value="application !== ''" persistent width="60%" max-width="800">
<v-card
dark
:loading="!complete"
>
<template slot="progress">
<v-progress-linear color="primary" indeterminate></v-progress-linear>
</template>
<v-toolbar flat dense >
<v-toolbar-title>
<span class="subheading"><v-icon left>mdi-update</v-icon>Updating {{ application }}{{ complete ? " done!" : "..." }}</span>
</v-toolbar-title>
</v-toolbar>
<v-card-text class="pt-6 pb-2">
<v-data-table
:headers="headers"
:options="options"
:items="messages"
item-key="date"
hide-default-footer
hide-default-header
disable-pagination
class="updaterLog"
ref="updaterLog"
:custom-sort="customSort"
sort-by="date"
:sort-desc="true"
color="primary"
>
<template #no-data>
<div class="py-2">empty</div>
</template>
<template #item="{ item }">
<tr>
<td class="log-cell title-cell py-2">
{{ formatTime(item.date)}}
</td>
<td class="log-cell content-cell pl-0 py-2" colspan="2" style="width:100%;">
<span v-if="item.message" class="message" v-html="item.message"></span>
</td>
</tr>
</template>
</v-data-table>
<v-row>
<v-col class="text-center pt-5">
<v-btn @click="close" :disabled="!complete" color="primary">close</v-btn>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-dialog>
</template>
<script>
import {mapState} from "vuex";
export default {
name: "UpdateDialog.vue",
data: function() {
return {
headers: [
{
text: 'Date',
value: 'date',
width: '1%',
dateType: 'Date',
}, {
text: 'Message',
sortable: false,
value: 'message',
width: '99%'
},
],
options: {
},
}
},
computed: {
...mapState({
application: state => state.server.updateManager.updateResponse.application,
complete: state => state.server.updateManager.updateResponse.complete,
messages: state => state.server.updateManager.updateResponse.messages,
})
},
methods: {
formatTime(date) {
let hours = date.getHours();
if (hours < 10) hours = "0"+hours.toString();
let minutes = date.getMinutes();
if (minutes < 10) minutes = "0"+minutes.toString();
let seconds = date.getSeconds();
if (seconds < 10) seconds = "0"+seconds.toString();
return hours+":"+minutes+":"+seconds;
},
customSort: function(items, index, isDesc) {
items.sort((a, b) => {
if (index[0] === 'date') {
if (!isDesc[0]) return new Date(b[index]) - new Date(a[index]);
else return new Date(a[index]) - new Date(b[index]);
} else {
if(typeof a[index] !== 'undefined'){
if (!isDesc[0]) return a[index].toLowerCase().localeCompare(b[index].toLowerCase());
else return b[index].toLowerCase().localeCompare(a[index].toLowerCase());
}
}
});
return items;
},
close() {
if (this.application === "client" && this.complete) window.location.reload(true)
else this.$store.commit('server/updateManager/resetUpdateResponse')
}
},
updated(){
if (this.$refs.updaterLog) this.$refs.updaterLog.$el.scrollTop = this.$refs.updaterLog.$el.scrollHeight
}
}
</script>
+3 -1
View File
@@ -1,8 +1,10 @@
import panels from './panels'
import topCornerMenu from './TopCornerMenu'
import updateDialog from './UpdateDialog'
export default {
panels,
topCornerMenu
topCornerMenu,
updateDialog
}
@@ -30,7 +30,7 @@
<v-card-title>
Config Files
<v-spacer class="d-none d-sm-block"></v-spacer>
<input type="file" ref="fileUpload" style="display: none" @change="uploadFile" />
<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">
<v-btn v-if="currentPath !== '' && currentPath !== '/config_examples'" class="flex-grow-1" @click="uploadFileButton" :loading="loadings.includes['configFileUpload']"><v-icon>mdi-file-upload</v-icon></v-btn>
<v-btn v-if="currentPath !== '' && currentPath !== '/config_examples'" class="flex-grow-1" @click="createFile"><v-icon>mdi-file-plus</v-icon></v-btn>
@@ -73,7 +73,7 @@
<tr
class="file-list-cursor"
@click="clickRowGoBack">
<td class=" "><v-icon>mdi-folder-upload</v-icon></td>
<td class="pr-0 text-center" style="width: 32px;"><v-icon>mdi-folder-upload</v-icon></td>
<td class=" " colspan="8">..</td>
</tr>
</template>
@@ -84,7 +84,7 @@
@click="clickRow(item)"
class="file-list-cursor"
:data-name="item.filename">
<td class=" ">
<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>
@@ -176,6 +176,30 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
:timeout="-1"
:value="true"
fixed
right
bottom
dark
v-model="uploadSnackbar.status"
>
<span v-if="uploadSnackbar.max > 1" class="mr-1">({{ uploadSnackbar.number }}/{{ uploadSnackbar.max }})</span><strong>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>
@@ -243,6 +267,20 @@
show: false,
name: "",
},
uploadSnackbar: {
status: false,
filename: "",
percent: 0,
speed: 0,
total: 0,
number: 0,
max: 0,
cancelTokenSource: "",
lastProgress: {
time: 0,
loaded: 0
}
}
}
},
computed: {
@@ -453,14 +491,7 @@
}, 'files/getMove');
},
removeFile() {
let filename = (this.currentPath+"/"+this.contextMenu.item.filename);
axios.delete(
'//'+ this.hostname + ':' + this.port +'/server/files/'+filename
).then((result) => {
this.$toast.success(result.data.result+" successfully deleted.");
}).catch(() => {
this.$toast.error("Error! Cannot delete file.");
});
this.$socket.sendObj('server.files.delete_file', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteFile');
},
deleteDirectoryAction: function() {
this.$socket.sendObj('server.files.delete_directory', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteDir');
@@ -468,30 +499,75 @@
uploadFileButton: function() {
this.$refs.fileUpload.click()
},
uploadFile: function() {
async uploadFile() {
if (this.$refs.fileUpload.files.length) {
this.doUploadFile(this.$refs.fileUpload.files[0]).finally(() => {
this.$refs.fileUpload.value = ''
})
this.$store.commit('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.commit('socket/removeLoading', { name: 'configFileUpload' })
for(const file of successFiles) {
this.$toast.success("Upload of "+file+" successful!")
}
this.$refs.fileUpload.value = ''
}
},
doUploadFile: function(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', 'config');
formData.append('file', file, (this.currentPath+"/"+filename).substring(7));
this.$store.commit('socket/addLoading', { name: 'configFileUpload' });
return axios.post('//' + this.hostname + ':' + this.port + '/server/files/upload',
formData, { headers: { 'Content-Type': 'multipart/form-data' } }
).then((result) => {
this.$store.commit('socket/removeLoading', { name: 'configFileUpload' });
toast.success("Upload of "+result.data.result+" successful!");
}).catch(() => {
this.$store.commit('socket/removeLoading', { name: 'configFileUpload' });
toast.error("Cannot upload the file!");
});
return new Promise(resolve => {
this.uploadSnackbar.cancelTokenSource = axios.CancelToken.source();
axios.post('//' + this.hostname + ':' + this.port + '/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) => {
this.uploadSnackbar.status = false
resolve(result.data.result)
}).catch(() => {
this.uploadSnackbar.status = false
this.$store.commit('socket/removeLoading', { name: 'configFileUpload' });
toast.error("Cannot upload the file!");
})
})
},
cancelUpload: function() {
this.uploadSnackbar.cancelTokenSource.cancel()
this.uploadSnackbar.status = false
},
},
watch: {
+3 -12
View File
@@ -133,10 +133,7 @@
if ('current_hash' in object && 'remote_hash' in object && object.current_hash !== object.remote_hash) return 'primary'
if ('name' in object && object.name === "mainsail") {
let remote_version = object.remote_version.split(' ')
remote_version = (remote_version.length > 1) ? remote_version[1] : remote_version[0]
if (this.package_version !== remote_version) return 'primary'
if ('v'+this.package_version !== object.remote_version.replace('Version ', 'v')) return 'primary'
}
return 'green'
@@ -152,10 +149,7 @@
if ('current_hash' in object && 'remote_hash' in object && object.current_hash !== object.remote_hash) return 'update'
if ('name' in object && object.name === "mainsail") {
let remote_version = object.remote_version.split(' ')
remote_version = (remote_version.length > 1) ? remote_version[1] : remote_version[0]
if (this.package_version !== remote_version) return 'update'
if ('v'+this.package_version !== object.remote_version.replace('Version ', 'v')) return 'update'
}
return 'up-to-date'
@@ -171,10 +165,7 @@
if ('current_hash' in object && 'remote_hash' in object && object.current_hash !== object.remote_hash) return 'progress-upload'
if ('name' in object && object.name === "mainsail") {
let remote_version = object.remote_version.split(' ')
remote_version = (remote_version.length > 1) ? remote_version[1] : remote_version[0]
if (this.package_version !== remote_version) return 'progress-upload'
if ('v'+this.package_version !== object.remote_version.replace('Version ', 'v')) return 'progress-upload'
}
return 'check'
+108 -32
View File
@@ -53,7 +53,7 @@
<v-card-title>
G-Code Files
<v-spacer class="d-none d-sm-block"></v-spacer>
<input type="file" ref="fileUpload" style="display: none" @change="uploadFile" />
<input type="file" ref="fileUpload" accept=".gcode" 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" name="controllers">
<v-btn @click="clickUploadButton" title="Upload new Gcode" class="primary flex-grow-1" :loading="loadings.includes('gcodeUpload')"><v-icon>mdi-upload</v-icon></v-btn>
<v-btn @click="createDirectory" title="Create new Directory" class="flex-grow-1"><v-icon>mdi-folder-plus</v-icon></v-btn>
@@ -116,7 +116,7 @@
@click="clickRowGoBack"
@dragover="dragOverFilelist($event, {isDirectory: true, filename: '..'})" @dragleave="dragLeaveFilelist" @drop.prevent.stop="dragDropFilelist($event, {isDirectory: true, filename: '..'})"
>
<td class=" "><v-icon>mdi-folder-upload</v-icon></td>
<td class="pr-0 text-center" style="width: 32px;"><v-icon>mdi-folder-upload</v-icon></td>
<td class=" " colspan="8">..</td>
</tr>
</template>
@@ -132,7 +132,7 @@
@dragover="dragOverFilelist($event, item)" @dragleave="dragLeaveFilelist" @drop.prevent.stop="dragDropFilelist($event, item)"
:data-name="item.filename"
>
<td class="pr-0" style="width: 32px;">
<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 && !(item.thumbnails && item.thumbnails.length > 0)">mdi-file</v-icon>
<img v-if="!item.isDirectory && item.thumbnails && item.thumbnails.length > 0" :src="'data:image/gif;base64,'+(item.thumbnails.length ? item.thumbnails[0].data : '--')" />
@@ -231,6 +231,30 @@
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar
:timeout="-1"
:value="true"
fixed
right
bottom
dark
v-model="uploadSnackbar.status"
>
<span v-if="uploadSnackbar.max > 1" class="mr-1">({{ uploadSnackbar.number }}/{{ uploadSnackbar.max }})</span><strong>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>
@@ -298,7 +322,21 @@
},
input_rules: [
value => value.indexOf(" ") === -1 || 'Name contain spaces!'
]
],
uploadSnackbar: {
status: false,
filename: "",
percent: 0,
speed: 0,
total: 0,
number: 0,
max: 0,
cancelTokenSource: "",
lastProgress: {
time: 0,
loaded: 0
}
}
}
},
computed: {
@@ -354,11 +392,24 @@
})
},
methods: {
uploadFile: function() {
async uploadFile() {
if (this.$refs.fileUpload.files.length) {
this.doUploadFile(this.$refs.fileUpload.files[0]).finally(() => {
this.$refs.fileUpload.value = ''
})
this.$store.commit('socket/addLoading', { name: 'gcodeUpload' })
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.commit('socket/removeLoading', { name: 'gcodeUpload' })
for(const file of successFiles) {
this.$toast.success("Upload of "+file+" successful!")
}
this.$refs.fileUpload.value = ''
}
},
doUploadFile: function(file) {
@@ -366,22 +417,52 @@
let formData = new FormData()
let filename = file.name.replace(" ", "_")
formData.append('file', file, (this.currentPath+"/"+filename).substring(7))
this.$store.commit('socket/addLoading', { name: 'gcodeUpload' })
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
return axios.post('//' + this.hostname + ':' + this.port + '/server/files/upload',
formData, { headers: { 'Content-Type': 'multipart/form-data' } }
).then((result) => {
this.$store.commit('socket/removeLoading', { name: 'gcodeUpload' })
toast.success("Upload of "+result.data.result+" successful!");
}).catch(() => {
this.$store.commit('socket/removeLoading', { name: 'gcodeUpload' })
toast.error("Cannot upload the file!")
});
formData.append('file', file, (this.currentPath+"/"+filename).substring(7))
return new Promise(resolve => {
this.uploadSnackbar.cancelTokenSource = axios.CancelToken.source();
axios.post('//' + this.hostname + ':' + this.port + '/server/files/upload',
formData, {
cancelToken: this.uploadSnackbar.cancelTokenSource.token,
headers: { 'Content-Type': 'multipart/form-data' },
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) => {
this.uploadSnackbar.status = false
resolve(result.data.result)
}).catch(() => {
this.uploadSnackbar.status = false
this.$store.commit('socket/removeLoading', { name: 'gcodeUpload' })
toast.error("Cannot upload the file!")
})
})
},
clickUploadButton: function() {
this.$refs.fileUpload.click()
},
cancelUpload: function() {
this.uploadSnackbar.cancelTokenSource.cancel()
this.uploadSnackbar.status = false
},
refreshFileList: function() {
this.$socket.sendObj('server.files.get_directory', { path: this.currentPath }, 'files/getDirectory')
},
@@ -467,14 +548,7 @@
}, 'files/getMove');
},
removeFile() {
let filename = (this.currentPath+"/"+this.contextMenu.item.filename);
axios.delete(
'//'+ this.hostname + ':' + this.port +'/server/files/' + encodeURI(filename)
).then((result) => {
this.$toast.success(result.data.result+" successfully deleted.");
}).catch(() => {
this.$toast.error("Error! Cannot delete file.");
});
this.$socket.sendObj('server.files.delete_file', { path: this.currentPath+"/"+this.contextMenu.item.filename }, 'files/getDeleteFile');
},
createDirectory: function() {
this.dialogCreateDirectory.name = "";
@@ -672,11 +746,13 @@
displayMetadata: {
deep: true,
handler(newVal) {
Object.entries(newVal).forEach(value => {
if (this.headers.filter(header => header.value === value[0]).length) {
this.headers.filter(header => header.value === value[0])[0].visible = value[1];
}
});
if (newVal !== undefined && typeof(newVal) === 'object') {
Object.entries(newVal).forEach(value => {
if (this.headers.filter(header => header.value === value[0]).length) {
this.headers.filter(header => header.value === value[0])[0].visible = value[1];
}
})
}
}
},
showHiddenFiles: function() {
+1
View File
@@ -84,6 +84,7 @@ export default class WebSocketClient {
} else {
let result = data.result
if (result === "ok") result = { result: result }
if (typeof(result) === "string") result = { result: result }
let preload = {}
let wsData = this.wsData.filter(item => item.id === data.id)[0]
+11
View File
@@ -60,4 +60,15 @@ export default {
commit('void', null, { root: true });
}
},
getDeleteFile({ commit }, payload) {
if (payload.error) {
Vue.$toast.error(payload.error.message);
} else if ('result' in payload) {
let delPath = payload.result.substr(payload.result.lastIndexOf("/")+1);
Vue.$toast.success("Successfully deleted "+delPath);
commit('void', null, { root: true });
}
},
}
+35 -1
View File
@@ -3,6 +3,22 @@ import { themeDir } from "@/store/variables"
export default {
getSidebarLogo: (state, getters, rootState, rootGetters) => {
let configDir = findDirectory(state.filetree, ['config', themeDir])
let file = configDir.find(element =>
element.filename !== undefined && (
element.filename === 'sidebar-logo.svg' ||
element.filename === 'sidebar-logo.jpg' ||
element.filename === 'sidebar-logo.png' ||
element.filename === 'sidebar-logo.gif'
)
)
if (file) return rootGetters["socket/getUrl"]+'/server/files/config/'+themeDir+'/'+file.filename
return '/img/logo.svg'
},
getSidebarBackground: (state, getters, rootState, rootGetters) => {
let configDir = findDirectory(state.filetree, ['config', themeDir])
@@ -25,5 +41,23 @@ export default {
if (file) return rootGetters["socket/getUrl"]+'/server/files/config/'+themeDir+'/'+file.filename
return null
}
},
getFavicons: (state, getters, rootState, rootGetters) => {
let configDir = findDirectory(state.filetree, ['config', themeDir])
let favicon16 = configDir.find(element => element.filename !== undefined && element.filename === 'favicon-16x16.png')
if (favicon16) favicon16 = rootGetters["socket/getUrl"]+'/server/files/config/'+themeDir+'/'+favicon16.filename
let favicon16Default = '/img/favicon-16x16.png'
let favicon32 = configDir.find(element => element.filename !== undefined && element.filename === 'favicon-32x32.png')
if (favicon32) favicon32 = rootGetters["socket/getUrl"]+'/server/files/config/'+themeDir+'/'+favicon32.filename
let favicon32Default = '/img/favicon-32x32.png'
if (favicon16 && favicon32) return [favicon16, favicon32]
else if (favicon16) return [favicon16, favicon16]
else if (favicon32) return [favicon32, favicon32]
return [favicon16Default, favicon32Default]
},
}
+1 -1
View File
@@ -10,7 +10,7 @@ export function getDefaultState() {
updateResponse: {
application: "",
complete: true,
message: "",
messages: [],
}
}
}
+18 -3
View File
@@ -18,9 +18,24 @@ export default {
}
},
setUpdateResponse(state, payload) {
Vue.set(state, 'updateResponse', payload)
addUpdateResponse(state, payload) {
if (state.updateResponse.application !== payload.application)
Vue.set(state.updateResponse, 'application', payload.application)
if (payload.application === "client" && payload.complete) window.location.reload(true)
if (state.updateResponse.complete !== payload.complete)
Vue.set(state.updateResponse, 'complete', payload.complete)
state.updateResponse.messages.push({
date: new Date(),
message: payload.message
})
},
resetUpdateResponse(state) {
Vue.set(state, 'updateResponse', {
application: '',
complete: true,
messages: []
})
}
}
+1 -1
View File
@@ -71,7 +71,7 @@ export default {
break
case 'notify_update_response':
commit('server/updateManager/setUpdateResponse', payload.params[0], { root: true })
commit('server/updateManager/addUpdateResponse', payload.params[0], { root: true })
break
default:
+1
View File
@@ -4,6 +4,7 @@ const packageJson = fs.readFileSync('./package.json')
const version = JSON.parse(packageJson).version || 0
module.exports = {
productionSourceMap: false,
"transpileDependencies": [
"vuetify"
],