From f3b580277be0b79d32d962d315a03d985d764e4d Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Tue, 30 Apr 2019 13:48:16 +0530 Subject: [PATCH] Add UI for update enrollment --- .../devicemgt/app/conf/config.json | 1 + .../app/modules/business-controllers/user.js | 3 + .../app/pages/cdmf.page.devices/devices.hbs | 68 +++++++++++++++++++ .../app/pages/cdmf.page.devices/devices.js | 3 + .../cdmf.page.devices/public/js/listing.js | 62 +++++++++++++++++ 5 files changed, 137 insertions(+) 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 8e74ac0232..a87877d6dc 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 @@ -122,6 +122,7 @@ "perm:users:update", "perm:users:send-invitation", "perm:admin-users:view", + "perm:admin:devices:update-enrollment", "perm:groups:devices", "perm:groups:update", "perm:groups:add", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 416bb19795..25f92f9c7a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -620,6 +620,9 @@ var userModule = function () { if (publicMethods.isAuthorized("/permission/admin/device-mgt/topics/view")) { permissions["VIEW_TOPICS"] = true; } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/devices/update-enrollment")) { + permissions["UPDATE_ENROLLMENT"] = true; + } return permissions; }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index 96d763192b..0ff41a245b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -209,6 +209,22 @@ {{/if}} + + {{#if permissions.updateEnrollment}} +
  • + + + + + + Update Enrollment + +
  • + {{/if}} + @@ -513,6 +529,58 @@ + +
    + + + +
    + +
    + + + +
    + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js index 41afed6ae9..a04b0ab8ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js @@ -43,6 +43,9 @@ function onRequest(context) { if (uiPermissions.ADD_DEVICE) { viewModel.permissions.enroll = true; } + if (uiPermissions.UPDATE_ENROLLMENT) { + viewModel.permissions.updateEnrollment = true; + } viewModel.currentUser = currentUser; var deviceCount = 0; if (groupId) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index 26f3ea8ec6..c80e877b68 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -809,6 +809,68 @@ function attachDeviceEvents() { }); }); + /** + * Following click function would execute + * when a user clicks on "Update Enrollment" link + * on Device Management page. + */ + $("a.update-enrollment-link").click(function () { + var deviceIdentifiers = []; + var deviceId = $(this).data("deviceid"); + var deviceType = $(this).data("devicetype"); + + if (deviceId && deviceType) { + deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; + } else { + deviceIdentifiers = getSelectedDevices(); + } + + if (deviceIdentifiers.length === 0) { + $(modalPopupContent).html($('#no-device-selected').html()); + $("a#no-device-selected-link").click(function () { + hidePopup(); + }); + showPopup(); + return; + } + + $(modalPopupContent).html($('#update-enrollment-modal-content').html()); + showPopup(); + + $("a#update-enrollment-yes-link").click(function () { + var username = $("#update-enrollment-name").val(); + console.log(username); + if (username) { + var i; + var deviceIds = []; + for (i=0; i