loading g-codes,

This commit is contained in:
sanjayk03-dev
2024-01-22 01:45:57 +05:30
parent 293e1f7420
commit b8394d7266
2 changed files with 39 additions and 41 deletions

View File

@@ -23,6 +23,7 @@ module.exports = {
"default", "default",
], ],
newGcode: ["", "", "", "", "", "", "", ""], newGcode: ["", "", "", "", "", "", "", ""],
macrosList: this.config.macros.map((item) => item.name),
}; };
}, },
computed: { computed: {
@@ -54,19 +55,15 @@ module.exports = {
cache: "no-cache", cache: "no-cache",
}); });
const text = (await response.text()).split(" ").join("\n"); const text = (await response.text()).split(" ").join("\n");
console.log(text);
Vue.nextTick(() => {
if (text.length > 20e6) { if (text.length > 20e6) {
this.newGcode[this.tab - 1] = "File is large - gcode view disabled"; this.newGcode[this.tab - 1] = "File is large - gcode view disabled";
} else { } else {
this.newGcode[this.tab - 1] = text; this.newGcode[this.tab - 1] = text;
} }
});
} else { } else {
Vue.nextTick(() => {
this.newGcode[this.tab - 1] = ""; this.newGcode[this.tab - 1] = "";
});
} }
console.log(this.newGcode[this.tab-1]);
}, },
upload: function (e) { upload: function (e) {
const files = e.target.files || e.dataTransfer.files; const files = e.target.files || e.dataTransfer.files;
@@ -131,27 +128,27 @@ module.exports = {
console.log(this.state.selected, this.state.selected_time); console.log(this.state.selected, this.state.selected_time);
console.log(this.selectedValues[this.tab - 1]); console.log(this.selectedValues[this.tab - 1]);
// if (this.state.selected == "default") { if (this.state.selected == "default") {
// var file = this.newGcode[this.tab - 1]; var file = this.newGcode[this.tab - 1];
// this.uploadGCode(macrosName, file); this.uploadGCode(macrosName, file);
// } }
// this.config.macros[this.tab - 1].name = macrosName; this.config.macros[this.tab - 1].name = macrosName;
// this.config.macros[this.tab - 1].color = macrosColor; this.config.macros[this.tab - 1].color = macrosColor;
// this.config.macros[this.tab - 1].gcode_file_name = this.config.macros[this.tab - 1].gcode_file_name =
// this.state.selected == "default" ? macrosName : this.state.selected; this.state.selected == "default" ? macrosName : this.state.selected;
// this.config.macros[this.tab - 1].gcode_file_time = this.config.macros[this.tab - 1].gcode_file_time =
// this.state.selected_time; this.state.selected_time;
// this.cancelMacros(this.tab - 1); this.cancelMacros(this.tab - 1);
// this.confirmSave = false; this.confirmSave = false;
// try { try {
// await api.put("config/save", this.config); await api.put("config/save", this.config);
// console.log("Successfully saved"); console.log("Successfully saved");
// this.$dispatch("update"); this.$dispatch("update");
// } catch (error) { } catch (error) {
// console.error("Restore Failed: ", error); console.error("Restore Failed: ", error);
// alert("Restore failed"); alert("Restore failed");
// } }
}, },
cancelMacros: function () { cancelMacros: function () {
document.getElementById(`macros-name-${this.tab - 1}`).value = ""; document.getElementById(`macros-name-${this.tab - 1}`).value = "";
@@ -159,13 +156,13 @@ module.exports = {
document.getElementById(`gcodeSelect-${this.tab - 1}`).value = "default"; document.getElementById(`gcodeSelect-${this.tab - 1}`).value = "default";
this.newGcode[this.tab - 1] = ""; this.newGcode[this.tab - 1] = "";
}, },
macrosList: function () { // macrosList: function () {
const macros = this.state.files.filter( // const macros = this.state.files.filter(
(name) => !this.config.macros.some((obj) => obj.name === name) // (name) => !this.config.macros.some((obj) => obj.name === name)
); // );
console.log("Only Macros: ", macros); // console.log("Only Macros: ", macros);
return macros; // return macros;
}, // },
resetConfig: async function () { resetConfig: async function () {
this.config.macros = [ this.config.macros = [
{ {
@@ -226,8 +223,8 @@ module.exports = {
alert("Restore failed"); alert("Restore failed");
} }
}, },
},
printState: function () { printState: function () {
console.log(this.state); console.log(this.state);
}, },
},
}; };

View File

@@ -77,6 +77,7 @@ script#macros-template(type="text/x-template")
.gcodeContainer .gcodeContainer
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode") textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'") //- gcode-viewer(v-if="state.selected !== 'default'")
p.new-gcode {{newGcode[tab-1]}}
button.submit-macros(title="Save Macros",@click="confirmSave=true", button.submit-macros(title="Save Macros",@click="confirmSave=true",
style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border:0;margin-top:30px") Save
button.submit-macros(title="Cancel Macros",@click="cancelMacros", button.submit-macros(title="Cancel Macros",@click="cancelMacros",