diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 3838155c1e0..62036c2778c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -128,6 +128,12 @@ public interface DeviceManagementService {
@QueryParam("status")
@Size(max = 45)
String status,
+ @ApiParam(
+ name = "groupId",
+ value = "Id of the group which device belongs",
+ required = false)
+ @QueryParam("groupId")
+ int groupId,
@ApiParam(
name = "since",
value = "Checks if the requested variant was created since the specified date-time.\n" +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index e88805bfe86..ad6c9bc68ce 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -71,6 +71,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@QueryParam("user") String user,
@QueryParam("ownership") String ownership,
@QueryParam("status") String status,
+ @QueryParam("groupId") int groupId,
@QueryParam("since") String since,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("offset") int offset,
@@ -107,6 +108,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
RequestValidationUtil.validateStatus(status);
request.setStatus(status);
}
+ if (groupId != 0 ) {
+ request.setGroupId(groupId);
+ }
// this is the user who initiates the request
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
index d4569b68046..1bc1d80e179 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js
@@ -53,11 +53,11 @@ var groupModule = {};
);
};
- groupModule.getGroupDeviceCount = function (groupName, owner) {
- endPoint = deviceServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices/count";
+ groupModule.getGroupDeviceCount = function (groupId) {
+ endPoint = deviceServiceEndpoint + "/groups/id/" + groupId + "/devices/count";
return serviceInvokers.XMLHttp.get(
endPoint, function (responsePayload) {
- return responsePayload;
+ return responsePayload["responseText"];
},
function (responsePayload) {
log.error(responsePayload);
@@ -67,7 +67,7 @@ var groupModule = {};
};
groupModule.getGroupDevices = function (groupName, owner) {
- endPoint = deviceServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices";
+ endPoint = deviceServiceEndpoint + "/groups/owner/" + owner + "/name/" + groupName + "/devices";
return serviceInvokers.XMLHttp.get(
endPoint, function (responsePayload) {
return responsePayload;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
index ae506f4b074..40d7ee1d6bb 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js
@@ -22,7 +22,7 @@ function onRequest(context) {
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var groupName = request.getParameter("groupName");
- var groupOwner = request.getParameter("groupOwner");
+ var groupId = request.getParameter("groupId");
var viewModel = {};
var title = "Devices";
@@ -41,9 +41,9 @@ function onRequest(context) {
}
viewModel.currentUser = currentUser;
var deviceCount = 0;
- if (groupName && groupOwner) {
+ if (groupId) {
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
- deviceCount = groupModule.getGroupDeviceCount(groupName, groupOwner);
+ deviceCount = groupModule.getGroupDeviceCount(groupId);
} else {
deviceCount = deviceModule.getDevicesCount();
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
index 0e384c7016c..171b77346e5 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js
@@ -554,7 +554,7 @@ function attachDeviceEvents() {
var serviceURL;
if ($.hasPermission("LIST_ALL_GROUPS")) {
- serviceURL = "/api/device-mgt/v1.0/groups/all";
+ serviceURL = "/api/device-mgt/v1.0/groups";
} else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser + "/all";
@@ -563,18 +563,18 @@ function attachDeviceEvents() {
invokerUtil.get(serviceURL, function (data) {
var groups = JSON.parse(data);
var str = '
';
$('#user-groups').html(str);
$("a#group-device-yes-link").show();
$("a#group-device-yes-link").click(function () {
var selectedGroup = $('#assign-group-selector').val();
- serviceURL = "/api/device-mgt/v1.0/groups/owner/" + selectedGroup + "/devices";
- var device = {"id": deviceId, "type": deviceType};
- invokerUtil.post(serviceURL, device, function (data) {
+ serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices";
+ var deviceIdentifiers = [{"id":deviceId,"type":deviceType}];
+ invokerUtil.post(serviceURL, deviceIdentifiers, function (data) {
$(modalPopupContent).html($('#group-associate-device-200-content').html());
setTimeout(function () {
hidePopup();
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
index ae6870abd34..2dc32ce70f1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
@@ -45,9 +45,8 @@ $(function () {
} else {
var group = {"name": name, "description": description};
- var successCallback = function (jqXHR) {
- var data = JSON.parse(jqXHR);
- if (data.status == 201) {
+ var successCallback = function (jqXHR, status, resp) {
+ if (resp.status == 201) {
$('.wr-validation-summary strong').text("Group created. You will be redirected to groups");
$('.wr-validation-summary').removeClass("hidden");
$('.wr-validation-summary strong').removeClass("label-danger");
@@ -56,11 +55,11 @@ $(function () {
window.location = "../groups";
}, 1500);
} else {
- displayErrors(data.status);
+ displayErrors(resp.status);
}
};
- invokerUtil.post("/devicemgt_admin/groups", group,
+ invokerUtil.post("/api/device-mgt/v1.0/groups", group,
successCallback, function (message) {
displayErrors(message);
});
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
index 7ad04791e10..5ffc014f056 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/groups.hbs
@@ -18,7 +18,7 @@
{{unit "cdmf.unit.ui.title" pageTitle="Group Management"}}
{{unit "cdmf.unit.ui.content.title" pageHeader="Groups"}}
-{{unit "cdmf.unit.lib.data-table"}}
+{{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}}