GCodeListr in config
This commit is contained in:
@@ -115,7 +115,8 @@ module.exports = new Vue({
|
||||
ip: "<>",
|
||||
wifiName: "not connected",
|
||||
macros:[{},{},{},{},{},{},{},{}],
|
||||
macrosList:[]
|
||||
macrosList:[],
|
||||
GCodeList:[]
|
||||
},
|
||||
state: {
|
||||
messages: [],
|
||||
|
||||
@@ -205,8 +205,8 @@ module.exports = {
|
||||
gcodeFiles: function () {
|
||||
const filesWithNoMacros=this.state.files.filter(item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name == item));
|
||||
console.log('filesWithNoMacros: ',filesWithNoMacros);
|
||||
console.log("this.config.gcodeList",this.config.gcodeList)
|
||||
const unionSet = new Set([...filesWithNoMacros, ...this.config.gcodeList]);
|
||||
console.log("this.config.GCodeList",this.config.GCodeList)
|
||||
const unionSet = new Set([...filesWithNoMacros, ...this.config.GCodeList]);
|
||||
const files = [...unionSet];
|
||||
console.log("files: ",files);
|
||||
return files;
|
||||
@@ -278,7 +278,7 @@ module.exports = {
|
||||
this.$dispatch("send", msg);
|
||||
},
|
||||
|
||||
load: function() {
|
||||
loadGCode: function() {
|
||||
const file_time = this.state.selected_time;
|
||||
const file = this.state.selected;
|
||||
if (this.last_file == file && this.last_file_time == file_time) {
|
||||
@@ -355,7 +355,7 @@ module.exports = {
|
||||
utils.clickFileInput("gcode-file-input");
|
||||
},
|
||||
|
||||
upload: async function(e) {
|
||||
uploadGCode: async function(e) {
|
||||
const files = e.target.files || e.dataTransfer.files;
|
||||
if (!files.length) {
|
||||
return;
|
||||
@@ -375,10 +375,10 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
const isAlreadyPresent = this.config.gcodeList.find((element) => element == file.name);
|
||||
const isAlreadyPresent = this.config.GCodeList.find((element) => element == file.name);
|
||||
if(isAlreadyPresent == undefined){
|
||||
console.log('new gcode file');
|
||||
this.config.gcodeList.push(file.name);
|
||||
this.config.GCodeList.push(file.name);
|
||||
try {
|
||||
await api.put("config/save", this.config);
|
||||
this.$dispatch("update");
|
||||
@@ -392,7 +392,7 @@ module.exports = {
|
||||
|
||||
if(this.config.macrosList.some(obj => obj.gcode_file_name == file.name)){
|
||||
console.log("It is a macros, remove it from macrosList")
|
||||
// this.config.gcodeList.push(file.name);
|
||||
// this.config.GCodeList.push(file.name);
|
||||
}
|
||||
|
||||
SvelteComponents.showDialog("Upload", {
|
||||
|
||||
@@ -164,7 +164,7 @@ module.exports = {
|
||||
|
||||
if (this.selectedValues[this.tab - 1] == "default") {
|
||||
var file = this.newGcode[this.tab - 1];
|
||||
this.uploadGCode(macrosName, file);
|
||||
this.uploadGCode(macrosName+'.ngc', file);
|
||||
}
|
||||
|
||||
this.config.macros[this.tab - 1].name = macrosName;
|
||||
|
||||
@@ -268,7 +268,7 @@ script#control-view-template(type="text/x-template")
|
||||
.fa.fa-folder-open
|
||||
|
||||
form.gcode-file-input.file-upload
|
||||
input(type="file", @change="upload", :disabled="!is_ready",
|
||||
input(type="file", @change="uploadGCode", :disabled="!is_ready",
|
||||
accept=".nc,.ngc,.gcode,.gc")
|
||||
|
||||
a(:disabled="!state.selected", download,
|
||||
@@ -295,7 +295,7 @@ script#control-view-template(type="text/x-template")
|
||||
| Selected
|
||||
|
||||
select(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="state.selected", @change="loadGCode", :disabled="!is_ready",
|
||||
style="max-width:100%")
|
||||
option(v-for="file in gcodeFiles", :value="file") {{file}}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ class Config(object):
|
||||
self.log = ctrl.log.get('Config')
|
||||
|
||||
self.values = {}
|
||||
self.values['gcodeList'] = []
|
||||
|
||||
try:
|
||||
self.version = "1.4.0"
|
||||
@@ -63,7 +62,6 @@ class Config(object):
|
||||
|
||||
try:
|
||||
self._upgrade(config)
|
||||
config['gcodeList'] = self.get('gcodeList', ["Test.ngc"])
|
||||
except Exception: self.log.exception('Internal error: Failed to upgrade config')
|
||||
|
||||
except Exception as e:
|
||||
@@ -86,7 +84,6 @@ class Config(object):
|
||||
self._upgrade(config)
|
||||
self._update(config, False)
|
||||
|
||||
config['gcodeList'] = self.get('gcodeList')
|
||||
|
||||
with open(self.ctrl.get_path('config.json'), 'w') as f:
|
||||
json.dump(config, f, indent=2)
|
||||
|
||||
@@ -690,6 +690,15 @@
|
||||
}
|
||||
},
|
||||
|
||||
"GCodeList": {
|
||||
"type": "list",
|
||||
"index": "numeric",
|
||||
"default": [ ],
|
||||
"template": {
|
||||
"type": "text"
|
||||
}
|
||||
},
|
||||
|
||||
"admin": {
|
||||
"auto-check-upgrade": {
|
||||
"type": "bool",
|
||||
|
||||
Reference in New Issue
Block a user