Fixing policy retrieve api

merge-requests/7/head
Rasika Perera 8 years ago
parent 99fee36f2c
commit 1bae3d2213

@ -17,7 +17,6 @@
*/
(function () {
var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type");
@ -46,7 +45,7 @@
});
});
function loadOperationsLog(update) {
var operationsLogTable = "#operations-log-table";
if (update) {
@ -58,92 +57,67 @@
serverSide: true,
processing: false,
searching: false,
ordering: false,
pageLength: 10,
ordering: false,
pageLength : 10,
order: [],
ajax: {
url: "/emm/api/operation/paginate",
data: {
deviceId: deviceIdentifier,
deviceType: deviceType
},
url: context + "/api/operation/paginate",
data: {deviceId : deviceIdentifier, deviceType: deviceType},
dataSrc: function (json) {
$("#operations-spinner").addClass(
"hidden");
$("#operations-spinner").addClass("hidden");
$("#operations-log-container").empty();
return json.data;
}
},
columnDefs: [
{targets: 0, data: "code"},
{
targets: 1,
data: "status",
render: function (status) {
{targets: 0, data: "code" },
{targets: 1, data: "status", render:
function (status) {
var html;
switch (status) {
case "COMPLETED" :
html =
"<span><i class='fw fw-ok icon-success'></i> Completed</span>";
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>";
html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break;
case "ERROR" :
html =
"<span><i class='fw fw-error icon-danger'></i> Error</span>";
html = "<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>";
html = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
break;
case "REPEATED" :
html =
"<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
html = "<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
break;
}
return html;
}
},
{
targets: 2,
data: "createdTimeStamp",
render: function (date) {
{targets: 2, data: "createdTimeStamp", render:
function (date) {
var value = String(date);
return value.slice(0, 16);
}
}
],
"createdRow": function (row, data) {
"createdRow": function(row, data) {
$(row).attr("data-type", "selectable");
$(row).attr("data-id", data["id"]);
$.each($("td", row),
function (colIndex) {
switch (colIndex) {
function(colIndex) {
switch(colIndex) {
case 1:
$(this).attr(
"data-grid-label",
"Code");
$(this).attr(
"data-display",
data["code"]);
$(this).attr("data-grid-label", "Code");
$(this).attr("data-display", data["code"]);
break;
case 2:
$(this).attr(
"data-grid-label",
"Status");
$(this).attr(
"data-display",
data["status"]);
$(this).attr("data-grid-label", "Status");
$(this).attr("data-display", data["status"]);
break;
case 3:
$(this).attr(
"data-grid-label",
"Created Timestamp");
$(this).attr(
"data-display",
data["createdTimeStamp"]);
$(this).attr("data-grid-label", "Created Timestamp");
$(this).attr("data-display", data["createdTimeStamp"]);
break;
}
}
@ -163,10 +137,8 @@
"policy-view",
policyComplianceTemplate,
function (template) {
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId
+ "/effective-policy";
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId
+ "/compliance-data";
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
invokerUtil.get(
getEffectivePolicyURL,
@ -191,8 +163,7 @@
if (data["complianceData"]["complianceFeatures"] &&
data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["compliance"] = "NON-COMPLIANT";
viewModel["complianceFeatures"] =
data["complianceData"]["complianceFeatures"];
viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
content = template(viewModel);
$("#policy-list-container").html(content);
} else {
@ -202,18 +173,17 @@
$("#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>");
$("#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>");
$("#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>");
}
);
}
@ -221,10 +191,9 @@
},
// 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>");
$("#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>");
}
);
}

Loading…
Cancel
Save