From 6126776fcfb6ea871e04ee3390946daa0abbed60 Mon Sep 17 00:00:00 2001 From: Ace Date: Wed, 30 Nov 2016 16:51:30 +0530 Subject: [PATCH] Adding android operations bar related changes --- .../public/js/device-view.js | 151 ++++++------ .../public/templates/operations-log.hbs | 24 -- .../app/units/cdmf.unit.device.view/view.hbs | 219 ++++++++---------- .../app/units/cdmf.unit.device.view/view.js | 26 +-- 4 files changed, 182 insertions(+), 238 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/templates/operations-log.hbs 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 20cc6f96f51..61c094c3b6b 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 @@ -20,6 +20,7 @@ var deviceId = $(".device-id"); var deviceIdentifier = deviceId.data("deviceid"); var deviceType = deviceId.data("type"); + var deviceOwner = deviceId.data("owner"); $(document).ready(function () { $(".panel-body").removeClass("hidden"); @@ -45,7 +46,7 @@ }); }); - + function loadOperationsLog(update) { var operationsLogTable = "#operations-log-table"; if (update) { @@ -54,76 +55,78 @@ return; } operationTable = $(operationsLogTable).datatables_extended({ - serverSide: true, - processing: false, - searching: false, - ordering: false, - pageLength : 10, - order: [], - ajax: { - url: context + "/api/operation/paginate", - data: {deviceId : deviceIdentifier, deviceType: deviceType}, - 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; - } - } - ); - } - }); + 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() { @@ -175,7 +178,7 @@ } else { $("#policy-list-container"). html("

This device " + - "has no policy applied.

"); + "has no policy applied.

"); } } }, @@ -183,7 +186,7 @@ function () { $("#policy-list-container"). html("


Loading policy compliance related data " + - "was not successful. please try refreshing data in a while.

"); + "was not successful. please try refreshing data in a while.

"); } ); } @@ -193,7 +196,7 @@ function () { $("#policy-list-container"). html("


Loading policy compliance related data " + - "was not successful. please try refreshing data in a while.

"); + "was not successful. please try refreshing data in a while.

"); } ); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/templates/operations-log.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/templates/operations-log.hbs deleted file mode 100644 index cc5db5117ad..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/public/templates/operations-log.hbs +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - {{#each operations}} - - - - - - {{/each}} -
- -
Operation CodeStatusRequest created at
{{code}} - {{#equal status "COMPLETED"}} Completed{{/equal}} - {{#equal status "PENDING"}} Pending{{/equal}} - {{#equal status "ERROR"}} Error{{/equal}} - {{#equal status "IN_PROGRESS"}} In Progress{{/equal}} - {{createdTimeStamp}}
\ No newline at end of file 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 ba038a531ba..252d7679ff9 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 @@ -59,141 +59,108 @@ - {{#defineZone "device-detail-properties"}} -

- - - -
-
- -
- {{unit "cdmf.unit.device.details" device=device}} -
-
-
Policies
-
- -
-
- No policies found -
-
-
+
+ +
+
+ + + {{#defineZone "device-view-tab-contents"}} + {{#defineZone "device-details-tab-contents"}} +
+

+ + No Device details avaialbe yet. +

- - - - - Add device specific policy -
- -
-
Policy Compliance
-
- -
-
Device Location
-
-
-
-
- Not available yet -
-
-
-
-
-
Operations Log
-
- -
+ {{/defineZone}} + {{/defineZone}} +
- - {{/defineZone}} +
{{else}}

@@ -206,6 +173,7 @@

Device not found

+
You have tried to access either a removed or non-existing device. {{/if}} @@ -221,7 +189,4 @@ - {{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js index 209f3c06541..c93097ab791 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.js @@ -95,8 +95,8 @@ function onRequest(context) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { viewModel["internalMemory"]["usage"] = Math. round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; + filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) + / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; } else { viewModel["internalMemory"]["usage"] = 0; } @@ -107,8 +107,8 @@ function onRequest(context) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) { viewModel["externalMemory"]["usage"] = Math. round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; + filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) + / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; } else { viewModel["externalMemory"]["usage"] = 0; } @@ -122,8 +122,8 @@ function onRequest(context) { if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) { viewModel["internalMemory"]["usage"] = Math. round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; + filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) + / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; } else { viewModel["internalMemory"]["usage"] = 0; } @@ -162,8 +162,8 @@ function onRequest(context) { if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) { viewModel["ramUsage"]["value"] = Math. round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] - - filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"]) - / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100; + filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"]) + / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100; } else { viewModel["ramUsage"]["value"] = 0; } @@ -174,8 +174,8 @@ function onRequest(context) { if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) { viewModel["internalMemory"]["usage"] = Math. round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] - - filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]) - / filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100; + filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]) + / filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100; } else { viewModel["internalMemory"]["usage"] = 0; } @@ -186,8 +186,8 @@ function onRequest(context) { if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) { viewModel["externalMemory"]["usage"] = Math. round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] - - filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"]) - / filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100; + filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"]) + / filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100; } else { viewModel["externalMemory"]["usage"] = 0; } @@ -196,7 +196,7 @@ function onRequest(context) { viewModel["deviceInfoAvailable"] = false; } - deviceViewData["deviceView"] = viewModel; + deviceViewData["device"] = viewModel; } else if (response["status"] == "unauthorized") { deviceViewData["deviceFound"] = true; deviceViewData["isAuthorized"] = false;