mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 20:07:37 -02:30
Show proper error message for missing job template form
when visiting the job template page for a job template that has been deleted or doesn't exist, we want to show the 404 error message, not an error message about tags or labels.
This commit is contained in:
@@ -448,31 +448,40 @@ export default
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
if($state.params.id !== "null"){
|
||||||
|
Rest.setUrl(defaultUrl + $state.params.id +
|
||||||
|
"/labels");
|
||||||
|
Rest.get()
|
||||||
|
.success(function(data) {
|
||||||
|
if (data.next) {
|
||||||
|
getNext(data, data.results, seeMoreResolve);
|
||||||
|
} else {
|
||||||
|
seeMoreResolve.resolve(data.results);
|
||||||
|
}
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + $state.params.id +
|
seeMoreResolve.promise.then(function (labels) {
|
||||||
"/labels");
|
$scope.$emit("choicesReady");
|
||||||
Rest.get()
|
var opts = labels
|
||||||
.success(function(data) {
|
.map(i => ({id: i.id + "",
|
||||||
if (data.next) {
|
test: i.name}));
|
||||||
getNext(data, data.results, seeMoreResolve);
|
CreateSelect2({
|
||||||
} else {
|
element:'#job_templates_labels',
|
||||||
seeMoreResolve.resolve(data.results);
|
multiple: true,
|
||||||
}
|
addNew: true,
|
||||||
|
opts: opts
|
||||||
seeMoreResolve.promise.then(function (labels) {
|
});
|
||||||
$scope.$emit("choicesReady");
|
Wait("stop");
|
||||||
var opts = labels
|
|
||||||
.map(i => ({id: i.id + "",
|
|
||||||
test: i.name}));
|
|
||||||
CreateSelect2({
|
|
||||||
element:'#job_templates_labels',
|
|
||||||
multiple: true,
|
|
||||||
addNew: true,
|
|
||||||
opts: opts
|
|
||||||
});
|
});
|
||||||
Wait("stop");
|
}).error(function(){
|
||||||
|
// job template id is null in this case
|
||||||
|
$scope.$emit("choicesReady");
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
// job template doesn't exist
|
||||||
|
$scope.$emit("choicesReady");
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors($scope, data, status, form, {
|
ProcessErrors($scope, data, status, form, {
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
export default ['$scope', 'Refresh', 'tagSearchService',
|
export default ['$scope', 'Refresh', 'tagSearchService', '$stateParams',
|
||||||
function($scope, Refresh, tagSearchService) {
|
function($scope, Refresh, tagSearchService, $stateParams) {
|
||||||
// JSONify passed field elements that can be searched
|
// JSONify passed field elements that can be searched
|
||||||
$scope.list = angular.fromJson($scope.list);
|
$scope.list = angular.fromJson($scope.list);
|
||||||
// Access config lines from list spec
|
// Access config lines from list spec
|
||||||
$scope.listConfig = $scope.$parent.list;
|
$scope.listConfig = $scope.$parent.list;
|
||||||
// Grab options for the left-dropdown of the searchbar
|
// Grab options for the left-dropdown of the searchbar
|
||||||
tagSearchService.getSearchTypes($scope.list, $scope.endpoint)
|
if($stateParams.id !== "null"){
|
||||||
.then(function(searchTypes) {
|
tagSearchService.getSearchTypes($scope.list, $scope.endpoint)
|
||||||
$scope.searchTypes = searchTypes;
|
.then(function(searchTypes) {
|
||||||
|
$scope.searchTypes = searchTypes;
|
||||||
|
|
||||||
// currently selected option of the left-dropdown
|
// currently selected option of the left-dropdown
|
||||||
$scope.currentSearchType = $scope.searchTypes[0];
|
$scope.currentSearchType = $scope.searchTypes[0];
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// shows/hide the search type dropdown
|
// shows/hide the search type dropdown
|
||||||
$scope.toggleTypeDropdown = function() {
|
$scope.toggleTypeDropdown = function() {
|
||||||
|
|||||||
@@ -84,41 +84,45 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu
|
|||||||
|
|
||||||
if (needsRequest.length) {
|
if (needsRequest.length) {
|
||||||
// make the options request to reutrn the typeOptions
|
// make the options request to reutrn the typeOptions
|
||||||
Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath);
|
var url = needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath;
|
||||||
Rest.options()
|
if(url.indexOf('null') === 0 ){
|
||||||
.success(function (data) {
|
Rest.setUrl(url);
|
||||||
try {
|
Rest.options()
|
||||||
var options = data.actions.GET;
|
.success(function (data) {
|
||||||
needsRequest = needsRequest
|
try {
|
||||||
.map(function (option) {
|
var options = data.actions.GET;
|
||||||
option.typeOptions = options[option
|
needsRequest = needsRequest
|
||||||
.value]
|
.map(function (option) {
|
||||||
.choices
|
option.typeOptions = options[option
|
||||||
.map(function(i) {
|
.value]
|
||||||
return {
|
.choices
|
||||||
value: i[0],
|
.map(function(i) {
|
||||||
label: i[1]
|
return {
|
||||||
};
|
value: i[0],
|
||||||
});
|
label: i[1]
|
||||||
return option;
|
};
|
||||||
});
|
});
|
||||||
}
|
return option;
|
||||||
catch(err){
|
});
|
||||||
if (!basePath){
|
|
||||||
$log.error('Cannot retrieve OPTIONS because the basePath parameter is not set on the list with the following fieldset: \n', list);
|
|
||||||
}
|
}
|
||||||
else { $log.error(err); }
|
catch(err){
|
||||||
}
|
if (!basePath){
|
||||||
Wait("stop");
|
$log.error('Cannot retrieve OPTIONS because the basePath parameter is not set on the list with the following fieldset: \n', list);
|
||||||
defer.resolve(joinOptions());
|
}
|
||||||
})
|
else { $log.error(err); }
|
||||||
.error(function (data, status) {
|
}
|
||||||
Wait("stop");
|
Wait("stop");
|
||||||
defer.reject("options request failed");
|
defer.resolve(joinOptions());
|
||||||
ProcessErrors(null, data, status, null, {
|
})
|
||||||
hdr: 'Error!',
|
.error(function (data, status) {
|
||||||
msg: 'Getting type options failed'});
|
Wait("stop");
|
||||||
});
|
defer.reject("options request failed");
|
||||||
|
ProcessErrors(null, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Getting type options failed'});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Wait("stop");
|
Wait("stop");
|
||||||
defer.resolve(joinOptions());
|
defer.resolve(joinOptions());
|
||||||
|
|||||||
Reference in New Issue
Block a user