|
|
@ -16,12 +16,12 @@
|
|
|
|
* under the License.
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
var deviceOwner = deviceId.data("owner");
|
|
|
|
var deviceOwner = deviceId.data("owner");
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function() {
|
|
|
|
$(".panel-body").removeClass("hidden");
|
|
|
|
$(".panel-body").removeClass("hidden");
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$("#loading-content").remove();
|
|
|
|
|
|
|
|
|
|
|
@ -34,25 +34,143 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#refresh-policy").click(function () {
|
|
|
|
$("#refresh-policy").click(function() {
|
|
|
|
$('#policy-spinner').removeClass('hidden');
|
|
|
|
$('#policy-spinner').removeClass('hidden');
|
|
|
|
loadPolicyCompliance();
|
|
|
|
loadPolicyCompliance();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#refresh-operations").click(function () {
|
|
|
|
$("#refresh-operations").click(function() {
|
|
|
|
$('#operations-spinner').removeClass('hidden');
|
|
|
|
$('#operations-spinner').removeClass('hidden');
|
|
|
|
loadOperationsLog(true);
|
|
|
|
loadOperationsLog(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadOperationsLog() {
|
|
|
|
|
|
|
|
var table = $('#operation-log').DataTable({
|
|
|
|
|
|
|
|
serverSide: true,
|
|
|
|
|
|
|
|
processing: false,
|
|
|
|
|
|
|
|
searching: false,
|
|
|
|
|
|
|
|
ordering: false,
|
|
|
|
|
|
|
|
pageLength: 10,
|
|
|
|
|
|
|
|
order: [],
|
|
|
|
|
|
|
|
autoWidth: false,
|
|
|
|
|
|
|
|
ajax: {
|
|
|
|
|
|
|
|
url: "/devicemgt/api/operation/paginate",
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
deviceId: deviceIdentifier,
|
|
|
|
|
|
|
|
deviceType: deviceType,
|
|
|
|
|
|
|
|
owner: deviceOwner
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
dataSrc: function(json) {
|
|
|
|
|
|
|
|
$("#operations-spinner").addClass("hidden");
|
|
|
|
|
|
|
|
$("#operations-log-container").empty();
|
|
|
|
|
|
|
|
return json.data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
columnDefs: [{
|
|
|
|
|
|
|
|
targets: 0,
|
|
|
|
|
|
|
|
data: "code",
|
|
|
|
|
|
|
|
class: "icon-only content-fill"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
targets: 1,
|
|
|
|
|
|
|
|
data: "createdTimeStamp",
|
|
|
|
|
|
|
|
class: "text-right",
|
|
|
|
|
|
|
|
render: function(date) {
|
|
|
|
|
|
|
|
var value = String(date);
|
|
|
|
|
|
|
|
return value.slice(0, 16);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
targets: 2,
|
|
|
|
|
|
|
|
data: "status",
|
|
|
|
|
|
|
|
class: "text-right extended-log-data log-record-status",
|
|
|
|
|
|
|
|
render: function(data, type, full, meta) {
|
|
|
|
|
|
|
|
return '<i class="icon fw fw-success"></i><span> ' + data + ' </span><i class="icon fw fw-down"></i>';
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
width: "100%"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
fnCreatedRow: function(nRow, aData, iDataIndex) {
|
|
|
|
|
|
|
|
$('td:eq(0)', nRow)
|
|
|
|
|
|
|
|
.attr('data-search', aData.Device_Type)
|
|
|
|
|
|
|
|
.attr('data-display', aData.Device_Type)
|
|
|
|
|
|
|
|
.addClass(' icon-only content-fill');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('td:eq(1), td:eq(2)', nRow).addClass('text-right');
|
|
|
|
|
|
|
|
$('td:eq(2)', nRow).addClass('log-record-status')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#operation-log tbody').on('click', 'td.extended-log-data', function() {
|
|
|
|
|
|
|
|
var tr = $(this).closest('tr');
|
|
|
|
|
|
|
|
var row = table.row(tr);
|
|
|
|
|
|
|
|
var rowData = row.data()
|
|
|
|
|
|
|
|
var deviceid = $('.device-id').data('deviceid');
|
|
|
|
|
|
|
|
var deviceType = $('.device-id').data('type');
|
|
|
|
|
|
|
|
var uri = "/api/device-mgt/v1.0/activities/" + rowData.activityId + "/" + deviceType + "/" + deviceid;
|
|
|
|
|
|
|
|
var contentType = "application/json";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (row.child.isShown()) {
|
|
|
|
|
|
|
|
row.child.hide();
|
|
|
|
|
|
|
|
$(row.child()).removeClass('log-data-row');
|
|
|
|
|
|
|
|
tr.removeClass('shown');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
invokerUtil.get(uri,(payload) => {
|
|
|
|
|
|
|
|
row.child(renderLogDetails(row.data(),payload)).show();
|
|
|
|
|
|
|
|
$(row.child()).addClass('log-data-row');
|
|
|
|
|
|
|
|
tr.addClass('shown');
|
|
|
|
|
|
|
|
},(error) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},contentType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function loadOperationsLog(update) {
|
|
|
|
function renderLogDetails(obj,data) {
|
|
|
|
|
|
|
|
var payload = JSON.parse(data);
|
|
|
|
|
|
|
|
var logStream = '<div class="log-data">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(payload.activityStatus).forEach(
|
|
|
|
|
|
|
|
([key, entry]) => {
|
|
|
|
|
|
|
|
logStream += '<div class="row log-entry">' +
|
|
|
|
|
|
|
|
'<div class="col-lg-8">' +
|
|
|
|
|
|
|
|
'<div class="log-status"><i class="icon fw ' + getLogStatusIcon(entry.status) + ' "></i>' +
|
|
|
|
|
|
|
|
'<span>' + entry.status + '</span></div>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'<div class="col-lg-4">' +
|
|
|
|
|
|
|
|
'<div class="log-time text-right"><span>' + entry.updatedTimestamp + '</span></div>' +
|
|
|
|
|
|
|
|
'</div>' +
|
|
|
|
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
logStream += '</div></div>';
|
|
|
|
|
|
|
|
return logStream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getLogStatusIcon(entry) {
|
|
|
|
|
|
|
|
switch (entry) {
|
|
|
|
|
|
|
|
case 'COMPLETED':
|
|
|
|
|
|
|
|
return 'fw-success'
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'PENDING':
|
|
|
|
|
|
|
|
return 'fw-pending'
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return 'fw-info'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadOperationsLog2(update) {
|
|
|
|
var operationsLogTable = "#operations-log-table";
|
|
|
|
var operationsLogTable = "#operations-log-table";
|
|
|
|
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
if (update) {
|
|
|
|
operationTable = $(operationsLogTable).DataTable();
|
|
|
|
operationTable = $(operationsLogTable).DataTable();
|
|
|
|
$("#operations-spinner").removeClass("hidden");
|
|
|
|
$("#operations-spinner").removeClass("hidden");
|
|
|
|
operationTable.ajax.reload(function ( json ) {
|
|
|
|
operationTable.ajax.reload(function(json) {
|
|
|
|
$("#operations-spinner").addClass("hidden");
|
|
|
|
$("#operations-spinner").addClass("hidden");
|
|
|
|
}, false);
|
|
|
|
}, false);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -62,45 +180,54 @@
|
|
|
|
processing: false,
|
|
|
|
processing: false,
|
|
|
|
searching: false,
|
|
|
|
searching: false,
|
|
|
|
ordering: false,
|
|
|
|
ordering: false,
|
|
|
|
pageLength : 10,
|
|
|
|
pageLength: 10,
|
|
|
|
order: [],
|
|
|
|
order: [],
|
|
|
|
ajax: {
|
|
|
|
ajax: {
|
|
|
|
|
|
|
|
|
|
|
|
url: "/devicemgt/api/operation/paginate",
|
|
|
|
url: "/devicemgt/api/operation/paginate",
|
|
|
|
data: {deviceId : deviceIdentifier, deviceType: deviceType, owner: deviceOwner},
|
|
|
|
data: {
|
|
|
|
dataSrc: function (json) {
|
|
|
|
deviceId: deviceIdentifier,
|
|
|
|
|
|
|
|
deviceType: deviceType,
|
|
|
|
|
|
|
|
owner: deviceOwner
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
dataSrc: function(json) {
|
|
|
|
$("#operations-spinner").addClass("hidden");
|
|
|
|
$("#operations-spinner").addClass("hidden");
|
|
|
|
$("#operations-log-container").empty();
|
|
|
|
$("#operations-log-container").empty();
|
|
|
|
return json.data;
|
|
|
|
return json.data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
columnDefs: [
|
|
|
|
columnDefs: [{
|
|
|
|
{targets: 0, data: "code" },
|
|
|
|
targets: 0,
|
|
|
|
{targets: 1, data: "status", render:
|
|
|
|
data: "code"
|
|
|
|
function (status) {
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
targets: 1,
|
|
|
|
|
|
|
|
data: "status",
|
|
|
|
|
|
|
|
render: function(status) {
|
|
|
|
var html;
|
|
|
|
var html;
|
|
|
|
switch (status) {
|
|
|
|
switch (status) {
|
|
|
|
case "COMPLETED" :
|
|
|
|
case "COMPLETED":
|
|
|
|
html = "<span><i class='fw fw-success icon-success'></i> Completed</span>";
|
|
|
|
html = "<span><i class='fw fw-success icon-success'></i> Completed</span>";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "PENDING" :
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
case "ERROR" :
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
case "IN_PROGRESS" :
|
|
|
|
case "IN_PROGRESS":
|
|
|
|
html = "<span><i class='fw fw-success icon-warning'></i> In Progress</span>";
|
|
|
|
html = "<span><i class='fw fw-success icon-warning'></i> In Progress</span>";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "REPEATED" :
|
|
|
|
case "REPEATED":
|
|
|
|
html = "<span><i class='fw fw-success icon-warning'></i> Repeated</span>";
|
|
|
|
html = "<span><i class='fw fw-success icon-warning'></i> Repeated</span>";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return html;
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{targets: 2, data: "createdTimeStamp", render:
|
|
|
|
{
|
|
|
|
function (date) {
|
|
|
|
targets: 2,
|
|
|
|
|
|
|
|
data: "createdTimeStamp",
|
|
|
|
|
|
|
|
render: function(date) {
|
|
|
|
var value = String(date);
|
|
|
|
var value = String(date);
|
|
|
|
return value.slice(0, 16);
|
|
|
|
return value.slice(0, 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -112,7 +239,7 @@
|
|
|
|
$(row).attr("data-id", data["id"]);
|
|
|
|
$(row).attr("data-id", data["id"]);
|
|
|
|
$.each($("td", row),
|
|
|
|
$.each($("td", row),
|
|
|
|
function(colIndex) {
|
|
|
|
function(colIndex) {
|
|
|
|
switch(colIndex) {
|
|
|
|
switch (colIndex) {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
$(this).attr("data-grid-label", "Code");
|
|
|
|
$(this).attr("data-grid-label", "Code");
|
|
|
|
$(this).attr("data-display", data["code"]);
|
|
|
|
$(this).attr("data-display", data["code"]);
|
|
|
@ -130,9 +257,9 @@
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadPolicyCompliance() {
|
|
|
|
function loadPolicyCompliance() {
|
|
|
|
var policyCompliance = $("#policy-view");
|
|
|
|
var policyCompliance = $("#policy-view");
|
|
|
|
var policyComplianceTemplate = policyCompliance.attr("src");
|
|
|
|
var policyComplianceTemplate = policyCompliance.attr("src");
|
|
|
|
var deviceId = policyCompliance.data("device-id");
|
|
|
|
var deviceId = policyCompliance.data("device-id");
|
|
|
@ -142,23 +269,23 @@
|
|
|
|
$.template(
|
|
|
|
$.template(
|
|
|
|
"policy-view",
|
|
|
|
"policy-view",
|
|
|
|
policyComplianceTemplate,
|
|
|
|
policyComplianceTemplate,
|
|
|
|
function (template) {
|
|
|
|
function(template) {
|
|
|
|
var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy";
|
|
|
|
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 getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data";
|
|
|
|
invokerUtil.get(
|
|
|
|
invokerUtil.get(
|
|
|
|
getEffectivePolicyURL,
|
|
|
|
getEffectivePolicyURL,
|
|
|
|
// success-callback
|
|
|
|
// success-callback
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
function(data, textStatus, jqXHR) {
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
$("#policy-spinner").addClass("hidden");
|
|
|
|
$("#policy-spinner").addClass("hidden");
|
|
|
|
if(data){
|
|
|
|
if (data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (data["active"] == true) {
|
|
|
|
if (data["active"] == true) {
|
|
|
|
activePolicy = data;
|
|
|
|
activePolicy = data;
|
|
|
|
invokerUtil.get(
|
|
|
|
invokerUtil.get(
|
|
|
|
getDeviceComplianceURL,
|
|
|
|
getDeviceComplianceURL,
|
|
|
|
// success-callback
|
|
|
|
// success-callback
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
function(data, textStatus, jqXHR) {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
var viewModel = {};
|
|
|
|
var viewModel = {};
|
|
|
|
viewModel["policy"] = activePolicy;
|
|
|
|
viewModel["policy"] = activePolicy;
|
|
|
@ -188,7 +315,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// error-callback
|
|
|
|
// error-callback
|
|
|
|
function () {
|
|
|
|
function() {
|
|
|
|
$("#policy-list-container").
|
|
|
|
$("#policy-list-container").
|
|
|
|
html("<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>");
|
|
|
@ -199,7 +326,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// error-callback
|
|
|
|
// error-callback
|
|
|
|
function () {
|
|
|
|
function() {
|
|
|
|
$("#policy-list-container").
|
|
|
|
$("#policy-list-container").
|
|
|
|
html("<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>");
|
|
|
@ -207,4 +334,4 @@
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|