Fix grouped device listing

4.x.x
Charitha Goonetilleke 9 years ago
parent e01b62086f
commit ca62c2ef73

@ -168,6 +168,24 @@ public class Group {
}
}
@Path("/user/{user}/all")
@GET
@Produces("application/json")
public Response getGroups(@PathParam("user") String userName) {
try {
List<DeviceGroup> deviceGroups = DeviceMgtAPIUtils.getGroupManagementProviderService()
.getGroups(userName);
if (deviceGroups.size() > 0) {
return Response.status(Response.Status.OK).entity(deviceGroups).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
} catch (GroupManagementException e) {
log.error(e.getMessage(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
@Path("/owner/{owner}/name/{groupName}")
@GET
@Produces("application/json")

@ -68,7 +68,7 @@ var deviceListing, currentUser, groupName, groupOwner;
*/
$(document).ready(function () {
deviceListing = $("#device-listing");
deviceListing.data("current-user");
currentUser = deviceListing.data("current-user");
groupName = getParameterByName("groupName");
groupOwner = getParameterByName("groupOwner");
@ -168,7 +168,9 @@ function toTitleCase(str) {
function loadDevices(searchType, searchParam){
var serviceURL;
if ($.hasPermission("LIST_DEVICES")) {
if (groupName && groupOwner && $.hasPermission("LIST_OWN_DEVICES")) {
serviceURL = "/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/devices";
} else if ($.hasPermission("LIST_DEVICES")) {
serviceURL = "/devicemgt_admin/devices";
} else if ($.hasPermission("LIST_OWN_DEVICES")) {
//Get authenticated users devices
@ -390,32 +392,6 @@ function openCollapsedNav() {
});
}
function initPage() {
var serviceURL;
if ($.hasPermission("LIST_DEVICES")) {
serviceURL = "/devicemgt_admin/devices/count";
} else if ($.hasPermission("LIST_OWN_DEVICES")) {
//Get authenticated users devices
serviceURL = "/devicemgt_admin/devices/user/" + currentUser + "/count";
}
invokerUtil.get(serviceURL,
function (data) {
if (data) {
data = JSON.parse(data);
if (Number(data) > 0) {
loadDevices();
} else {
$("#loading-content").remove();
$("#device-listing-status-msg").text("No enrolled devices found.");
$("#device-listing-status").removeClass(' hidden');
}
}
}, function (message) {
initPage();
}
);
}
/*
* DOM ready functions.
*/
@ -432,7 +408,7 @@ $(document).ready(function () {
}
}
initPage();
loadDevices();
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
@ -515,7 +491,7 @@ function attachDeviceEvents() {
serviceURL = "/devicemgt_admin/groups/all";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/devicemgt_admin/groups/user/" + currentUser;
serviceURL = "/devicemgt_admin/groups/user/" + currentUser + "/all";
}
invokerUtil.get(serviceURL, function (data) {

Loading…
Cancel
Save