mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 17:07:33 -02:30
Merge pull request #1711 from jlmitch5/relatedUsersTeams
Fixed related lists for users and teams edit
This commit is contained in:
@@ -716,6 +716,66 @@ var tower = angular.module('Tower', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$rootScope.deletePermissionFromUser = function (userId, userName, roleName, roleType, url) {
|
||||||
|
var action = function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({"disassociate": true, "id": userId})
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
$rootScope.$broadcast("refreshList", "permission");
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Could not disassociate user from role. Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: `Remove role`,
|
||||||
|
body: `
|
||||||
|
<div class="Prompt-bodyQuery">
|
||||||
|
Confirm the removal of the ${roleType}
|
||||||
|
<span class="Prompt-emphasis"> ${roleName} </span>
|
||||||
|
role associated with ${userName}.
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
action: action,
|
||||||
|
actionText: 'REMOVE'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$rootScope.deletePermissionFromTeam = function (teamId, teamName, roleName, roleType, url) {
|
||||||
|
var action = function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post({"disassociate": true, "id": teamId})
|
||||||
|
.success(function () {
|
||||||
|
Wait('stop');
|
||||||
|
$rootScope.$broadcast("refreshList", "role");
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Could not disassociate team from role. Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: `Remove role`,
|
||||||
|
body: `
|
||||||
|
<div class="Prompt-bodyQuery">
|
||||||
|
Confirm the removal of the ${roleType}
|
||||||
|
<span class="Prompt-emphasis"> ${roleName} </span>
|
||||||
|
role associated with the ${teamName} team.
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
action: action,
|
||||||
|
actionText: 'REMOVE'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function activateTab() {
|
function activateTab() {
|
||||||
// Make the correct tab active
|
// Make the correct tab active
|
||||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
|
|||||||
@@ -199,7 +199,8 @@ export function TeamsEdit($scope, $rootScope, $location,
|
|||||||
generator = GenerateForm,
|
generator = GenerateForm,
|
||||||
form = TeamForm,
|
form = TeamForm,
|
||||||
id = $stateParams.team_id,
|
id = $stateParams.team_id,
|
||||||
relatedSets = {};
|
relatedSets = {},
|
||||||
|
set;
|
||||||
|
|
||||||
$scope.team_id = id;
|
$scope.team_id = id;
|
||||||
|
|
||||||
@@ -263,6 +264,12 @@ export function TeamsEdit($scope, $rootScope, $location,
|
|||||||
relatedSets: relatedSets
|
relatedSets: relatedSets
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (set in relatedSets) {
|
||||||
|
$scope.search(relatedSets[set].iterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.team_obj = data;
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
url: GetBasePath('organizations'),
|
url: GetBasePath('organizations'),
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
@@ -298,6 +305,14 @@ export function TeamsEdit($scope, $rootScope, $location,
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
$scope.convertApiUrl = function(str) {
|
||||||
|
if (str) {
|
||||||
|
return str.replace("api/v1", "#");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* Related Set implementation TDB */
|
/* Related Set implementation TDB */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,8 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
form = UserForm,
|
form = UserForm,
|
||||||
master = {},
|
master = {},
|
||||||
id = $stateParams.user_id,
|
id = $stateParams.user_id,
|
||||||
relatedSets = {};
|
relatedSets = {},
|
||||||
|
set;
|
||||||
|
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
@@ -248,17 +249,25 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.convertApiUrl = function(str) {
|
||||||
|
if (str) {
|
||||||
|
return str.replace("api/v1", "#");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var setScopeRelated = function(data, related){
|
var setScopeRelated = function(data, related){
|
||||||
_(related)
|
_(related)
|
||||||
.pick(function(value, key){
|
.pick(function(value, key){
|
||||||
return data.related.hasOwnProperty(key) === true;
|
return data.related.hasOwnProperty(key) === true;
|
||||||
})
|
})
|
||||||
.forEach(function(value, key){
|
.forEach(function(value, key){
|
||||||
relatedSets[key] = {
|
relatedSets[key] = {
|
||||||
url: data.related[key],
|
url: data.related[key],
|
||||||
iterator: value.iterator
|
iterator: value.iterator
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.value();
|
.value();
|
||||||
};
|
};
|
||||||
// prepares a data payload for a PUT request to the API
|
// prepares a data payload for a PUT request to the API
|
||||||
@@ -295,6 +304,11 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
scope: $scope,
|
scope: $scope,
|
||||||
relatedSets: relatedSets
|
relatedSets: relatedSets
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (set in relatedSets) {
|
||||||
|
$scope.search(relatedSets[set].iterator);
|
||||||
|
}
|
||||||
|
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@
|
|||||||
description: $scope.description,
|
description: $scope.description,
|
||||||
enabled: $scope.host.enabled
|
enabled: $scope.host.enabled
|
||||||
};
|
};
|
||||||
DashboardHostService.putHost(host).then(function(res){
|
DashboardHostService.putHost(host).then(function(){
|
||||||
$state.go('^', null, {reload: true});
|
$state.go('^', null, {reload: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
var init = function(){
|
var init = function(){
|
||||||
$scope.host = host;
|
$scope.host = host;
|
||||||
@@ -38,13 +38,13 @@
|
|||||||
generator.inject(form, {mode: 'edit', related: false, scope: $scope});
|
generator.inject(form, {mode: 'edit', related: false, scope: $scope});
|
||||||
$scope.extraVars = $scope.host.variables === '' ? '---' : $scope.host.variables;
|
$scope.extraVars = $scope.host.variables === '' ? '---' : $scope.host.variables;
|
||||||
$scope.name = host.name;
|
$scope.name = host.name;
|
||||||
$scope.description = host.description;
|
$scope.description = host.description;
|
||||||
ParseTypeChange({
|
ParseTypeChange({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
field_id: 'host_variables',
|
field_id: 'host_variables',
|
||||||
variable: 'extraVars',
|
variable: 'extraVars',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -5,9 +5,17 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$scope', '$state', '$stateParams', 'PageRangeSetup', 'GetBasePath', 'DashboardHostsList',
|
['$scope', '$state', '$stateParams', 'PageRangeSetup', 'GetBasePath', 'DashboardHostsList',
|
||||||
'generateList', 'PaginateInit', 'SetStatus', 'DashboardHostService', 'hosts',
|
'generateList', 'PaginateInit', 'SetStatus', 'DashboardHostService', 'hosts',
|
||||||
function($scope, $state, $stateParams, PageRangeSetup, GetBasePath, DashboardHostsList, GenerateList, PaginateInit, SetStatus, DashboardHostService, hosts){
|
function($scope, $state, $stateParams, PageRangeSetup, GetBasePath, DashboardHostsList, GenerateList, PaginateInit, SetStatus, DashboardHostService, hosts){
|
||||||
|
var setJobStatus = function(){
|
||||||
|
_.forEach($scope.hosts, function(value){
|
||||||
|
SetStatus({
|
||||||
|
scope: $scope,
|
||||||
|
host: value
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
var generator = GenerateList,
|
var generator = GenerateList,
|
||||||
list = DashboardHostsList,
|
list = DashboardHostsList,
|
||||||
defaultUrl = GetBasePath('hosts');
|
defaultUrl = GetBasePath('hosts');
|
||||||
@@ -23,21 +31,13 @@ export default
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.$on('PostRefresh', function(){
|
$scope.$on('PostRefresh', function(){
|
||||||
$scope.hosts = _.map($scope.hosts, function(value, key){
|
$scope.hosts = _.map($scope.hosts, function(value){
|
||||||
value.inventory_name = value.summary_fields.inventory.name;
|
value.inventory_name = value.summary_fields.inventory.name;
|
||||||
value.inventory_id = value.summary_fields.inventory.id;
|
value.inventory_id = value.summary_fields.inventory.id;
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
setJobStatus();
|
setJobStatus();
|
||||||
});
|
});
|
||||||
var setJobStatus = function(){
|
|
||||||
_.forEach($scope.hosts, function(value, key){
|
|
||||||
SetStatus({
|
|
||||||
scope: $scope,
|
|
||||||
host: value
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var init = function(){
|
var init = function(){
|
||||||
$scope.list = list;
|
$scope.list = list;
|
||||||
$scope.host_active_search = false;
|
$scope.host_active_search = false;
|
||||||
@@ -61,4 +61,4 @@ export default
|
|||||||
$scope.hostLoading = false;
|
$scope.hostLoading = false;
|
||||||
};
|
};
|
||||||
init();
|
init();
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default function(){
|
|||||||
"YAML:<br />\n" +
|
"YAML:<br />\n" +
|
||||||
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
"<blockquote>---<br />somevar: somevalue<br />password: magic<br /></blockquote>\n" +
|
||||||
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
'<p>View JSON examples at <a href="http://www.json.org" target="_blank">www.json.org</a></p>' +
|
||||||
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
'<p>View YAML examples at <a href="http://docs.ansible.com/YAMLSyntax.html" target="_blank">docs.ansible.com</a></p>',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
@@ -74,4 +74,4 @@ export default function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -89,5 +89,5 @@ export default function(){
|
|||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ var dashboardHostsList = {
|
|||||||
var defaultUrl = GetBasePath('hosts') + '?page_size=10';
|
var defaultUrl = GetBasePath('hosts') + '?page_size=10';
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
return Rest.get().then(function(res){
|
return Rest.get().then(function(res){
|
||||||
var results = _.map(res.data.results, function(value, key){
|
var results = _.map(res.data.results, function(value){
|
||||||
value.inventory_name = value.summary_fields.inventory.name;
|
value.inventory_name = value.summary_fields.inventory.name;
|
||||||
value.inventory_id = value.summary_fields.inventory.id;
|
value.inventory_id = value.summary_fields.inventory.id;
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
res.data.results = results;
|
res.data.results = results;
|
||||||
return res.data
|
return res.data;
|
||||||
});
|
});
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
@@ -61,4 +61,4 @@ var dashboardHostsEdit = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export {dashboardHostsList, dashboardHostsEdit};
|
export {dashboardHostsList, dashboardHostsEdit};
|
||||||
|
|||||||
@@ -59,11 +59,10 @@ export default
|
|||||||
},
|
},
|
||||||
|
|
||||||
related: {
|
related: {
|
||||||
/*
|
access_list: {
|
||||||
permissions: {
|
|
||||||
basePath: 'teams/:id/access_list/',
|
basePath: 'teams/:id/access_list/',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
title: 'Permissions',
|
title: 'Users',
|
||||||
iterator: 'permission',
|
iterator: 'permission',
|
||||||
index: false,
|
index: false,
|
||||||
open: false,
|
open: false,
|
||||||
@@ -76,148 +75,59 @@ export default
|
|||||||
actionClass: 'btn List-buttonSubmit',
|
actionClass: 'btn List-buttonSubmit',
|
||||||
buttonContent: '+ ADD'
|
buttonContent: '+ ADD'
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
credentials: {
|
|
||||||
type: 'collection',
|
|
||||||
title: 'Credentials',
|
|
||||||
iterator: 'credential',
|
|
||||||
open: false,
|
|
||||||
index: false,
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: "add('credentials')",
|
|
||||||
label: 'Add',
|
|
||||||
add: 'Add a new credential',
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: '+ ADD'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
name: {
|
|
||||||
key: true,
|
|
||||||
label: 'Name'
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'Description'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fieldActions: {
|
|
||||||
edit: {
|
|
||||||
label: 'Edit',
|
|
||||||
ngClick: "edit('credentials', credential.id, credential.name)",
|
|
||||||
icon: 'icon-edit',
|
|
||||||
awToolTip: 'Modify the credential',
|
|
||||||
'class': 'btn btn-default'
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
label: 'Delete',
|
|
||||||
ngClick: "delete('credentials', credential.id, credential.name, 'credential')",
|
|
||||||
icon: 'icon-trash',
|
|
||||||
"class": 'btn-danger',
|
|
||||||
awToolTip: 'Remove the credential'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
projects: {
|
|
||||||
type: 'collection',
|
|
||||||
title: 'Projects',
|
|
||||||
iterator: 'project',
|
|
||||||
open: false,
|
|
||||||
index: false,
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: "add('projects')",
|
|
||||||
label: 'Add',
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: '+ ADD'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
name: {
|
|
||||||
key: true,
|
|
||||||
label: 'Name'
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'Description'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fieldActions: {
|
|
||||||
edit: {
|
|
||||||
label: 'Edit',
|
|
||||||
ngClick: "edit('projects', project.id, project.name)",
|
|
||||||
icon: 'icon-edit',
|
|
||||||
awToolTip: 'Modify the project',
|
|
||||||
'class': 'btn btn-default'
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
label: 'Delete',
|
|
||||||
ngClick: "delete('projects', project.id, project.name, 'project')",
|
|
||||||
icon: 'icon-trash',
|
|
||||||
"class": 'btn-danger',
|
|
||||||
awToolTip: 'Remove the project'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
users: {
|
|
||||||
type: 'collection',
|
|
||||||
title: 'Users',
|
|
||||||
iterator: 'user',
|
|
||||||
open: false,
|
|
||||||
index: false,
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: "add('users')",
|
|
||||||
label: 'Add',
|
|
||||||
awToolTip: 'Add a user',
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: '+ ADD'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
username: {
|
username: {
|
||||||
key: true,
|
key: true,
|
||||||
label: 'Username'
|
label: 'User',
|
||||||
|
linkBase: 'users',
|
||||||
|
class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4'
|
||||||
},
|
},
|
||||||
first_name: {
|
role: {
|
||||||
label: 'First Name'
|
label: 'Role',
|
||||||
},
|
type: 'role',
|
||||||
last_name: {
|
noSort: true,
|
||||||
label: 'Last Name'
|
class: 'col-lg-9 col-md-9 col-sm-9 col-xs-8'
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fieldActions: {
|
|
||||||
edit: {
|
|
||||||
label: 'Edit',
|
|
||||||
ngClick: "edit('users', user.id, user.username)",
|
|
||||||
icon: 'icon-edit',
|
|
||||||
awToolTip: 'Edit user',
|
|
||||||
'class': 'btn btn-default'
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
label: 'Delete',
|
|
||||||
ngClick: "delete('users', user.id, user.username, 'user')",
|
|
||||||
icon: 'icon-terash',
|
|
||||||
"class": 'btn-danger',
|
|
||||||
awToolTip: 'Remove user'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
roles: {
|
||||||
|
type: 'collection',
|
||||||
|
title: 'Permissions',
|
||||||
|
iterator: 'role',
|
||||||
|
open: false,
|
||||||
|
index: false,
|
||||||
|
actions: {},
|
||||||
|
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
label: 'Name',
|
||||||
|
ngBind: 'role.summary_fields.resource_name',
|
||||||
|
linkTo: '{{convertApiUrl(role.related[role.summary_fields.resource_type])}}',
|
||||||
|
noSort: true
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
label: 'Type',
|
||||||
|
ngBind: 'role.summary_fields.resource_type_display_name',
|
||||||
|
noSort: true
|
||||||
|
},
|
||||||
|
role: {
|
||||||
|
label: 'Role',
|
||||||
|
ngBind: 'role.name',
|
||||||
|
noSort: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fieldActions: {
|
||||||
|
"delete": {
|
||||||
|
label: 'Remove',
|
||||||
|
ngClick: 'deletePermissionFromTeam(team_id, team_obj.name, role.name, role.summary_fields.resource_name, role.related.teams)',
|
||||||
|
class: "List-actionButton--delete",
|
||||||
|
iconClass: 'fa fa-times',
|
||||||
|
awToolTip: 'Dissasociate permission from team'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hideOnSuperuser: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
|
||||||
|
|
||||||
}); //InventoryForm
|
}); //InventoryForm
|
||||||
|
|||||||
@@ -115,71 +115,6 @@ export default
|
|||||||
},
|
},
|
||||||
|
|
||||||
related: {
|
related: {
|
||||||
/*
|
|
||||||
permissions: {
|
|
||||||
basePath: 'teams/:id/access_list/',
|
|
||||||
type: 'collection',
|
|
||||||
title: 'Permissions',
|
|
||||||
iterator: 'permission',
|
|
||||||
index: false,
|
|
||||||
open: false,
|
|
||||||
searchType: 'select',
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: "addPermission",
|
|
||||||
label: 'Add',
|
|
||||||
awToolTip: 'Add a permission',
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: '+ ADD'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
*/
|
|
||||||
|
|
||||||
credentials: {
|
|
||||||
type: 'collection',
|
|
||||||
title: 'Credentials',
|
|
||||||
iterator: 'credential',
|
|
||||||
open: false,
|
|
||||||
index: false,
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: "add('credentials')",
|
|
||||||
label: 'Add',
|
|
||||||
awToolTip: 'Add a credential for this user',
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: '+ ADD'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fields: {
|
|
||||||
name: {
|
|
||||||
key: true,
|
|
||||||
label: 'Name'
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'Description'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fieldActions: {
|
|
||||||
edit: {
|
|
||||||
label: 'Edit',
|
|
||||||
ngClick: "edit('credentials', credential.id, credential.name)",
|
|
||||||
icon: 'icon-edit',
|
|
||||||
awToolTip: 'Edit the credential',
|
|
||||||
'class': 'btn btn-default'
|
|
||||||
},
|
|
||||||
"delete": {
|
|
||||||
label: 'Delete',
|
|
||||||
ngClick: "delete('credentials', credential.id, credential.name, 'credential')",
|
|
||||||
icon: 'icon-trash',
|
|
||||||
"class": 'btn-danger',
|
|
||||||
awToolTip: 'Delete the credential'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
organizations: {
|
organizations: {
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
title: 'Organizations',
|
title: 'Organizations',
|
||||||
@@ -197,9 +132,9 @@ export default
|
|||||||
description: {
|
description: {
|
||||||
label: 'Description'
|
label: 'Description'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
hideOnSuperuser: true
|
||||||
},
|
},
|
||||||
|
|
||||||
teams: {
|
teams: {
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
title: 'Teams',
|
title: 'Teams',
|
||||||
@@ -217,8 +152,44 @@ export default
|
|||||||
description: {
|
description: {
|
||||||
label: 'Description'
|
label: 'Description'
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
hideOnSuperuser: true
|
||||||
|
},
|
||||||
|
roles: {
|
||||||
|
hideSearchAndActions: true,
|
||||||
|
type: 'collection',
|
||||||
|
title: 'Permissions',
|
||||||
|
iterator: 'permission',
|
||||||
|
open: false,
|
||||||
|
index: false,
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
label: 'Name',
|
||||||
|
ngBind: 'permission.summary_fields.resource_name',
|
||||||
|
linkTo: '{{convertApiUrl(permission.related[permission.summary_fields.resource_type])}}',
|
||||||
|
noSort: true
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
label: 'Type',
|
||||||
|
ngBind: 'permission.summary_fields.resource_type_display_name',
|
||||||
|
noSort: true
|
||||||
|
},
|
||||||
|
role: {
|
||||||
|
label: 'Role',
|
||||||
|
ngBind: 'permission.name',
|
||||||
|
noSort: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fieldActions: {
|
||||||
|
"delete": {
|
||||||
|
label: 'Remove',
|
||||||
|
ngClick: 'deletePermissionFromUser(user_id, username, permission.name, permission.summary_fields.resource_name, permission.related.users)',
|
||||||
|
iconClass: 'fa fa-times',
|
||||||
|
awToolTip: 'Dissasociate permission from user'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hideOnSuperuser: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}); //UserForm
|
});
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export default ['GetBasePath', function(GetBasePath) {
|
|||||||
delete f[i].ngClass;
|
delete f[i].ngClass;
|
||||||
delete f[i].ngClick;
|
delete f[i].ngClick;
|
||||||
delete f[i].icon;
|
delete f[i].icon;
|
||||||
|
delete f[i].linkTo;
|
||||||
return {[i]: f[i]};
|
return {[i]: f[i]};
|
||||||
}).reduce(function (acc, i) {
|
}).reduce(function (acc, i) {
|
||||||
var key = Object.keys(i);
|
var key = Object.keys(i);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu
|
|||||||
obj.value = value;
|
obj.value = value;
|
||||||
obj.label = label;
|
obj.label = label;
|
||||||
obj.type = type;
|
obj.type = type;
|
||||||
obj.basePath = field['basePath'] || null;
|
obj.basePath = field.basePath || null;
|
||||||
|
|
||||||
// return the built option
|
// return the built option
|
||||||
if (type === 'select') {
|
if (type === 'select') {
|
||||||
@@ -81,7 +81,7 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu
|
|||||||
Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath);
|
Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath);
|
||||||
Rest.options()
|
Rest.options()
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
try {
|
try {
|
||||||
var options = data.actions.GET;
|
var options = data.actions.GET;
|
||||||
needsRequest = needsRequest
|
needsRequest = needsRequest
|
||||||
.map(function (option) {
|
.map(function (option) {
|
||||||
|
|||||||
@@ -1462,7 +1462,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += (options.mode === 'edit') ? this.form.editTitle : this.form.addTitle;
|
html += (options.mode === 'edit') ? this.form.editTitle : this.form.addTitle;
|
||||||
if(this.form.name === "user"){
|
if(this.form.name === "user"){
|
||||||
html+= "<span class=\"Form-title--is_superuser\" "+
|
html+= "<span class=\"Form-title--is_superuser\" "+
|
||||||
"ng-if=is_superuser>Admin</span>";
|
"ng-if=is_superuser>System Administrator</span>";
|
||||||
}
|
}
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
html += "<div class=\"Form-header--fields\">";
|
html += "<div class=\"Form-header--fields\">";
|
||||||
@@ -1781,14 +1781,16 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
});
|
});
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<div class=\"row\">
|
<div class=\"row\"
|
||||||
|
ng-show=\"${collection.hideSearchAndActions ? true : false}\">
|
||||||
<div class=\"col-lg-8\"
|
<div class=\"col-lg-8\"
|
||||||
ng-show=\"${collection.iterator}Loading == true ||
|
ng-show=\"${collection.iterator}Loading == true ||
|
||||||
${collection.iterator}_active_search == true || (
|
${collection.iterator}_active_search == true || (
|
||||||
${collection.iterator}Loading == false &&
|
${collection.iterator}Loading == false &&
|
||||||
${collection.iterator}_active_search == false &&
|
${collection.iterator}_active_search == false &&
|
||||||
${collection.iterator}_total_rows > 0
|
${collection.iterator}_total_rows > 0)\"
|
||||||
)\">
|
ng-hide=\"is_superuser && ${collection.hideOnSuperuser}\"
|
||||||
|
>
|
||||||
${tagSearch}
|
${tagSearch}
|
||||||
</div>
|
</div>
|
||||||
<div class=\"col-lg-4\">
|
<div class=\"col-lg-4\">
|
||||||
@@ -1800,18 +1802,39 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Message for when a search returns no results. This should only get shown after a search is executed with no results.
|
// Message for when a search returns no results. This should only get shown after a search is executed with no results.
|
||||||
html += "<div class=\"row\" ng-show=\"" + collection.iterator + "Loading == false && " + collection.iterator + "_active_search == true && " + itm + ".length == 0\">\n";
|
var hideOnSuperuser = (hideOnSuperuser === true) ? true : false;
|
||||||
html += "<div class=\"col-lg-12 List-searchNoResults\">No records matched your search.</div>\n";
|
html += `
|
||||||
html += "</div>\n";
|
<div
|
||||||
|
class=\"row\"
|
||||||
|
ng-show=\" ${collection.iterator}Loading == false &&
|
||||||
|
${collection.iterator}_active_search == true &&
|
||||||
|
${itm}.length == 0 &&
|
||||||
|
!(is_superuser && ${collection.hideOnSuperuser})\">
|
||||||
|
<div class=\"col-lg-12 List-searchNoResults\">
|
||||||
|
No records matched your search.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
// Show the "no items" box when loading is done and the user isn't actively searching and there are no results
|
// Show the "no items" box when loading is done and the user isn't actively searching and there are no results
|
||||||
html += "<div class=\"List-noItems\" ng-show=\"" + collection.iterator + "Loading == false && " + collection.iterator + "_active_search == false && " + collection.iterator + "_total_rows < 1\">PLEASE ADD ITEMS TO THIS LIST</div>";
|
html += "<div class=\"List-noItems\" ng-show=\"" + collection.iterator + "Loading == false && " + collection.iterator + "_active_search == false && " + collection.iterator + "_total_rows < 1\">PLEASE ADD ITEMS TO THIS LIST</div>";
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<div class=\"List-noItems\" ng-show=\"is_superuser\">
|
||||||
|
System Administrators have access to all ${collection.iterator}s
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
// Start the list
|
// Start the list
|
||||||
html += "<div class=\"list-wrapper\" ng-show=\"" + collection.iterator + "Loading == true || (" + collection.iterator + "Loading == false && " + itm + ".length > 0)\">\n";
|
html += `
|
||||||
html += "<table id=\"" + itm + "_table" + "\" class=\"" + collection.iterator + " List-table\">\n";
|
<div class=\"list-wrapper\"
|
||||||
html += "<thead>\n";
|
ng-show=\"(${collection.iterator}Loading == true ||
|
||||||
html += "<tr class=\"List-tableHeaderRow\">\n";
|
(${collection.iterator}Loading == false && ${itm}.length > 0)) &&
|
||||||
|
!(is_superuser && ${collection.hideOnSuperuser})\">
|
||||||
|
<table id=\"${itm}_table\" class=\"${collection.iterator} List-table\">
|
||||||
|
<thead>
|
||||||
|
<tr class=\"List-tableHeaderRow\">
|
||||||
|
`;
|
||||||
html += (collection.index === undefined || collection.index !== false) ? "<th class=\"col-xs-1\">#</th>\n" : "";
|
html += (collection.index === undefined || collection.index !== false) ? "<th class=\"col-xs-1\">#</th>\n" : "";
|
||||||
for (fld in collection.fields) {
|
for (fld in collection.fields) {
|
||||||
html += "<th class=\"List-tableHeader list-header ";
|
html += "<th class=\"List-tableHeader list-header ";
|
||||||
@@ -1918,7 +1941,8 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += PaginateWidget({
|
html += PaginateWidget({
|
||||||
set: itm,
|
set: itm,
|
||||||
iterator: collection.iterator,
|
iterator: collection.iterator,
|
||||||
mini: true
|
mini: true,
|
||||||
|
hideOnSuperuser: collection.hideOnSuperuser
|
||||||
});
|
});
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -772,9 +772,13 @@ angular.module('GeneratorHelpers', [systemStatus.name])
|
|||||||
return function (params) {
|
return function (params) {
|
||||||
var iterator = params.iterator,
|
var iterator = params.iterator,
|
||||||
set = params.set,
|
set = params.set,
|
||||||
|
hideOnSuperuser = (params.hideOnSuperuser) ? true : false,
|
||||||
html = '';
|
html = '';
|
||||||
html += "<!-- Paginate Widget -->\n";
|
html += "<!-- Paginate Widget -->\n";
|
||||||
html += "<div id=\"" + iterator + "-pagination\" class=\"List-pagination page-row\">\n";
|
html += `
|
||||||
|
<div id=\"${iterator}-pagination\" class=\"List-pagination page-row\"
|
||||||
|
ng-hide=\"is_superuser && ${hideOnSuperuser}\">
|
||||||
|
`;
|
||||||
html += "<div class=\"List-paginationPagerHolder\">";
|
html += "<div class=\"List-paginationPagerHolder\">";
|
||||||
html += "<div class=\"List-paginationPager\" ng-hide=\"" + iterator + "HidePaginator || " + iterator + "_num_pages <= 1\">";
|
html += "<div class=\"List-paginationPager\" ng-hide=\"" + iterator + "HidePaginator || " + iterator + "_num_pages <= 1\">";
|
||||||
html += "<ul id=\"pagination-links\" class=\"pagination\">\n";
|
html += "<ul id=\"pagination-links\" class=\"pagination\">\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user