mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
applying callback mechanism to job tmeplate list
This commit is contained in:
@@ -8,12 +8,12 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
|
|||||||
'Alert','TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors',
|
'Alert','TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors',
|
||||||
'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter',
|
'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter',
|
||||||
'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet',
|
'Dataset', 'rbacUiControlService', 'TemplatesService','QuerySet',
|
||||||
'GetChoices', 'TemplateCopyService', 'DataOptions',
|
'GetChoices', 'TemplateCopyService',
|
||||||
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, DataOptions
|
qs, GetChoices, TemplateCopyService
|
||||||
) {
|
) {
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -37,29 +37,39 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest',
|
|||||||
$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;
|
$scope.options = {};
|
||||||
|
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
|
|
||||||
$scope.$watchCollection('templates', function() {
|
|
||||||
$scope[list.name].forEach(function(item, item_idx) {
|
|
||||||
var itm = $scope[list.name][item_idx];
|
|
||||||
|
|
||||||
// Set the item type label
|
|
||||||
if (list.fields.type) {
|
|
||||||
$scope.options.type.choices.every(function(choice) {
|
|
||||||
if (choice[0] === item.type) {
|
|
||||||
itm.type_label = choice[1];
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.$on(`${list.iterator}_options`, function(event, data){
|
||||||
|
debugger;
|
||||||
|
$scope.options = data.data.actions.GET;
|
||||||
|
optionsRequestDataProcessing();
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$watchCollection('templates', function() {
|
||||||
|
optionsRequestDataProcessing();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// iterate over the list and add fields like type label, after the
|
||||||
|
// OPTIONS request returns, or the list is sorted/paginated/searched
|
||||||
|
function optionsRequestDataProcessing(){
|
||||||
|
$scope[list.name].forEach(function(item, item_idx) {
|
||||||
|
var itm = $scope[list.name][item_idx];
|
||||||
|
|
||||||
|
// Set the item type label
|
||||||
|
if (list.fields.type && $scope.options.hasOwnProperty('type')) {
|
||||||
|
$scope.options.type.choices.every(function(choice) {
|
||||||
|
if (choice[0] === item.type) {
|
||||||
|
itm.type_label = choice[1];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, function () {
|
$scope.$on(`ws-jobs`, function () {
|
||||||
|
|||||||
@@ -46,20 +46,6 @@ 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