mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Merge pull request #518 from gconsidine/ui/fix/credential-kind-list-display
Use credential_type to fetch associated types in list view
This commit is contained in:
@@ -41,10 +41,7 @@ function LegacyCredentialsService (pathService) {
|
|||||||
|
|
||||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
credentialType: ['CredentialTypeModel', CredentialType => {
|
|
||||||
return new CredentialType('get');
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,21 +43,28 @@ function requestWithCache (method, resource) {
|
|||||||
* supported by the API.
|
* supported by the API.
|
||||||
*
|
*
|
||||||
* @arg {Object} params - An object of keys and values to to format and
|
* @arg {Object} params - An object of keys and values to to format and
|
||||||
* to the URL as a query string. Refer to the API documentation for the
|
* to the URL as a query string. Refer to the API documentation for the
|
||||||
* resource in use for specifics.
|
* resource in use for specifics.
|
||||||
* @arg {Object} config - Configuration specific to the UI to accommodate
|
* @arg {Object} config - Configuration specific to the UI to accommodate
|
||||||
* common use cases.
|
* common use cases.
|
||||||
*
|
*
|
||||||
* @yields {boolean} - Indicating a match has been found. If so, the results
|
* @yields {boolean} - Indicating a match has been found. If so, the results
|
||||||
* are set on the model.
|
* are set on the model.
|
||||||
*/
|
*/
|
||||||
function search (params, config) {
|
function search (params = {}, config = {}) {
|
||||||
let req = {
|
let req = {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: this.path,
|
url: this.path
|
||||||
params
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof params === 'string') {
|
||||||
|
req.url = `?params`;
|
||||||
|
} else if (Array.isArray(params)) {
|
||||||
|
req.url += `?${params.join('&')}`;
|
||||||
|
} else {
|
||||||
|
req.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
return $http(req)
|
return $http(req)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
if (!data.count) {
|
if (!data.count) {
|
||||||
|
|||||||
@@ -5,10 +5,13 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', 'GetBasePath',
|
export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', 'GetBasePath',
|
||||||
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'credentialType', 'i18n',
|
'Wait', '$state', '$filter', 'rbacUiControlService', 'Dataset', 'CredentialTypeModel',
|
||||||
|
'i18n',
|
||||||
function($scope, Rest, CredentialList, Prompt,
|
function($scope, Rest, CredentialList, Prompt,
|
||||||
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset,
|
ProcessErrors, GetBasePath, Wait, $state, $filter, rbacUiControlService, Dataset,
|
||||||
credentialType, i18n) {
|
CredentialType, i18n) {
|
||||||
|
|
||||||
|
const credentialType = new CredentialType();
|
||||||
|
|
||||||
var list = CredentialList,
|
var list = CredentialList,
|
||||||
defaultUrl = GetBasePath('credentials');
|
defaultUrl = GetBasePath('credentials');
|
||||||
@@ -45,9 +48,25 @@ export default ['$scope', 'Rest', 'CredentialList', 'Prompt', 'ProcessErrors', '
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope[list.name].forEach(credential => {
|
const params = $scope[list.name]
|
||||||
credential.kind = credentialType.match('id', credential.credential_type).name;
|
.reduce((accumulator, credential) => {
|
||||||
});
|
accumulator.push(credential.credential_type);
|
||||||
|
|
||||||
|
return accumulator;
|
||||||
|
}, [])
|
||||||
|
.filter((id, i, array) => array.indexOf(id) === i)
|
||||||
|
.map(id => `or__id=${id}`);
|
||||||
|
|
||||||
|
credentialType.search(params)
|
||||||
|
.then(found => {
|
||||||
|
if (!found) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope[list.name].forEach(credential => {
|
||||||
|
credential.kind = credentialType.match('id', credential.credential_type).name;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterate over the list and add fields like type label, after the
|
// iterate over the list and add fields like type label, after the
|
||||||
|
|||||||
Reference in New Issue
Block a user