settings dropdown individual, nexttick for textarea
This commit is contained in:
@@ -12,6 +12,16 @@ module.exports = {
|
||||
tab: "1",
|
||||
confirmReset: false,
|
||||
confirmSave: false,
|
||||
selectedValues: [
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
"default",
|
||||
],
|
||||
newGcode: ["", "", "", "", "", "", "", ""],
|
||||
};
|
||||
},
|
||||
@@ -38,19 +48,24 @@ module.exports = {
|
||||
utils.clickFileInput("gcode-file-input");
|
||||
},
|
||||
load: async function () {
|
||||
const file = this.state.selected;
|
||||
if(this.state.selected!='default'){
|
||||
const response = await fetch(`/api/file/${file}`, { cache: "no-cache" });
|
||||
const text = await response.text();
|
||||
const file = this.selectedValues[this.tab - 1];
|
||||
if (this.selectedValues[this.tab - 1] != "default") {
|
||||
const response = await fetch(`/api/file/${file}`, {
|
||||
cache: "no-cache",
|
||||
});
|
||||
const text = (await response.text()).split(" ").join("\n");
|
||||
console.log(text);
|
||||
if (text.length > 20e6) {
|
||||
this.newGcode[this.tab - 1] = "File is large - gcode view disabled";
|
||||
} else {
|
||||
this.newGcode[this.tab - 1] = text;
|
||||
}
|
||||
}else{
|
||||
this.newGcode='';
|
||||
} else {
|
||||
this.newGcode = "";
|
||||
}
|
||||
Vue.nextTick(() => {
|
||||
console.log("updated");
|
||||
});
|
||||
},
|
||||
upload: function (e) {
|
||||
const files = e.target.files || e.dataTransfer.files;
|
||||
@@ -103,7 +118,6 @@ module.exports = {
|
||||
|
||||
xhr.open("PUT", `/api/file/${encodeURIComponent(filename)}`, true);
|
||||
xhr.send(file);
|
||||
|
||||
},
|
||||
saveMacros: async function () {
|
||||
var macrosName = document.getElementById(
|
||||
@@ -113,33 +127,36 @@ module.exports = {
|
||||
`macros-color-${this.tab - 1}`
|
||||
).value;
|
||||
|
||||
if (this.state.selected == "default") {
|
||||
var file = this.newGcode[this.tab - 1];
|
||||
this.uploadGCode(macrosName, file);
|
||||
}
|
||||
console.log(this.state.selected, this.state.selected_time);
|
||||
console.log(this.selectedValues[this.tab - 1]);
|
||||
|
||||
this.config.macros[this.tab - 1].name = macrosName;
|
||||
this.config.macros[this.tab - 1].color = macrosColor;
|
||||
this.config.macros[this.tab - 1].gcode_file_name =
|
||||
this.state.selected == "default" ? macrosName : this.state.selected;
|
||||
this.config.macros[this.tab - 1].gcode_file_time =
|
||||
this.state.selected_time;
|
||||
this.cancelMacros(this.tab - 1);
|
||||
this.confirmSave = false;
|
||||
try {
|
||||
await api.put("config/save", this.config);
|
||||
console.log("Successfully saved");
|
||||
this.$dispatch("update");
|
||||
} catch (error) {
|
||||
console.error("Restore Failed: ", error);
|
||||
alert("Restore failed");
|
||||
}
|
||||
// if (this.state.selected == "default") {
|
||||
// var file = this.newGcode[this.tab - 1];
|
||||
// this.uploadGCode(macrosName, file);
|
||||
// }
|
||||
|
||||
// this.config.macros[this.tab - 1].name = macrosName;
|
||||
// this.config.macros[this.tab - 1].color = macrosColor;
|
||||
// this.config.macros[this.tab - 1].gcode_file_name =
|
||||
// this.state.selected == "default" ? macrosName : this.state.selected;
|
||||
// this.config.macros[this.tab - 1].gcode_file_time =
|
||||
// this.state.selected_time;
|
||||
// this.cancelMacros(this.tab - 1);
|
||||
// this.confirmSave = false;
|
||||
// try {
|
||||
// await api.put("config/save", this.config);
|
||||
// console.log("Successfully saved");
|
||||
// this.$dispatch("update");
|
||||
// } catch (error) {
|
||||
// console.error("Restore Failed: ", error);
|
||||
// alert("Restore failed");
|
||||
// }
|
||||
},
|
||||
cancelMacros: function () {
|
||||
document.getElementById(`macros-name-${this.tab - 1}`).value = "";
|
||||
document.getElementById(`macros-color-${this.tab - 1}`).value = "#ffffff";
|
||||
document.getElementById(`gcodeSelect-${this.tab - 1}`).value = "default";
|
||||
this.newGcode[this.tab-1] = '';
|
||||
this.newGcode[this.tab - 1] = "";
|
||||
},
|
||||
resetConfig: async function () {
|
||||
this.config.macros = [
|
||||
@@ -202,7 +219,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
},
|
||||
printState: function (){
|
||||
printState: function () {
|
||||
console.log(this.state);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-0(title="Select previously uploaded GCode programs.",selected
|
||||
v-model="state.selected",@change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]",@change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option( selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -91,7 +91,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-1(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -121,7 +121,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-2(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -151,7 +151,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-3(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -181,7 +181,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-4(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -211,7 +211,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-5(title="Select previously uploaded GCode programs.",
|
||||
v-model="state.selected", @change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]", @change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -241,7 +241,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-6(title="Select previously uploaded GCode programs.",selected
|
||||
v-model="state.selected",@change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]",@change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
@@ -271,7 +271,7 @@ script#macros-template(type="text/x-template")
|
||||
p.title G-Code
|
||||
.select-upload-gcode
|
||||
select#gcodeSelect-7(title="Select previously uploaded GCode programs.",selected
|
||||
v-model="state.selected",@change="load", :disabled="!is_ready",
|
||||
v-model="selectedValues[tab - 1]",@change="load", :disabled="!is_ready",
|
||||
style="max-width:100%;height:40px;border-radius:5px")
|
||||
option(selected='' value='default') Create G-Code
|
||||
option(v-for="file in state.files", :value="file") {{file}}
|
||||
|
||||
@@ -146,11 +146,6 @@ class State(object):
|
||||
files.append(filename)
|
||||
files.sort()
|
||||
self.set('files', files)
|
||||
self.log.info('===================')
|
||||
for i in files:
|
||||
self.log.info(i)
|
||||
self.log.info('===================')
|
||||
|
||||
self.select_file(filename)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user