not deleting default macros
This commit is contained in:
105
src/js/macros.js
105
src/js/macros.js
@@ -15,6 +15,40 @@ module.exports = {
|
|||||||
deleteGCode: false,
|
deleteGCode: false,
|
||||||
selectedValues: ["default", "default", "default", "default", "default", "default", "default", "default"],
|
selectedValues: ["default", "default", "default", "default", "default", "default", "default", "default"],
|
||||||
newGcode: ["", "", "", "", "", "", "", ""],
|
newGcode: ["", "", "", "", "", "", "", ""],
|
||||||
|
defaultMacrosList: [
|
||||||
|
{
|
||||||
|
gcode_file_name: "FireLaser.ngc",
|
||||||
|
gcode_file_time: 1705008250.2333415,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "GoHomeXYZ.ngc",
|
||||||
|
gcode_file_time: 1705008321.710827,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "ParkRearRightWW.ngc",
|
||||||
|
gcode_file_time: 1705008360.977644,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "SpindleWarmUp1Minute.ngc",
|
||||||
|
gcode_file_time: 1705008372.967075,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "TurnOnSpindle.ngc",
|
||||||
|
gcode_file_time: 1705008405.5059154,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "TurnOffSpindleAndLaser.ngc",
|
||||||
|
gcode_file_time: 1705008384.6566093,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "VacOn.ngc",
|
||||||
|
gcode_file_time: 1705008413.7756715,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gcode_file_name: "TurnOffVac.ngc",
|
||||||
|
gcode_file_time: 1705008395.476232,
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -34,8 +68,11 @@ module.exports = {
|
|||||||
macrosList: function () {
|
macrosList: function () {
|
||||||
return this.config.macrosList.map(el => el.gcode_file_name);
|
return this.config.macrosList.map(el => el.gcode_file_name);
|
||||||
},
|
},
|
||||||
getMacrosData: function (key) {
|
getMacrosColor: function () {
|
||||||
return this.config.macros[this.tab - 1][key];
|
return this.config.macros[this.tab - 1]['color'];
|
||||||
|
},
|
||||||
|
getMacrosName: function () {
|
||||||
|
return this.config.macros[this.tab - 1]['name'];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -45,6 +82,9 @@ module.exports = {
|
|||||||
updateNewGcode: function (event) {
|
updateNewGcode: function (event) {
|
||||||
this.newGcode[this.tab - 1] = event.target.value;
|
this.newGcode[this.tab - 1] = event.target.value;
|
||||||
},
|
},
|
||||||
|
isPresent: function (obj) {
|
||||||
|
this.defaultMacrosList.find(item => item.gcode_file_name == obj.gcode_file_name);
|
||||||
|
},
|
||||||
loadMacrosGcode: async function () {
|
loadMacrosGcode: async function () {
|
||||||
const file = this.selectedValues[this.tab - 1];
|
const file = this.selectedValues[this.tab - 1];
|
||||||
if (this.selectedValues[this.tab - 1] != "default") {
|
if (this.selectedValues[this.tab - 1] != "default") {
|
||||||
@@ -138,7 +178,8 @@ module.exports = {
|
|||||||
gcode_file_name: filename,
|
gcode_file_name: filename,
|
||||||
gcode_file_time: this.state.selected_time,
|
gcode_file_time: this.state.selected_time,
|
||||||
};
|
};
|
||||||
if(this.config.macrosList.some(item => item[gcode_file_name] !== filename)){
|
if (this.config.macrosList.some(item => item[gcode_file_name] !== filename)) {
|
||||||
|
console.log('new item');
|
||||||
this.config.macrosList.push(gcodeData);
|
this.config.macrosList.push(gcodeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,11 +221,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
delete_current: async function () {
|
delete_current: async function () {
|
||||||
console.log("delete a gcode");
|
console.log("delete a gcode");
|
||||||
if(this.selectedValues[this.tab - 1] == "default"){
|
if (this.selectedValues[this.tab - 1] == "default") {
|
||||||
this.$set("newGcode[this.tab-1]", "");
|
this.$set("newGcode[this.tab-1]", "");
|
||||||
}else{
|
} else {
|
||||||
|
if (!this.isPresent({ gcode_file_name: this.selectedValues[this.tab - 1] })) {
|
||||||
|
console.log('this is not default macros');
|
||||||
api.delete(`file/${this.selectedValues[this.tab - 1]}`);
|
api.delete(`file/${this.selectedValues[this.tab - 1]}`);
|
||||||
this.config.macrosList = this.config.macrosList.filter(item=> item.gcode_file_name !== this.selectedValues[this.tab - 1])
|
this.$set("newGcode[this.tab-1]", "");
|
||||||
|
this.config.macrosList = this.config.macrosList.filter(
|
||||||
|
item => item.gcode_file_name !== this.selectedValues[this.tab - 1],
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
this.$dispatch("update");
|
this.$dispatch("update");
|
||||||
@@ -192,46 +238,14 @@ module.exports = {
|
|||||||
console.error("Restore Failed: ", error);
|
console.error("Restore Failed: ", error);
|
||||||
alert("Restore failed");
|
alert("Restore failed");
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
alert("You cannot delete GCode of Default Macros");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.deleteGCode = false;
|
this.deleteGCode = false;
|
||||||
},
|
},
|
||||||
delete_all_macros: async function () {
|
delete_all_macros: async function () {
|
||||||
const defaultMacrosList = [
|
const itemsToDelete = this.config.macrosList.filter(el => !this.isPresent(el));
|
||||||
{
|
|
||||||
gcode_file_name: "FireLaser.ngc",
|
|
||||||
gcode_file_time: 1705008250.2333415,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "GoHomeXYZ.ngc",
|
|
||||||
gcode_file_time: 1705008321.710827,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "ParkRearRightWW.ngc",
|
|
||||||
gcode_file_time: 1705008360.977644,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "SpindleWarmUp1Minute.ngc",
|
|
||||||
gcode_file_time: 1705008372.967075,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "TurnOnSpindle.ngc",
|
|
||||||
gcode_file_time: 1705008405.5059154,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "TurnOffSpindleAndLaser.ngc",
|
|
||||||
gcode_file_time: 1705008384.6566093,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "VacOn.ngc",
|
|
||||||
gcode_file_time: 1705008413.7756715,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
gcode_file_name: "TurnOffVac.ngc",
|
|
||||||
gcode_file_time: 1705008395.476232,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const isPresent = obj => defaultMacrosList.find(item => item.gcode_file_name == obj.gcode_file_name);
|
|
||||||
const itemsToDelete = this.config.macrosList.filter(el => !isPresent(el));
|
|
||||||
const macrosList = itemsToDelete.map(item => item.gcode_file_name).toString();
|
const macrosList = itemsToDelete.map(item => item.gcode_file_name).toString();
|
||||||
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macrosList}`);
|
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macrosList}`);
|
||||||
this.config.macrosList = defaultMacrosList;
|
this.config.macrosList = defaultMacrosList;
|
||||||
@@ -250,13 +264,6 @@ 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 () {
|
|
||||||
// const macros = this.state.files.filter(
|
|
||||||
// (name) => !this.config.macros.some((obj) => obj.name === name)
|
|
||||||
// );
|
|
||||||
// console.log("Only Macros: ", macros);
|
|
||||||
// return macros;
|
|
||||||
// },
|
|
||||||
resetConfig: async function () {
|
resetConfig: async function () {
|
||||||
this.config.macros = [
|
this.config.macros = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ script#macros-template(type="text/x-template")
|
|||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="confirmSave=false") Cancel
|
button.pure-button(@click="confirmSave=false") Cancel
|
||||||
button.pure-button.pure-button-primary(@click="saveMacros") Confirm
|
button.pure-button.pure-button-primary(@click="saveMacros") Confirm
|
||||||
|
|
||||||
message(:show.sync="deleteGCode")
|
message(:show.sync="deleteGCode")
|
||||||
h3(slot="header") Delete GCode?
|
h3(slot="header") Delete?
|
||||||
p(slot="body")
|
p(slot="body")
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="deleteGCode = false") Cancel
|
button.pure-button(@click="deleteGCode = false") Cancel
|
||||||
@@ -67,8 +68,8 @@ script#macros-template(type="text/x-template")
|
|||||||
.macros-form
|
.macros-form
|
||||||
p.title Name
|
p.title Name
|
||||||
.input-container
|
.input-container
|
||||||
input.input-color(type="color",id="macros-color-0",v-model="getMacrosData('color')")
|
input.input-color(type="color",id="macros-color-0",v-model="getMacrosColor")
|
||||||
input.input-name(type="text",minlength='1',maxlength='15',id="macros-name-0" v-model="getMacrosData('name')")
|
input.input-name(type="text",minlength='1',maxlength='15',id="macros-name-0" v-model="getMacrosName")
|
||||||
p.title G-Code
|
p.title G-Code
|
||||||
.select-upload-gcode
|
.select-upload-gcode
|
||||||
select#gcodeSelect-0(title="Select previously uploaded GCode programs.",selected
|
select#gcodeSelect-0(title="Select previously uploaded GCode programs.",selected
|
||||||
@@ -85,7 +86,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:40px;width:130px;font-weight:normal;border-radius:5px;margin-left:4px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -118,7 +119,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -151,7 +152,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -184,7 +185,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -217,7 +218,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -250,7 +251,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -283,7 +284,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
@@ -316,7 +317,7 @@ script#macros-template(type="text/x-template")
|
|||||||
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
input(type="file", @change="uploadMacrosGcode", :disabled="!is_ready",
|
||||||
accept=".nc,.ngc,.gcode,.gc")
|
accept=".nc,.ngc,.gcode,.gc")
|
||||||
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
button.pure-button(title="Delete Macros GCodes",@click="deleteGCode = true",
|
||||||
:disabled="!state.selected",style="height:50px;width:170px;font-weight:normal;color:#fff;background-color:#5a9ad7;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete GCode
|
:disabled="!selectedValues[tab-1]=='default'",style="height:40px;width:130px;font-weight:normal;border-radius:5px;background-color:#5a9ad7;color:#fff;display:flex;align-items:center;justify-content:space-around;margin-left:1rem") Delete
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
br
|
br
|
||||||
.gcodeContainer
|
.gcodeContainer
|
||||||
|
|||||||
@@ -968,7 +968,7 @@ tt.save
|
|||||||
vertical-align middle
|
vertical-align middle
|
||||||
|
|
||||||
.modal-container
|
.modal-container
|
||||||
width 300px
|
width 350px
|
||||||
margin 0px auto
|
margin 0px auto
|
||||||
padding 20px 30px
|
padding 20px 30px
|
||||||
background-color #fff
|
background-color #fff
|
||||||
@@ -983,6 +983,8 @@ tt.save
|
|||||||
|
|
||||||
.modal-footer
|
.modal-footer
|
||||||
text-align right
|
text-align right
|
||||||
|
display flex
|
||||||
|
justify-content space-between
|
||||||
|
|
||||||
.modal-enter, .modal-leave
|
.modal-enter, .modal-leave
|
||||||
opacity 0
|
opacity 0
|
||||||
|
|||||||
Reference in New Issue
Block a user