-
-
Enter user name to manage group sharing
-
-
- - -
- - - -
-
- Next
-
+
+
+ + + + + + Group Sharing + +
+ +
+
+
+
+
+
+
+ Enter user name to manage group sharing
+
+
+
+ Enter user name to manage group sharing
+
+
+
+
+
+
+
+ Cancel
+
+
+ Next
+
-
- Cancel
-
-
-
-
-{{/zone}}
\ No newline at end of file
+{{/zone}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs
index ca52690eb0..fe87cb7896 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-bar/operation-bar.hbs
@@ -36,10 +36,14 @@
{{#each control_operations}}
- {{#if icon}}
-
+ {{#if iconFont}}
+
{{else}}
-
+ {{#if icon}}
+
+ {{else}}
+
+ {{/if}}
{{/if}}
{{name}}
@@ -61,7 +65,8 @@
-
-
-
-
+
+ Select sharing roles
--
Loading...
-
-
- OK
-
-
-
- Cancel
-
-
+
+
+ + + + + + Group Sharing + +
+ +
+
+
+
+
+
+
+ Select sharing roles
+
+
+ {{#if permissions.CREATE_GROUP_ROLES}}
+
+ {{/if}}
+
+ Select sharing roles
+
+
+
+
+
+
+ OK
+
+
+
+ Cancel
+
+
+
+
+
@@ -181,34 +276,46 @@
+
+ + + + + + Group Sharing Role + +
+ +
+
+
+
+
+
+
+ Enter Group Sharing Role Name
+
+
+
+ {{#each groupPermissions}}
+
+
+
+ Enter Group Sharing Role Name
+
+
+
+ Role Permissions
+
+
+ {{this}} | ++ + + + | +
+
+
+ OK
+
+
+
+ Cancel
+
-
-
'; } $('#user-roles').html(str); @@ -490,6 +524,9 @@ function generateRoleMap(groupId, selectedUser, allRoles) { } updateGroupShare(groupId, selectedUser, roles); }); + $("a#share-group-w2-add-new-role-link").click(function () { + addNewRole(groupId, selectedUser, allRoles); + }); } else { displayErrors(xhr); } @@ -497,7 +534,7 @@ function generateRoleMap(groupId, selectedUser, allRoles) { invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles?userName=" + selectedUser, successCallback, function (message) { - displayErrors(message); + displayErrors(message); }); $("a#share-group-w2-cancel-link").click(function () { @@ -505,6 +542,63 @@ function generateRoleMap(groupId, selectedUser, allRoles) { }); } +function addNewRole(groupId, selectedUser, allRoles) { + $(modalPopupContent).html($('#share-group-w3-modal-content').html()); + function getPermissions() { + var PERMISSION_PREFIX = '/permission/admin/'; + var permissions = []; + $('#permission-table-container').find('tr').each(function () { + var row = $(this).closest('tr'); + var permission = $(row).find('td:nth-child(1)').text(); + var check = $(row).find('td:nth-child(2) a').data('value'); + if(check === 'checked') { + permission = PERMISSION_PREFIX + permission; + permissions.push(permission); + } + }); + return permissions; + }; + $("a#share-group-w3-yes-link").click(function () { + var successCallback = function (data, status, jqXHR) { + if(status == "success") { + getAllRoles(groupId, selectedUser); + } + } + var roleName = $('#group-sharing-role-name').val(); + var users = []; + if(roleName) { + var groupRoleInfo = {"roleName": roleName, "permissions": getPermissions(), "users": users}; + var currentUser = $("#group-listing").data("current-user"); + invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles/create?userName=" + currentUser, + groupRoleInfo, successCallback, function (message) { + displayErrors(message); + }); + } else { + var errorMsgWrapper = "#notification-error-msg"; + var errorMsg = "#notification-error-msg span"; + $(errorMsg).text("Role name cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } + }); + $("a#share-group-w3-cancel-link").click(function () { + hidePopup(); + }); +} + +function togglePermissionAction(element) { + $(element).data('value', 'checked'); + var icon = $(element).find("i")[1]; + if($(icon).hasClass('fw-minus')) { + $(icon).removeClass('fw-minus'); + $(icon).addClass('fw-add'); + $(element).data('value', 'unchecked'); + } else { + $(icon).removeClass('fw-add'); + $(icon).addClass('fw-minus'); + $(element).data('value', 'checked'); + } +} + function updateGroupShare(groupId, selectedUser, roles) { var successCallback = function (data) { $(modalPopupContent).html($('#share-group-200-content').html()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs index 7961b2b65b..105c65ac6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs @@ -49,10 +49,12 @@ - {{defineZone "signInForm-below" scope="protected"}} +
-
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js
index 532ce661c7..0c04f9bb2d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.js
@@ -20,11 +20,13 @@ function onRequest(context) {
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var constants = require("/app/modules/constants.js");
+ var groupPermissions = require("/app/pages/cdmf.page.groups/public/group-permissions.json");
var currentUser = session.get(constants.USER_SESSION_KEY);
var page = {};
if (currentUser) {
page.permissions = userModule.getUIPermissions();
page.permissions.list = stringify(page.permissions);
+ page.groupPermissions = groupPermissions.permissionList;
page.currentUser = currentUser;
var groupCount = groupModule.getGroupCount();
if (groupCount > 0) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/group-permissions.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/group-permissions.json
new file mode 100644
index 0000000000..92a8ccfd5d
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/group-permissions.json
@@ -0,0 +1,15 @@
+{
+ "permissionList":["device-mgt/admin/groups/view",
+ "device-mgt/groups/add",
+ "device-mgt/groups/devices/add",
+ "device-mgt/groups/devices/remove",
+ "device-mgt/groups/devices/view",
+ "device-mgt/groups/remove",
+ "device-mgt/groups/roles/create",
+ "device-mgt/groups/roles/view",
+ "device-mgt/groups/share",
+ "device-mgt/groups/update",
+ "device-mgt/groups/users/view",
+ "device-mgt/groups/view"
+ ]
+}
\ 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.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
index ee24c4393f..1770cd26c4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
@@ -154,26 +154,38 @@ function loadGroups() {
class: 'text-right content-fill text-left-on-grid-view no-wrap',
render: function (id, type, row, meta) {
var html;
- html = '' +
- '' +
- 'View Devices';
-
- html += '' +
- '' +
- 'Analytics';
-
- html += '' +
- 'Share';
-
- html += '' +
- 'Edit';
-
- html += '' +
- 'Delete';
-
+ if ($.hasPermission("VIEW_GROUP_DEVICES")){
+ html = '' +
+ '' +
+ 'View Devices';
+
+ html += '' +
+ '' +
+ 'Analytics';
+ } else {
+ html = '';
+ }
+ if($.hasPermission("SHARE_GROUP")) {
+ html += '' +
+ 'Share';
+ } else {
+ html += '';
+ }
+ if($.hasPermission("UPDATE_GROUP")) {
+ html += '' +
+ 'Edit';
+ } else {
+ html += '';
+ }
+ if ($.hasPermission("REMOVE_GROUP")) {
+ html += '' +
+ 'Delete';
+ } else {
+ html += '';
+ }
return html;
}
}
@@ -237,6 +249,17 @@ function openCollapsedNav() {
* DOM ready functions.
*/
$(document).ready(function () {
+ var permissionSet = {};
+
+ //This method is used to setup permission for device listing
+ $.setPermission = function (permission) {
+ permissionSet[permission] = true;
+ };
+
+ $.hasPermission = function (permission) {
+ return permissionSet[permission];
+ };
+
var permissionList = $("#permission").data("permission");
for (var key in permissionList) {
if (permissionList.hasOwnProperty(key)) {
@@ -321,7 +344,6 @@ function hidePopup() {
* Following functions should be triggered after AJAX request is made.
*/
function attachEvents() {
-
/**
* Following click function would execute
* when a user clicks on "Share" link
@@ -334,12 +356,25 @@ function attachEvents() {
$("a#share-group-next-link").show();
showPopup();
$("a#share-group-next-link").click(function () {
+ var successCallback = function (data) {
+ if(data === 'true') {
+ getAllRoles(groupId, selectedUser);
+ } else {
+ var errorMsgWrapper = "#notification-error-msg";
+ var errorMsg = "#notification-error-msg span";
+ $(errorMsg).text("User does not exist.");
+ $(errorMsgWrapper).removeClass("hidden");
+ }
+ }
var selectedUser = $('#share-user-selector').val();
if (selectedUser == $("#group-listing").data("current-user")) {
$("#user-names").html("Please specify a user other than current user.");
$("a#share-group-next-link").hide();
} else {
- getAllRoles(groupId, selectedUser);
+ invokerUtil.get("/api/device-mgt/v1.0/users/checkUser?username=" + selectedUser,
+ successCallback, function (message) {
+ displayErrors(message);
+ });
}
});
$("a#share-group-w1-cancel-link").click(function () {
@@ -431,7 +466,6 @@ function attachEvents() {
function getAllRoles(groupId, selectedUser) {
$(modalPopupContent).html($('#share-group-w2-modal-content').html());
- $('#user-roles').html('');
$("a#share-group-yes-link").hide();
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
@@ -464,7 +498,7 @@ function generateRoleMap(groupId, selectedUser, allRoles) {
if(data != "EMPTY") {
userRoles = data.roles;
}
- var str = '';
+ var str = $('#user-roles').html();
for (var i = 0; i < allRoles.length; i++) {
var isChecked = '';
@@ -474,8 +508,8 @@ function generateRoleMap(groupId, selectedUser, allRoles) {
break;
}
}
- str += '';
+ str += '
-
- -
- -
Please enter new name and description for the group
-- -
-
-
- - -
-
-
-
-
- Update
-
+
+
+ + + + + + Update Group + +
+ +
+
+
+
+
+
+
+ Enter new name and description for the group
+
+
+
+ Enter new name and description for the group
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+ Update
+
-
- Cancel
-
-
- '; } $('#user-roles').html(str); @@ -490,6 +524,9 @@ function generateRoleMap(groupId, selectedUser, allRoles) { } updateGroupShare(groupId, selectedUser, roles); }); + $("a#share-group-w2-add-new-role-link").click(function () { + addNewRole(groupId, selectedUser, allRoles); + }); } else { displayErrors(xhr); } @@ -497,7 +534,7 @@ function generateRoleMap(groupId, selectedUser, allRoles) { invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles?userName=" + selectedUser, successCallback, function (message) { - displayErrors(message); + displayErrors(message); }); $("a#share-group-w2-cancel-link").click(function () { @@ -505,6 +542,63 @@ function generateRoleMap(groupId, selectedUser, allRoles) { }); } +function addNewRole(groupId, selectedUser, allRoles) { + $(modalPopupContent).html($('#share-group-w3-modal-content').html()); + function getPermissions() { + var PERMISSION_PREFIX = '/permission/admin/'; + var permissions = []; + $('#permission-table-container').find('tr').each(function () { + var row = $(this).closest('tr'); + var permission = $(row).find('td:nth-child(1)').text(); + var check = $(row).find('td:nth-child(2) a').data('value'); + if(check === 'checked') { + permission = PERMISSION_PREFIX + permission; + permissions.push(permission); + } + }); + return permissions; + }; + $("a#share-group-w3-yes-link").click(function () { + var successCallback = function (data, status, jqXHR) { + if(status == "success") { + getAllRoles(groupId, selectedUser); + } + } + var roleName = $('#group-sharing-role-name').val(); + var users = []; + if(roleName) { + var groupRoleInfo = {"roleName": roleName, "permissions": getPermissions(), "users": users}; + var currentUser = $("#group-listing").data("current-user"); + invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles/create?userName=" + currentUser, + groupRoleInfo, successCallback, function (message) { + displayErrors(message); + }); + } else { + var errorMsgWrapper = "#notification-error-msg"; + var errorMsg = "#notification-error-msg span"; + $(errorMsg).text("Role name cannot be empty."); + $(errorMsgWrapper).removeClass("hidden"); + } + }); + $("a#share-group-w3-cancel-link").click(function () { + hidePopup(); + }); +} + +function togglePermissionAction(element) { + $(element).data('value', 'checked'); + var icon = $(element).find("i")[1]; + if($(icon).hasClass('fw-minus')) { + $(icon).removeClass('fw-minus'); + $(icon).addClass('fw-add'); + $(element).data('value', 'unchecked'); + } else { + $(icon).removeClass('fw-add'); + $(icon).addClass('fw-minus'); + $(element).data('value', 'checked'); + } +} + function updateGroupShare(groupId, selectedUser, roles) { var successCallback = function (data) { $(modalPopupContent).html($('#share-group-200-content').html()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs index 7961b2b65b..105c65ac6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs @@ -49,10 +49,12 @@ - {{defineZone "signInForm-below" scope="protected"}} +
-