From 9148c3baeaf8c74963cfa99db665e847afe9de71 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 22 Sep 2016 08:54:40 +0530 Subject: [PATCH 1/4] Fixing dashboard styling issues --- .../pages/cdmf.page.dashboard/dashboard.hbs | 129 ++++++++---------- .../pages/cdmf.page.dashboard/dashboard.js | 18 +-- 2 files changed, 65 insertions(+), 82 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs index 02be4f0a7e3..199e362a46d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs @@ -26,25 +26,26 @@ {{/zone}} {{#zone "content"}} -
+
{{#if permissions.VIEW_DASHBOARD}} -
-
-
-
Devices
-
-
-
- {{device_count}} +
+
+
Devices
+
+
+
+ {{deviceCount}} - - - - - - View - + {{#if deviceCount}} + + + + + + View + + {{/if}} @@ -54,20 +55,19 @@ Add -
-
-
-
-
Groups
-
-
-
- {{group_count}} +
+
+
Groups
+
+
+
+ {{groupCount}} + {{#if groupCount}} @@ -76,6 +76,7 @@ View + {{/if}} @@ -85,20 +86,19 @@ Add -
-
-
-
-
Users
-
-
-
- {{user_count}} +
+
+
Users
+
+
+
+ {{userCount}} + {{#if userCount}} @@ -107,6 +107,7 @@ View + {{/if}} @@ -116,20 +117,19 @@ Add -
-
-
-
-
Policies
-
-
-
- {{policy_count}} +
+
+
Policies
+
+
+
+ {{policyCount}} + {{#if policyCount}} @@ -138,6 +138,7 @@ View + {{/if}} @@ -147,20 +148,19 @@ Add -
-
-
-
-
Roles
-
-
-
- {{role_count}} +
+
+
Roles
+
+
+
+ {{roleCount}} + {{#if roleCount}} @@ -169,6 +169,7 @@ View + {{/if}} @@ -178,32 +179,14 @@ Add -
{{else}} - Permission denied +

+ Permitted None +

{{/if}}
- {{/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.dashboard/dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js index c5682c0c5b8..c848b86f6eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js @@ -32,16 +32,16 @@ function onRequest() { return; } - var page = {}; - page.permissions = permissions; - page.enrollmentURL = devicemgtProps.enrollmentURL; - page.device_count = deviceModule.getDevicesCount(); + var viewModel = {}; + viewModel.permissions = permissions; + viewModel.enrollmentURL = devicemgtProps.enrollmentURL; + viewModel.deviceCount = deviceModule.getDevicesCount(); //TODO: Enable Group Management Service API on CDMF //page.group_count = groupModule.getGroupCount(); - page.group_count = -1; - page.user_count = userModule.getUsersCount(); - page.policy_count = policyModule.getPoliciesCount(); - page.role_count = userModule.getRolesCount(); + viewModel.groupCount = -1; + viewModel.userCount = userModule.getUsersCount(); + viewModel.policyCount = policyModule.getPoliciesCount(); + viewModel.roleCount = userModule.getRolesCount(); - return page; + return viewModel; } \ No newline at end of file From 0fb87f3aa273922a570dc1b7d58fc21b84fa834e Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 22 Sep 2016 08:56:12 +0530 Subject: [PATCH 2/4] Fixing device types not shown issue --- .../cdmf.unit.device.types.listing/listing.js | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js index e9c68c64521..62ca011b0bf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/listing.js @@ -27,12 +27,12 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; var typesListResponse = deviceModule.getDeviceTypes(); if (typesListResponse["status"] == "success") { - var deviceTypes = typesListResponse["content"]; + var deviceTypes = typesListResponse.content.deviceTypes; if (deviceTypes) { var deviceTypesList = [], virtualDeviceTypesList = []; for (var i = 0; i < deviceTypes.length; i++) { - - var deviceTypeLabel = deviceTypes[i].name; + var deviceType = deviceTypes[i]; + var deviceTypeLabel = deviceType; var configs = utility.getDeviceTypeConfig(deviceTypeLabel); var deviceCategory = "device"; if (configs) { @@ -45,22 +45,20 @@ function onRequest(context) { } if (deviceCategory == 'virtual') { virtualDeviceTypesList.push({ - "hasCustTemplate": false, - "deviceTypeLabel": deviceTypeLabel, - "deviceTypeName": deviceTypes[i].name, - "deviceCategory": deviceCategory, - "deviceTypeId": deviceTypes[i].id, - "thumb": utility.getDeviceThumb(deviceTypes[i].name) - }); + "hasCustTemplate": false, + "deviceTypeLabel": deviceTypeLabel, + "deviceTypeName": deviceType, + "deviceCategory": deviceCategory, + "thumb": utility.getDeviceThumb(deviceType) + }); } else { deviceTypesList.push({ - "hasCustTemplate": false, - "deviceTypeLabel": deviceTypeLabel, - "deviceTypeName": deviceTypes[i].name, - "deviceCategory": deviceCategory, - "deviceTypeId": deviceTypes[i].id, - "thumb": utility.getDeviceThumb(deviceTypes[i].name) - }); + "hasCustTemplate": false, + "deviceTypeLabel": deviceTypeLabel, + "deviceTypeName": deviceType, + "deviceCategory": deviceCategory, + "thumb": utility.getDeviceThumb(deviceType) + }); } } if (virtualDeviceTypesList.length > 0) { From 513015c1b5f752215f79c78b89261f071190e0ed Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 22 Sep 2016 08:56:41 +0530 Subject: [PATCH 3/4] Changing context path /emm into /devicemgt on cdmf base app --- .../main/resources/jaggeryapps/devicemgt/app/conf/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index cf19f5ec5b1..9625762d806 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,5 +1,5 @@ { - "appContext": "/emm/", + "appContext": "/devicemgt/", "webAgentContext" : "/emm-web-agent/", "apiContext": "api", "httpsURL" : "%https.ip%", From e71d3947cba6eb7dc369481b8920f304f15cba4f Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 22 Sep 2016 08:57:34 +0530 Subject: [PATCH 4/4] Adding intuitive error when specified notification provider is not found --- .../DeviceManagementPluginRepository.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java index 504d29d5f18..8246c7e2839 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementPluginRepository.java @@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; +import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent; @@ -74,7 +75,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis } } catch (DeviceManagementException e) { throw new DeviceManagementException("Error occurred while adding device management provider '" + - deviceType + "'", e); + deviceType + "'", e); } if (isSharedWithAllTenants) { DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType); @@ -137,10 +138,16 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId); } + if (pushNoteConfig != null) { - NotificationStrategy notificationStrategy = - DeviceManagementDataHolder.getInstance().getPushNotificationProviderRepository().getProvider( - pushNoteConfig.getType()).getNotificationStrategy(pushNoteConfig); + PushNotificationProvider provider = DeviceManagementDataHolder.getInstance() + .getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType()); + if (provider == null) { + throw new DeviceManagementException( + "No registered push notification provider found for the type: '" + + pushNoteConfig.getType() + "'."); + } + NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig); operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl( notificationStrategy)); } else { @@ -172,7 +179,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis deviceTypeName = provider.getType().toLowerCase(); ProvisioningConfig provisioningConfig = provider.getProvisioningConfig(); int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain()); - DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, provisioningConfig.isSharedWithAllTenants()); + DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, + provisioningConfig.isSharedWithAllTenants()); registerPushNotificationStrategy(provider); //TODO: //This is a temporory fix. @@ -180,12 +188,13 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis //until fix that, use following variable to enable and disable of checking user authorization. DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(), - provider.getDeviceManager().requireDeviceAuthorization()); + provider.getDeviceManager() + .requireDeviceAuthorization()); } catch (Throwable e) { /* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters, etc - should not block the initialization of other device management providers */ log.error("Error occurred while initializing device management provider '" + - provider.getType() + "'", e); + provider.getType() + "'", e); } } this.isInited = true;