groupedDevices = groupDAO.getDevices(deviceGroup.getGroupId(), 0, 10, TestDataHolder.SUPER_TENANT_ID);
Assert.assertNotEquals(groupedDevices.size(), 0, "No device found");
Assert.assertNotNull(groupedDevices.get(0), "Device is null");
Assert.assertEquals(groupedDevices.get(0).getId(), initialTestDevice.getId(), "Device ids not matched");
@@ -165,9 +143,10 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
public void removeDeviceFromGroupTest() {
Device initialTestDevice = TestDataHolder.initialTestDevice;
DeviceGroup deviceGroup = getGroupById(groupId);
+ Assert.assertNotNull(deviceGroup, "Group is null");
try {
GroupManagementDAOFactory.beginTransaction();
- groupDAO.removeDevice(deviceGroup.getName(), deviceGroup.getOwner(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
+ groupDAO.removeDevice(deviceGroup.getGroupId(), initialTestDevice.getId(), TestDataHolder.SUPER_TENANT_ID);
GroupManagementDAOFactory.commitTransaction();
log.debug("Device added to group.");
} catch (GroupManagementDAOException e) {
@@ -196,8 +175,7 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
group.setDescription(desc);
try {
GroupManagementDAOFactory.beginTransaction();
- groupDAO.updateGroup(group, TestDataHolder.generateDummyGroupData().getName(),
- TestDataHolder.generateDummyGroupData().getOwner(), TestDataHolder.SUPER_TENANT_ID);
+ groupDAO.updateGroup(group, groupId, TestDataHolder.SUPER_TENANT_ID);
GroupManagementDAOFactory.commitTransaction();
log.debug("Group updated");
} catch (GroupManagementDAOException e) {
@@ -226,7 +204,7 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
try {
Assert.assertNotNull(group, "Group is null");
GroupManagementDAOFactory.beginTransaction();
- groupDAO.deleteGroup(group.getName(), group.getOwner(), TestDataHolder.SUPER_TENANT_ID);
+ groupDAO.deleteGroup(group.getGroupId(), TestDataHolder.SUPER_TENANT_ID);
GroupManagementDAOFactory.commitTransaction();
log.debug("Group deleted");
} catch (GroupManagementDAOException e) {
@@ -245,7 +223,7 @@ public class GroupPersistTests extends BaseDeviceManagementTest {
Assert.assertNull(group, "Group is not deleted");
}
- public DeviceGroup getGroupById(int groupId) {
+ private DeviceGroup getGroupById(int groupId) {
try {
GroupManagementDAOFactory.openConnection();
return groupDAO.getGroup(groupId, TestDataHolder.SUPER_TENANT_ID);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
index 14b0dd7502..362a2dbaaa 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
@@ -22,7 +22,7 @@
device-mgt
org.wso2.carbon.devicemgt
- 1.2.6-SNAPSHOT
+ 1.2.7-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
index fdd192103b..e66303d3a7 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
@@ -22,7 +22,7 @@
device-mgt
org.wso2.carbon.devicemgt
- 1.2.6-SNAPSHOT
+ 1.2.7-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag
index ac30769bb4..c581aad791 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag
@@ -28,12 +28,13 @@ var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
if (uriMatcher.match("/{context}/api/operation/paginate")) {
var deviceType = request.getParameter("deviceType");
var deviceId = request.getParameter("deviceId");
+ var owner = request.getParameter("owner");
var index = request.getParameter("start");
var length = request.getParameter("length");
var search = request.getParameter("search[value]");
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
- "/devices/" + deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length;
+ "/devices/" + deviceType + "/" + deviceId + "/operations?owner=" + owner + "&offset=" + index + "&limit=" + length;
serviceInvokers.XMLHttp.get(
restAPIEndpoint,
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
index 4e907782be..7cda3b7391 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
@@ -5,7 +5,7 @@
"httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%",
"httpsWebURL" : "%https.ip%",
- "wssURL" : "%https.ip%",
+ "wssURL" : "https://localhost:9444",
"wsURL" : "%http.ip%",
"dashboardServerURL" : "%https.ip%",
"enrollmentDir": "/emm-web-agent/enrollment",
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
index 26233a32d8..bec644d249 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
@@ -118,13 +118,18 @@ deviceModule = function () {
if (properties["DEVICE_INFO"]) {
var initialDeviceInfoList = parse(properties["DEVICE_INFO"]);
var initialDeviceInfo = {};
- for (var j = 0; j < initialDeviceInfoList.length; j++) {
- if (initialDeviceInfoList[j]["value"]) {
- initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
- initialDeviceInfoList[j]["value"];
+ if (Array.isArray(initialDeviceInfoList)) {
+ for (var j = 0; j < initialDeviceInfoList.length; j++) {
+ if (initialDeviceInfoList[j]["value"]) {
+ initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
+ initialDeviceInfoList[j]["value"];
+ }
}
+ } else {
+ initialDeviceInfo = initialDeviceInfoList;
}
+
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"] = initialDeviceInfo;
}
}
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 fcbeea8a5a..5862f6bc8e 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
@@ -26,8 +26,7 @@ var groupModule = {};
var utility = require("/app/modules/utility.js").utility;
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
- var groupServiceEndpoint = devicemgtProps["httpsURL"] +
- devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/groups";
+ var deviceServiceEndpoint = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0";
var user = session.get(constants.USER_SESSION_KEY);
@@ -36,29 +35,29 @@ var groupModule = {};
groupModule.getGroupCount = function () {
var permissions = userModule.getUIPermissions();
if (permissions.LIST_ALL_GROUPS) {
- endPoint = groupServiceEndpoint + "/count";
+ endPoint = deviceServiceEndpoint + "/admin/groups/count";
} else if (permissions.LIST_GROUPS) {
- endPoint = groupServiceEndpoint + "/user/" + user.username + "/count";
+ endPoint = deviceServiceEndpoint + "/groups/count";
} else {
log.error("Access denied for user: " + carbonUser.username);
return -1;
}
return serviceInvokers.XMLHttp.get(
endPoint, function (responsePayload) {
- return responsePayload;
+ return responsePayload["responseText"];
},
function (responsePayload) {
- log.error(responsePayload);
+ log.error(responsePayload["responseText"]);
return -1;
}
);
};
- groupModule.getGroupDeviceCount = function (groupName, owner) {
- endPoint = groupServiceEndpoint + "/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,8 +66,8 @@ var groupModule = {};
);
};
- groupModule.getGroupDevices = function (groupName, owner) {
- endPoint = groupServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices";
+ groupModule.getGroupDevices = function (groupId) {
+ endPoint = deviceServiceEndpoint + "/groups/id/" + groupId + "/devices?limit=10";
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/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
index 67743b3bc0..950b9158bc 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js
@@ -485,10 +485,10 @@ var userModule = function () {
if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) {
permissions["LIST_OWN_DEVICES"] = true;
}
- if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/list")) {
+ if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) {
permissions["LIST_ALL_GROUPS"] = true;
}
- if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/list")) {
+ if (publicMethods.isAuthorized("/permission/admin/device-mgt/groups/view")) {
permissions["LIST_GROUPS"] = true;
}
if (publicMethods.isAuthorized("/permission/admin/device-mgt/users/list")) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
index 4d0f953422..46e213d374 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
@@ -51,14 +51,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
Do you really want to remove this certificate ?
-
-
-
-
-
-
-
-
-
-
-
-
{{/zone}}
{{#zone "bottomJs"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
index 01acf088d1..959a3472da 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
@@ -54,8 +54,11 @@ function hidePopup() {
*/
function removeCertificate(serialNumber) {
var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber;
- $(modalPopupContent).html($('#remove-certificate-modal-content').html());
- showPopup();
+ modalDialog.header('Do you really want to remove this certificate ?');
+ modalDialog.footer('');
+ modalDialog.show();
$("a#remove-certificate-yes-link").click(function () {
invokerUtil.delete(
@@ -63,23 +66,29 @@ function removeCertificate(serialNumber) {
function () {
$("#" + serialNumber).remove();
var newCertificateListCount = $(".user-list > span").length;
- $("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount);
- $(modalPopupContent).html($('#remove-certificate-success-content').html());
+ $("#certificate-listing-status-msg").text("Total number of Certificates found : " +
+ newCertificateListCount);
+ modalDialog.header('Done. Certificate was successfully removed.');
+ modalDialog.footer('');
$("a#remove-certificate-success-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
},
function () {
- $(modalPopupContent).html($('#remove-certificate-error-content').html());
+ modalDialog.header('An unexpected error occurred. Please try again later.');
+ modalDialog.footer('');
+ modalDialog.showAsError();
$("a#remove-certificate-error-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
);
});
$("a#remove-certificate-cancel-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
@@ -103,8 +112,9 @@ function InitiateViewOption() {
if ($("#can-view").val()) {
$(location).attr('href', $(this).data("url"));
} else {
- $(modalPopupContent).html($('#errorCertificateView').html());
- showPopup();
+ modalDialog.header('Unauthorized action!');
+ modalDialog.content('You do not have permission to view this certificate.');
+ modalDialog.showAsAWarning();
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js
index c848b86f6e..35a4eb0c05 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js
@@ -36,9 +36,7 @@ function onRequest() {
viewModel.permissions = permissions;
viewModel.enrollmentURL = devicemgtProps.enrollmentURL;
viewModel.deviceCount = deviceModule.getDevicesCount();
- //TODO: Enable Group Management Service API on CDMF
- //page.group_count = groupModule.getGroupCount();
- viewModel.groupCount = -1;
+ viewModel.groupCount = groupModule.getGroupCount();
viewModel.userCount = userModule.getUsersCount();
viewModel.policyCount = policyModule.getPoliciesCount();
viewModel.roleCount = userModule.getRolesCount();
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 ae506f4b07..40d7ee1d6b 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 778b467ea4..6fefcb9bcb 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
@@ -573,9 +573,9 @@ function attachDeviceEvents() {
showPopup();
var serviceURL;
- if (permissionsUtil.hasPermission("LIST_ALL_GROUPS")) {
- serviceURL = "/api/device-mgt/v1.0/groups/all";
- } else if (permissionsUtil.hasPermission("LIST_GROUPS")) {
+ if ($.hasPermission("LIST_ALL_GROUPS")) {
+ 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";
}
@@ -583,18 +583,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.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js
index fe9a550516..19f783ed56 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js
@@ -20,11 +20,16 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js").utility;
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
var groupName = context.uriParams.name;
- var groupOwner = context.uriParams.owner;
- var devices = groupModule.getGroupDevices(groupName, groupOwner).data;
+ var groupId = context.uriParams.id;
+ var devices = [];
+ var deviceResponse = groupModule.getGroupDevices(groupId).responseText;
+
+ if(deviceResponse != null) {
+ var deviceResponseObj = parse(deviceResponse);
+ devices = deviceResponseObj.devices;
+ }
var page = {
"groupName": groupName,
- "groupOwner": groupOwner,
"title": groupName + " Analytics"
};
if (devices) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json
index 9a06298a8c..2e2fea333e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
- "uri": "/group/{owner}/{name}/analytics",
+ "uri": "/group/{name}/{id}/analytics",
"layout": "cdmf.layout.default"
}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
index fe9663f24f..8ae4393a8f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
@@ -1,4 +1,5 @@
{{unit "cdmf.unit.ui.title" pageTitle="Group Management"}}
+{{unit "cdmf.unit.ui.modal"}}
{{#zone "breadcrumbs"}}
@@ -55,22 +56,6 @@
-
-
-
-
-
-
Unexpected error occurred!
-
-
-
-
-
-
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/group-add.js"}}
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 ae6870abd3..b2a5598c0f 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);
});
@@ -71,10 +70,13 @@ $(function () {
});
function displayErrors(message) {
- showPopup();
$('#error-msg').html(message.responseText);
- $(modalPopupContent).html($('#group-error-content').html());
+ modalDialog.header('Unexpected error occurred!');
+ modalDialog.content('');
+ modalDialog.footer('');
+ modalDialog.showAsError();
$("a#group-unexpected-error-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
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 8fbf407873..87dbeecb29 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"}}
{{unit "cdmf.unit.lib.ui-permissions-utility"}}
{{#zone "breadcrumbs"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
index 26d7387a7f..ee24c4393f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js
@@ -22,6 +22,12 @@
var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container";
+function InitiateViewOption() {
+ if ($(".select-enable-btn").text() == "Select") {
+ $(location).attr('href', $(this).data("url"));
+ }
+}
+
/*
* On Select All Groups button click function.
*
@@ -86,11 +92,11 @@ function loadGroups() {
var groupListing = $("#group-listing");
var currentUser = groupListing.data("currentUser");
var serviceURL;
- if (permissionsUtil.hasPermission("LIST_ALL_GROUPS")) {
- serviceURL = "/devicemgt_admin/groups";
- } else if (permissionsUtil.hasPermission("LIST_GROUPS")) {
+ if ($.hasPermission("LIST_ALL_GROUPS")) {
+ serviceURL = "/api/device-mgt/v1.0/groups";
+ } else if ($.hasPermission("LIST_GROUPS")) {
//Get authenticated users groups
- serviceURL = "/devicemgt_admin/groups/user/" + currentUser;
+ serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser;
} else {
$("#loading-content").remove();
$('#device-table').addClass('hidden');
@@ -99,78 +105,120 @@ function loadGroups() {
return;
}
- $('#group-grid').datatables_extended ({
- serverSide: true,
- processing: false,
- searching: true,
- ordering: false,
- filter: false,
- pageLength : 16,
- ajax: { url : '/devicemgt/api/groups', data : {url : serviceURL},
- dataSrc: function ( json ) {
- $('#group-grid').removeClass('hidden');
- var $list = $("#group-listing :input[type='search']");
- $list.each(function(){
- $(this).addClass("hidden");
- });
- return json.data;
- }
+ var dataFilter = function (data) {
+ data = JSON.parse(data);
+ var objects = [];
+ $(data.deviceGroups).each(function (index) {
+ objects.push({
+ groupId: data.deviceGroups[index].id,
+ name: data.deviceGroups[index].name,
+ description: data.deviceGroups[index].description,
+ owner: data.deviceGroups[index].owner,
+ dateOfCreation: data.deviceGroups[index].dateOfCreation
+ })
+ });
+ var json = {
+ "recordsTotal": data.count,
+ "data": objects
+ }
+
+ return JSON.stringify(json);
+ };
+
+ var columns = [{
+ targets: 0,
+ data: 'id',
+ class: 'remove-padding icon-only content-fill',
+ render: function (data, type, row, meta) {
+ return '';
+ }
+ },
+ {
+ targets: 1,
+ data: 'name',
+ class: 'fade-edge'
},
- columnDefs: [
- { targets: 0, data: 'id', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
- return '';
- }},
- {targets: 1, data: 'name', className: 'fade-edge'},
- { 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' ,
- render: function ( id, type, row, meta ) {
- var html;
- html = '' +
- '' +
- 'View Devices';
-
- html += '' +
- '' +
- 'Analytics';
-
- html += '' +
- 'Share';
-
- html += '' +
- 'Edit';
-
- html += '' +
- 'Delete';
-
- return html;
- }}
- ],
- "createdRow": function( row, data, dataIndex ) {
- $(row).attr('data-type', 'selectable');
- $(row).attr('data-groupid', data.id);
- $.each($('td', row), function (colIndex) {
- switch(colIndex) {
- case 1:
- $(this).attr('data-grid-label', "Name");
- $(this).attr('data-search', data.name);
- $(this).attr('data-display', data.name);
- break;
- case 2:
- $(this).attr('data-grid-label', "Owner");
- $(this).attr('data-search', data.owner);
- $(this).attr('data-display', data.owner);
- break;
- }
- });
+ {
+ targets: 2,
+ data: 'owner',
+ class: 'fade-edge remove-padding-top',
},
- "fnDrawCallback": function( oSettings ) {
+ {
+ targets: 3,
+ data: 'description',
+ class: 'fade-edge remove-padding-top',
+ },
+ {
+ targets: 4,
+ data: 'id',
+ class: 'text-right content-fill text-left-on-grid-view no-wrap',
+ render: function (id, type, row, meta) {
+ var html;
+ html = '' +
+ '' +
+ 'View Devices';
+
+ html += '' +
+ '' +
+ 'Analytics';
+
+ html += '' +
+ 'Share';
+
+ html += '' +
+ 'Edit';
+
+ html += '' +
+ 'Delete';
+
+ return html;
+ }
+ }
+
+ ];
+
+ var fnCreatedRow = function (row, data) {
+ $(row).attr('data-type', 'selectable');
+ $(row).attr('data-groupid', data.id);
+ $.each($('td', row), function (colIndex) {
+ switch (colIndex) {
+ case 1:
+ $(this).attr('data-grid-label', "Name");
+ $(this).attr('data-search', data.name);
+ $(this).attr('data-display', data.name);
+ break;
+ case 2:
+ $(this).attr('data-grid-label', "Owner");
+ $(this).attr('data-search', data.owner);
+ $(this).attr('data-display', data.owner);
+ break;
+ case 3:
+ $(this).attr('data-grid-label', "Description");
+ $(this).attr('data-search', data.description);
+ $(this).attr('data-display', data.description);
+ break;
+ }
+ });
+ };
+
+
+ $('#group-grid').datatables_extended_serverside_paging(
+ null,
+ serviceURL,
+ dataFilter,
+ columns,
+ fnCreatedRow,
+ function (oSettings) {
$(".icon .text").res_text(0.2);
attachEvents();
- }
- });
+ },
+ {
+ "placeholder": "Search By Group Name",
+ "searchKey": "name"
+ });
$(groupCheckbox).click(function () {
addGroupSelectedClass(this);
});
@@ -280,7 +328,7 @@ function attachEvents() {
* on Group Management page in WSO2 Device Management Server Console.
*/
$("a.share-group-link").click(function () {
- var groupName = $(this).data("group-name");
+ var groupId = $(this).data("group-id");
var groupOwner = $(this).data("group-owner");
$(modalPopupContent).html($('#share-group-w1-modal-content').html());
$("a#share-group-next-link").show();
@@ -291,7 +339,7 @@ function attachEvents() {
$("#user-names").html("Please specify a user other than current user.");
$("a#share-group-next-link").hide();
} else {
- getAllRoles(groupName, groupOwner, selectedUser);
+ getAllRoles(groupId, selectedUser);
}
});
$("a#share-group-w1-cancel-link").click(function () {
@@ -305,7 +353,7 @@ function attachEvents() {
* on Group Management page in WSO2 IoT Server Console.
*/
$("a.remove-group-link").click(function () {
- var groupName = $(this).data("group-name");
+ var groupId = $(this).data("group-id");
var groupOwner = $(this).data("group-owner");
$(modalPopupContent).html($('#remove-group-modal-content').html());
@@ -313,7 +361,6 @@ function attachEvents() {
$("a#remove-group-yes-link").click(function () {
var successCallback = function (data, textStatus, xhr) {
- data = JSON.parse(data);
if (xhr.status == 200) {
$(modalPopupContent).html($('#remove-group-200-content').html());
setTimeout(function () {
@@ -325,7 +372,7 @@ function attachEvents() {
}
};
- invokerUtil.delete("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName,
+ invokerUtil.delete("/api/device-mgt/v1.0/groups/id/" + groupId,
successCallback, function (message) {
displayErrors(message);
});
@@ -343,6 +390,7 @@ function attachEvents() {
* on Device Management page in WSO2 MDM Console.
*/
$("a.edit-group-link").click(function () {
+ var groupId = $(this).data("group-id");
var groupName = $(this).data("group-name");
var groupOwner = $(this).data("group-owner");
var groupDescription = $(this).data("group-description");
@@ -358,8 +406,8 @@ function attachEvents() {
var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner};
var successCallback = function (data, textStatus, xhr) {
- data = JSON.parse(data);
if (xhr.status == 200) {
+ $(modalPopupContent).html($('#edit-group-200-content').html());
setTimeout(function () {
hidePopup();
location.reload(false);
@@ -369,7 +417,7 @@ function attachEvents() {
}
};
- invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName, group,
+ invokerUtil.put("/api/device-mgt/v1.0/groups/id/" + groupId, group,
successCallback, function (message) {
displayErrors(message);
});
@@ -381,15 +429,15 @@ function attachEvents() {
});
}
-function getAllRoles(groupName, groupOwner, selectedUser) {
+function getAllRoles(groupId, selectedUser) {
$(modalPopupContent).html($('#share-group-w2-modal-content').html());
$('#user-roles').html('');
$("a#share-group-yes-link").hide();
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
if (xhr.status == 200) {
- if (data.length > 0) {
- generateRoleMap(groupName, groupOwner, selectedUser, data);
+ if (data.roles.length > 0) {
+ generateRoleMap(groupId, selectedUser, data.roles);
} else {
$('#user-roles').html("There is no any roles for this group.");
}
@@ -398,7 +446,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) {
displayErrors(message);
});
@@ -408,11 +456,14 @@ function getAllRoles(groupName, groupOwner, selectedUser) {
});
}
-function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
+function generateRoleMap(groupId, selectedUser, allRoles) {
var successCallback = function (data, textStatus, xhr) {
data = JSON.parse(data);
if (xhr.status == 200) {
- var userRoles = data;
+ var userRoles = [];
+ if(data != "EMPTY") {
+ userRoles = data.roles;
+ }
var str = '';
for (var i = 0; i < allRoles.length; i++) {
@@ -437,14 +488,14 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
roles.push(allRoles[i]);
}
}
- updateGroupShare(groupName, groupOwner, selectedUser, roles);
+ updateGroupShare(groupId, selectedUser, roles);
});
} else {
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) {
displayErrors(message);
});
@@ -454,7 +505,7 @@ function generateRoleMap(groupName, groupOwner, selectedUser, allRoles) {
});
}
-function updateGroupShare(groupName, groupOwner, selectedUser, roles) {
+function updateGroupShare(groupId, selectedUser, roles) {
var successCallback = function (data) {
$(modalPopupContent).html($('#share-group-200-content').html());
setTimeout(function () {
@@ -463,8 +514,9 @@ function updateGroupShare(groupName, groupOwner, selectedUser, roles) {
}, 2000);
};
- invokerUtil.put("/devicemgt_admin/groups/owner/" + groupOwner + "/name/" + groupName + "/user/" + selectedUser + "/share/roles",
- roles, successCallback, function (message) {
+ var deviceGroupShare = {"username": selectedUser, "groupRoles": roles };
+ invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/share",
+ deviceGroupShare, 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.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
index 1eb81672aa..4c5280f154 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
@@ -17,6 +17,7 @@
}}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
+{{unit "cdmf.unit.ui.modal"}}
{{#zone "topCss"}}