Fixed mainaining state while deleting, removed time from config

This commit is contained in:
sanjayk03-dev
2024-01-23 14:18:26 +05:30
parent 4d311bd083
commit aa48701bcc
3 changed files with 525 additions and 528 deletions

View File

@@ -22,18 +22,18 @@ module.exports = {
speed_override: 1, speed_override: 1,
feed_override: 1, feed_override: 1,
jog_incr_amounts: { jog_incr_amounts: {
"METRIC": { METRIC: {
fine: 0.1, fine: 0.1,
small: 1.0, small: 1.0,
medium: 10, medium: 10,
large: 100, large: 100,
}, },
"IMPERIAL": { IMPERIAL: {
fine: 0.005, fine: 0.005,
small: 0.05, small: 0.05,
medium: 0.5, medium: 0.5,
large: 5, large: 5,
} },
}, },
jog_incr: localStorage.getItem("jog_incr") || "small", jog_incr: localStorage.getItem("jog_incr") || "small",
jog_step: cookie.get_bool("jog-step"), jog_step: cookie.get_bool("jog-step"),
@@ -48,7 +48,7 @@ module.exports = {
components: { components: {
"axis-control": require("./axis-control"), "axis-control": require("./axis-control"),
"path-viewer": require("./path-viewer"), "path-viewer": require("./path-viewer"),
"gcode-viewer": require("./gcode-viewer") "gcode-viewer": require("./gcode-viewer"),
}, },
watch: { watch: {
@@ -58,11 +58,9 @@ module.exports = {
"state.metric": { "state.metric": {
handler: function (metric) { handler: function (metric) {
this.mach_units = metric this.mach_units = metric ? "METRIC" : "IMPERIAL";
? "METRIC"
: "IMPERIAL";
}, },
immediate: true immediate: true,
}, },
"state.line": function () { "state.line": function () {
@@ -81,7 +79,7 @@ module.exports = {
jog_adjust: function () { jog_adjust: function () {
cookie.set("jog-adjust", this.jog_adjust); cookie.set("jog-adjust", this.jog_adjust);
} },
}, },
computed: { computed: {
@@ -94,7 +92,7 @@ module.exports = {
this.config.settings.units = value; this.config.settings.units = value;
this.$root.display_units = value; this.$root.display_units = value;
this.$dispatch("config-changed"); this.$dispatch("config-changed");
} },
}, },
metric: function () { metric: function () {
@@ -203,14 +201,16 @@ module.exports = {
return Math.min(1, p); return Math.min(1, p);
}, },
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(
console.log('filesWithNoMacros: ',filesWithNoMacros); item => !this.config.macrosList.some(compareItem => compareItem.gcode_file_name == item),
console.log("this.state.GCodeList",this.state.GCodeList) );
console.log("filesWithNoMacros: ", filesWithNoMacros);
console.log("this.state.GCodeList", this.state.GCodeList);
const unionSet = new Set([...filesWithNoMacros, ...this.state.GCodeList]); const unionSet = new Set([...filesWithNoMacros, ...this.state.GCodeList]);
const files = [...unionSet]; const files = [...unionSet];
console.log("files: ", files); console.log("files: ", files);
return files; return files;
} },
}, },
events: { events: {
@@ -244,10 +244,10 @@ module.exports = {
SvelteComponents.registerControllerMethods({ SvelteComponents.registerControllerMethods({
stop: (...args) => this.stop(...args), stop: (...args) => this.stop(...args),
send: (...args) => this.send(...args), send: (...args) => this.send(...args),
isAxisHomed: (axis) => this[axis].homed, isAxisHomed: axis => this[axis].homed,
unhome: (...args) => this.unhome(...args), unhome: (...args) => this.unhome(...args),
set_position: (...args) => this.set_position(...args), set_position: (...args) => this.set_position(...args),
set_home: (...args) => this.set_home(...args) set_home: (...args) => this.set_home(...args),
}); });
}, },
@@ -375,9 +375,9 @@ module.exports = {
return; return;
} }
const isAlreadyPresent = this.state.GCodeList.find((element) => element == file.name); const isAlreadyPresent = this.state.GCodeList.find(element => element == file.name);
if (isAlreadyPresent == undefined) { if (isAlreadyPresent == undefined) {
console.log('new gcode file'); console.log("new gcode file");
this.state.GCodeList.push(file.name); this.state.GCodeList.push(file.name);
try { try {
await api.put("config/save", this.config); await api.put("config/save", this.config);
@@ -387,11 +387,11 @@ module.exports = {
alert("Restore failed"); alert("Restore failed");
} }
} else { } else {
console.log('Already exists'); console.log("Already exists");
} }
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);
} }
@@ -400,7 +400,7 @@ module.exports = {
onComplete: () => { onComplete: () => {
this.last_file_time = undefined; // Force reload this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name); this.$broadcast("gcode-reload", file.name);
} },
}); });
}, },
@@ -410,7 +410,7 @@ module.exports = {
api.delete(`file/${this.state.selected}`); api.delete(`file/${this.state.selected}`);
} }
} else { } else {
this.state.GCodeList.filter(item=>item!=this.state.selected); this.state.GCodeList = this.state.GCodeList.filter(item => item != this.state.selected);
} }
this.deleteGCode = false; this.deleteGCode = false;
@@ -461,7 +461,7 @@ module.exports = {
}, },
set_position: function (axis, position) { set_position: function (axis, position) {
api.put(`position/${axis}`, { "position": parseFloat(position) }); api.put(`position/${axis}`, { position: parseFloat(position) });
}, },
zero_all: function () { zero_all: function () {
@@ -537,9 +537,12 @@ module.exports = {
SvelteComponents.showDialog("Probe", { probeType }); SvelteComponents.showDialog("Probe", { probeType });
}, },
runMacros: function (id) { runMacros: function (id) {
if( this.config.macros[id].gcode_file_name != this.state.selected || this.config.macros[id].gcode_file_time != this.state.selected_time ){ if (
this.config.macros[id].gcode_file_name != this.state.selected ||
this.config.macros[id].gcode_file_time != this.state.selected_time
) {
this.state.selected = this.config.macros[id].gcode_file_name; this.state.selected = this.config.macros[id].gcode_file_name;
this.state.selected_time=this.config.macros[id].gcode_file_time this.state.selected_time = this.config.macros[id].gcode_file_time;
} }
try { try {
this.loadGCode(); this.loadGCode();
@@ -550,5 +553,5 @@ module.exports = {
}, },
}, },
mixins: [ require("./axis-vars") ] mixins: [require("./axis-vars")],
}; };

View File

@@ -145,9 +145,9 @@ module.exports = {
file, file,
onComplete: () => { onComplete: () => {
this.last_file_time = undefined; // Force reload this.last_file_time = undefined; // Force reload
this.loadMacrosGcode();
}, },
}); });
this.loadMacrosGcode();
}, },
uploadGCode: async function (filename, file) { uploadGCode: async function (filename, file) {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();

View File

@@ -681,13 +681,7 @@
"gcode_file_name": "TurnOffVac.ngc", "gcode_file_name": "TurnOffVac.ngc",
"gcode_file_time": 1705008395.476232 "gcode_file_time": 1705008395.476232
} }
], ]
"template": {
"gcode_file_time": {
"type": "int",
"default": 1705008395
}
}
}, },
"admin": { "admin": {