hotfix(gcodefiles): fix printed files filter

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej 2021-09-08 20:47:49 +02:00
parent 62afec1934
commit 2cf4d8ba58
2 changed files with 26 additions and 33 deletions

View File

@ -797,11 +797,11 @@ export default class PageFiles extends Mixins(BaseMixin) {
}
created() {
this.$socket.emit('server.files.get_directory', { path: this.currentPath }, { action: 'files/getDirectory' })
this.loadPath()
}
loadPath() {
this.$socket.emit('server.files.get_directory', { path: this.currentPath }, { action: 'files/getDirectory' })
let dirArray = this.currentPath.split("/")
this.files = findDirectory(this.filetree, dirArray)
if (this.files !== null) {
@ -809,46 +809,27 @@ export default class PageFiles extends Mixins(BaseMixin) {
this.files = this.files.filter(file => file.filename !== "thumbs" && file.filename.substr(0, 1) !== ".")
}
if (!this.showPrintedFiles) {
this.files = this.files.filter(file => this.$store.getters["server/history/getPrintStatus"]({
filename: (this.currentPath+"/"+file.filename).substr(7),
modified: file.modified.getTime()
}) !== 'completed')
this.files = this.files.filter(file => {
if (file.isDirectory) return true
else {
return (this.$store.getters["server/history/getPrintStatusByFilename"](
(this.currentPath+"/"+file.filename).substr(7),
file.modified.getTime()
) !== 'completed')
}
})
}
}
}
@Watch('filetree', { deep: true })
filetreeChanged(newVal: FileStateFile[]) {
let dirArray = this.currentPath.split("/");
this.files = findDirectory(newVal, dirArray);
if (this.files?.length && !this.showHiddenFiles) {
this.files = this.files.filter(file => file.filename !== "thumbs" && file.filename.substr(0, 1) !== ".");
}
if (this.files?.length && !this.showPrintedFiles) {
this.files = this.files.filter(file => this.$store.getters["server/history/getPrintStatus"]({
filename: (this.currentPath+"/"+file.filename).substr(7),
modified: new Date(file.modified).getTime()
}) !== 'completed')
}
filetreeChanged() {
this.loadPath()
}
@Watch('currentPath')
currentPathChanged(newVal: string) {
let dirArray = newVal.split("/");
this.files = findDirectory(this.filetree, dirArray);
if (this.files?.length && !this.showHiddenFiles) {
this.files = this.files.filter(file => file.filename !== "thumbs" && file.filename.substr(0, 1) !== ".");
}
if (this.files?.length && !this.showPrintedFiles) {
this.files = this.files.filter(file => this.$store.getters["server/history/getPrintStatus"]({
filename: (this.currentPath+"/"+file.filename).substr(7),
modified: new Date(file.modified).getTime()
}) !== 'completed')
}
currentPathChanged() {
this.loadPath()
}
formatPrintTime(totalSeconds: number) {

View File

@ -168,6 +168,18 @@ export const getters: GetterTree<ServerHistoryState, any> = {
return ""
},
getPrintStatusByFilename: (state) => (filename: string, modified: number) => {
if (state.jobs.length) {
const job = state.jobs.find((job) => {
return job.filename === filename && parseInt(job.metadata?.modified*1000) === modified
})
return job?.status ?? ""
}
return ""
},
getPrintStatusChipColor: () => (status: string) => {
switch(status) {
case 'in_progress': return 'blue accent-3' //'blue-grey darken-1'