|
|
|
@ -97,6 +97,71 @@ function machineEditorOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function newMachineEditorOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
app.dialog.preloader("Loading editor...");
|
|
|
|
|
|
|
|
|
|
apirequest(
|
|
|
|
|
"getmachineformfields",
|
|
|
|
|
{},
|
|
|
|
|
function (resp) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
if (resp.status == "ERROR") {
|
|
|
|
|
app.dialog.alert(resp.msg, "Error");
|
|
|
|
|
reject();
|
|
|
|
|
} else {
|
|
|
|
|
var context = {
|
|
|
|
|
machineid: "",
|
|
|
|
|
info: {}
|
|
|
|
|
};
|
|
|
|
|
var tabindex = 0;
|
|
|
|
|
for (var k in resp.formdata.inputtypes) {
|
|
|
|
|
if (resp.formdata.inputtypes.hasOwnProperty(k)) {
|
|
|
|
|
context.info[k] = {
|
|
|
|
|
name: k,
|
|
|
|
|
value: "",
|
|
|
|
|
type: (typeof resp.formdata.inputtypes[k] == "string" ? resp.formdata.inputtypes[k] : "text"),
|
|
|
|
|
label: (typeof resp.formdata.labels[k] == "string" ? resp.formdata.labels[k] : k),
|
|
|
|
|
icon: (typeof resp.formdata.icons[k] == "string" ? resp.formdata.icons[k] : "fas fa-square"),
|
|
|
|
|
tabindex: tabindex
|
|
|
|
|
};
|
|
|
|
|
if (context.info[k].type == "select") {
|
|
|
|
|
console.log(resp.formdata.options[k]);
|
|
|
|
|
var options = [];
|
|
|
|
|
for (var m in resp.formdata.options[k]) {
|
|
|
|
|
if (resp.formdata.options[k].hasOwnProperty(m)) {
|
|
|
|
|
options.push({
|
|
|
|
|
value: "val_" + m,
|
|
|
|
|
label: resp.formdata.options[k][m]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(options);
|
|
|
|
|
context.info[k].options = options;
|
|
|
|
|
}
|
|
|
|
|
tabindex++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(context);
|
|
|
|
|
|
|
|
|
|
resolve({
|
|
|
|
|
templateUrl: "pages/machineeditor.html",
|
|
|
|
|
}, {
|
|
|
|
|
context: context
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function (xhr) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
var error = $.parseJSON(xhr.responseText);
|
|
|
|
|
if (error && typeof error.msg != 'undefined') {
|
|
|
|
|
app.dialog.alert(error.msg, "Error");
|
|
|
|
|
} else {
|
|
|
|
|
app.dialog.alert("A server or network error occurred.", "Error");
|
|
|
|
|
}
|
|
|
|
|
reject();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function machineInfoOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
app.dialog.preloader("Loading...");
|
|
|
|
|
|
|
|
|
@ -157,6 +222,9 @@ function machineInfoOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
var tabindex = 0;
|
|
|
|
|
for (var k in resp.info) {
|
|
|
|
|
if (resp.info.hasOwnProperty(k)) {
|
|
|
|
|
// if (resp.info[k] == null) {
|
|
|
|
|
// resp.info[k] = "";
|
|
|
|
|
// }
|
|
|
|
|
switch (k) {
|
|
|
|
|
case "type":
|
|
|
|
|
case "clientid":
|
|
|
|
@ -164,7 +232,7 @@ function machineInfoOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
var value = resp.info[k];
|
|
|
|
|
if (value == false || value == 0) {
|
|
|
|
|
if (value == false || value == 0 || value == null) {
|
|
|
|
|
value = false;
|
|
|
|
|
} else {
|
|
|
|
|
value = value.toString().replace("\n", " <br />");
|
|
|
|
@ -203,9 +271,16 @@ function machineInfoOpenAsync(routeTo, routeFrom, resolve, reject) {
|
|
|
|
|
function saveMachineEdits(machineid) {
|
|
|
|
|
app.dialog.preloader("Saving...");
|
|
|
|
|
|
|
|
|
|
var machinedata = {
|
|
|
|
|
id: machineid
|
|
|
|
|
};
|
|
|
|
|
if (typeof machineid == "undefined" || machineid == null) {
|
|
|
|
|
var apirequesttype = "addmachine";
|
|
|
|
|
var machinedata = {};
|
|
|
|
|
} else {
|
|
|
|
|
var apirequesttype = "editmachine";
|
|
|
|
|
var machinedata = {
|
|
|
|
|
id: machineid
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$("#machineform .machinefield").each(function (i, o) {
|
|
|
|
|
if ($(this).parent().is(".smart-select")) {
|
|
|
|
|
machinedata[$(this).attr("name")] = app.smartSelect.get('#smartselect-' + $(this).attr("name")).getValue().replace("val_", "");
|
|
|
|
@ -215,7 +290,7 @@ function saveMachineEdits(machineid) {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
apirequest(
|
|
|
|
|
"editmachine",
|
|
|
|
|
apirequesttype,
|
|
|
|
|
machinedata,
|
|
|
|
|
function (resp) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
@ -226,7 +301,11 @@ function saveMachineEdits(machineid) {
|
|
|
|
|
text: 'Machine saved!',
|
|
|
|
|
closeTimeout: 2000,
|
|
|
|
|
}).open();
|
|
|
|
|
addMachineToSearchHistory(resp.id);
|
|
|
|
|
router.back();
|
|
|
|
|
if (apirequesttype === "addmachine") {
|
|
|
|
|
router.navigate("/machine/" + resp.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function (xhr) {
|
|
|
|
|