re enabling device renaming

revert-70aa11f8
kamidu 8 years ago
parent 590e21f419
commit 6fe7470af5

@ -70,7 +70,7 @@ $(document).ready(function () {
deviceListing = $("#device-listing"); deviceListing = $("#device-listing");
currentUser = deviceListing.data("current-user"); currentUser = deviceListing.data("current-user");
groupId = getParameterByName("groupId"); groupId = getParameterByName("groupId");
/* Adding selected class for selected devices */ /* Adding selected class for selected devices */
@ -80,11 +80,11 @@ $(document).ready(function () {
/* for device list sorting drop down */ /* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({ $(".ctrl-filter-type-switcher").popover({
html: true, html: true,
content: function () { content: function () {
return $("#content-filter-types").html(); return $("#content-filter-types").html();
} }
}); });
}); });
/* /*
@ -247,7 +247,7 @@ function loadDevices(searchType, searchParam) {
class: 'remove-padding icon-only content-fill viewEnabledIcon', class: 'remove-padding icon-only content-fill viewEnabledIcon',
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<div class="thumbnail icon"><img class="square-element text fw " src="' return '<div class="thumbnail icon"><img class="square-element text fw " src="'
+ getDeviceTypeThumb(row.deviceType) + '"/></div>'; + getDeviceTypeThumb(row.deviceType) + '"/></div>';
} }
}, },
{ {
@ -325,47 +325,47 @@ function loadDevices(searchType, searchParam) {
if (analyticsEnabled(row.deviceType)) { if (analyticsEnabled(row.deviceType)) {
html += '<a href="' + context + '/device/' + deviceType + '/analytics?deviceId=' + html += '<a href="' + context + '/device/' + deviceType + '/analytics?deviceId=' +
deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' + deviceIdentifier + '&deviceName=' + row.name + '" ' + 'data-click-event="remove-form"' +
' class="btn padding-reduce-on-grid-view" data-placement="top" data-toggle="tooltip" data-original-title="Analytics"><span class="fw-stack">' + ' class="btn padding-reduce-on-grid-view" data-placement="top" data-toggle="tooltip" data-original-title="Analytics"><span class="fw-stack">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' + '<i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-statistics fw-stack-1x"></i></span>' +
'<span class="hidden-xs hidden-on-grid-view">Analytics</span>'; '<span class="hidden-xs hidden-on-grid-view">Analytics</span>';
} }
if (!groupId && groupingEnabled(row.deviceType)) { if (!groupId && groupingEnabled(row.deviceType)) {
html += html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view group-device-link" '
+ +
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + + '" data-devicename="' +
row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Group"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Group"><span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-group fw-stack-1x"></i></span>' + '<i class="fw fw-group fw-stack-1x"></i></span>' +
'<span class="hidden-xs hidden-on-grid-view">Group</span></a>'; '<span class="hidden-xs hidden-on-grid-view">Group</span></a>';
} }
// html += html +=
// '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
// + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
// + '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Edit">' + '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Edit">'
// + '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' + '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
// + '<i class="fw fw-edit fw-stack-1x"></i></span>' + '<i class="fw fw-edit fw-stack-1x"></i></span>'
// + '<span class="hidden-xs hidden-on-grid-view">Edit</span></a>'; + '<span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
var groupOwner = $('#group_owner').text(); var groupOwner = $('#group_owner').text();
if (groupId && groupOwner != "wso2.system.user") { if (groupId && groupOwner != "wso2.system.user") {
html += html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Remove from group">' + '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Remove from group">'
+ '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' + '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
+ '<i class="fw fw-delete fw-stack-1x"></i></span>' + '<i class="fw fw-delete fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Remove from group</span>'; + '<span class="hidden-xs hidden-on-grid-view">Remove from group</span>';
} else { } else {
html += html +=
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" ' '<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
+ '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Delete">' + '" data-devicename="' + row.name + '" data-placement="top" data-toggle="tooltip" data-original-title="Delete">'
+ '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>' + '<span class="fw-stack"><i class="fw fw-circle-outline fw-stack-2x"></i>'
+ '<i class="fw fw-delete fw-stack-1x"></i></span>' + '<i class="fw fw-delete fw-stack-1x"></i></span>'
+ '<span class="hidden-xs hidden-on-grid-view">Delete</span>'; + '<span class="hidden-xs hidden-on-grid-view">Delete</span>';
} }
} }
return html; return html;
@ -417,7 +417,7 @@ function loadDevices(searchType, searchParam) {
}); });
}; };
function htmlspecialchars(text){ function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html(); return jQuery('<div/>').text(text).html();
} }
@ -427,16 +427,16 @@ function loadDevices(searchType, searchParam) {
$(data.devices).each(function (index) { $(data.devices).each(function (index) {
objects.push( objects.push(
{ {
model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"),
vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), vendor: getPropertyValue(data.devices[index].properties, "VENDOR"),
user: data.devices[index].enrolmentInfo.owner, user: data.devices[index].enrolmentInfo.owner,
status: data.devices[index].enrolmentInfo.status, status: data.devices[index].enrolmentInfo.status,
ownership: data.devices[index].enrolmentInfo.ownership, ownership: data.devices[index].enrolmentInfo.ownership,
deviceType: data.devices[index].type, deviceType: data.devices[index].type,
deviceIdentifier: data.devices[index].deviceIdentifier, deviceIdentifier: data.devices[index].deviceIdentifier,
name: data.devices[index].name name: data.devices[index].name
} }
); );
}); });
@ -449,28 +449,28 @@ function loadDevices(searchType, searchParam) {
}; };
$('#device-grid').datatables_extended_serverside_paging( $('#device-grid').datatables_extended_serverside_paging(
null, null,
serviceURL, serviceURL,
dataFilter, dataFilter,
columns, columns,
fnCreatedRow, fnCreatedRow,
function () { function () {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
$('#device-grid').removeClass('hidden'); $('#device-grid').removeClass('hidden');
$("#loading-content").remove(); $("#loading-content").remove();
attachDeviceEvents(); attachDeviceEvents();
if($('.advance-search').length < 1){ if ($('.advance-search').length < 1) {
$(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
.after('<a href="'+context+'/devices/search"' + .after('<a href="' + context + '/devices/search"' +
' class="advance-search add-padding-3x">Advance Search</a>'); ' class="advance-search add-padding-3x">Advance Search</a>');
}
}, {
"placeholder": "Search By Device Name",
"searchKey": "name"
} }
}, {
"placeholder": "Search By Device Name",
"searchKey": "name"
}
); );
$(deviceCheckbox).click(function () { $(deviceCheckbox).click(function () {
@ -507,11 +507,11 @@ $(document).ready(function () {
/* for device list sorting drop down */ /* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({ $(".ctrl-filter-type-switcher").popover({
html: true, html: true,
content: function () { content: function () {
return $("#content-filter-types").html(); return $("#content-filter-types").html();
} }
}); });
/* for data tables*/ /* for data tables*/
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
@ -519,17 +519,17 @@ $(document).ready(function () {
$("[data-toggle=popover]").popover(); $("[data-toggle=popover]").popover();
$(".ctrl-filter-type-switcher").popover({ $(".ctrl-filter-type-switcher").popover({
html: true, html: true,
content: function () { content: function () {
return $('#content-filter-types').html(); return $('#content-filter-types').html();
} }
}); });
$('#nav').affix({ $('#nav').affix({
offset: { offset: {
top: $('header').height() top: $('header').height()
} }
}); });
}); });
@ -583,9 +583,9 @@ function markAlreadyAssignedGroups(deviceId, deviceType) {
}; };
invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType, invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType,
successCallback, function (message) { successCallback, function (message) {
displayErrors(message); displayErrors(message);
}); });
} }
/** /**
@ -604,7 +604,7 @@ function attachDeviceEvents() {
var deviceType = $(this).data("devicetype"); var deviceType = $(this).data("devicetype");
$(modalPopupContent).html($('#group-device-modal-content').html()); $(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').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-update-link").hide(); $("a#group-device-update-link").hide();
showPopup(); showPopup();
@ -629,9 +629,9 @@ function attachDeviceEvents() {
} }
if (hasGroups) { if (hasGroups) {
html = '<br/><h4>Please select device group(s)</h4><br/>' + html = '<br/><h4>Please select device group(s)</h4><br/>' +
'<div class="wr-input-control">' + '<div class="wr-input-control">' +
'<select id="groups" class="form-control select2" multiple="multiple">' + '<select id="groups" class="form-control select2" multiple="multiple">' +
html + '</select></div>'; html + '</select></div>';
markAlreadyAssignedGroups(deviceId, deviceType); markAlreadyAssignedGroups(deviceId, deviceType);
$("a#group-device-update-link").show(); $("a#group-device-update-link").show();
$("a#group-add-link").hide(); $("a#group-add-link").hide();
@ -642,8 +642,8 @@ function attachDeviceEvents() {
} }
$('#user-groups').html(html); $('#user-groups').html(html);
$("select.select2[multiple=multiple]").select2({ $("select.select2[multiple=multiple]").select2({
tags: false tags: false
}); });
$("a#group-device-update-link").click(function () { $("a#group-device-update-link").click(function () {
var deviceIdentifier = {"id": deviceId, "type": deviceType}; var deviceIdentifier = {"id": deviceId, "type": deviceType};
var deviceGroupIds = $("#groups").val(); var deviceGroupIds = $("#groups").val();
@ -787,7 +787,7 @@ function attachDeviceEvents() {
$(modalPopupContent).html($('#group-device-modal-content').html()); $(modalPopupContent).html($('#group-device-modal-content').html());
$('#user-groups').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-add-link").hide(); $("a#group-device-add-link").hide();
showPopup(); showPopup();
@ -806,13 +806,13 @@ function attachDeviceEvents() {
for (var i = 0; i < groups.deviceGroups.length; i++) { for (var i = 0; i < groups.deviceGroups.length; i++) {
if (groups.deviceGroups[i].owner != "wso2.system.user") { if (groups.deviceGroups[i].owner != "wso2.system.user") {
html += '<option value="' + groups.deviceGroups[i].id + '">' + html += '<option value="' + groups.deviceGroups[i].id + '">' +
groups.deviceGroups[i].name + '</option>'; groups.deviceGroups[i].name + '</option>';
hasGroups = true; hasGroups = true;
} }
} }
if (hasGroups) { if (hasGroups) {
html = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">' + html = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">' +
html + '</select>'; html + '</select>';
$("a#group-add-link").hide(); $("a#group-add-link").hide();
$("a#group-device-add-link").show(); $("a#group-device-add-link").show();
} else { } else {
@ -898,7 +898,7 @@ function displayDeviceErrors(jqXHR) {
function getParameterByName(name) { function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search); results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
} }
@ -911,10 +911,10 @@ function getSelectedDevices() {
thisTable.api().rows().every(function () { thisTable.api().rows().every(function () {
if ($(this.node()).hasClass('DTTT_selected')) { if ($(this.node()).hasClass('DTTT_selected')) {
deviceList.push( deviceList.push(
{ {
"id": $(thisTable.api().row(this).node()).data('deviceid'), "id": $(thisTable.api().row(this).node()).data('deviceid'),
"type": $(thisTable.api().row(this).node()).data('devicetype') "type": $(thisTable.api().row(this).node()).data('devicetype')
} }
); );
} }
}); });

Loading…
Cancel
Save