diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/group-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/group-api.jag
index e64ad14d16..4d5bd9973f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/group-api.jag
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/group-api.jag
@@ -80,4 +80,8 @@ if (!user) {
}
}
+if (result) {
+ print(result);
+}
+
%>
\ 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.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 2e9690071b..259daf255f 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
@@ -37,7 +37,7 @@
{{#if groupCount}}
-
+
@@ -270,9 +270,6 @@
{{/zone}}
{{#zone "bottomJs"}}
-
{{#if groupCount}}
{{js "js/listing.js"}}
{{/if}}
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 a2d95a3c4e..9d4b89a8f0 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
@@ -97,48 +97,97 @@ function toTitleCase(str) {
function loadGroups() {
var groupListing = $("#group-listing");
- var groupListingSrc = groupListing.attr("src");
var currentUser = groupListing.data("currentUser");
- $.template("group-listing", groupListingSrc, function (template) {
-
- var successCallback = function (data) {
- data = JSON.parse(data);
- var viewModel = {};
- viewModel.groups = data.data;
- $('#group-grid').removeClass('hidden');
- var content = template(viewModel);
- $("#ast-container").html(content);
-
- /*
- * On group checkbox select add parent selected style class
- */
- $(groupCheckbox).click(function () {
- addGroupSelectedClass(this);
- });
- attachEvents();
+ var serviceURL;
+ if ($.hasPermission("LIST_ALL_GROUPS")) {
+ serviceURL = "/devicemgt_admin/groups?start=0&rowCount=1000";
+ } else if ($.hasPermission("LIST_GROUPS")) {
+ //Get authenticated users groups
+ serviceURL = "/devicemgt_admin/groups/user/" + currentUser + "?start=0&rowCount=1000";
+ } else {
+ $("#loading-content").remove();
+ $('#device-table').addClass('hidden');
+ $('#device-listing-status-msg').text('Permission denied.');
+ $("#device-listing-status").removeClass(' hidden');
+ return;
+ }
- $('#group-grid').datatables_extended();
+ $('#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;
+ }
+ },
+ 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' , render: function ( name, type, row, meta ) {
+ return '' + name + '
';
+ }},
+ { 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;
+ }
+ });
+ },
+ "fnDrawCallback": function( oSettings ) {
$(".icon .text").res_text(0.2);
- };
-
- var serviceURL;
- if ($.hasPermission("LIST_ALL_GROUPS")) {
- serviceURL = "/devicemgt_admin/groups?start=0&rowCount=1000";
- } else if ($.hasPermission("LIST_GROUPS")) {
- //Get authenticated users groups
- serviceURL = "/devicemgt_admin/groups/user/" + currentUser + "?start=0&rowCount=1000";
- } else {
- $("#loading-content").remove();
- $('#device-table').addClass('hidden');
- $('#device-listing-status-msg').text('Permission denied.');
- $("#device-listing-status").removeClass(' hidden');
- return;
+ attachEvents();
}
-
- invokerUtil.get(serviceURL, successCallback, function (message) {
- displayErrors(message.content);
- });
-
+ });
+ $(groupCheckbox).click(function () {
+ addGroupSelectedClass(this);
});
}