added method for upload gcode and ui fix in macros and checking the func in control-view

This commit is contained in:
sanjayk03-dev
2023-12-30 18:57:16 +05:30
parent 9b8e52edaf
commit e3ca0ba3a3
3 changed files with 35 additions and 2 deletions

View File

@@ -203,7 +203,7 @@ module.exports = {
return Math.min(1, p);
},
isMacrosPresent: function(){
return this.config.macros!=undefined;
return this.config.macros==undefined;
},
},

View File

@@ -53,6 +53,34 @@ module.exports = {
this.toolpath_progress = 0;
this.load_toolpath(file, file_time);
},
upload: function(e) {
const files = e.target.files || e.dataTransfer.files;
if (!files.length) {
return;
}
const file = files[0];
const extension = file.name.split(".").pop();
switch (extension.toLowerCase()) {
case "nc":
case "ngc":
case "gcode":
case "gc":
break;
default:
alert(`Unsupported file type: ${extension}`);
return;
}
SvelteComponents.showDialog("Upload", {
file,
onComplete: () => {
this.last_file_time = undefined; // Force reload
this.$broadcast("gcode-reload", file.name);
}
});
},
saveMacros: function(){
var macrosName = document.getElementById("macros-name").value;
var macrosColor = document.getElementById("macros-color").value;

View File

@@ -11,8 +11,13 @@ script#macros-template(type="text/x-template")
v-model="state.selected", @change="load", :disabled="!is_ready",
style="max-width:100%;height:40px;border-radius:5px")
option(v-for="file in state.files", :value="file") {{file}}
button.pure-button(title="Upload a new GCode program.", @click="open",
:disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px") Upload
:disabled="!is_ready",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px") Upload
form.gcode-file-input.file-upload
input(type="file", @change="upload", :disabled="!is_ready",
accept=".nc,.ngc,.gcode,.gc")
br
button.submit-macros(title="Save Macros",@click="saveMacros",
style="height:50px;width:140px;font-weight:normal;background-color:#add1ad;color:#fff;border-color:#add1ad;margin-top:15px") Save Macros