From 8cdc8cfb246e7bf299351e90e597ac604382a13f Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Wed, 30 Nov 2016 14:18:40 +0530 Subject: [PATCH 1/2] IOTS-296: Refactoring Policy create/edit units --- .../public/js/policy-create.js | 12 +++++- .../app/units/cdmf.unit.policy.edit/edit.hbs | 2 +- .../public/js/policy-edit.js | 38 +++++++++++++++---- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js index b66dfd75665..2f849a44c94 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js @@ -59,6 +59,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) { } }; +/** + * Load all device groups. + * + * @param callback function to call on loading completion. + */ function loadGroups(callback) { invokerUtil.get( "/api/device-mgt/v1.0/groups", @@ -68,6 +73,12 @@ function loadGroups(callback) { }); } +/** + * Creates DeviceGroupWrapper object from selected groups. + * + * @param selectedGroups + * @returns {Array} DeviceGroupWrapper list. + */ var createDeviceGroupWrapper = function (selectedGroups) { var groupObjects = []; loadGroups(function (deviceGroups) { @@ -136,7 +147,6 @@ stepForwardFrom["policy-platform"] = function (actionButton) { $.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) { var content = template(); $("#device-type-policy-operations").html(content).removeClass("hidden"); - // $("#device-type-policy-operations").removeClass("hidden"); $(".policy-platform").addClass("hidden"); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs index 5863d6ba762..9a6135b607d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/edit.hbs @@ -63,7 +63,7 @@ -
+
"); } } }, @@ -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;