naming conventions
This commit is contained in:
@@ -463,17 +463,25 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
delete_current: function () {
|
delete_current: async function () {
|
||||||
if (this.config.macros_list.find(item => item.file_name == this.state.selected) == undefined) {
|
if (this.config.macros_list.find(item => item.file_name == this.state.selected) == undefined) {
|
||||||
if (this.state.selected) {
|
if (this.state.selected) {
|
||||||
this.config.non_macros_list = this.config.non_macros_list.filter(
|
this.config.non_macros_list = this.config.non_macros_list.filter(
|
||||||
item => item.file_name != this.state.selected,
|
item => item.file_name != this.state.selected,
|
||||||
);
|
);
|
||||||
|
//TODO: remove file from the gcode_list
|
||||||
api.delete(`file/${this.state.selected}`);
|
api.delete(`file/${this.state.selected}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
|
this.config.non_macros_list = this.config.non_macros_list.filter(item => item.file_name != this.state.selected);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
await api.put("config/save", this.config);
|
||||||
|
this.$dispatch("update");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Restore Failed: ", error);
|
||||||
|
alert("Restore failed");
|
||||||
|
}
|
||||||
|
|
||||||
this.deleteGCode = false;
|
this.deleteGCode = false;
|
||||||
},
|
},
|
||||||
@@ -487,6 +495,7 @@ module.exports = {
|
|||||||
const macrosList = this.config.macros_list.map(item => item.file_name).toString();
|
const macrosList = this.config.macros_list.map(item => item.file_name).toString();
|
||||||
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
|
api.delete(`file/EgZjaHJvbWUqCggBEAAYsQMYgAQyBggAEEUYOTIKCAE${macrosList}`);
|
||||||
this.config.non_macros_list = [];
|
this.config.non_macros_list = [];
|
||||||
|
this.config.gcode_list = [];
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
this.$dispatch("update");
|
this.$dispatch("update");
|
||||||
|
|||||||
@@ -191,9 +191,9 @@ module.exports = {
|
|||||||
this.config.macros_list.push(gcodeData);
|
this.config.macros_list.push(gcodeData);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveMacros: async function () {
|
save_macro: async function () {
|
||||||
if (this.tab == 0) {
|
if (this.tab == 0) {
|
||||||
this.clearMacros();
|
this.clear_macro();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const macros = [...this.config.macros];
|
const macros = [...this.config.macros];
|
||||||
@@ -256,12 +256,7 @@ module.exports = {
|
|||||||
this.fileName = "default";
|
this.fileName = "default";
|
||||||
this.deleteGCode = false;
|
this.deleteGCode = false;
|
||||||
},
|
},
|
||||||
delete_all_macros: async function () {
|
clear_macro: async function () {
|
||||||
const macros_list = this.config.macros_list.map(item => item.file_name).toString();
|
|
||||||
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macros_list}`);
|
|
||||||
this.config.macros_list = [];
|
|
||||||
},
|
|
||||||
clearMacros: async function () {
|
|
||||||
if (this.tab == 0 || this.tab > this.config.macros.length) {
|
if (this.tab == 0 || this.tab > this.config.macros.length) {
|
||||||
document.getElementById("macros-name").value = "";
|
document.getElementById("macros-name").value = "";
|
||||||
document.getElementById("macros-color").value = "#ffffff";
|
document.getElementById("macros-color").value = "#ffffff";
|
||||||
@@ -279,7 +274,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
this.edited = false;
|
this.edited = false;
|
||||||
},
|
},
|
||||||
deleteAllMacros: async function () {
|
delete_all_macros: async function () {
|
||||||
this.config.macros = [
|
this.config.macros = [
|
||||||
{
|
{
|
||||||
name: "Macros 1",
|
name: "Macros 1",
|
||||||
@@ -330,8 +325,10 @@ module.exports = {
|
|||||||
alert: true,
|
alert: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
this.delete_all_macros();
|
const macros_list = this.config.macros_list.map(item => item.file_name).toString();
|
||||||
this.clearMacros();
|
api.delete(`file/DINCAIQABiDARixAxiABDIHCAMQABiABDIHCAQQABiABDIH${macros_list}`);
|
||||||
|
this.config.macros_list = [];
|
||||||
|
this.clear_macro();
|
||||||
this.edited = false;
|
this.edited = false;
|
||||||
this.confirmReset = false;
|
this.confirmReset = false;
|
||||||
try {
|
try {
|
||||||
@@ -342,7 +339,7 @@ module.exports = {
|
|||||||
alert("Restore failed");
|
alert("Restore failed");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addNewMacros: async function () {
|
add_new_macro: async function () {
|
||||||
const length = this.config.macros.length;
|
const length = this.config.macros.length;
|
||||||
if (length >= 20) {
|
if (length >= 20) {
|
||||||
this.maxLimitReached = true;
|
this.maxLimitReached = true;
|
||||||
@@ -364,13 +361,13 @@ module.exports = {
|
|||||||
alert("Restore failed");
|
alert("Restore failed");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteSelectedMacros: async function () {
|
delete_selected_macro: async function () {
|
||||||
if (this.tab == 0) {
|
if (this.tab == 0) {
|
||||||
this.clearMacros();
|
this.clear_macro();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.config.macros.splice(this.tab - 1, 1);
|
this.config.macros.splice(this.tab - 1, 1);
|
||||||
this.clearMacros();
|
this.clear_macro();
|
||||||
try {
|
try {
|
||||||
await api.put("config/save", this.config);
|
await api.put("config/save", this.config);
|
||||||
this.$dispatch("update");
|
this.$dispatch("update");
|
||||||
@@ -381,4 +378,10 @@ module.exports = {
|
|||||||
this.deleteSelected = false;
|
this.deleteSelected = false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
print_config: function () {
|
||||||
|
console.log(this.config);
|
||||||
|
},
|
||||||
|
print_state: function () {
|
||||||
|
console.log(this.state);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ script#macros-template(type="text/x-template")
|
|||||||
|
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="confirmReset=false") Cancel
|
button.pure-button(@click="confirmReset=false") Cancel
|
||||||
button.pure-button.button-error(@click="deleteAllMacros")
|
button.pure-button.button-error(@click="delete_all_macros")
|
||||||
| Delete All
|
| Delete All
|
||||||
|
|
||||||
message(:show.sync="confirmSave")
|
message(:show.sync="confirmSave")
|
||||||
@@ -17,7 +17,7 @@ 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="save_macro") Confirm
|
||||||
|
|
||||||
message(:show.sync="deleteGCode")
|
message(:show.sync="deleteGCode")
|
||||||
h3(slot="header") Delete?
|
h3(slot="header") Delete?
|
||||||
@@ -33,7 +33,7 @@ script#macros-template(type="text/x-template")
|
|||||||
p(slot="body")
|
p(slot="body")
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="deleteSelected = false") Cancel
|
button.pure-button(@click="deleteSelected = false") Cancel
|
||||||
button.pure-button.button-error(@click="deleteSelectedMacros")
|
button.pure-button.button-error(@click="delete_selected_macro")
|
||||||
.fa.fa-trash
|
.fa.fa-trash
|
||||||
| Yes
|
| Yes
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ script#macros-template(type="text/x-template")
|
|||||||
p(slot="body")
|
p(slot="body")
|
||||||
div(slot="footer")
|
div(slot="footer")
|
||||||
button.pure-button(@click="addMacros = false") Cancel
|
button.pure-button(@click="addMacros = false") Cancel
|
||||||
button.pure-button.button-submit(@click="addNewMacros") Add
|
button.pure-button.button-submit(@click="add_new_macro") Add
|
||||||
|
|
||||||
h1 Macros Configuration
|
h1 Macros Configuration
|
||||||
.flex-row-container
|
.flex-row-container
|
||||||
@@ -73,7 +73,7 @@ script#macros-template(type="text/x-template")
|
|||||||
div(style="display:flex;align-items:center;margin-left:30px")
|
div(style="display:flex;align-items:center;margin-left:30px")
|
||||||
h2 Select Macros
|
h2 Select Macros
|
||||||
select(id="macros-select",title="Select a Macros to edit.",selected
|
select(id="macros-select",title="Select a Macros to edit.",selected
|
||||||
v-model="tab",@change="clearMacros",
|
v-model="tab",@change="clear_macro",
|
||||||
style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px")
|
style="width:250px;height:50px;border-radius:10px;padding-left:15px;font-weight:bold;margin-left:30px")
|
||||||
option( selected='' value='0') Select a Macros
|
option( selected='' value='0') Select a Macros
|
||||||
option(v-for="(index,file) in macros_list", :value="index+1") {{file}}
|
option(v-for="(index,file) in macros_list", :value="index+1") {{file}}
|
||||||
@@ -108,4 +108,7 @@ script#macros-template(type="text/x-template")
|
|||||||
textarea.new-gcode(id="gcode-field", v-model="newGcode" ,@keypress="updateNewGcode")
|
textarea.new-gcode(id="gcode-field", v-model="newGcode" ,@keypress="updateNewGcode")
|
||||||
|
|
||||||
button.submit-macros.button-success(title="Save Macros",@click="confirmSave=true",:disabled="!edited") Save
|
button.submit-macros.button-success(title="Save Macros",@click="confirmSave=true",:disabled="!edited") Save
|
||||||
button.submit-macros(title="Cancel Macros",@click="clearMacros",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") Cancel
|
button.submit-macros(title="Cancel Macros",@click="clear_macro",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") Cancel
|
||||||
|
|
||||||
|
button.submit-macros(title="Cancel Macros",@click="print_config",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") CONFIG
|
||||||
|
button.submit-macros(title="Cancel Macros",@click="print_state",style="margin-left:5px;background-color:#fafafa;",:disabled="initial_tab") STATE
|
||||||
|
|||||||
Reference in New Issue
Block a user