mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
revamp services for pulling in the search options
This commit is contained in:
@@ -176,7 +176,7 @@ TeamsAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
|||||||
|
|
||||||
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
|
export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
|
LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, LookUpInit, Prompt, GetBasePath, CheckAccess,
|
||||||
OrganizationList, Wait, Stream, permissionsLabel) {
|
OrganizationList, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -188,12 +188,22 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
id = $routeParams.team_id,
|
id = $routeParams.team_id,
|
||||||
relatedSets = {};
|
relatedSets = {};
|
||||||
|
|
||||||
$scope.permission_label = {};
|
$scope.permission_label = {};
|
||||||
|
$scope.permission_search_select = [];
|
||||||
|
|
||||||
permissionsLabel({
|
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||||
|
var permissionsChoice = permissionsChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
}).then(function(choices) {
|
});
|
||||||
|
|
||||||
|
// manipulate the choices from the options request to be set on
|
||||||
|
// scope and be usable by the list form
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
choices =
|
||||||
|
permissionsLabel({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
_.map(choices, function(n, key) {
|
_.map(choices, function(n, key) {
|
||||||
$scope.permission_label[key] = n;
|
$scope.permission_label[key] = n;
|
||||||
});
|
});
|
||||||
@@ -201,8 +211,17 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
$scope.team_id = id;
|
$scope.team_id = id;
|
||||||
|
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
// manipulate the choices from the options request to be usable
|
||||||
generator.reset();
|
// by the search option for permission_type, you can't inject the
|
||||||
|
// list until this is done!
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
form.related.permissions.fields.permission_type.searchOptions =
|
||||||
|
permissionsSearchSelect({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
|
generator.reset();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.PermissionAddAllowed = false;
|
$scope.PermissionAddAllowed = false;
|
||||||
|
|
||||||
@@ -412,5 +431,5 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
TeamsEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit',
|
||||||
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsLabel'
|
'ReturnToCaller', 'ClearScope', 'LookUpInit', 'Prompt', 'GetBasePath', 'CheckAccess', 'OrganizationList', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$r
|
|||||||
|
|
||||||
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
|
export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm, GenerateForm, Rest, Alert,
|
||||||
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
|
ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, GetBasePath,
|
||||||
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsLabel) {
|
Prompt, CheckAccess, ResetForm, Wait, Stream, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -221,11 +221,21 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
relatedSets = {};
|
relatedSets = {};
|
||||||
|
|
||||||
$scope.permission_label = {};
|
$scope.permission_label = {};
|
||||||
|
$scope.permission_search_select = [];
|
||||||
|
|
||||||
permissionsLabel({
|
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||||
|
var permissionsChoice = permissionsChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
}).then(function(choices) {
|
});
|
||||||
|
|
||||||
|
// manipulate the choices from the options request to be set on
|
||||||
|
// scope and be usable by the list form
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
choices =
|
||||||
|
permissionsLabel({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
_.map(choices, function(n, key) {
|
_.map(choices, function(n, key) {
|
||||||
$scope.permission_label[key] = n;
|
$scope.permission_label[key] = n;
|
||||||
});
|
});
|
||||||
@@ -235,9 +245,17 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
$scope.removeFormReady();
|
$scope.removeFormReady();
|
||||||
}
|
}
|
||||||
$scope.removeFormReady = $scope.$on('formReady', function () {
|
$scope.removeFormReady = $scope.$on('formReady', function () {
|
||||||
|
// manipulate the choices from the options request to be usable
|
||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
// by the search option for permission_type, you can't inject the
|
||||||
generator.reset();
|
// list until this is done!
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
form.related.permissions.fields.permission_type.searchOptions =
|
||||||
|
permissionsSearchSelect({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
|
generator.reset();
|
||||||
|
});
|
||||||
|
|
||||||
if ($scope.removePostRefresh) {
|
if ($scope.removePostRefresh) {
|
||||||
$scope.removePostRefresh();
|
$scope.removePostRefresh();
|
||||||
@@ -501,5 +519,5 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log, $routeP
|
|||||||
|
|
||||||
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
UsersEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||||
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsLabel'
|
'GetBasePath', 'Prompt', 'CheckAccess', 'ResetForm', 'Wait', 'Stream', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -158,16 +158,7 @@ export default
|
|||||||
permission_type: {
|
permission_type: {
|
||||||
label: 'Permission',
|
label: 'Permission',
|
||||||
ngBind: 'getPermissionText()',
|
ngBind: 'getPermissionText()',
|
||||||
searchType: 'select',
|
searchType: 'select'
|
||||||
searchOptions: [
|
|
||||||
{ name: "Read Inventory", value: "read" },
|
|
||||||
{ name: "Edit Inventory", value: "write" },
|
|
||||||
{ name: "Administrate Inventory", value: "admin" },
|
|
||||||
{ name: "Deploy to Inventory", value: "run" },
|
|
||||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
|
||||||
{ name: "Scan an Inventory", value: "scan" },
|
|
||||||
{ name: "Create a Job Template", value: "create" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -213,16 +213,7 @@ export default
|
|||||||
permission_type: {
|
permission_type: {
|
||||||
label: 'Permission',
|
label: 'Permission',
|
||||||
ngBind: 'getPermissionText()',
|
ngBind: 'getPermissionText()',
|
||||||
searchType: 'select',
|
searchType: 'select'
|
||||||
searchOptions: [
|
|
||||||
{ name: "Read Inventory", value: "read" },
|
|
||||||
{ name: "Edit Inventory", value: "write" },
|
|
||||||
{ name: "Administrate Inventory", value: "admin" },
|
|
||||||
{ name: "Deploy to Inventory", value: "run" },
|
|
||||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
|
||||||
{ name: "Scan an Inventory", value: "scan" },
|
|
||||||
{ name: "Create a Job Template", value: "create" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
* @description This controller for permissions add
|
* @description This controller for permissions add
|
||||||
*/
|
*/
|
||||||
export default
|
export default
|
||||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel',
|
||||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, ReturnToCaller, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -22,10 +22,16 @@ export default
|
|||||||
base = $location.path().replace(/^\//, '').split('/')[0],
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
master = {};
|
master = {};
|
||||||
|
|
||||||
permissionsLabel({
|
var permissionsChoice = permissionsChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
url: 'api/v1/' + base + '/' + id + '/permissions/'
|
||||||
}).then(function(choices) {
|
});
|
||||||
|
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
return permissionsLabel({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
|
}).then(function (choices) {
|
||||||
_.map(choices, function(n, key) {
|
_.map(choices, function(n, key) {
|
||||||
$scope.permission_label[key] = n;
|
$scope.permission_label[key] = n;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
* @description This controller for permissions edit
|
* @description This controller for permissions edit
|
||||||
*/
|
*/
|
||||||
export default
|
export default
|
||||||
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsLabel',
|
['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'permissionsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'Prompt', 'GetBasePath', 'InventoryList', 'ProjectList', 'LookUpInit', 'CheckAccess', 'Wait', 'permissionsCategoryChange', 'permissionsChoices', 'permissionsLabel',
|
||||||
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsLabel) {
|
function($scope, $rootScope, $compile, $location, $log, $routeParams, permissionsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, Prompt, GetBasePath, InventoryList, ProjectList, LookUpInit, CheckAccess, Wait, permissionsCategoryChange, permissionsChoices, permissionsLabel) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -25,10 +25,16 @@ export default
|
|||||||
|
|
||||||
$scope.permission_label = {};
|
$scope.permission_label = {};
|
||||||
|
|
||||||
permissionsLabel({
|
var permissionsChoice = permissionsChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||||
}).then(function(choices) {
|
});
|
||||||
|
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
return permissionsLabel({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
|
}).then(function (choices) {
|
||||||
_.map(choices, function(n, key) {
|
_.map(choices, function(n, key) {
|
||||||
$scope.permission_label[key] = n;
|
$scope.permission_label[key] = n;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsLabel',
|
['$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'permissionsList', 'generateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'CheckAccess', 'Wait', 'permissionsChoices', 'permissionsLabel', 'permissionsSearchSelect',
|
||||||
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsLabel) {
|
function ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, permissionsList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, CheckAccess, Wait, permissionsChoices, permissionsLabel, permissionsSearchSelect) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -24,17 +24,37 @@ export default
|
|||||||
generator = GenerateList;
|
generator = GenerateList;
|
||||||
|
|
||||||
$scope.permission_label = {};
|
$scope.permission_label = {};
|
||||||
|
$scope.permission_search_select = [];
|
||||||
|
|
||||||
permissionsLabel({
|
// return a promise from the options request with the permission type choices (including adhoc) as a param
|
||||||
|
var permissionsChoice = permissionsChoices({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
url: 'api/v1/' + base + '/' + base_id + '/permissions/'
|
||||||
}).then(function(choices) {
|
});
|
||||||
|
|
||||||
|
// manipulate the choices from the options request to be set on
|
||||||
|
// scope and be usable by the list form
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
choices =
|
||||||
|
permissionsLabel({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
_.map(choices, function(n, key) {
|
_.map(choices, function(n, key) {
|
||||||
$scope.permission_label[key] = n;
|
$scope.permission_label[key] = n;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
generator.inject(list, { mode: 'edit', scope: $scope, breadCrumbs: true });
|
// manipulate the choices from the options request to be usable
|
||||||
|
// by the search option for permission_type, you can't inject the
|
||||||
|
// list until this is done!
|
||||||
|
permissionsChoice.then(function (choices) {
|
||||||
|
list.fields.permission_type.searchOptions =
|
||||||
|
permissionsSearchSelect({
|
||||||
|
choices: choices
|
||||||
|
});
|
||||||
|
generator.inject(list, { mode: 'edit', scope: $scope, breadCrumbs: true });
|
||||||
|
});
|
||||||
|
|
||||||
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
defaultUrl += ($routeParams.user_id !== undefined) ? $routeParams.user_id : $routeParams.team_id;
|
||||||
defaultUrl += '/permissions/';
|
defaultUrl += '/permissions/';
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,13 @@
|
|||||||
return function (params) {
|
return function (params) {
|
||||||
// convert the choices from the API from the format
|
// convert the choices from the API from the format
|
||||||
// [["read", "Read Inventory"], ...] to
|
// [["read", "Read Inventory"], ...] to
|
||||||
// {name: "read", value: "Read Inventory", ...}
|
// [{name: "read", value: "Read Inventory"}, ...]
|
||||||
return params.choices.reduce(function(obj, kvp) {
|
return params.choices.filter(function (kvp) {
|
||||||
// for now, remove adhoc from those choices
|
return (kvp[0] !== "adhoc");
|
||||||
if (kvp[0] !== adhoc) {
|
}).map(function (kvp) {
|
||||||
return {name: kvp[0], value: kvp[1]};
|
if (kvp[0] !== "adhoc") {
|
||||||
} else {
|
return {name: kvp[1], value: kvp[0]};
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}, {});
|
});
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -38,16 +38,7 @@
|
|||||||
permission_type: {
|
permission_type: {
|
||||||
label: 'Permission',
|
label: 'Permission',
|
||||||
ngBind: 'getPermissionText()',
|
ngBind: 'getPermissionText()',
|
||||||
searchType: 'select',
|
searchType: 'select'
|
||||||
searchOptions: [
|
|
||||||
{ name: "Read Inventory", value: "read" },
|
|
||||||
{ name: "Edit Inventory", value: "write" },
|
|
||||||
{ name: "Administrate Inventory", value: "admin" },
|
|
||||||
{ name: "Deploy to Inventory", value: "run" },
|
|
||||||
{ name: "Deploy to Inventory (Dry Run)", value: "check" },
|
|
||||||
{ name: "Scan an Inventory", value: "scan" },
|
|
||||||
{ name: "Create a Job Template", value: "create" }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user