mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 03:30:02 -03:30
Job event detail page now working. Search expanded to work with boolean an integer types. Added new form generator layout. Fixed pagination bugs. Job cancel/delete working.
This commit is contained in:
@@ -167,7 +167,7 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re
|
||||
Rest.setUrl(data.related.start);
|
||||
Rest.post()
|
||||
.success( function(data, status, headers, config) {
|
||||
$location.path(GetBasePath('jobs'));
|
||||
$location.path('/jobs');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function JobsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath, LookUpInit)
|
||||
function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobList,
|
||||
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
|
||||
ClearScope, ProcessErrors, GetBasePath, LookUpInit)
|
||||
{
|
||||
ClearScope('htmlTemplate');
|
||||
var list = JobList;
|
||||
@@ -33,16 +33,73 @@ function JobsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Aler
|
||||
}
|
||||
|
||||
scope.viewEvents = function(id) {
|
||||
console.log('headed to: ' + $location.path() + '/' + id + '/job_events');
|
||||
$location.path($location.path() + '/' + id + '/job_events');
|
||||
}
|
||||
|
||||
scope.deleteJob = function(id, name) {
|
||||
Rest.setUrl(defaultUrl + id + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
|
||||
var url, action_label, restcall, hdr;
|
||||
|
||||
if (data.status == 'pending') {
|
||||
url = data.related.cancel;
|
||||
action_label = 'cancel';
|
||||
hdr = 'Cancel Job';
|
||||
}
|
||||
else {
|
||||
url = defaultUrl + id + '/';
|
||||
action_label = 'delete';
|
||||
hdr = 'Delete Job';
|
||||
}
|
||||
|
||||
var action = function() {
|
||||
Rest.setUrl(url);
|
||||
if (action_label == 'cancel') {
|
||||
Rest.post()
|
||||
.success( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
scope.search(list.iterator);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
else {
|
||||
Rest.delete()
|
||||
.success( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
scope.search(list.iterator);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
$('#prompt-modal').modal('hide');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Prompt({ hdr: hdr,
|
||||
body: 'Are you sure you want to ' + action_label + ' job ' + id + '?',
|
||||
action: action
|
||||
});
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get job details. GET returned status: ' + status });
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JobsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobList',
|
||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'ProcessErrors','GetBasePath', 'LookUpInit'
|
||||
];
|
||||
JobsListCtrl.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobList',
|
||||
'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
|
||||
'ProcessErrors','GetBasePath', 'LookUpInit'
|
||||
];
|
||||
|
||||
|
||||
function JobsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobForm,
|
||||
@@ -274,7 +331,8 @@ JobsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$
|
||||
|
||||
|
||||
function JobEvents ($scope, $rootScope, $compile, $location, $log, $routeParams, JobEventForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath)
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, SearchInit,
|
||||
PaginateInit, GetBasePath)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@@ -285,31 +343,57 @@ function JobEvents ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
var scope = GenerateForm.inject(form, {mode: 'edit', related: true});
|
||||
generator.reset();
|
||||
|
||||
var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events';
|
||||
var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/';
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
var master = {};
|
||||
var id = $routeParams.id;
|
||||
var relatedSets = {};
|
||||
|
||||
|
||||
if (scope.PostRefreshRemove){
|
||||
scope.PostRefreshRemove();
|
||||
}
|
||||
scope.PostRefreshRemove = scope.$on('PostRefresh', function() {
|
||||
var results = scope[form.items.event.set][0];
|
||||
// Disable Next/Prev buttons when we rich the end/beginning of array
|
||||
scope[form.items.event.iterator + 'NextUrlDisable'] = (scope[form.items.event.iterator + 'NextUrl']) ? "" : "disabled";
|
||||
scope[form.items.event.iterator + 'PrevUrlDisable'] = (scope[form.items.event.iterator + 'PrevUrl']) ? "" : "disabled";
|
||||
|
||||
// Set the scope input field values
|
||||
for (var fld in form.items.event.fields) {
|
||||
if (fld == 'event_data') {
|
||||
scope.event_data = JSON.stringify(results[fld]);
|
||||
}
|
||||
else {
|
||||
if (results[fld]) {
|
||||
scope[fld] = results[fld];
|
||||
}
|
||||
}
|
||||
}
|
||||
scope['event_status'] = (results.failed) ? 'failed' : 'success';
|
||||
});
|
||||
|
||||
// Retrieve detail record and prepopulate the form
|
||||
Rest.setUrl(defaultUrl);
|
||||
Rest.get({ params: {page_size: 1} })
|
||||
.success( function(data, status, headers, config) {
|
||||
LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name });
|
||||
var results = data.results[0];
|
||||
scope[form.items.event.iterator + 'NextUrl'] = data.next;
|
||||
scope[form.items.event.iterator + 'PrevUrl'] = data.previous;
|
||||
scope[form.items.event.iterator + 'Count'] = data.count;
|
||||
LoadBreadCrumbs({ path: '/jobs/' + id, title: results["summary_fields"].job.name });
|
||||
for (var fld in form.fields) {
|
||||
if (data[fld]) {
|
||||
scope[fld] = data[fld];
|
||||
if (results[fld]) {
|
||||
scope[fld] = results[fld];
|
||||
}
|
||||
if (form.fields[fld].sourceModel && results.summary_fields[form.fields[fld].sourceModel]) {
|
||||
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
|
||||
results.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
|
||||
}
|
||||
}
|
||||
for (var fld in form.items) {
|
||||
if (data[fld]) {
|
||||
scope[fld] = data[fld];
|
||||
}
|
||||
}
|
||||
scope['event_satus'] = (data.failed) ? 'failed' : 'success';
|
||||
scope.next = data.next;
|
||||
scope.previous = data.previous;
|
||||
scope[form.items.event.set] = data.results;
|
||||
SearchInit({ scope: scope, set: form.items.event.set, list: form.items.event, iterator: form.items.event.iterator, url: defaultUrl });
|
||||
PaginateInit({ scope: scope, list: form.items.event, iterator: form.items.event.iterator, url: defaultUrl , pageSize: 1 });
|
||||
scope.$emit('PostRefresh');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
@@ -319,5 +403,6 @@ function JobEvents ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
}
|
||||
|
||||
JobEvents.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobEventForm',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath' ];
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'SearchInit',
|
||||
'PaginateInit', 'GetBasePath' ];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user