From 075b5a89017f773d2ed2e7d5e22d809d9e32f2c4 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 18 May 2016 10:10:21 +0530 Subject: [PATCH] Fix for https://wso2.org/jira/browse/IOTS-155 & https://wso2.org/jira/browse/IOTS-164 --- .../cdmf.page.group.analytics/analytics.hbs | 39 +- .../cdmf.page.group.analytics/analytics.js | 48 +- .../app/pages/cdmf.page.policies/policies.hbs | 601 +++++++++++++++++- .../app/pages/cdmf.page.policies/policies.js | 44 +- .../public/js/policy-list.js | 0 .../public/js/bottomJs.js | 2 +- .../cdmf.unit.policy.listing/listing.hbs | 550 ---------------- .../units/cdmf.unit.policy.listing/listing.js | 60 -- .../cdmf.unit.policy.listing/listing.json | 3 - 9 files changed, 680 insertions(+), 667 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.policy.listing => pages/cdmf.page.policies}/public/js/policy-list.js (100%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.hbs delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.json diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs index 7fc77538b0c..b8fdc158ab0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs @@ -34,19 +34,34 @@ {{#zone "content"}}
-
-
-

{{groupName}} Analytics

+ {{#if deviceTypes}} +
+ {{unit "cdmf.unit.analytics.date-range-picker" deviceTypes=deviceTypes}}
- {{unit "cdmf.unit.analytics.date-range-picker" deviceTypes=deviceTypes}} -
-
-
-
- {{#each deviceTypes}} - {{unit deviceAnalyticsViewUnitName devices=devices}} - {{/each}} -
+
+
+
+ {{#each deviceTypes}} + {{unit deviceAnalyticsViewUnitName devices=devices}} + {{/each}} +
+ {{else}} +
+ +
+ {{/if}}
{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js index 64173b06c80..563660dadb2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js @@ -21,31 +21,35 @@ function onRequest(context) { var groupModule = require("/app/modules/group.js").groupModule; var groupName = context.uriParams.name; var groupOwner = context.uriParams.owner; - var deviceTypes = []; var devices = groupModule.getGroupDevices(groupName, groupOwner).data; - - for (var i = 0; i < devices.length; i++) { - var hasDeviceType = false; - for (var j = 0; j < deviceTypes.length; j++) { - if (deviceTypes[j].type === devices[i].type) { - deviceTypes[j].devices.push(devices[i]); - hasDeviceType = true; - break; + var page = { + "groupName": groupName, + "groupOwner": groupOwner, + "title": groupName + " Analytics" + }; + if (devices) { + var deviceTypes = []; + for (var i = 0; i < devices.length; i++) { + var hasDeviceType = false; + for (var j = 0; j < deviceTypes.length; j++) { + if (deviceTypes[j].type === devices[i].type) { + deviceTypes[j].devices.push(devices[i]); + hasDeviceType = true; + break; + } + } + if (!hasDeviceType) { + var deviceType = {}; + deviceType.type = devices[i].type; + deviceType.devices = []; + deviceType.devices.push(devices[i]); + deviceType.deviceAnalyticsViewUnitName = utility.getTenantedDeviceUnitName(deviceType.type, "analytics-view"); + deviceTypes.push(deviceType); } } - if (!hasDeviceType) { - var deviceType = {}; - deviceType.type = devices[i].type; - deviceType.devices = []; - deviceType.devices.push(devices[i]); - deviceType.deviceAnalyticsViewUnitName = utility.getTenantedDeviceUnitName(deviceType.type, "analytics-view"); - deviceTypes.push(deviceType); - } + page.deviceTypes = deviceTypes; + page.devices = devices; } - return { - "groupName": groupName, - "groupOwner": groupOwner, - "deviceTypes": deviceTypes - }; + return page; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs index 83299a80b7d..6a12ef4f905 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs @@ -1,7 +1,14 @@ {{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} - {{unit "cdmf.unit.data-tables-extended"}} +{{#zone "topCss"}} + +{{/zone}} + {{#zone "breadcrumbs"}}
  • @@ -17,26 +24,28 @@ {{#zone "navbarActions"}} {{#if permissions.ADD_ADMIN_POLICY}} -
  • - +
  • + - Add Policy - -
  • + Add Policy + + {{/if}} {{#if permissions.CHANGE_POLICY_PRIORITY}} -
  • - - - - - - Policy Priority - -
  • + {{#equal noPolicy false}} +
  • + + + + + + Policy Priority + +
  • + {{/equal}} {{/if}}
  • @@ -50,5 +59,565 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.policy.listing"}} + {{#equal noPolicy true}} + + {{/equal}} + {{#equal noPolicy false}} + {{#equal isUpdated true}} + + {{/equal}} +
    + + Loading policies . . . +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{#each policyListToView}} + + + + + + + + + + + + {{/each}} +
    + + + {{/equal}} +
    + + + +
    +
    +
    +
    +

    Do you really want to remove the selected policy(s)?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully removed.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    You cannot remove policies that are already applied to devices. Please deselect + them and try + again.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to publish the selected policy(s)?

    + +
    + Yes + No +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully published.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to unpublish the selected policy(s)?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully unpublished.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. New Policy priorities were successfully updated.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    +

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to apply changes to all policies?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Changes applied successfully.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + Please select a policy or a list of policies to unpublish. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + You cannot select already inactive policies. Please deselect inactive policies + and try again. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + You cannot select already active policies. Please deselect active policies and + try again. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + Please select a policy or a list of policies to publish. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + Please select a policy or a list of policies to remove. +

    + + +
    +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/policy-list.js"}} {{/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/pages/cdmf.page.policies/policies.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js index 90e536e62dd..b21d376f06a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.js @@ -27,6 +27,44 @@ function onRequest(context) { return options.fn(this); } }); - var userModule = require("/app/modules/user.js").userModule; - return {permissions: userModule.getUIPermissions()}; -} \ No newline at end of file + var page = {}; + var policyModule = require("/app/modules/policy.js")["policyModule"]; + var userModule = require("/app/modules/user.js")["userModule"]; + var response = policyModule.getAllPolicies(); + if (response["status"] == "success") { + var policyListToView = response["content"]; + page["policyListToView"] = policyListToView; + var policyCount = policyListToView.length; + if (policyCount == 0) { + page["policyListingStatusMsg"] = "No policy is available to be displayed."; + page["saveNewPrioritiesButtonEnabled"] = false; + page["noPolicy"] = true; + } else if (policyCount == 1) { + page["saveNewPrioritiesButtonEnabled"] = false; + page["noPolicy"] = false; + page["isUpdated"] = response["updated"]; + } else { + page["saveNewPrioritiesButtonEnabled"] = true; + page["noPolicy"] = false; + page["isUpdated"] = response["updated"]; + } + } else { + // here, response["status"] == "error" + page["policyListToView"] = []; + page["policyListingStatusMsg"] = "An unexpected error occurred @ backend. Please try again later."; + page["saveNewPrioritiesButtonEnabled"] = false; + page["noPolicy"] = true; + } + + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/delete")) { + page["removePermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) { + page["removePermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) { + page["editPermitted"] = true; + } + page.permissions = userModule.getUIPermissions(); + return page; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/public/js/policy-list.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/public/js/policy-list.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js index 3963ffeba18..cff14da8955 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js @@ -264,7 +264,6 @@ $(document).ready(function () { // Refreshing with success message $("#user-create-form").addClass("hidden"); $("#user-created-msg").removeClass("hidden"); - generateQRCode("#user-created-msg .qr-code"); } else if (data["statusCode"] == 409) { $(errorMsg).text(data["messageFromServer"]); $(errorMsgWrapper).removeClass("hidden"); @@ -273,6 +272,7 @@ $(document).ready(function () { $(errorMsgWrapper).removeClass("hidden"); } }, function (data) { + data = JSON.parse(data.responseText); if (data["statusCode"] == 409) { $(errorMsg).text("User : " + username + " already exists. Pick another username."); } else if (data["statusCode"] == 500) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.hbs deleted file mode 100644 index 257f17fae12..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.hbs +++ /dev/null @@ -1,550 +0,0 @@ -{{#zone "topCss"}} - -{{/zone}} -{{#equal isUpdated true}} - -{{/equal}} -
    - - Loading policies . . . -
    -
    - -{{#equal noPolicy false}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each policyListToView}} - - - - - - - - - - - - {{/each}} -
    - - -{{/equal}} -
    - - - -
    -
    -
    -
    -

    Do you really want to remove the selected policy(s)?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. Selected policy was successfully removed.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    You cannot remove policies that are already applied to devices. Please deselect - them and try - again.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to publish the selected policy(s)?

    - -
    - Yes - No -
    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. Selected policy was successfully published.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to unpublish the selected policy(s)?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. Selected policy was successfully unpublished.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. New Policy priorities were successfully updated.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    -

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to apply changes to all policies?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. Changes applied successfully.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - Please select a policy or a list of policies to unpublish. -

    - - -
    -
    -
    -
    -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - You cannot select already inactive policies. Please deselect inactive policies - and try again. -

    - - -
    -
    -
    -
    -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - You cannot select already active policies. Please deselect active policies and - try again. -

    - - -
    -
    -
    -
    -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - Please select a policy or a list of policies to publish. -

    - - -
    -
    -
    -
    -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - Please select a policy or a list of policies to remove. -

    - - -
    -
    -
    -
    - - -{{#zone "bottomJs"}} - {{js "js/policy-list.js"}} -{{/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.policy.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js deleted file mode 100644 index b3c27be6cd4..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - // var log = new Log("policy-listing.js"); - var policyModule = require("/app/modules/policy.js")["policyModule"]; - var userModule = require("/app/modules/user.js")["userModule"]; - var response = policyModule.getAllPolicies(); - if (response["status"] == "success") { - var policyListToView = response["content"]; - context["policyListToView"] = policyListToView; - var policyCount = policyListToView.length; - if (policyCount == 0) { - context["policyListingStatusMsg"] = "No policy is available to be displayed."; - context["saveNewPrioritiesButtonEnabled"] = false; - context["noPolicy"] = true; - } else if (policyCount == 1) { - context["saveNewPrioritiesButtonEnabled"] = false; - context["noPolicy"] = false; - context["isUpdated"] = response["updated"]; - } else { - context["saveNewPrioritiesButtonEnabled"] = true; - context["noPolicy"] = false; - context["isUpdated"] = response["updated"]; - } - } else { - // here, response["status"] == "error" - context["policyListToView"] = []; - context["policyListingStatusMsg"] = "An unexpected error occurred @ backend. Please try again later."; - context["saveNewPrioritiesButtonEnabled"] = false; - context["noPolicy"] = true; - } - - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/delete")) { - context["removePermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) { - context["removePermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) { - context["editPermitted"] = true; - } - - return context; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.json deleted file mode 100644 index ec74a2db536..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.listing/listing.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file