From ae9dd807ccd7de8ca37977ace045b470067369cd Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Tue, 1 Jan 2019 08:19:53 +0000 Subject: [PATCH] Enrollment application install feature for policy --- .../devicemgt/app/conf/config.json | 6 +- .../modules/business-controllers/policy.js | 66 +++++++++ .../pages/cdmf.page.policy.create/create.hbs | 18 +++ .../app/pages/cdmf.page.policy.edit/edit.hbs | 18 +++ .../app/pages/cdmf.page.policy.view/view.hbs | 18 +++ .../units/cdmf.unit.policy.create/create.hbs | 4 +- .../units/cdmf.unit.policy.create/create.js | 20 +++ .../public/js/policy-create.js | 39 ++++- .../app/units/cdmf.unit.policy.edit/edit.hbs | 2 +- .../app/units/cdmf.unit.policy.edit/edit.js | 21 +++ .../public/js/policy-edit.js | 38 ++++- .../impl/ComplianceDecisionPointImpl.java | 133 ++++++++++-------- .../core/util/PolicyManagementConstants.java | 2 + 13 files changed, 320 insertions(+), 65 deletions(-) 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 d717cdae31e..ffe9bcaa863 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 @@ -156,10 +156,12 @@ "perm:admin:device-type", "perm:device:enroll", "perm:geo-service:analytics-view", - "perm:geo-service:alerts-manage" + "perm:geo-service:alerts-manage", + "appm:read" ], "isOAuthEnabled": true, "backendRestEndpoints": { - "deviceMgt": "/api/device-mgt/v1.0" + "deviceMgt": "/api/device-mgt/v1.0", + "appMgt": "/api/appm/store/v1.1" } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js index de106c6ecb6..c1be205a634 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js @@ -14,6 +14,23 @@ * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. + * + * + * Copyright (c) 2018, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. 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. */ var policyModule; @@ -180,6 +197,55 @@ policyModule = function () { } }; + /* + Get apps available in the store from backend service. + */ + publicMethods.getStoreAppsForPolicy = function () { + var carbonUser = session.get(constants["USER_SESSION_KEY"]); + if (!carbonUser) { + log.error("User object was not found in the session"); + userModule.logout(function () { + response.sendRedirect(devicemgtProps["appContext"] + "login"); + }); + } + try { + var url = devicemgtProps["managerHTTPSURL"] + devicemgtProps["backendRestEndpoints"]["appMgt"] + + "/apps/mobileapp?field-filter=all"; + return serviceInvokers.XMLHttp.get(url, + function (backendResponse) { + var response = {}; + if (backendResponse.status === 200 && backendResponse.responseText) { + var appListFromRestEndpoint = parse(backendResponse.responseText)["appList"]; + var storeApps = []; + var i, appObjectFromRestEndpoint, appObjectToView; + for (i=0; i