From 9d4a2f528edb26b329b1e673050b029c967a91a5 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Tue, 18 Jun 2013 18:12:28 -0400 Subject: [PATCH] Fixed missing host and status values on Job Events page. --- .../ui/static/js/controllers/JobEvents.js | 13 +---- ansibleworks/ui/static/js/controllers/Jobs.js | 55 +++++++++---------- ansibleworks/ui/static/js/helpers/Children.js | 4 +- ansibleworks/ui/static/js/lists/JobEvents.js | 2 +- 4 files changed, 30 insertions(+), 44 deletions(-) diff --git a/ansibleworks/ui/static/js/controllers/JobEvents.js b/ansibleworks/ui/static/js/controllers/JobEvents.js index c34621bb6e..040aa1a2f7 100644 --- a/ansibleworks/ui/static/js/controllers/JobEvents.js +++ b/ansibleworks/ui/static/js/controllers/JobEvents.js @@ -40,6 +40,7 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, set[i]['level'] = 0; set[i]['spaces'] = 0; } + scope.jobevents[i].status = (scope.jobevents[i].failed) ? 'error' : 'success'; } }); @@ -57,18 +58,6 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } LoadBreadCrumbs(); - - if (scope.PostRefreshRemove) { - scope.PostRefreshRemove(); - } - scope.PostRefreshRemove = scope.$on('PostRefresh', function() { - for (var i=0; i < scope.jobevents.length; i++) { - scope.jobevents[i].status = (scope.jobevents[i].failed) ? 'error' : 'success'; - if (scope.jobevents[i].host !== null) { - scope.jobevents[i].host_name = scope.jobevents[i].summary_fields.host.name; - } - } - }); scope.editJobEvent = function(id) { $location.path($location.path() + '/' + id); diff --git a/ansibleworks/ui/static/js/controllers/Jobs.js b/ansibleworks/ui/static/js/controllers/Jobs.js index f45a7290fe..38adc05ff3 100644 --- a/ansibleworks/ui/static/js/controllers/Jobs.js +++ b/ansibleworks/ui/static/js/controllers/Jobs.js @@ -27,9 +27,9 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, } scope.PostRefreshRemove = scope.$on('PostRefresh', function() { $("tr.success").each(function(index) { - // Make sure no rows have a green background - var ngc = $(this).attr('ng-class'); - scope[ngc] = ""; + // Make sure no rows have a green background + var ngc = $(this).attr('ng-class'); + scope[ngc] = ""; }); }); @@ -61,10 +61,8 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, scope.deleteJob = function(id, name) { Rest.setUrl(defaultUrl + id + '/'); Rest.get() - .success( function(data, status, headers, config) { - + .success( function(data, status, headers, config) { var url, action_label, restcall, hdr; - if (data.status == 'pending' || data.status == 'running') { url = data.related.cancel; action_label = 'cancel'; @@ -80,34 +78,35 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, 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 }); - }); + .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.destroy() - .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 }); - }); + .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 - }); + 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, diff --git a/ansibleworks/ui/static/js/helpers/Children.js b/ansibleworks/ui/static/js/helpers/Children.js index 433585d1f6..9d8afb8482 100644 --- a/ansibleworks/ui/static/js/helpers/Children.js +++ b/ansibleworks/ui/static/js/helpers/Children.js @@ -43,9 +43,7 @@ angular.module('ChildrenHelper', ['RestServices', 'Utilities']) for (var j=0; j < data.results.length; j++) { data.results[j].level = level; data.results[j].spaces = spaces; - //if (data.results[j].related.children === undefined) { - // data.results[j].spaces += 12 - //} + data.results[j].status = (data.results[j].failed) ? 'error' : 'success'; data.results[j].event_display = data.results[j].event_display.replace(/^\u00a0*/g,''); if (data.results[j].related.children) { data.results[j]['ngclick'] = "toggleChildren(" + data.results[j].id + ", \"" + data.results[j].related.children + "\")"; diff --git a/ansibleworks/ui/static/js/lists/JobEvents.js b/ansibleworks/ui/static/js/lists/JobEvents.js index c0b8c78a51..ae6a571f12 100644 --- a/ansibleworks/ui/static/js/lists/JobEvents.js +++ b/ansibleworks/ui/static/js/lists/JobEvents.js @@ -32,7 +32,7 @@ angular.module('JobEventsListDefinition', []) host: { label: 'Host', ngClick: "viewHost(\{\{ jobevent.host \}\})", - ngBind: 'jobevent.host_name', + ngBind: 'jobevent.summary_fields.host.name', sourceModel: 'host', sourceField: 'name', searchField: 'hosts__name',