|
|
@ -22,6 +22,12 @@
|
|
|
|
var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
|
|
|
|
var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
|
|
|
|
var assetContainer = "#ast-container";
|
|
|
|
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.
|
|
|
|
* On Select All Groups button click function.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -100,10 +106,10 @@ function loadGroups() {
|
|
|
|
var currentUser = groupListing.data("currentUser");
|
|
|
|
var currentUser = groupListing.data("currentUser");
|
|
|
|
var serviceURL;
|
|
|
|
var serviceURL;
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
serviceURL = "/devicemgt_admin/groups";
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups";
|
|
|
|
} else if ($.hasPermission("LIST_GROUPS")) {
|
|
|
|
} else if ($.hasPermission("LIST_GROUPS")) {
|
|
|
|
//Get authenticated users groups
|
|
|
|
//Get authenticated users groups
|
|
|
|
serviceURL = "/devicemgt_admin/groups/user/" + currentUser;
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$('#device-table').addClass('hidden');
|
|
|
|
$('#device-table').addClass('hidden');
|
|
|
@ -112,33 +118,46 @@ function loadGroups() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#group-grid').datatables_extended ({
|
|
|
|
var dataFilter = function (data) {
|
|
|
|
serverSide: true,
|
|
|
|
data = JSON.parse(data);
|
|
|
|
processing: false,
|
|
|
|
var objects = [];
|
|
|
|
searching: true,
|
|
|
|
$(data.deviceGroups).each(function (index) {
|
|
|
|
ordering: false,
|
|
|
|
objects.push({
|
|
|
|
filter: false,
|
|
|
|
groupId: data.deviceGroups[index].id,
|
|
|
|
pageLength : 16,
|
|
|
|
name: data.deviceGroups[index].name,
|
|
|
|
ajax: { url : '/devicemgt/api/groups', data : {url : serviceURL},
|
|
|
|
description: data.deviceGroups[index].description,
|
|
|
|
dataSrc: function ( json ) {
|
|
|
|
owner: data.deviceGroups[index].owner,
|
|
|
|
$('#group-grid').removeClass('hidden');
|
|
|
|
dateOfCreation: data.deviceGroups[index].dateOfCreation
|
|
|
|
var $list = $("#group-listing :input[type='search']");
|
|
|
|
})
|
|
|
|
$list.each(function(){
|
|
|
|
});
|
|
|
|
$(this).addClass("hidden");
|
|
|
|
var json = {
|
|
|
|
});
|
|
|
|
"recordsTotal": data.count,
|
|
|
|
return json.data;
|
|
|
|
"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 '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
columnDefs: [
|
|
|
|
{
|
|
|
|
{ targets: 0, data: 'id', className: 'remove-padding icon-only content-fill' , render: function ( data, type, row, meta ) {
|
|
|
|
targets: 1,
|
|
|
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
|
|
|
data: 'name',
|
|
|
|
}},
|
|
|
|
class: 'fade-edge'
|
|
|
|
{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' ,
|
|
|
|
targets: 3,
|
|
|
|
|
|
|
|
data: 'id',
|
|
|
|
|
|
|
|
class: 'text-right content-fill text-left-on-grid-view no-wrap',
|
|
|
|
render: function (id, type, row, meta) {
|
|
|
|
render: function (id, type, row, meta) {
|
|
|
|
var html;
|
|
|
|
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="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>';
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">View Devices</span></a>';
|
|
|
|
|
|
|
|
|
|
|
@ -151,17 +170,20 @@ function loadGroups() {
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Share</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
'data-group-owner="' + row.owner + '" data-group-description="' + row.description + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
'data-group-owner="' + row.owner + '" data-group-description="' + row.description + '" data-group-id="'+row.groupId+'"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
|
|
|
'<i class="fw fw-edit fw-stack-1x"></i></span><span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-name="' + row.name + '" ' +
|
|
|
|
html += '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-group-link" data-group-id="' + row.groupId + '" ' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>' +
|
|
|
|
'data-group-owner="' + row.owner + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i>' +
|
|
|
|
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
|
|
|
|
'</span><span class="hidden-xs hidden-on-grid-view">Delete</span></a>';
|
|
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
return html;
|
|
|
|
}}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
}
|
|
|
|
"createdRow": function( row, data, dataIndex ) {
|
|
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fnCreatedRow = function (row, data) {
|
|
|
|
$(row).attr('data-type', 'selectable');
|
|
|
|
$(row).attr('data-type', 'selectable');
|
|
|
|
$(row).attr('data-groupid', data.id);
|
|
|
|
$(row).attr('data-groupid', data.id);
|
|
|
|
$.each($('td', row), function (colIndex) {
|
|
|
|
$.each($('td', row), function (colIndex) {
|
|
|
@ -178,11 +200,22 @@ function loadGroups() {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
"fnDrawCallback": function( oSettings ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#group-grid').datatables_extended_serverside_paging(
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
serviceURL,
|
|
|
|
|
|
|
|
dataFilter,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
|
|
|
|
fnCreatedRow,
|
|
|
|
|
|
|
|
function (oSettings) {
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
attachEvents();
|
|
|
|
attachEvents();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"placeholder": "Search By Group Name",
|
|
|
|
|
|
|
|
"searchKey": "name"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(groupCheckbox).click(function () {
|
|
|
|
$(groupCheckbox).click(function () {
|
|
|
|
addGroupSelectedClass(this);
|
|
|
|
addGroupSelectedClass(this);
|
|
|
@ -318,15 +351,13 @@ function attachEvents() {
|
|
|
|
* on Group Management page in WSO2 IoT Server Console.
|
|
|
|
* on Group Management page in WSO2 IoT Server Console.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("a.remove-group-link").click(function () {
|
|
|
|
$("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());
|
|
|
|
$(modalPopupContent).html($('#remove-group-modal-content').html());
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
|
|
|
|
|
|
|
|
|
$("a#remove-group-yes-link").click(function () {
|
|
|
|
$("a#remove-group-yes-link").click(function () {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
$(modalPopupContent).html($('#remove-group-200-content').html());
|
|
|
|
$(modalPopupContent).html($('#remove-group-200-content').html());
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
@ -338,7 +369,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) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -356,6 +387,7 @@ function attachEvents() {
|
|
|
|
* on Device Management page in WSO2 MDM Console.
|
|
|
|
* on Device Management page in WSO2 MDM Console.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("a.edit-group-link").click(function () {
|
|
|
|
$("a.edit-group-link").click(function () {
|
|
|
|
|
|
|
|
var groupId = $(this).data("group-id");
|
|
|
|
var groupName = $(this).data("group-name");
|
|
|
|
var groupName = $(this).data("group-name");
|
|
|
|
var groupOwner = $(this).data("group-owner");
|
|
|
|
var groupOwner = $(this).data("group-owner");
|
|
|
|
var groupDescription = $(this).data("group-description");
|
|
|
|
var groupDescription = $(this).data("group-description");
|
|
|
@ -371,8 +403,8 @@ function attachEvents() {
|
|
|
|
var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner};
|
|
|
|
var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner};
|
|
|
|
|
|
|
|
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#edit-group-200-content').html());
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
location.reload(false);
|
|
|
|
location.reload(false);
|
|
|
@ -382,7 +414,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) {
|
|
|
|
successCallback, function (message) {
|
|
|
|
displayErrors(message);
|
|
|
|
displayErrors(message);
|
|
|
|
});
|
|
|
|
});
|
|
|
|