|
|
@ -151,21 +151,31 @@ function loadGroups() {
|
|
|
|
data: 'name',
|
|
|
|
data: 'name',
|
|
|
|
class: 'fade-edge'
|
|
|
|
class: 'fade-edge'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
targets: 2,
|
|
|
|
|
|
|
|
data: 'owner',
|
|
|
|
|
|
|
|
class: 'fade-edge remove-padding-top',
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
targets: 3,
|
|
|
|
targets: 3,
|
|
|
|
|
|
|
|
data: 'description',
|
|
|
|
|
|
|
|
class: 'fade-edge remove-padding-top',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
targets: 4,
|
|
|
|
data: 'id',
|
|
|
|
data: 'id',
|
|
|
|
class: 'text-right content-fill text-left-on-grid-view no-wrap',
|
|
|
|
class: '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?groupId=' + row.groupId + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
html = '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name + '" 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="group/' + row.owner + '/' + row.name + '/analytics" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
html += '<a href="group/' + row.name + '/' + row.groupId + '/analytics" 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-id="' + row.groupId + '" ' +
|
|
|
|
'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>';
|
|
|
|
|
|
|
|
|
|
|
@ -198,6 +208,11 @@ function loadGroups() {
|
|
|
|
$(this).attr('data-search', data.owner);
|
|
|
|
$(this).attr('data-search', data.owner);
|
|
|
|
$(this).attr('data-display', data.owner);
|
|
|
|
$(this).attr('data-display', data.owner);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
|
|
$(this).attr('data-grid-label', "Description");
|
|
|
|
|
|
|
|
$(this).attr('data-search', data.description);
|
|
|
|
|
|
|
|
$(this).attr('data-display', data.description);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -326,7 +341,7 @@ 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 groupName = $(this).data("group-name");
|
|
|
|
var groupId = $(this).data("group-id");
|
|
|
|
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());
|
|
|
|
$("a#share-group-next-link").show();
|
|
|
|
$("a#share-group-next-link").show();
|
|
|
@ -337,7 +352,7 @@ function attachEvents() {
|
|
|
|
$("#user-names").html("Please specify a user other than current user.");
|
|
|
|
$("#user-names").html("Please specify a user other than current user.");
|
|
|
|
$("a#share-group-next-link").hide();
|
|
|
|
$("a#share-group-next-link").hide();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
getAllRoles(groupName, groupOwner, selectedUser);
|
|
|
|
getAllRoles(groupId, selectedUser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("a#share-group-w1-cancel-link").click(function () {
|
|
|
|
$("a#share-group-w1-cancel-link").click(function () {
|
|
|
@ -352,6 +367,7 @@ function attachEvents() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("a.remove-group-link").click(function () {
|
|
|
|
$("a.remove-group-link").click(function () {
|
|
|
|
var groupId = $(this).data("group-id");
|
|
|
|
var groupId = $(this).data("group-id");
|
|
|
|
|
|
|
|
var groupOwner = $(this).data("group-owner");
|
|
|
|
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#remove-group-modal-content').html());
|
|
|
|
$(modalPopupContent).html($('#remove-group-modal-content').html());
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
@ -426,15 +442,15 @@ function attachEvents() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getAllRoles(groupName, groupOwner, selectedUser) {
|
|
|
|
function getAllRoles(groupId, 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, textStatus, xhr) {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
if (data.length > 0) {
|
|
|
|
if (data.roles.length > 0) {
|
|
|
|
generateRoleMap(groupName, groupOwner, selectedUser, data);
|
|
|
|
generateRoleMap(groupId, selectedUser, data.roles);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$('#user-roles').html("There is no any roles for this group.");
|
|
|
|
$('#user-roles').html("There is no any roles for this group.");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -443,7 +459,7 @@ function getAllRoles(groupName, groupOwner, selectedUser) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles",
|
|
|
|
invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles",
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -453,11 +469,14 @@ function getAllRoles(groupName, groupOwner, selectedUser) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
|
|
|
|
function generateRoleMap(groupId, selectedUser, allRoles) {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
var userRoles = data;
|
|
|
|
var userRoles = [];
|
|
|
|
|
|
|
|
if(data != "EMPTY") {
|
|
|
|
|
|
|
|
userRoles = data.roles;
|
|
|
|
|
|
|
|
}
|
|
|
|
var str = '';
|
|
|
|
var str = '';
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < allRoles.length; i++) {
|
|
|
|
for (var i = 0; i < allRoles.length; i++) {
|
|
|
@ -482,14 +501,14 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
|
|
|
|
roles.push(allRoles[i]);
|
|
|
|
roles.push(allRoles[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateGroupShare(groupName, groupOwner, selectedUser, roles);
|
|
|
|
updateGroupShare(groupId, selectedUser, roles);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
displayErrors(xhr);
|
|
|
|
displayErrors(xhr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.get("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/share/roles?userName=" + selectedUser,
|
|
|
|
invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles?userName=" + selectedUser,
|
|
|
|
successCallback, function (message) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -499,7 +518,7 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateGroupShare(groupName, groupOwner, selectedUser, roles) {
|
|
|
|
function updateGroupShare(groupId, selectedUser, roles) {
|
|
|
|
var successCallback = function (data) {
|
|
|
|
var successCallback = function (data) {
|
|
|
|
$(modalPopupContent).html($('#share-group-200-content').html());
|
|
|
|
$(modalPopupContent).html($('#share-group-200-content').html());
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
@ -508,8 +527,9 @@ function updateGroupShare(groupName, groupOwner, selectedUser, roles) {
|
|
|
|
}, 2000);
|
|
|
|
}, 2000);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/user/" + selectedUser + "/share/roles",
|
|
|
|
var deviceGroupShare = {"username": selectedUser, "groupRoles": roles };
|
|
|
|
roles, successCallback, function (message) {
|
|
|
|
invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/share",
|
|
|
|
|
|
|
|
deviceGroupShare, successCallback, function (message) {
|
|
|
|
displayErrors(message);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|