|
|
@ -100,10 +100,10 @@ function loadGroups() {
|
|
|
|
var currentUser = groupListing.data("currentUser");
|
|
|
|
var currentUser = groupListing.data("currentUser");
|
|
|
|
var serviceURL;
|
|
|
|
var serviceURL;
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
serviceURL = "/devicemgt_admin/groups?start=0&rowCount=1000";
|
|
|
|
serviceURL = "/devicemgt_admin/groups";
|
|
|
|
} else if ($.hasPermission("LIST_GROUPS")) {
|
|
|
|
} else if ($.hasPermission("LIST_GROUPS")) {
|
|
|
|
//Get authenticated users groups
|
|
|
|
//Get authenticated users groups
|
|
|
|
serviceURL = "/devicemgt_admin/groups/user/" + currentUser + "?start=0&rowCount=1000";
|
|
|
|
serviceURL = "/devicemgt_admin/groups/user/" + currentUser;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$('#device-table').addClass('hidden');
|
|
|
|
$('#device-table').addClass('hidden');
|
|
|
@ -133,32 +133,30 @@ function loadGroups() {
|
|
|
|
{ targets: 0, data: 'id', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
|
|
|
{ targets: 0, data: 'id', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
|
|
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
|
|
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
{ targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) {
|
|
|
|
{targets: 1, data: 'name', className: 'fade-edge'},
|
|
|
|
return '<h4 data-groupid="' + row.id + '">' + name + '</h4>';
|
|
|
|
|
|
|
|
}},
|
|
|
|
|
|
|
|
{ targets: 2, data: 'owner', className: 'fade-edge remove-padding-top'},
|
|
|
|
{ targets: 2, data: 'owner', className: 'fade-edge remove-padding-top'},
|
|
|
|
{ targets: 3, data: 'id', className: 'text-right content-fill text-left-on-grid-view no-wrap' ,
|
|
|
|
{ targets: 3, data: 'id', className: 'text-right content-fill text-left-on-grid-view no-wrap' ,
|
|
|
|
render: function ( id, type, row, meta ) {
|
|
|
|
render: function ( id, type, row, meta ) {
|
|
|
|
var html;
|
|
|
|
var html;
|
|
|
|
html = '<a href="devices?groupName=' + row.name + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
html = '<a href="devices?groupName=' + row.name + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-view fw-stack-1x"></i></span>' +
|
|
|
|
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-view fw-stack-1x"></i></span>' +
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">View Devices</span></a>';
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">View Devices</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="analytics?groupName=' + row.name + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
html += '<a href="analytics?groupName=' + row.name + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' +
|
|
|
|
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' +
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Analytics</span></a>';
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Analytics</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view share-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view share-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-share fw-stack-1x"></i></span>' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-share fw-stack-1x"></i></span>' +
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
'data-group-owner="' + row.owner + '" data-group-description="' + row.description + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
'data-group-owner="' + row.owner + '" data-group-description="' + row.description + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
|
|
|
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>' +
|
|
|
|
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
|
|
|
|
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
return html;
|
|
|
|
}}
|
|
|
|
}}
|
|
|
@ -221,12 +219,12 @@ $(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
/* for device list sorting drop down */
|
|
|
|
/* for device list sorting drop down */
|
|
|
|
$(".ctrl-filter-type-switcher").popover(
|
|
|
|
$(".ctrl-filter-type-switcher").popover(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
html: true,
|
|
|
|
html: true,
|
|
|
|
content: function () {
|
|
|
|
content: function () {
|
|
|
|
return $("#content-filter-types").html();
|
|
|
|
return $("#content-filter-types").html();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/* for data tables*/
|
|
|
|
/* for data tables*/
|
|
|
@ -235,20 +233,20 @@ $(document).ready(function () {
|
|
|
|
$("[data-toggle=popover]").popover();
|
|
|
|
$("[data-toggle=popover]").popover();
|
|
|
|
|
|
|
|
|
|
|
|
$(".ctrl-filter-type-switcher").popover(
|
|
|
|
$(".ctrl-filter-type-switcher").popover(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
html: true,
|
|
|
|
html: true,
|
|
|
|
content: function () {
|
|
|
|
content: function () {
|
|
|
|
return $('#content-filter-types').html();
|
|
|
|
return $('#content-filter-types').html();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$('#nav').affix(
|
|
|
|
$('#nav').affix(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
offset: {
|
|
|
|
offset: {
|
|
|
|
top: $('header').height()
|
|
|
|
top: $('header').height()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -293,58 +291,23 @@ function attachEvents() {
|
|
|
|
* on Group Management page in WSO2 Device Management Server Console.
|
|
|
|
* on Group Management page in WSO2 Device Management Server Console.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("a.share-group-link").click(function () {
|
|
|
|
$("a.share-group-link").click(function () {
|
|
|
|
var username = $("#group-listing").data("current-user");
|
|
|
|
|
|
|
|
var groupName = $(this).data("group-name");
|
|
|
|
var groupName = $(this).data("group-name");
|
|
|
|
var groupOwner = $(this).data("group-owner");
|
|
|
|
var groupOwner = $(this).data("group-owner");
|
|
|
|
$(modalPopupContent).html($('#share-group-w1-modal-content').html());
|
|
|
|
$(modalPopupContent).html($('#share-group-w1-modal-content').html());
|
|
|
|
$('#user-names').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-next-link").show();
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
|
$("a#share-group-next-link").hide();
|
|
|
|
$("a#share-group-next-link").click(function () {
|
|
|
|
var userRequest = $.ajax(
|
|
|
|
var selectedUser = $('#share-user-selector').val();
|
|
|
|
{
|
|
|
|
if (selectedUser == $("#group-listing").data("current-user")) {
|
|
|
|
url: "api/user/all",
|
|
|
|
$("#user-names").html("Please specify a user other than current user.");
|
|
|
|
method: "GET",
|
|
|
|
$("a#share-group-next-link").hide();
|
|
|
|
contentType: "application/json",
|
|
|
|
|
|
|
|
accept: "application/json"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
userRequest.done(function (data, txtStatus, jqxhr) {
|
|
|
|
|
|
|
|
var users = JSON.parse(data);
|
|
|
|
|
|
|
|
var status = jqxhr.status;
|
|
|
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
|
|
|
var str = '<br /><select id="share-user-selector" style="color:#3f3f3f;padding:5px;width:250px;">';
|
|
|
|
|
|
|
|
var hasUsers = false;
|
|
|
|
|
|
|
|
users = users.content;
|
|
|
|
|
|
|
|
for (var user in users) {
|
|
|
|
|
|
|
|
if (users[user].username != username) {
|
|
|
|
|
|
|
|
str += '<option value="' + users[user].username + '">' + users[user].username + '</option>';
|
|
|
|
|
|
|
|
hasUsers = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
str += '</select>';
|
|
|
|
|
|
|
|
if (!hasUsers) {
|
|
|
|
|
|
|
|
str = "There is no any other users registered";
|
|
|
|
|
|
|
|
$('#user-names').html(str);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#user-names').html(str);
|
|
|
|
|
|
|
|
$("a#share-group-next-link").show();
|
|
|
|
|
|
|
|
$("a#share-group-next-link").click(function () {
|
|
|
|
|
|
|
|
var selectedUser = $('#share-user-selector').val();
|
|
|
|
|
|
|
|
getAllRoles(groupName, groupOwner, selectedUser);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
displayErrors(status);
|
|
|
|
getAllRoles(groupName, groupOwner, selectedUser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
userRequest.fail(function (jqXHR) {
|
|
|
|
|
|
|
|
displayErrors(jqXHR);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("a#share-group-w1-cancel-link").click(function () {
|
|
|
|
$("a#share-group-w1-cancel-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -360,23 +323,23 @@ 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.delete("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName,
|
|
|
|
invokerUtil.delete("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName,
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message.content);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("a#remove-group-cancel-link").click(function () {
|
|
|
|
$("a#remove-group-cancel-link").click(function () {
|
|
|
@ -405,22 +368,22 @@ 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName, group,
|
|
|
|
invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName, group,
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message.content);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("a#edit-group-cancel-link").click(function () {
|
|
|
|
$("a#edit-group-cancel-link").click(function () {
|
|
|
@ -433,23 +396,23 @@ 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles",
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles",
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message.content);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("a#share-group-w2-cancel-link").click(function () {
|
|
|
|
$("a#share-group-w2-cancel-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
@ -457,77 +420,63 @@ 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 str = '';
|
|
|
|
var str = '';
|
|
|
|
var isChecked = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var role in allRoles) {
|
|
|
|
for (var i = 0; i < allRoles.length; i++) {
|
|
|
|
var objRole = {"role": allRoles[role], "assigned": false};
|
|
|
|
var isChecked = '';
|
|
|
|
for (var usrRole in userRoles) {
|
|
|
|
for (var j = 0; j < userRoles.length; j++) {
|
|
|
|
if (allRoles[role] == userRoles[usrRole]) {
|
|
|
|
if (allRoles[i] == userRoles[j]) {
|
|
|
|
objRole.assigned = true;
|
|
|
|
|
|
|
|
isChecked = 'checked';
|
|
|
|
isChecked = 'checked';
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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-' + allRoles[i] + '" value="' + allRoles[i]
|
|
|
|
+ '" ' + isChecked + '/>' + roleMap[role].role + '</label> ';
|
|
|
|
+ '" ' + isChecked + '/>' + allRoles[i] + '</label> ';
|
|
|
|
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) {
|
|
|
|
var roles = [];
|
|
|
|
return false;
|
|
|
|
for (var i = 0; i < allRoles.length; i++) {
|
|
|
|
}
|
|
|
|
if ($('#user-role-' + allRoles[i]).is(':checked')) {
|
|
|
|
$("a#share-group-yes-link").html("Wait...");
|
|
|
|
roles.push(allRoles[i]);
|
|
|
|
isOngoing = true;
|
|
|
|
|
|
|
|
for (var role in roleMap) {
|
|
|
|
|
|
|
|
if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) {
|
|
|
|
|
|
|
|
roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked');
|
|
|
|
|
|
|
|
updateGroupShare(groupName, groupOwner, selectedUser, roleMap[role]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateGroupShare(groupName, groupOwner, selectedUser, roles);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
displayErrors(status);
|
|
|
|
displayErrors(xhr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles?userName=" + selectedUser,
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles?userName=" + selectedUser,
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message.content);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("a#share-group-w2-cancel-link").click(function () {
|
|
|
|
$("a#share-group-w2-cancel-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateGroupShare(groupName, groupOwner, selectedUser, role) {
|
|
|
|
function updateGroupShare(groupName, groupOwner, selectedUser, roles) {
|
|
|
|
var successCallback = function (data) {
|
|
|
|
var successCallback = function (data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
$(modalPopupContent).html($('#share-group-200-content').html());
|
|
|
|
var status = data.status;
|
|
|
|
setTimeout(function () {
|
|
|
|
if (status == 200) {
|
|
|
|
hidePopup();
|
|
|
|
$(modalPopupContent).html($('#share-group-200-content').html());
|
|
|
|
location.reload(false);
|
|
|
|
setTimeout(function () {
|
|
|
|
}, 2000);
|
|
|
|
hidePopup();
|
|
|
|
|
|
|
|
location.reload(false);
|
|
|
|
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
displayErrors(status);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles?userName=" + selectedUser,
|
|
|
|
invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/user/" + selectedUser + "/share/roles",
|
|
|
|
role, successCallback, function (message) {
|
|
|
|
roles, successCallback, function (message) {
|
|
|
|
displayErrors(message.content);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -543,6 +492,12 @@ function displayErrors(jqXHR) {
|
|
|
|
$("a#group-403-link").click(function () {
|
|
|
|
$("a#group-403-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (jqXHR.status == 404) {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#group-404-content').html());
|
|
|
|
|
|
|
|
$("#group-404-message").html(jqXHR.responseText);
|
|
|
|
|
|
|
|
$("a#group-404-link").click(function () {
|
|
|
|
|
|
|
|
hidePopup();
|
|
|
|
|
|
|
|
});
|
|
|
|
} else if (jqXHR.status == 409) {
|
|
|
|
} else if (jqXHR.status == 409) {
|
|
|
|
$(modalPopupContent).html($('#group-409-content').html());
|
|
|
|
$(modalPopupContent).html($('#group-409-content').html());
|
|
|
|
$("a#group-409-link").click(function () {
|
|
|
|
$("a#group-409-link").click(function () {
|
|
|
|