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