Fixing policy retrieve api

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

@ -17,7 +17,6 @@
*/ */
(function () { (function () {
var deviceId = $(".device-id"); var deviceId = $(".device-id");
var deviceIdentifier = deviceId.data("deviceid"); var deviceIdentifier = deviceId.data("deviceid");
var deviceType = deviceId.data("type"); var deviceType = deviceId.data("type");
@ -62,54 +61,41 @@
pageLength : 10, pageLength : 10,
order: [], order: [],
ajax: { ajax: {
url: "/emm/api/operation/paginate", url: context + "/api/operation/paginate",
data: { data: {deviceId : deviceIdentifier, deviceType: deviceType},
deviceId: deviceIdentifier,
deviceType: deviceType
},
dataSrc: function (json) { dataSrc: function (json) {
$("#operations-spinner").addClass( $("#operations-spinner").addClass("hidden");
"hidden");
$("#operations-log-container").empty(); $("#operations-log-container").empty();
return json.data; return json.data;
} }
}, },
columnDefs: [ columnDefs: [
{targets: 0, data: "code" }, {targets: 0, data: "code" },
{ {targets: 1, data: "status", render:
targets: 1, function (status) {
data: "status",
render: function (status) {
var html; var html;
switch (status) { switch (status) {
case "COMPLETED" : case "COMPLETED" :
html = html = "<span><i class='fw fw-ok icon-success'></i> Completed</span>";
"<span><i class='fw fw-ok icon-success'></i> Completed</span>";
break; break;
case "PENDING" : case "PENDING" :
html = html = "<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
"<span><i class='fw fw-warning icon-warning'></i> Pending</span>";
break; break;
case "ERROR" : case "ERROR" :
html = html = "<span><i class='fw fw-error icon-danger'></i> Error</span>";
"<span><i class='fw fw-error icon-danger'></i> Error</span>";
break; break;
case "IN_PROGRESS" : case "IN_PROGRESS" :
html = html = "<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
"<span><i class='fw fw-ok icon-warning'></i> In Progress</span>";
break; break;
case "REPEATED" : case "REPEATED" :
html = html = "<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
"<span><i class='fw fw-ok icon-warning'></i> Repeated</span>";
break; break;
} }
return html; return html;
} }
}, },
{ {targets: 2, data: "createdTimeStamp", render:
targets: 2, function (date) {
data: "createdTimeStamp",
render: function (date) {
var value = String(date); var value = String(date);
return value.slice(0, 16); return value.slice(0, 16);
} }
@ -122,28 +108,16 @@
function(colIndex) { function(colIndex) {
switch(colIndex) { switch(colIndex) {
case 1: case 1:
$(this).attr( $(this).attr("data-grid-label", "Code");
"data-grid-label", $(this).attr("data-display", data["code"]);
"Code");
$(this).attr(
"data-display",
data["code"]);
break; break;
case 2: case 2:
$(this).attr( $(this).attr("data-grid-label", "Status");
"data-grid-label", $(this).attr("data-display", data["status"]);
"Status");
$(this).attr(
"data-display",
data["status"]);
break; break;
case 3: case 3:
$(this).attr( $(this).attr("data-grid-label", "Created Timestamp");
"data-grid-label", $(this).attr("data-display", data["createdTimeStamp"]);
"Created Timestamp");
$(this).attr(
"data-display",
data["createdTimeStamp"]);
break; break;
} }
} }
@ -163,10 +137,8 @@
"policy-view", "policy-view",
policyComplianceTemplate, policyComplianceTemplate,
function (template) { function (template) {
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
+ "/effective-policy"; var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId
+ "/compliance-data";
invokerUtil.get( invokerUtil.get(
getEffectivePolicyURL, getEffectivePolicyURL,
@ -191,8 +163,7 @@
if (data["complianceData"]["complianceFeatures"] && if (data["complianceData"]["complianceFeatures"] &&
data["complianceData"]["complianceFeatures"].length > 0) { data["complianceData"]["complianceFeatures"].length > 0) {
viewModel["compliance"] = "NON-COMPLIANT"; viewModel["compliance"] = "NON-COMPLIANT";
viewModel["complianceFeatures"] = viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"];
data["complianceData"]["complianceFeatures"];
content = template(viewModel); content = template(viewModel);
$("#policy-list-container").html(content); $("#policy-list-container").html(content);
} else { } else {
@ -202,17 +173,16 @@
$("#policy-compliance-table").addClass("hidden"); $("#policy-compliance-table").addClass("hidden");
} }
} else { } else {
$("#policy-list-container").html( $("#policy-list-container").
"<div class='panel-body'><br><p class='fw-warning'> This device " + html("<div class='panel-body'><br><p class='fw-warning'> This device " +
"has no policy applied.<p></div>"); "has no policy applied.<p></div>");
} }
} }
}, },
// error-callback // error-callback
function () { function () {
$("#policy-list-container").html( $("#policy-list-container").
"<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " 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>"); "was not successful. please try refreshing data in a while.<p></div>");
} }
); );
@ -221,9 +191,8 @@
}, },
// error-callback // error-callback
function () { function () {
$("#policy-list-container").html( $("#policy-list-container").
"<div class='panel-body'><br><p class='fw-warning'> Loading policy compliance related data " 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>"); "was not successful. please try refreshing data in a while.<p></div>");
} }
); );

Loading…
Cancel
Save