|
|
@ -16,6 +16,8 @@
|
|
|
|
* under the License.
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var configRowId = 0;
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
var configParams = {
|
|
|
|
var configParams = {
|
|
|
@ -41,25 +43,25 @@ $(document).ready(function () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.get(
|
|
|
|
invokerUtil.get(
|
|
|
|
"/api/device-mgt/v1.0/configuration",
|
|
|
|
"/api/device-mgt/v1.0/configuration",
|
|
|
|
function (data) {
|
|
|
|
function (data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (data && data.configuration) {
|
|
|
|
if (data && data.configuration) {
|
|
|
|
for (var i = 0; i < data.configuration.length; i++) {
|
|
|
|
for (var i = 0; i < data.configuration.length; i++) {
|
|
|
|
var config = data.configuration[i];
|
|
|
|
var config = data.configuration[i];
|
|
|
|
if (config.name == configParams["NOTIFIER_FREQUENCY"]) {
|
|
|
|
if (config.name == configParams["NOTIFIER_FREQUENCY"]) {
|
|
|
|
$("input#monitoring-config-frequency").val(config.value / 1000);
|
|
|
|
$("input#monitoring-config-frequency").val(config.value / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function (data) {
|
|
|
|
}
|
|
|
|
console.log(data);
|
|
|
|
}, function (data) {
|
|
|
|
});
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Following click function would execute
|
|
|
|
* Following click function would execute
|
|
|
|
* when a user clicks on "Save" button
|
|
|
|
* when a user clicks on "Save" button
|
|
|
|
* on General platform configuration page in WSO2 EMM Console.
|
|
|
|
* on General platform configuration page in Entgra devicemgt Console.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("button#save-general-btn").click(function () {
|
|
|
|
$("button#save-general-btn").click(function () {
|
|
|
|
var notifierFrequency = $("input#monitoring-config-frequency").val();
|
|
|
|
var notifierFrequency = $("input#monitoring-config-frequency").val();
|
|
|
@ -87,33 +89,33 @@ $(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
var addConfigAPI = "/api/device-mgt/v1.0/configuration";
|
|
|
|
var addConfigAPI = "/api/device-mgt/v1.0/configuration";
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
addConfigAPI,
|
|
|
|
addConfigAPI,
|
|
|
|
addConfigFormData,
|
|
|
|
addConfigFormData,
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
data = jqXHR.status;
|
|
|
|
data = jqXHR.status;
|
|
|
|
if (data == 200) {
|
|
|
|
if (data == 200) {
|
|
|
|
$("#config-save-form").addClass("hidden");
|
|
|
|
$("#config-save-form").addClass("hidden");
|
|
|
|
$("#record-created-msg").removeClass("hidden");
|
|
|
|
$("#record-created-msg").removeClass("hidden");
|
|
|
|
} else if (data == 500) {
|
|
|
|
} else if (data == 500) {
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
} else if (data == 403) {
|
|
|
|
} else if (data == 403) {
|
|
|
|
$(errorMsg).text("Action was not permitted.");
|
|
|
|
$(errorMsg).text("Action was not permitted.");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
}, function (data) {
|
|
|
|
}, function (data) {
|
|
|
|
data = data.status;
|
|
|
|
data = data.status;
|
|
|
|
if (data == 500) {
|
|
|
|
if (data == 500) {
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
} else if (data == 403) {
|
|
|
|
} else if (data == 403) {
|
|
|
|
$(errorMsg).text("Action was not permitted.");
|
|
|
|
$(errorMsg).text("Action was not permitted.");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
}
|
|
|
|
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -154,3 +156,121 @@ var artifactGeoUpload = function () {
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
|
}, contentType);
|
|
|
|
}, contentType);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var loadDynamicDeviceTypeConfig = function (deviceType) {
|
|
|
|
|
|
|
|
var configAPI = '/api/device-mgt/v1.0/device-types/' + deviceType + '/configs';
|
|
|
|
|
|
|
|
invokerUtil.get(
|
|
|
|
|
|
|
|
configAPI,
|
|
|
|
|
|
|
|
function (data) {
|
|
|
|
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
var fieldWrapper = "#" + deviceType + "-config-field-wrapper";
|
|
|
|
|
|
|
|
$(fieldWrapper).html("");
|
|
|
|
|
|
|
|
if (data.configuration) {
|
|
|
|
|
|
|
|
var config;
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
for (i = 0; i < data.configuration.length; i++) {
|
|
|
|
|
|
|
|
config = data.configuration[i];
|
|
|
|
|
|
|
|
onDynamicConfigAddNew(deviceType, config.name, config.value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(fieldWrapper).append(
|
|
|
|
|
|
|
|
'<div class="row form-group ' + deviceType + '-config-row"' +
|
|
|
|
|
|
|
|
' id="' + deviceType + '-config-row-' + (++configRowId) + '">' +
|
|
|
|
|
|
|
|
'<div class="col-xs-3">' +
|
|
|
|
|
|
|
|
'<input type="text" class="form-control ' + deviceType + '-config-name" placeholder="name"/>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'<div class="col-xs-4">' +
|
|
|
|
|
|
|
|
'<textarea aria-describedby="basic-addon1" placeholder="value" data-error-msg="invalid value"' +
|
|
|
|
|
|
|
|
' class="form-control ' + deviceType + '-config-value" rows="1" cols="30"></textarea>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'<button type="button" class="wr-btn wr-btn-horizontal"' +
|
|
|
|
|
|
|
|
' onclick="onDynamicConfigAddNew(\'' + deviceType + '\', \'\', \'\')">' +
|
|
|
|
|
|
|
|
'<i class="fa fa-plus"></i>' +
|
|
|
|
|
|
|
|
'</button>' +
|
|
|
|
|
|
|
|
'</div>'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}, function (data) {
|
|
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var onDynamicConfigSubmit = function (deviceType) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var errorMsgWrapper = "#" + deviceType + "-config-error-msg";
|
|
|
|
|
|
|
|
var errorMsg = "#" + deviceType + "-config-error-msg span";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var addConfigFormData = {};
|
|
|
|
|
|
|
|
var configList = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.' + deviceType + '-config-row').each(function () {
|
|
|
|
|
|
|
|
var configName = $(this).find("." + deviceType + "-config-name").val();
|
|
|
|
|
|
|
|
var configVal = $(this).find("." + deviceType + "-config-value").val();
|
|
|
|
|
|
|
|
if (configName && configName.trim() !== "" && configVal && configVal.trim() !== "") {
|
|
|
|
|
|
|
|
var configurationEntry = {};
|
|
|
|
|
|
|
|
configurationEntry.name = configName.trim();
|
|
|
|
|
|
|
|
configurationEntry.contentType = "text";
|
|
|
|
|
|
|
|
configurationEntry.value = configVal.trim();
|
|
|
|
|
|
|
|
configList.push(configurationEntry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addConfigFormData.type = deviceType;
|
|
|
|
|
|
|
|
addConfigFormData.configuration = configList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var addConfigAPI = '/api/device-mgt/v1.0/admin/device-types/' + deviceType + '/configs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.post(
|
|
|
|
|
|
|
|
addConfigAPI,
|
|
|
|
|
|
|
|
addConfigFormData,
|
|
|
|
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
|
|
|
|
data = jqXHR.status;
|
|
|
|
|
|
|
|
if (data == 200) {
|
|
|
|
|
|
|
|
$("#config-save-form").addClass("hidden");
|
|
|
|
|
|
|
|
$("#record-created-msg").removeClass("hidden");
|
|
|
|
|
|
|
|
} else if (data == 500) {
|
|
|
|
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
|
|
|
|
} else if (data == 400) {
|
|
|
|
|
|
|
|
$(errorMsg).text("Configurations cannot be empty.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
|
|
|
|
}, function (data) {
|
|
|
|
|
|
|
|
data = data.status;
|
|
|
|
|
|
|
|
if (data == 500) {
|
|
|
|
|
|
|
|
$(errorMsg).text("Exception occurred at backend.");
|
|
|
|
|
|
|
|
} else if (data == 403) {
|
|
|
|
|
|
|
|
$(errorMsg).text("Action was not permitted.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(errorMsg).text("An unexpected error occurred.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(errorMsgWrapper).removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var onDynamicConfigAddNew = function (deviceType, name, value) {
|
|
|
|
|
|
|
|
$("#" + deviceType + "-config-field-wrapper").append(
|
|
|
|
|
|
|
|
'<div class="row form-group ' + deviceType + '-config-row"' +
|
|
|
|
|
|
|
|
' id="' + deviceType + '-config-row-' + (++configRowId) + '">' +
|
|
|
|
|
|
|
|
'<div class="col-xs-3">' +
|
|
|
|
|
|
|
|
'<input type="text" class="form-control ' + deviceType + '-config-name" placeholder="name"' +
|
|
|
|
|
|
|
|
' value="' + name + '"/>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'<div class="col-xs-4">' +
|
|
|
|
|
|
|
|
'<textarea aria-describedby="basic-addon1" placeholder="value" data-error-msg="invalid value"' +
|
|
|
|
|
|
|
|
' class="form-control ' + deviceType + '-config-value" rows="1" cols="30">' + value + '</textarea>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'<button type="button" class="wr-btn wr-btn-horizontal"' +
|
|
|
|
|
|
|
|
' onclick="onDynamicConfigRemove(\'' + deviceType + '\', ' + configRowId + ')">' +
|
|
|
|
|
|
|
|
'<i class="fa fa-minus"></i>' +
|
|
|
|
|
|
|
|
'</button>' +
|
|
|
|
|
|
|
|
'</div>'
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var onDynamicConfigRemove = function (deviceType, rawId) {
|
|
|
|
|
|
|
|
$("#" + deviceType + "-config-row-" + rawId).remove()
|
|
|
|
|
|
|
|
};
|