bugfix: update notify_filelist_changed
Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
<v-btn color="primary ml-4 " :loading="loadingGcodeUpload" @click="clickUploadButton"><v-icon>mdi-upload</v-icon>Upload</v-btn>
|
<v-btn color="primary ml-4 " :loading="loadingGcodeUpload" @click="clickUploadButton"><v-icon>mdi-upload</v-icon>Upload</v-btn>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle>
|
<v-card-subtitle>
|
||||||
Current path: {{ this.currentPath }}
|
Current path: {{ this.currentPath !== 'gcodes' ? "/"+this.currentPath.substring(7) : "/" }}
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@@ -231,7 +231,7 @@
|
|||||||
import { mapState, mapGetters } from 'vuex';
|
import { mapState, mapGetters } from 'vuex';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { findDirectory } from "../plugins/helpers";
|
import { findDirectory } from "../plugins/helpers";
|
||||||
import Vue from "vue";
|
/*import Vue from "vue";*/
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
@@ -335,12 +335,6 @@
|
|||||||
).then((result) => {
|
).then((result) => {
|
||||||
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
|
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
|
||||||
toast.success("Upload of "+result.data.result+" successful!");
|
toast.success("Upload of "+result.data.result+" successful!");
|
||||||
this.$socket.sendObj('get_directory', { path: this.currentPath }, 'getDirectory');
|
|
||||||
|
|
||||||
let filename = (this.currentPath+"/"+file.name).substring(7);
|
|
||||||
setTimeout(function() {
|
|
||||||
Vue.prototype.$socket.sendObj("get_file_metadata", { filename: filename }, "getMetadata");
|
|
||||||
}, 1000);
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
|
this.$store.commit('removeLoading', { name: 'loadingGcodeUpload' });
|
||||||
@@ -435,7 +429,6 @@
|
|||||||
'http://'+ this.hostname + ':' + this.port +'/server/files/'+filename
|
'http://'+ this.hostname + ':' + this.port +'/server/files/'+filename
|
||||||
).then((result) => {
|
).then((result) => {
|
||||||
this.$toast.success(result.data.result+" successfully deleted.");
|
this.$toast.success(result.data.result+" successfully deleted.");
|
||||||
this.$socket.sendObj('get_directory', { path: this.currentPath }, 'getDirectory');
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.$toast.error("Error! Cannot delete file.");
|
this.$toast.error("Error! Cannot delete file.");
|
||||||
});
|
});
|
||||||
@@ -538,9 +531,14 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.target.parentElement.style.backgroundColor = 'transparent';
|
e.target.parentElement.style.backgroundColor = 'transparent';
|
||||||
|
|
||||||
|
let dest = "";
|
||||||
|
if (row.filename === '..') {
|
||||||
|
dest = this.currentPath.substring(0, this.currentPath.lastIndexOf("/") + 1)+this.draggingFile.item.filename;
|
||||||
|
} else dest = this.currentPath+"/"+row.filename+"/"+this.draggingFile.item.filename;
|
||||||
|
|
||||||
this.$socket.sendObj('post_file_move', {
|
this.$socket.sendObj('post_file_move', {
|
||||||
source: this.currentPath+"/"+this.draggingFile.item.filename,
|
source: this.currentPath+"/"+this.draggingFile.item.filename,
|
||||||
dest: this.currentPath+"/"+row.filename+"/"+this.draggingFile.item.filename,
|
dest: dest
|
||||||
}, 'getPostFileMove');
|
}, 'getPostFileMove');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -36,7 +36,31 @@ export default {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'notify_filelist_changed':
|
case 'notify_filelist_changed':
|
||||||
commit('setFileList', data.params[0].filelist);
|
switch(data.params[0].action) {
|
||||||
|
case 'added':
|
||||||
|
commit('setFileChangeAdded', data.params[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'removed':
|
||||||
|
commit('setFileChangeRemoved', data.params[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'file_move':
|
||||||
|
commit('setFileChangeFileMove', data.params[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'add_directory':
|
||||||
|
commit('setFileChangeAddDirectory', data.params[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'delete_directory':
|
||||||
|
commit('setFileChangeDeleteDirectory', data.params[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
window.console.error("Unknown filelist_changed action: "+data.params[0].action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -96,7 +120,6 @@ export default {
|
|||||||
idle_timeout: [],
|
idle_timeout: [],
|
||||||
display_status: [],
|
display_status: [],
|
||||||
});
|
});
|
||||||
Vue.prototype.$socket.sendObj('get_file_list', {}, 'getFileList');
|
|
||||||
Vue.prototype.$socket.sendObj('get_directory', { path: 'gcodes' }, 'getDirectory');
|
Vue.prototype.$socket.sendObj('get_directory', { path: 'gcodes' }, 'getDirectory');
|
||||||
Vue.prototype.$socket.sendObj('get_printer_gcode_help', {}, 'getHelpList');
|
Vue.prototype.$socket.sendObj('get_printer_gcode_help', {}, 'getHelpList');
|
||||||
} else if (data !== undefined && !data.is_ready) commit('setKlippyStatus', 'disconnect');
|
} else if (data !== undefined && !data.is_ready) commit('setKlippyStatus', 'disconnect');
|
||||||
@@ -157,11 +180,6 @@ export default {
|
|||||||
commit('setPrinterConfig', data);
|
commit('setPrinterConfig', data);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFileList({ commit }, data) {
|
|
||||||
commit('setFileList', data);
|
|
||||||
commit('removeLoading', 'loadingGcodeRefresh');
|
|
||||||
},
|
|
||||||
|
|
||||||
getDirectory({ commit }, data) {
|
getDirectory({ commit }, data) {
|
||||||
commit('setDirectory', data);
|
commit('setDirectory', data);
|
||||||
commit('removeLoading', { name: 'loadingGcodeRefresh' });
|
commit('removeLoading', { name: 'loadingGcodeRefresh' });
|
||||||
@@ -179,11 +197,9 @@ export default {
|
|||||||
if (data.error) {
|
if (data.error) {
|
||||||
Vue.$toast.error(data.error.message);
|
Vue.$toast.error(data.error.message);
|
||||||
} else if (data.result === "ok") {
|
} else if (data.result === "ok") {
|
||||||
let currentPath = data.requestParams.path.substr(0, data.requestParams.path.lastIndexOf("/"));
|
|
||||||
let newPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
|
let newPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
|
||||||
|
|
||||||
Vue.$toast.success("Successfully created "+newPath);
|
Vue.$toast.success("Successfully created "+newPath);
|
||||||
Vue.prototype.$socket.sendObj('get_directory', { path: currentPath }, 'getDirectory');
|
|
||||||
commit('voidMutation');
|
commit('voidMutation');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -192,15 +208,10 @@ export default {
|
|||||||
if (data.error) {
|
if (data.error) {
|
||||||
Vue.$toast.error(data.error.message);
|
Vue.$toast.error(data.error.message);
|
||||||
} else if (data.result === "ok") {
|
} else if (data.result === "ok") {
|
||||||
let currentPath = data.requestParams.path.substr(0, data.requestParams.path.lastIndexOf("/"));
|
|
||||||
let delPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
|
let delPath = data.requestParams.path.substr(data.requestParams.path.lastIndexOf("/")+1);
|
||||||
|
|
||||||
Vue.$toast.success("Successfully deleted "+delPath);
|
Vue.$toast.success("Successfully deleted "+delPath);
|
||||||
//Vue.prototype.$socket.sendObj('get_directory', { path: currentPath }, 'getDirectory');
|
commit('voidMutation');
|
||||||
commit('removeDirFromFiletree', {
|
|
||||||
currentPath: currentPath,
|
|
||||||
delPathName: delPath
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -214,11 +225,7 @@ export default {
|
|||||||
|
|
||||||
if (sourceDir === destDir) Vue.$toast.success("Successfully renamed "+filename);
|
if (sourceDir === destDir) Vue.$toast.success("Successfully renamed "+filename);
|
||||||
else Vue.$toast.success("Successfully moved "+filename);
|
else Vue.$toast.success("Successfully moved "+filename);
|
||||||
|
commit('voidMutation');
|
||||||
commit('renameMetadataFilename', {
|
|
||||||
source: data.requestParams.source,
|
|
||||||
dest: data.requestParams.dest
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -215,29 +215,74 @@ export default {
|
|||||||
if (data.configfile) Vue.set(state, 'config', data.configfile.config);
|
if (data.configfile) Vue.set(state, 'config', data.configfile.config);
|
||||||
},
|
},
|
||||||
|
|
||||||
setFileList(state, data) {
|
setFileChangeAdded(state, data) {
|
||||||
state.files = [];
|
let filename = data.filename.substr(data.filename.lastIndexOf("/")).replace("/", "");
|
||||||
//window.console.log(data);
|
let path = data.filename.substr(0, data.filename.lastIndexOf("/"));
|
||||||
let array = Object.entries(data);
|
let parent = findDirectory(state.filetree, (data.root+"/"+path).split("/"));
|
||||||
|
|
||||||
for (let [key, file] of array) {
|
if (parent) {
|
||||||
if (file.filename !== "gui.json") {
|
parent.push({
|
||||||
state.files.push({
|
isDirectory: false,
|
||||||
number: key,
|
filename: filename,
|
||||||
filename: file.filename,
|
modified: new Date(),
|
||||||
modified: Date.parse(file.modified),
|
size: 0,
|
||||||
size: file.size,
|
metadataPulled: false,
|
||||||
slicer: file.slicer,
|
});
|
||||||
filament_total: file.filament_total,
|
|
||||||
estimated_time: file.estimated_time,
|
setTimeout(function() {
|
||||||
layer_height: file.layer_height,
|
Vue.prototype.$socket.sendObj("get_file_metadata", { filename: data.filename }, "getMetadata");
|
||||||
first_layer_height: file.first_layer_height,
|
}, 500);
|
||||||
object_height: file.object_height,
|
}
|
||||||
thumbnails : file.thumbnails ? file.thumbnails : [],
|
},
|
||||||
|
|
||||||
|
setFileChangeRemoved(state, data) {
|
||||||
|
let currentPath = data.filename.substr(0, data.filename.lastIndexOf("/"));
|
||||||
|
let delPath = data.filename.substr(data.filename.lastIndexOf("/")+1);
|
||||||
|
currentPath = findDirectory(state.filetree, (data.root+"/"+currentPath).split("/"));
|
||||||
|
let index = currentPath.findIndex(element => element.filename === delPath);
|
||||||
|
|
||||||
|
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
setFileChangeFileMove(state, data) {
|
||||||
|
let oldPath = data.prev_file.substr(0, data.prev_file.lastIndexOf("/") + 1);
|
||||||
|
let newPath = data.filename.substr(0, data.filename.lastIndexOf("/") + 1);
|
||||||
|
let filenameOld = data.prev_file.substr(data.prev_file.lastIndexOf("/")+1);
|
||||||
|
let filenameNew = data.filename.substr(data.filename.lastIndexOf("/")+1);
|
||||||
|
|
||||||
|
oldPath = findDirectory(state.filetree, (data.root+"/"+oldPath).split("/"));
|
||||||
|
let indexFile = oldPath.findIndex(element => element.filename === filenameOld);
|
||||||
|
|
||||||
|
if (indexFile >= 0 && oldPath[indexFile]) {
|
||||||
|
let file = oldPath.splice(indexFile, 1)[0];
|
||||||
|
file.filename = filenameNew;
|
||||||
|
newPath = findDirectory(state.filetree, (data.root+"/"+newPath).split("/"));
|
||||||
|
newPath.push(file);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setFileChangeAddDirectory(state, data) {
|
||||||
|
let filename = data.filename.substr(data.filename.lastIndexOf("/") + 1);
|
||||||
|
let path = data.filename.substr(0, data.filename.lastIndexOf("/"));
|
||||||
|
let parent = findDirectory(state.filetree, (data.root+"/"+path).split("/"));
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
|
parent.push({
|
||||||
|
isDirectory: true,
|
||||||
|
filename: filename,
|
||||||
|
modified: new Date(),
|
||||||
|
childrens: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
//state.files = data;
|
|
||||||
|
setFileChangeDeleteDirectory(state, data) {
|
||||||
|
let currentPath = data.filename.substr(0, data.filename.lastIndexOf("/"));
|
||||||
|
let delPath = data.filename.substr(data.filename.lastIndexOf("/")+1);
|
||||||
|
currentPath = findDirectory(state.filetree, (data.root+"/"+currentPath).split("/"));
|
||||||
|
let index = currentPath.findIndex(element => element.filename === delPath);
|
||||||
|
|
||||||
|
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
setDirectory(state, data) {
|
setDirectory(state, data) {
|
||||||
@@ -311,6 +356,8 @@ export default {
|
|||||||
slicer: data.slicer ? data.slicer : undefined,
|
slicer: data.slicer ? data.slicer : undefined,
|
||||||
thumbnails: data.thumbnails ? data.thumbnails : undefined,
|
thumbnails: data.thumbnails ? data.thumbnails : undefined,
|
||||||
metadataPulled: true,
|
metadataPulled: true,
|
||||||
|
modified: Date.parse(data.modified),
|
||||||
|
size: parseInt(data.size),
|
||||||
};
|
};
|
||||||
|
|
||||||
let newObject = Object.assign(path[index], newData);
|
let newObject = Object.assign(path[index], newData);
|
||||||
@@ -351,14 +398,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeDirFromFiletree(state, data) {
|
|
||||||
let currentPathArray = data.currentPath.split("/");
|
|
||||||
let currentPath = findDirectory(state.filetree, currentPathArray);
|
|
||||||
let index = currentPath.findIndex(element => element.filename === data.delPathName);
|
|
||||||
|
|
||||||
if (index >= 0 && currentPath[index]) currentPath.splice(index, 1);
|
|
||||||
},
|
|
||||||
|
|
||||||
setHelpList(state, data) {
|
setHelpList(state, data) {
|
||||||
state.helplist = [];
|
state.helplist = [];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user