revert-70aa11f8
Charitha Goonetilleke 9 years ago
commit d15e52491a

@ -1035,6 +1035,13 @@
<method>GET</method> <method>GET</method>
</Permission> </Permission>
<Permission>
<name>Group Roles</name>
<path>/device-mgt/user/groups/roles</path>
<url>/groups/owner/*/name/*/share/roles</url>
<method>PUT</method>
</Permission>
<Permission> <Permission>
<name>Group Permissions</name> <name>Group Permissions</name>
<path>/device-mgt/admin/groups/roles/permissions</path> <path>/device-mgt/admin/groups/roles/permissions</path>

@ -360,16 +360,16 @@ function attachEvents() {
showPopup(); showPopup();
$("a#remove-group-yes-link").click(function () { $("a#remove-group-yes-link").click(function () {
var successCallback = function (data) { var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.status == 200) { if (xhr.status == 200) {
$(modalPopupContent).html($('#remove-group-200-content').html()); $(modalPopupContent).html($('#remove-group-200-content').html());
setTimeout(function () { setTimeout(function () {
hidePopup(); hidePopup();
location.reload(false); location.reload(false);
}, 2000); }, 2000);
} else { } else {
displayErrors(status); displayErrors(xhr);
} }
}; };
@ -405,15 +405,15 @@ function attachEvents() {
var newGroupDescription = $('#edit-group-description').val(); var newGroupDescription = $('#edit-group-description').val();
var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner}; var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner};
var successCallback = function (data) { var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.status == 200) { if (xhr.status == 200) {
setTimeout(function () { setTimeout(function () {
hidePopup(); hidePopup();
location.reload(false); location.reload(false);
}, 2000); }, 2000);
} else { } else {
displayErrors(status); displayErrors(xhr);
} }
}; };
@ -433,16 +433,16 @@ function getAllRoles(groupName, groupOwner, selectedUser) {
$(modalPopupContent).html($('#share-group-w2-modal-content').html()); $(modalPopupContent).html($('#share-group-w2-modal-content').html());
$('#user-roles').html('<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>'); $('#user-roles').html('<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
$("a#share-group-yes-link").hide(); $("a#share-group-yes-link").hide();
var successCallback = function (data) { var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.status == 200) { if (xhr.status == 200) {
if (data.data.length > 0) { if (data.length > 0) {
generateRoleMap(groupName, groupOwner, selectedUser, data.data); generateRoleMap(groupName, groupOwner, selectedUser, data);
} else { } else {
$('#user-roles').html("There is no any roles for this group."); $('#user-roles').html("There is no any roles for this group.");
} }
} else { } else {
displayErrors(status); displayErrors(xhr);
} }
}; };
@ -457,10 +457,10 @@ function getAllRoles(groupName, groupOwner, selectedUser) {
} }
function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) { function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
var successCallback = function (data) { var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.status == 200) { if (xhr.status == 200) {
var userRoles = data.data; var userRoles = data;
var roleMap = []; var roleMap = [];
var str = ''; var str = '';
var isChecked = ''; var isChecked = '';
@ -474,20 +474,15 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
break; break;
} }
} }
roleMap.push(objRole);
str += '<label class="checkbox-text"><input type="checkbox" id="user-role-' + roleMap[role].role + '" value="' + roleMap[role].role str += '<label class="checkbox-text"><input type="checkbox" id="user-role-' + roleMap[role].role + '" value="' + roleMap[role].role
+ '" ' + isChecked + '/>' + roleMap[role].role + '</label>&nbsp;&nbsp;&nbsp;&nbsp;'; + '" ' + isChecked + '/>' + roleMap[role].role + '</label>&nbsp;&nbsp;&nbsp;&nbsp;';
roleMap.push(objRole);
} }
$('#user-roles').html(str); $('#user-roles').html(str);
$("a#share-group-yes-link").show(); $("a#share-group-yes-link").show();
var isOngoing; $("a#share-group-yes-link").show();
$("a#share-group-yes-link").click(function () { $("a#share-group-yes-link").click(function () {
if (isOngoing) {
return false;
}
$("a#share-group-yes-link").html("Wait...");
isOngoing = true;
for (var role in roleMap) { for (var role in roleMap) {
if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) { if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) {
roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked'); roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked');
@ -496,7 +491,7 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
} }
}); });
} else { } else {
displayErrors(status); displayErrors(xhr);
} }
}; };
@ -511,9 +506,9 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
} }
function updateGroupShare(groupName, groupOwner, selectedUser, role) { function updateGroupShare(groupName, groupOwner, selectedUser, role) {
var successCallback = function (data) { var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data); data = JSON.parse(data);
var status = data.status; var status = xhr.status;
if (status == 200) { if (status == 200) {
$(modalPopupContent).html($('#share-group-200-content').html()); $(modalPopupContent).html($('#share-group-200-content').html());
setTimeout(function () { setTimeout(function () {
@ -521,7 +516,7 @@ function updateGroupShare(groupName, groupOwner, selectedUser, role) {
location.reload(false); location.reload(false);
}, 2000); }, 2000);
} else { } else {
displayErrors(status); displayErrors(xhr);
} }
}; };

Loading…
Cancel
Save