Fixing policy retrieve api

revert-70aa11f8
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");
@ -62,54 +61,41 @@
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: 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);
}
@ -122,28 +108,16 @@
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,17 +173,16 @@
$("#policy-compliance-table").addClass("hidden");
}
} else {
$("#policy-list-container").html(
"<div class='panel-body'><br><p class='fw-warning'> This device " +
$("#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 "
+
$("#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,9 +191,8 @@
},
// error-callback
function () {
$("#policy-list-container").html(
"<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data "
+
$("#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