|
|
@ -16,10 +16,12 @@
|
|
|
|
* under the License.
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var loadRoleBasedActionURL = function (action, rolename) {
|
|
|
|
var loadRoleBasedActionURL = function (action, rolename) {
|
|
|
|
var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename;
|
|
|
|
var href = $("#ast-container").data("app-context") + "roles/" + action + "?rolename=" + rolename;
|
|
|
|
$(location).attr('href', href);
|
|
|
|
$(location).attr('href', href);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var apiBasePath = "/api/device-mgt/v1.0";
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Following function would execute
|
|
|
|
* Following function would execute
|
|
|
|
* when a user clicks on the list item
|
|
|
|
* when a user clicks on the list item
|
|
|
@ -38,34 +40,34 @@ var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGr
|
|
|
|
var templateSrc = $(objectGridTemplateSrc).attr("src");
|
|
|
|
var templateSrc = $(objectGridTemplateSrc).attr("src");
|
|
|
|
$.template(objectGridId, templateSrc, function (template) {
|
|
|
|
$.template(objectGridId, templateSrc, function (template) {
|
|
|
|
invokerUtil.get(serviceURL,
|
|
|
|
invokerUtil.get(serviceURL,
|
|
|
|
function (data) {
|
|
|
|
function (data) {
|
|
|
|
data = callback(data);
|
|
|
|
data = callback(data);
|
|
|
|
if (data.length > 0 && data != null) {
|
|
|
|
if (data.length > 0 && data != null) {
|
|
|
|
$('#ast-container').removeClass('hidden');
|
|
|
|
$('#ast-container').removeClass('hidden');
|
|
|
|
$('#role-listing-status').hide();
|
|
|
|
$('#role-listing-status').hide();
|
|
|
|
for (var i = 0; i < data.viewModel.roles.length; i++) {
|
|
|
|
for (var i = 0; i < data.viewModel.roles.length; i++) {
|
|
|
|
data.viewModel.roles[i].adminRole = $("#role-table").data("role");
|
|
|
|
data.viewModel.roles[i].adminRole = $("#role-table").data("role");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var content = template(data.viewModel);
|
|
|
|
var content = template(data.viewModel);
|
|
|
|
$(objectGridContainer).html(content);
|
|
|
|
$(objectGridContainer).html(content);
|
|
|
|
if (isInit) {
|
|
|
|
if (isInit) {
|
|
|
|
$('#role-grid').datatables_extended();
|
|
|
|
$('#role-grid').datatables_extended_serverside_paging();
|
|
|
|
isInit = false;
|
|
|
|
isInit = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$("#dt-select-all").addClass("hidden");
|
|
|
|
$("#dt-select-all").addClass("hidden");
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$('#ast-container').addClass('hidden');
|
|
|
|
$('#ast-container').addClass('hidden');
|
|
|
|
$('#role-listing-status-msg').text('No roles are available to be displayed.');
|
|
|
|
$('#role-listing-status-msg').text('No roles are available to be displayed.');
|
|
|
|
$('#role-listing-status').show();
|
|
|
|
$('#role-listing-status').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//$(objectGridId).datatables_extended();
|
|
|
|
//$(objectGridId).datatables_extended();
|
|
|
|
}, function (message) {
|
|
|
|
}, function (message) {
|
|
|
|
$('#ast-container').addClass('hidden');
|
|
|
|
$('#ast-container').addClass('hidden');
|
|
|
|
$('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' +
|
|
|
|
$('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' +
|
|
|
|
'query');
|
|
|
|
'query');
|
|
|
|
$('#role-listing-status').show();
|
|
|
|
$('#role-listing-status').show();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -73,46 +75,72 @@ var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGr
|
|
|
|
function loadRoles(searchQuery) {
|
|
|
|
function loadRoles(searchQuery) {
|
|
|
|
var loadingContent = $("#loading-content");
|
|
|
|
var loadingContent = $("#loading-content");
|
|
|
|
loadingContent.show();
|
|
|
|
loadingContent.show();
|
|
|
|
var serviceURL = "/devicemgt_admin/roles";
|
|
|
|
|
|
|
|
if (searchQuery) {
|
|
|
|
var dataFilter = function(data){
|
|
|
|
serviceURL = serviceURL + "/search?filter=" + searchQuery;
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var objects = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(data.roles).each(function( index ) {
|
|
|
|
|
|
|
|
objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json = {
|
|
|
|
|
|
|
|
"recordsTotal": data.count,
|
|
|
|
|
|
|
|
"recordsFiltered": data.count,
|
|
|
|
|
|
|
|
"data": objects
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return JSON.stringify( json );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var callback = function (data) {
|
|
|
|
|
|
|
|
if (data != null || data == "null") {
|
|
|
|
|
|
|
|
data = JSON.parse(data);
|
|
|
|
|
|
|
|
var canRemove = $("#can-remove").val();
|
|
|
|
|
|
|
|
var canEdit = $("#can-edit").val();
|
|
|
|
|
|
|
|
var roles = [];
|
|
|
|
|
|
|
|
for(var i=0; i<data.responseContent.length; i++){
|
|
|
|
|
|
|
|
roles.push({"roleName":data.responseContent[i]});
|
|
|
|
|
|
|
|
if(canRemove != null && canRemove != undefined) {
|
|
|
|
|
|
|
|
roles[i].canRemove = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(canEdit != null && canEdit != undefined) {
|
|
|
|
var fnCreatedRow = function( nRow, aData, iDataIndex ) {
|
|
|
|
roles[i].canEdit = true;
|
|
|
|
$(nRow).attr('data-type', 'selectable');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
var columns = [
|
|
|
|
"viewModel": {
|
|
|
|
{
|
|
|
|
"roles": roles
|
|
|
|
class: "remove-padding icon-only content-fill",
|
|
|
|
},
|
|
|
|
data: null,
|
|
|
|
"length": roles.length
|
|
|
|
defaultContent: '<div class="thumbnail icon"> <i class="square-element text fw fw-user" style="font-size: 30px;"></i></div>'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
class: "fade-edge remove-padding-top",
|
|
|
|
|
|
|
|
data: "name",
|
|
|
|
|
|
|
|
defaultContent: ''
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
class: "text-right content-fill text-left-on-grid-view no-wrap",
|
|
|
|
|
|
|
|
data: null,
|
|
|
|
|
|
|
|
render: function ( data, type, row, meta ) {
|
|
|
|
|
|
|
|
return '<a onclick="javascript:loadRoleBasedActionURL(\'edit-role\', \'' + data.name + '\')" data-role="' + data.name +
|
|
|
|
|
|
|
|
'" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-role-link"><span class="fw-stack fw-lg">' +
|
|
|
|
|
|
|
|
'<i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-user fw-stack-1x"></i>' +
|
|
|
|
|
|
|
|
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
|
|
|
|
|
|
|
|
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' +
|
|
|
|
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Edit</span></a>' +
|
|
|
|
|
|
|
|
'<a onclick="javascript:loadRoleBasedActionURL(\'edit-role-permission\', \'' + data.name +
|
|
|
|
|
|
|
|
'\')" data-role="' + data.name + '" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link">' +
|
|
|
|
|
|
|
|
'<span class="fw-stack fw-lg"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-security-policy fw-stack-1x"></i>' +
|
|
|
|
|
|
|
|
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
|
|
|
|
|
|
|
|
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' +
|
|
|
|
|
|
|
|
'<span class="hidden-xs hidden-on-grid-view">Edit Permission</span></a>' +
|
|
|
|
|
|
|
|
'<a data-role="' + data.name + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-role-link">' +
|
|
|
|
|
|
|
|
'<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">Remove</span></a>'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
|
|
|
"placeholder": "Search By Role Name",
|
|
|
|
|
|
|
|
"searchKey" : "filter"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
loadPaginatedObjects("#role-grid", "#ast-container", "#role-listing", serviceURL, callback);
|
|
|
|
$('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
|
|
|
|
|
|
|
|
|
|
|
|
loadingContent.hide();
|
|
|
|
loadingContent.hide();
|
|
|
|
var sortableElem = '.wr-sortable';
|
|
|
|
|
|
|
|
$(sortableElem).sortable({
|
|
|
|
|
|
|
|
beforeStop: function () {
|
|
|
|
|
|
|
|
var sortedIDs = $(this).sortable('toArray');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$(sortableElem).disableSelection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var modalPopup = ".wr-modalpopup";
|
|
|
|
var modalPopup = ".wr-modalpopup";
|
|
|
@ -153,7 +181,7 @@ function hidePopup() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("#role-grid").on("click", ".remove-role-link", function () {
|
|
|
|
$("#role-grid").on("click", ".remove-role-link", function () {
|
|
|
|
var role = $(this).data("role");
|
|
|
|
var role = $(this).data("role");
|
|
|
|
var removeRoleAPI = "/devicemgt_admin/roles?rolename=" + role;
|
|
|
|
var removeRoleAPI = apiBasePath + "/roles/" + role;
|
|
|
|
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#remove-role-modal-content').html());
|
|
|
|
$(modalPopupContent).html($('#remove-role-modal-content').html());
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
|