|
|
@ -17,6 +17,11 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var deviceId = $(".device-id");
|
|
|
|
|
|
|
|
var deviceIdentifier = deviceId.data("deviceid");
|
|
|
|
|
|
|
|
var deviceType = deviceId.data("type");
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(".panel-body").removeClass("hidden");
|
|
|
|
$(".panel-body").removeClass("hidden");
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$("#loading-content").remove();
|
|
|
@ -25,10 +30,6 @@
|
|
|
|
loadOperationsLog();
|
|
|
|
loadOperationsLog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($('#policies').length) {
|
|
|
|
|
|
|
|
loadPolicies();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($('#policy_compliance').length) {
|
|
|
|
if ($('#policy_compliance').length) {
|
|
|
|
loadPolicyCompliance();
|
|
|
|
loadPolicyCompliance();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -47,158 +48,187 @@
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function loadOperationsLog(update) {
|
|
|
|
function loadOperationsLog(update) {
|
|
|
|
var operationsLog = $("#operations-log");
|
|
|
|
var operationsLogTable = "#operations-log-table";
|
|
|
|
var deviceListingSrc = operationsLog.attr("src");
|
|
|
|
if (update) {
|
|
|
|
var deviceId = operationsLog.data("device-id");
|
|
|
|
operationTable = $(operationsLogTable).DataTable();
|
|
|
|
var deviceType = operationsLog.data("device-type");
|
|
|
|
operationTable.ajax.reload(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
$.template("operations-log", deviceListingSrc, function (template) {
|
|
|
|
}
|
|
|
|
var serviceURL = "/devicemgt_admin/operations/" + deviceType + "/" + deviceId;
|
|
|
|
operationTable = $(operationsLogTable).datatables_extended({
|
|
|
|
|
|
|
|
serverSide: true,
|
|
|
|
var successCallback = function (data) {
|
|
|
|
processing: false,
|
|
|
|
data = JSON.parse(data);
|
|
|
|
searching: false,
|
|
|
|
$('#operations-spinner').addClass('hidden');
|
|
|
|
ordering: false,
|
|
|
|
var viewModel = {};
|
|
|
|
pageLength: 10,
|
|
|
|
viewModel.operations = data;
|
|
|
|
order: [],
|
|
|
|
if (data.length > 0) {
|
|
|
|
ajax: {
|
|
|
|
var content = template(viewModel);
|
|
|
|
url: "/emm/api/operation/paginate",
|
|
|
|
if (!update) {
|
|
|
|
data: {
|
|
|
|
$("#operations-log-container").html(content);
|
|
|
|
deviceId: deviceIdentifier,
|
|
|
|
$('#operations-log-table').datatables_extended();
|
|
|
|
deviceType: deviceType
|
|
|
|
} else {
|
|
|
|
},
|
|
|
|
$('#operations-log-table').dataTable().fnClearTable();
|
|
|
|
dataSrc: function (json) {
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
$("#operations-spinner").addClass(
|
|
|
|
var status;
|
|
|
|
"hidden");
|
|
|
|
if (data[i].status == "COMPLETED") {
|
|
|
|
$("#operations-log-container").empty();
|
|
|
|
status = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
|
|
|
|
return json.data;
|
|
|
|
} else if (data[i].status == "PENDING") {
|
|
|
|
}
|
|
|
|
status = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
|
|
|
|
},
|
|
|
|
} else if (data[i].status == "ERROR") {
|
|
|
|
columnDefs: [
|
|
|
|
status = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
|
|
|
|
{targets: 0, data: "code"},
|
|
|
|
} else if (data[i].status == "IN_PROGRESS") {
|
|
|
|
{
|
|
|
|
status = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
|
|
|
|
targets: 1,
|
|
|
|
}
|
|
|
|
data: "status",
|
|
|
|
|
|
|
|
render: function (status) {
|
|
|
|
$('#operations-log-table').dataTable().fnAddData([
|
|
|
|
var html;
|
|
|
|
data[i].code,
|
|
|
|
switch (status) {
|
|
|
|
status,
|
|
|
|
case "COMPLETED" :
|
|
|
|
data[i].createdTimeStamp
|
|
|
|
html =
|
|
|
|
]);
|
|
|
|
"<span><i class='fw fw-ok icon-success'></i> Completed</span>";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "PENDING" :
|
|
|
|
}
|
|
|
|
html =
|
|
|
|
|
|
|
|
"<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
invokerUtil.get(serviceURL,
|
|
|
|
case "ERROR" :
|
|
|
|
successCallback, function (message) {
|
|
|
|
html =
|
|
|
|
console.log(message);
|
|
|
|
"<span><i class='fw fw-error icon-danger'></i> Error</span>";
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
});
|
|
|
|
case "IN_PROGRESS" :
|
|
|
|
|
|
|
|
html =
|
|
|
|
}
|
|
|
|
"<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
|
|
|
|
|
|
|
|
break;
|
|
|
|
function loadPolicies() {
|
|
|
|
case "REPEATED" :
|
|
|
|
var policyList = $("#policy-list");
|
|
|
|
html =
|
|
|
|
var policyListingSrc = policyList.attr("src");
|
|
|
|
"<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
|
|
|
|
var deviceId = policyList.data("device-id");
|
|
|
|
break;
|
|
|
|
var deviceType = policyList.data("device-type");
|
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
$.template("policy-list", policyListingSrc, function (template) {
|
|
|
|
}
|
|
|
|
var serviceURL = "/devicemgt_admin/policies";
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
var successCallback = function (data) {
|
|
|
|
targets: 2,
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data: "createdTimeStamp",
|
|
|
|
$('#policy-spinner').addClass('hidden');
|
|
|
|
render: function (date) {
|
|
|
|
var policyListFromRestEndpoint = data.responseContent;
|
|
|
|
var value = String(date);
|
|
|
|
if (policyListFromRestEndpoint.length > 0) {
|
|
|
|
return value.slice(0, 16);
|
|
|
|
var viewModel = {};
|
|
|
|
}
|
|
|
|
var policyListToView = [];
|
|
|
|
}
|
|
|
|
var i, policyObjectFromRestEndpoint, policyObjectToView;
|
|
|
|
],
|
|
|
|
for (i = 0; i < policyListFromRestEndpoint.length; i++) {
|
|
|
|
"createdRow": function (row, data) {
|
|
|
|
// get list object
|
|
|
|
$(row).attr("data-type", "selectable");
|
|
|
|
policyObjectFromRestEndpoint = policyListFromRestEndpoint[i];
|
|
|
|
$(row).attr("data-id", data["id"]);
|
|
|
|
// populate list object values to view-object
|
|
|
|
$.each($("td", row),
|
|
|
|
policyObjectToView = {};
|
|
|
|
function (colIndex) {
|
|
|
|
policyObjectToView["id"] = policyObjectFromRestEndpoint["id"];
|
|
|
|
switch (colIndex) {
|
|
|
|
policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"];
|
|
|
|
case 1:
|
|
|
|
policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"];
|
|
|
|
$(this).attr(
|
|
|
|
policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]["name"];
|
|
|
|
"data-grid-label",
|
|
|
|
policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"];
|
|
|
|
"Code");
|
|
|
|
policyObjectToView["compliance"] = policyObjectFromRestEndpoint["compliance"];
|
|
|
|
$(this).attr(
|
|
|
|
|
|
|
|
"data-display",
|
|
|
|
if (policyObjectFromRestEndpoint["active"] == true && policyObjectFromRestEndpoint["updated"] == true) {
|
|
|
|
data["code"]);
|
|
|
|
policyObjectToView["status"] = "Active/Updated";
|
|
|
|
break;
|
|
|
|
} else if (policyObjectFromRestEndpoint["active"] == true && policyObjectFromRestEndpoint["updated"] == false) {
|
|
|
|
case 2:
|
|
|
|
policyObjectToView["status"] = "Active";
|
|
|
|
$(this).attr(
|
|
|
|
} else if (policyObjectFromRestEndpoint["active"] == false && policyObjectFromRestEndpoint["updated"] == true) {
|
|
|
|
"data-grid-label",
|
|
|
|
policyObjectToView["status"] = "Inactive/Updated";
|
|
|
|
"Status");
|
|
|
|
} else if (policyObjectFromRestEndpoint["active"] == false && policyObjectFromRestEndpoint["updated"] == false) {
|
|
|
|
$(this).attr(
|
|
|
|
policyObjectToView["status"] = "Inactive";
|
|
|
|
"data-display",
|
|
|
|
}
|
|
|
|
data["status"]);
|
|
|
|
// push view-objects to list
|
|
|
|
break;
|
|
|
|
policyListToView.push(policyObjectToView);
|
|
|
|
case 3:
|
|
|
|
}
|
|
|
|
$(this).attr(
|
|
|
|
viewModel.policies = policyListToView;
|
|
|
|
"data-grid-label",
|
|
|
|
var content = template(viewModel);
|
|
|
|
"Created Timestamp");
|
|
|
|
$("#policy-list-container").html(content);
|
|
|
|
$(this).attr(
|
|
|
|
$('#policy-table').datatables_extended();
|
|
|
|
"data-display",
|
|
|
|
}
|
|
|
|
data["createdTimeStamp"]);
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
invokerUtil.get(serviceURL,
|
|
|
|
}
|
|
|
|
successCallback, function (message) {
|
|
|
|
}
|
|
|
|
console.log(message);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadPolicyCompliance() {
|
|
|
|
function loadPolicyCompliance() {
|
|
|
|
var policyCompliance = $("#policy-view");
|
|
|
|
var policyCompliance = $("#policy-view");
|
|
|
|
var policySrc = policyCompliance.attr("src");
|
|
|
|
var policyComplianceTemplate = policyCompliance.attr("src");
|
|
|
|
var deviceId = policyCompliance.data("device-id");
|
|
|
|
var deviceId = policyCompliance.data("device-id");
|
|
|
|
var deviceType = policyCompliance.data("device-type");
|
|
|
|
var deviceType = policyCompliance.data("device-type");
|
|
|
|
var activePolicy = null;
|
|
|
|
var activePolicy = null;
|
|
|
|
|
|
|
|
|
|
|
|
$.template("policy-view", policySrc, function (template) {
|
|
|
|
$.template(
|
|
|
|
var serviceURLPolicy = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId + "/active-policy"
|
|
|
|
"policy-view",
|
|
|
|
var serviceURLCompliance = "/devicemgt_admin/policies/" + deviceType + "/" + deviceId;
|
|
|
|
policyComplianceTemplate,
|
|
|
|
|
|
|
|
function (template) {
|
|
|
|
var successCallbackCompliance = function (data) {
|
|
|
|
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId
|
|
|
|
var viewModel = {};
|
|
|
|
+ "/effective-policy";
|
|
|
|
viewModel.policy = activePolicy;
|
|
|
|
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId
|
|
|
|
viewModel.deviceType = deviceType;
|
|
|
|
+ "/compliance-data";
|
|
|
|
if (data != null && data.complianceFeatures != null && data.complianceFeatures != undefined && data.complianceFeatures.length > 0) {
|
|
|
|
|
|
|
|
viewModel.compliance = "NON-COMPLIANT";
|
|
|
|
invokerUtil.get(
|
|
|
|
viewModel.complianceFeatures = data.complianceFeatures;
|
|
|
|
getEffectivePolicyURL,
|
|
|
|
var content = template(viewModel);
|
|
|
|
// success-callback
|
|
|
|
$("#policy-list-container").html(content);
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
} else {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
viewModel.compliance = "COMPLIANT";
|
|
|
|
data = JSON.parse(data);
|
|
|
|
var content = template(viewModel);
|
|
|
|
$("#policy-spinner").addClass("hidden");
|
|
|
|
$("#policy-list-container").html(content);
|
|
|
|
if (data["active"] == true) {
|
|
|
|
$("#policy-compliance-table").addClass("hidden");
|
|
|
|
activePolicy = data;
|
|
|
|
}
|
|
|
|
invokerUtil.get(
|
|
|
|
|
|
|
|
getDeviceComplianceURL,
|
|
|
|
};
|
|
|
|
// success-callback
|
|
|
|
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
var successCallbackPolicy = function (data) {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
var viewModel = {};
|
|
|
|
$('#policy-spinner').addClass('hidden');
|
|
|
|
viewModel["policy"] = activePolicy;
|
|
|
|
if (data != null && data.active == true) {
|
|
|
|
viewModel["deviceType"] = deviceType;
|
|
|
|
activePolicy = data;
|
|
|
|
data = JSON.parse(data);
|
|
|
|
invokerUtil.get(serviceURLCompliance,
|
|
|
|
var content;
|
|
|
|
successCallbackCompliance, function (message) {
|
|
|
|
if (data["complianceData"]) {
|
|
|
|
console.log(message);
|
|
|
|
if (data["complianceData"]["complianceFeatures"] &&
|
|
|
|
});
|
|
|
|
data["complianceData"]["complianceFeatures"].length > 0) {
|
|
|
|
}
|
|
|
|
viewModel["compliance"] = "NON-COMPLIANT";
|
|
|
|
};
|
|
|
|
viewModel["complianceFeatures"] =
|
|
|
|
|
|
|
|
data["complianceData"]["complianceFeatures"];
|
|
|
|
invokerUtil.get(serviceURLPolicy,
|
|
|
|
content = template(viewModel);
|
|
|
|
successCallbackPolicy, function (message) {
|
|
|
|
$("#policy-list-container").html(content);
|
|
|
|
console.log(message);
|
|
|
|
} else {
|
|
|
|
});
|
|
|
|
viewModel["compliance"] = "COMPLIANT";
|
|
|
|
});
|
|
|
|
content = template(viewModel);
|
|
|
|
|
|
|
|
$("#policy-list-container").html(content);
|
|
|
|
|
|
|
|
$("#policy-compliance-table").addClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$("#policy-list-container").html(
|
|
|
|
|
|
|
|
"<div class='panel-body'><br><p class='fw-warning'> This device " +
|
|
|
|
|
|
|
|
"has no policy applied.<p></div>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// error-callback
|
|
|
|
|
|
|
|
function () {
|
|
|
|
|
|
|
|
$("#policy-list-container").html(
|
|
|
|
|
|
|
|
"<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data "
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
"was not successful. please try refreshing data in a while.<p></div>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// error-callback
|
|
|
|
|
|
|
|
function () {
|
|
|
|
|
|
|
|
$("#policy-list-container").html(
|
|
|
|
|
|
|
|
"<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data "
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
"was not successful. please try refreshing data in a while.<p></div>");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}());
|
|
|
|
}());
|
|
|
|