|
|
|
@ -261,7 +261,7 @@ function loadDevices(searchType, searchParam) {
|
|
|
|
|
return '<a href="' + context + '/device/' + row.deviceType + '?id=' + row.deviceIdentifier
|
|
|
|
|
+ '"><div class="thumbnail icon"><img class="square-element text fw " src="'
|
|
|
|
|
+ getDeviceTypeThumb(
|
|
|
|
|
row.deviceType) + '"/></div></a>';
|
|
|
|
|
row.deviceType) + '"/></div></a>';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
@ -347,31 +347,31 @@ function loadDevices(searchType, searchParam) {
|
|
|
|
|
|
|
|
|
|
if ((!groupName || !groupId) && groupingEnabled(row.deviceType)) {
|
|
|
|
|
html +=
|
|
|
|
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' +
|
|
|
|
|
row.name + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
|
'<i class="fw fw-grouping fw-stack-1x"></i></span>' +
|
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Group</span></a>';
|
|
|
|
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' +
|
|
|
|
|
row.name + '"><span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
|
|
|
|
'<i class="fw fw-grouping fw-stack-1x"></i></span>' +
|
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Group</span></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html +=
|
|
|
|
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' + row.name + '">' +
|
|
|
|
|
'<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>';
|
|
|
|
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' + row.name + '">' +
|
|
|
|
|
'<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>';
|
|
|
|
|
html +=
|
|
|
|
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' + row.name + '">' +
|
|
|
|
|
'<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 href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
|
|
|
|
|
+
|
|
|
|
|
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
|
|
|
|
+ '" data-devicename="' + row.name + '">' +
|
|
|
|
|
'<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>';
|
|
|
|
|
}
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
@ -427,16 +427,16 @@ function loadDevices(searchType, searchParam) {
|
|
|
|
|
|
|
|
|
|
$(data.devices).each(function (index) {
|
|
|
|
|
objects.push(
|
|
|
|
|
{
|
|
|
|
|
model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"),
|
|
|
|
|
vendor: getPropertyValue(data.devices[index].properties, "VENDOR"),
|
|
|
|
|
user: data.devices[index].enrolmentInfo.owner,
|
|
|
|
|
status: data.devices[index].enrolmentInfo.status,
|
|
|
|
|
ownership: data.devices[index].enrolmentInfo.ownership,
|
|
|
|
|
deviceType: data.devices[index].type,
|
|
|
|
|
deviceIdentifier: data.devices[index].deviceIdentifier,
|
|
|
|
|
name: data.devices[index].name
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"),
|
|
|
|
|
vendor: getPropertyValue(data.devices[index].properties, "VENDOR"),
|
|
|
|
|
user: data.devices[index].enrolmentInfo.owner,
|
|
|
|
|
status: data.devices[index].enrolmentInfo.status,
|
|
|
|
|
ownership: data.devices[index].enrolmentInfo.ownership,
|
|
|
|
|
deviceType: data.devices[index].type,
|
|
|
|
|
deviceIdentifier: data.devices[index].deviceIdentifier,
|
|
|
|
|
name: data.devices[index].name
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -449,20 +449,20 @@ function loadDevices(searchType, searchParam) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$('#device-grid').datatables_extended_serverside_paging(
|
|
|
|
|
null,
|
|
|
|
|
serviceURL,
|
|
|
|
|
dataFilter,
|
|
|
|
|
columns,
|
|
|
|
|
fnCreatedRow,
|
|
|
|
|
function () {
|
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
|
$('#device-grid').removeClass('hidden');
|
|
|
|
|
$("#loading-content").remove();
|
|
|
|
|
attachDeviceEvents();
|
|
|
|
|
}, {
|
|
|
|
|
"placeholder": "Search By Device Name",
|
|
|
|
|
"searchKey": "name"
|
|
|
|
|
}
|
|
|
|
|
null,
|
|
|
|
|
serviceURL,
|
|
|
|
|
dataFilter,
|
|
|
|
|
columns,
|
|
|
|
|
fnCreatedRow,
|
|
|
|
|
function () {
|
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
|
$('#device-grid').removeClass('hidden');
|
|
|
|
|
$("#loading-content").remove();
|
|
|
|
|
attachDeviceEvents();
|
|
|
|
|
}, {
|
|
|
|
|
"placeholder": "Search By Device Name",
|
|
|
|
|
"searchKey": "name"
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$(deviceCheckbox).click(function () {
|
|
|
|
@ -556,6 +556,34 @@ function hidePopup() {
|
|
|
|
|
$('.modal-backdrop').remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function markAlreadyAssignedGroups(deviceId, deviceType) {
|
|
|
|
|
var successCallback = function (data, textStatus, xhr) {
|
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
if (xhr.status == 200) {
|
|
|
|
|
if (data.length > 0) {
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
|
$('.groupCheckBoxes').each(
|
|
|
|
|
function () {
|
|
|
|
|
if (data[i].id == $(this).data('groupid')) {
|
|
|
|
|
$(this).attr('checked', true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
displayErrors(xhr);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType,
|
|
|
|
|
successCallback, function (message) {
|
|
|
|
|
displayErrors(message);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Following functions should be triggered after AJAX request is made.
|
|
|
|
|
*/
|
|
|
|
@ -572,33 +600,48 @@ function attachDeviceEvents() {
|
|
|
|
|
var deviceType = $(this).data("devicetype");
|
|
|
|
|
$(modalPopupContent).html($('#group-device-modal-content').html());
|
|
|
|
|
$('#user-groups').html(
|
|
|
|
|
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
|
|
|
|
|
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
|
|
|
|
|
$("a#group-device-yes-link").hide();
|
|
|
|
|
showPopup();
|
|
|
|
|
|
|
|
|
|
var serviceURL;
|
|
|
|
|
if ($.hasPermission("LIST_ALL_GROUPS")) {
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups";
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100";
|
|
|
|
|
} else if ($.hasPermission("LIST_GROUPS")) {
|
|
|
|
|
//Get authenticated users groups
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups/user/" + currentUser + "/all";
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups?limit=100";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
invokerUtil.get(serviceURL, function (data) {
|
|
|
|
|
var groups = JSON.parse(data);
|
|
|
|
|
var str = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">';
|
|
|
|
|
var html = '<br />';
|
|
|
|
|
for (var i = 0; i < groups.deviceGroups.length; i++) {
|
|
|
|
|
str += '<option value="' + groups.deviceGroups[i].id + '">' +
|
|
|
|
|
groups.deviceGroups[i].name + '</option>';
|
|
|
|
|
if (groups.deviceGroups[i].owner != "wso2.system.user") {
|
|
|
|
|
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' +
|
|
|
|
|
'<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' +
|
|
|
|
|
'<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name +
|
|
|
|
|
'</span></label></div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
str += '</select>';
|
|
|
|
|
$('#user-groups').html(str);
|
|
|
|
|
$('#user-groups').html(html);
|
|
|
|
|
markAlreadyAssignedGroups(deviceId, deviceType);
|
|
|
|
|
$("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/id/" + selectedGroup + "/devices/add";
|
|
|
|
|
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
|
|
|
|
|
invokerUtil.post(serviceURL, deviceIdentifiers, function (data) {
|
|
|
|
|
var deviceIdentifier = {"id": deviceId, "type": deviceType};
|
|
|
|
|
var deviceGroupIds = [];
|
|
|
|
|
$('.modal .groupCheckBoxes').each(
|
|
|
|
|
function () {
|
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
|
deviceGroupIds.push($(this).data('groupid'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
var deviceToGroupsAssignment = {
|
|
|
|
|
deviceIdentifier: deviceIdentifier,
|
|
|
|
|
deviceGroupIds: deviceGroupIds
|
|
|
|
|
};
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups/device/assign";
|
|
|
|
|
invokerUtil.post(serviceURL, deviceToGroupsAssignment, function (data) {
|
|
|
|
|
$(modalPopupContent).html($('#group-associate-device-200-content').html());
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
hidePopup();
|
|
|
|
@ -640,8 +683,8 @@ function attachDeviceEvents() {
|
|
|
|
|
showPopup();
|
|
|
|
|
|
|
|
|
|
$("a#remove-device-yes-link").click(function () {
|
|
|
|
|
if(groupId && groupName) {
|
|
|
|
|
var deviceIdentifiers = [{"id": deviceId,"type": deviceType}];
|
|
|
|
|
if (groupId && groupName) {
|
|
|
|
|
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
|
|
|
|
|
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {
|
|
|
|
|
$(modalPopupContent).html($('#remove-device-from-group-200-content').html());
|
|
|
|
@ -733,6 +776,6 @@ function displayDeviceErrors(jqXHR) {
|
|
|
|
|
function getParameterByName(name) {
|
|
|
|
|
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
|
|
|
|
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
|
|
|
|
results = regex.exec(location.search);
|
|
|
|
|
results = regex.exec(location.search);
|
|
|
|
|
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
|
|
|
}
|
|
|
|
|