changed gcode viewer in macros

This commit is contained in:
sanjayk03-dev
2024-01-21 22:52:49 +05:30
parent 0de1e234bf
commit d77e81aafb
4 changed files with 39 additions and 30 deletions

View File

@@ -15,11 +15,6 @@ module.exports = {
newGcode: ["", "", "", "", "", "", "", ""],
};
},
components: {
"axis-control": require("./axis-control"),
"path-viewer": require("./path-viewer"),
"gcode-viewer": require("./gcode-viewer"),
},
computed: {
mach_state: function () {
const cycle = this.state.cycle;
@@ -42,11 +37,15 @@ module.exports = {
open: function () {
utils.clickFileInput("gcode-file-input");
},
load: function () {
load: async function () {
const file = this.state.selected;
this.$broadcast("gcode-load", file);
this.$broadcast("gcode-line", this.state.line);
this.newGcode[this.tab - 1] = "";
const response = await fetch(`/api/file/${file}`, { cache: "no-cache" });
const text = await response.text();
if (text.length > 20e6) {
this.newGcode[this.tab - 1] = "File is large - gcode view disabled";
} else {
this.newGcode[this.tab - 1] = text;
}
},
upload: function (e) {
const files = e.target.files || e.dataTransfer.files;
@@ -72,11 +71,10 @@ module.exports = {
file,
onComplete: () => {
this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name);
},
});
},
uploadGCode: function (filename,file) {
uploadGCode: function (filename, file) {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
@@ -112,12 +110,13 @@ module.exports = {
if (this.state.selected == "default") {
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].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_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);
@@ -135,7 +134,7 @@ module.exports = {
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.$broadcast("gcode-clear");
this.newGcode[this.tab-1] = '';
},
resetConfig: async function () {
this.config.macros = [

View File

@@ -75,8 +75,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -105,8 +105,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -135,8 +135,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -165,8 +165,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -195,8 +195,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -225,8 +225,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -255,8 +255,8 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
@@ -285,9 +285,12 @@ script#macros-template(type="text/x-template")
accept=".nc,.ngc,.gcode,.gc")
br
.gcodeContainer
textarea.new-gcode( v-if="state.selected=='default'",:value='newGcode[tab-1]' @input="updateNewGcode")
gcode-viewer(v-if="state.selected !== 'default'")
textarea.new-gcode( :value='newGcode[tab-1]' @input="updateNewGcode")
//- gcode-viewer(v-if="state.selected !== 'default'")
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
button.submit-macros(title="Cancel Macros",@click="cancelMacros",
style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Cancel
button.submit-macros(title="Cancel Macros",@click="printState",
style="height:50px;width:140px;font-weight:normal;margin-left:5px;background-color:#f6f6f6;color:#000;border:0;margin-top:30px") Print State

View File

@@ -146,6 +146,10 @@ 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)

View File

@@ -628,8 +628,11 @@ span.unit
width 140px
font-weight normal
border-radius 10px
margin-left 1rem
border 0
color #fff
box-shadow rgba(0, 0, 0, 0.3) 0px 0px 5px
text-shadow: rgba(0, 0, 0, 0.8) 0px 0px 3px
#macros
width 104%