From b3642730ad723d0e966cc167d33a2125373092fb Mon Sep 17 00:00:00 2001 From: dunithd Date: Thu, 22 Jun 2017 16:49:01 +0530 Subject: [PATCH] Adding refresh button for the operations log tab --- .../public/js/device-view.js | 106 ++---------------- .../app/units/cdmf.unit.device.view/view.hbs | 30 +++-- 2 files changed, 24 insertions(+), 112 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js index cf6b1dda7c..21df805437 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/js/device-view.js @@ -46,7 +46,16 @@ $(document).ready(function() { }); -function loadOperationsLog() { +function loadOperationsLog(update) { + var operationsLogTable = "#operation-log"; + if (update) { + operationTable = $(operationsLogTable).DataTable(); + $("#operations-spinner").removeClass("hidden"); + operationTable.ajax.reload(function(json) { + $("#operations-spinner").addClass("hidden"); + }, false); + return; + } var table = $('#operation-log').DataTable({ serverSide: true, processing: false, @@ -164,101 +173,6 @@ function loadOperationsLog() { } } -function loadOperationsLog2(update) { - var operationsLogTable = "#operations-log-table"; - - if (update) { - operationTable = $(operationsLogTable).DataTable(); - $("#operations-spinner").removeClass("hidden"); - operationTable.ajax.reload(function(json) { - $("#operations-spinner").addClass("hidden"); - }, false); - return; - } - operationTable = $(operationsLogTable).datatables_extended({ - serverSide: true, - processing: false, - searching: false, - ordering: false, - pageLength: 10, - order: [], - 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" - }, - { - targets: 1, - data: "status", - render: function(status) { - var html; - switch (status) { - case "COMPLETED": - html = " Completed"; - break; - case "PENDING": - html = " Pending"; - break; - case "ERROR": - html = " Error"; - break; - case "IN_PROGRESS": - html = " In Progress"; - break; - case "REPEATED": - html = " Repeated"; - break; - } - return html; - } - }, - { - targets: 2, - data: "createdTimeStamp", - render: function(date) { - var value = String(date); - return value.slice(0, 16); - } - } - ], - "createdRow": function(row, data) { - - $(row).attr("data-type", "selectable"); - $(row).attr("data-id", data["id"]); - $.each($("td", row), - function(colIndex) { - switch (colIndex) { - case 1: - $(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"]); - break; - case 3: - $(this).attr("data-grid-label", "Created Timestamp"); - $(this).attr("data-display", data["createdTimeStamp"]); - break; - } - } - ); - } - }); -} - function loadPolicyCompliance() { var policyCompliance = $("#policy-view"); var policyComplianceTemplate = policyCompliance.attr("src"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs index e9b704cd7a..8e56318b74 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs @@ -56,10 +56,8 @@ -
- {{#defineZone "device-details"}} - {{/defineZone}} -
+ {{#defineZone "device-details"}} + {{/defineZone}} {{#defineZone "device-opetations"}}
@@ -82,6 +80,18 @@
{{#defineZone "device-view-tab-contents"}}
+
+ +
+
-
{{#defineZone "device-view-tab-injected-conents"}}