|
|
|
@ -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.
|
|
|
|
|
*
|
|
|
|
@ -100,10 +106,10 @@ function loadGroups() {
|
|
|
|
|
var currentUser = groupListing.data("currentUser");
|
|
|
|
|
var serviceURL;
|
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
|
serviceURL = "/devicemgt_admin/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');
|
|
|
|
@ -112,33 +118,46 @@ 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
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
columnDefs: [
|
|
|
|
|
{ targets: 0, data: 'id', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
|
|
|
|
|
|
|
|
|
return JSON.stringify(json);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var columns = [{
|
|
|
|
|
targets: 0,
|
|
|
|
|
data: 'id',
|
|
|
|
|
class: 'remove-padding icon-only content-fill',
|
|
|
|
|
render: function (data, type, row, meta) {
|
|
|
|
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
|
|
|
|
}},
|
|
|
|
|
{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 ) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
targets: 1,
|
|
|
|
|
data: 'name',
|
|
|
|
|
class: 'fade-edge'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
targets: 3,
|
|
|
|
|
data: 'id',
|
|
|
|
|
class: 'text-right content-fill text-left-on-grid-view no-wrap',
|
|
|
|
|
render: function (id, type, row, meta) {
|
|
|
|
|
var html;
|
|
|
|
|
html = '<a href="devices?groupName=' + row.name + '&groupOwner=' + row.owner + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view">' +
|
|
|
|
|
html = '<a href="devices?groupId=' + row.groupId + '&groupOwner=' + row.owner + '" 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="hidden-xs hidden-on-grid-view">View Devices</span></a>';
|
|
|
|
|
|
|
|
|
@ -159,13 +178,16 @@ function loadGroups() {
|
|
|
|
|
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}}
|
|
|
|
|
],
|
|
|
|
|
"createdRow": function( row, data, dataIndex ) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var fnCreatedRow = function (row, data) {
|
|
|
|
|
$(row).attr('data-type', 'selectable');
|
|
|
|
|
$(row).attr('data-groupid', data.id);
|
|
|
|
|
$.each($('td', row), function (colIndex) {
|
|
|
|
|
switch(colIndex) {
|
|
|
|
|
switch (colIndex) {
|
|
|
|
|
case 1:
|
|
|
|
|
$(this).attr('data-grid-label', "Name");
|
|
|
|
|
$(this).attr('data-search', data.name);
|
|
|
|
@ -178,11 +200,22 @@ function loadGroups() {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
"fnDrawCallback": function( oSettings ) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#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);
|
|
|
|
|