From 86fb8b16ef2929d97222811579c9deb357e30909 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Thu, 18 Jul 2019 22:25:44 +0530 Subject: [PATCH] Improve app subscription flow --- .../core/impl/SubscriptionManagerImpl.java | 16 +++++++++------- .../apps/release/install/AppInstallModal.js | 2 +- .../apps/release/install/DeviceInstall.js | 19 +++++++++++++------ .../main/resources/conf/application-mgt.xml | 4 ++++ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index bee2aad2af..5cbe5b8696 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -335,29 +335,31 @@ public class SubscriptionManagerImpl implements SubscriptionManager { ConnectionManagerUtil.beginDBTransaction(); List deviceSubIds = new ArrayList<>(); - List subscribedEntities = new ArrayList<>(); if (SubsciptionType.USER.toString().equalsIgnoreCase(subType)) { - subscribedEntities = subscriptionDAO.getSubscribedUserNames(params, tenantId); + List subscribedEntities = subscriptionDAO.getSubscribedUserNames(params, tenantId); if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { params.removeAll(subscribedEntities); subscriptionDAO.addUserSubscriptions(tenantId, username, params, applicationReleaseId); } + subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType, + action); } else if (SubsciptionType.ROLE.toString().equalsIgnoreCase(subType)) { - subscribedEntities = subscriptionDAO.getSubscribedRoleNames(params, tenantId); + List subscribedEntities = subscriptionDAO.getSubscribedRoleNames(params, tenantId); if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { params.removeAll(subscribedEntities); subscriptionDAO.addRoleSubscriptions(tenantId, username, params, applicationReleaseId); - } + subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType, + action); } else if (SubsciptionType.GROUP.toString().equalsIgnoreCase(subType)) { - subscribedEntities = subscriptionDAO.getSubscribedGroupNames(params, tenantId); + List subscribedEntities = subscriptionDAO.getSubscribedGroupNames(params, tenantId); if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { params.removeAll(subscribedEntities); subscriptionDAO.addGroupSubscriptions(tenantId, username, params, applicationReleaseId); } + subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType, + action); } - subscriptionDAO.updateSubscriptions(tenantId, username, subscribedEntities, applicationReleaseId, subType, - action); for (Activity activity : activities) { int operationId = Integer.parseInt(activity.getActivityId().split("ACTIVITY_")[1]); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js index c6bd55d9fb..7ce22fecfd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppInstallModal.js @@ -1,5 +1,5 @@ import React from "react"; -import {Button, Modal, Tabs} from "antd"; +import {Modal, Tabs} from "antd"; import UserInstall from "./UserInstall"; import GroupInstall from "./GroupInstall"; import RoleInstall from "./RoleInstall"; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js index 9ddd088697..7946dd833a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -130,7 +130,8 @@ class DeviceInstall extends React.Component { //send request to the invoker axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams, + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/devices?" + encodedExtraParams, ).then(res => { if (res.status === 200) { @@ -147,7 +148,8 @@ class DeviceInstall extends React.Component { if (error.hasOwnProperty("status") && error.response.status === 401) { //todo display a popop with error message.error('You are not logged in'); - window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login'; + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + + config.serverConfig.httpsPort + '/store/login'; } else { notification["error"]({ message: "There was a problem", @@ -185,7 +187,7 @@ class DeviceInstall extends React.Component { type: device.type }); }); - this.props.onInstall("device", payload); + this.props.onInstall("devices", payload); }; @@ -193,7 +195,10 @@ class DeviceInstall extends React.Component { const {data,pagination,loading,selectedRows} = this.state; return (
- Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users. + + Start installing the application for one or more users by entering the corresponding user name. + Select install to automatically start downloading the application for the respective user/users. +
- +
); } } -export default DeviceInstall; \ No newline at end of file +export default DeviceInstall; diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index c5d034e6ac..f844cb9195 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -183,4 +183,8 @@ 110 + + + https +