mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
fixing options request for template list
This commit is contained in:
@@ -4,15 +4,16 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Alert',
|
export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
|
||||||
'TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath',
|
'Alert','TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors',
|
||||||
'InitiatePlaybookRun', 'Wait', '$state', '$filter', 'Dataset', 'rbacUiControlService', 'TemplatesService',
|
'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter',
|
||||||
'QuerySet', 'GetChoices', 'TemplateCopyService',
|
'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet',
|
||||||
|
'GetChoices', 'TemplateCopyService', 'DataOptions',
|
||||||
function(
|
function(
|
||||||
$scope, $rootScope, $location, $stateParams, Rest, Alert,
|
$scope, $rootScope, $location, $stateParams, Rest, Alert,
|
||||||
TemplateList, Prompt, ClearScope, ProcessErrors, GetBasePath,
|
TemplateList, Prompt, ClearScope, ProcessErrors, GetBasePath,
|
||||||
InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService,
|
InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService,
|
||||||
qs, GetChoices, TemplateCopyService
|
qs, GetChoices, TemplateCopyService, DataOptions
|
||||||
) {
|
) {
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -36,38 +37,31 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Al
|
|||||||
$scope.list = list;
|
$scope.list = list;
|
||||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
$scope.options = DataOptions;
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
if ($scope.removeChoicesReady) {
|
$scope.$watchCollection('templates', function() {
|
||||||
$scope.removeChoicesReady();
|
$scope[list.name].forEach(function(item, item_idx) {
|
||||||
}
|
var itm = $scope[list.name][item_idx];
|
||||||
$scope.removeChoicesReady = $scope.$on('choicesReady', function() {
|
|
||||||
$scope[list.name].forEach(function(item, item_idx) {
|
|
||||||
var itm = $scope[list.name][item_idx];
|
|
||||||
|
|
||||||
// Set the item type label
|
// Set the item type label
|
||||||
if (list.fields.type) {
|
if (list.fields.type) {
|
||||||
$scope.type_choices.every(function(choice) {
|
$scope.options.type.choices.every(function(choice) {
|
||||||
if (choice.value === item.type) {
|
if (choice[0] === item.type) {
|
||||||
itm.type_label = choice.label;
|
itm.type_label = choice[1];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
GetChoices({
|
|
||||||
scope: $scope,
|
|
||||||
url: GetBasePath('unified_job_templates'),
|
|
||||||
field: 'type',
|
|
||||||
variable: 'type_choices',
|
|
||||||
callback: 'choicesReady'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, function () {
|
$scope.$on(`ws-jobs`, function () {
|
||||||
// @issue - this is no longer quite as ham-fisted but I'd like for someone else to take a peek
|
// @issue - this is no longer quite as ham-fisted but I'd like for someone else to take a peek
|
||||||
// calling $state.reload(); here was problematic when launching a job because job launch also
|
// calling $state.reload(); here was problematic when launching a job because job launch also
|
||||||
|
|||||||
@@ -46,6 +46,20 @@ export default {
|
|||||||
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
return qs.search(path, $stateParams[`${list.iterator}_search`]);
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
DataOptions: ['Rest', 'GetBasePath', '$stateParams', '$q', 'TemplateList',
|
||||||
|
function(Rest, GetBasePath, $stateParams, $q, list) {
|
||||||
|
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
||||||
|
Rest.setUrl(path);
|
||||||
|
var val = $q.defer();
|
||||||
|
Rest.options()
|
||||||
|
.then(function(data) {
|
||||||
|
val.resolve(data.data.actions.GET);
|
||||||
|
}, function(data) {
|
||||||
|
val.reject(data);
|
||||||
|
});
|
||||||
|
return val.promise;
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user