fixed last of the grunt issues

This commit is contained in:
John Mitchell
2016-04-22 15:55:28 -04:00
parent cd6fff70a8
commit 101954c146
11 changed files with 87 additions and 87 deletions

View File

@@ -351,29 +351,30 @@ export default
}; };
}]) }])
.factory('UpdateJobStatus', ['GetElapsed', 'Empty', 'JobIsFinished', function(GetElapsed, Empty, JobIsFinished) { .factory('UpdateJobStatus', ['GetElapsed', 'Empty', 'JobIsFinished', 'longDateFilter', function(GetElapsed, Empty, JobIsFinished, longDateFilter) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
failed = params.failed, failed = params.failed,
modified = params.modified, modified = params.modified,
started = params.started; started = params.started,
finished = params.finished;
if (failed && scope.job_status.status !== 'failed' && scope.job_status.status !== 'error' && if (failed && scope.job_status.status !== 'failed' && scope.job_status.status !== 'error' &&
scope.job_status.status !== 'canceled') { scope.job_status.status !== 'canceled') {
scope.job_status.status = 'failed'; scope.job_status.status = 'failed';
} }
if (JobIsFinished(scope) && !Empty(modified)) { if (JobIsFinished(scope) && !Empty(modified)) {
scope.job_status.finished = longDateFilter(modified) scope.job_status.finished = longDateFilter(modified);
} }
if (!Empty(started) && Empty(scope.job_status.started)) { if (!Empty(started) && Empty(scope.job_status.started)) {
scope.job_status.started = longDateFilter(modified) scope.job_status.started = longDateFilter(modified);
} }
if (!Empty(scope.job_status.finished) && !Empty(scope.job_status.started)) { if (!Empty(scope.job_status.finished) && !Empty(scope.job_status.started)) {
scope.job_status.elapsed = GetElapsed({ scope.job_status.elapsed = GetElapsed({
start: started, start: started,
end: finished end: finished
}); });
} }
}; };
}]) }])
@@ -900,8 +901,7 @@ export default
.factory('SelectTask', ['JobDetailService', function(JobDetailService) { .factory('SelectTask', ['JobDetailService', function(JobDetailService) {
return function(params) { return function(params) {
var scope = params.scope, var scope = params.scope,
id = params.id, id = params.id;
callback = params.callback;
scope.selectedTask = id; scope.selectedTask = id;
scope.tasks.forEach(function(task, idx) { scope.tasks.forEach(function(task, idx) {
@@ -912,11 +912,11 @@ export default
scope.tasks[idx].taskActiveClass = ''; scope.tasks[idx].taskActiveClass = '';
} }
}); });
var params = { params = {
parent: scope.selectedTask, parent: scope.selectedTask,
event__startswith: 'runner', event__startswith: 'runner',
page_size: scope.hostResultsMaxRows, page_size: scope.hostResultsMaxRows,
order: 'host_name,counter', order: 'host_name,counter',
}; };
JobDetailService.getRelatedJobEvents(scope.job.id, params).success(function(res){ JobDetailService.getRelatedJobEvents(scope.job.id, params).success(function(res){
scope.hostResults = JobDetailService.processHostEvents(res.results); scope.hostResults = JobDetailService.processHostEvents(res.results);

View File

@@ -804,7 +804,7 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm,
if((scope.portalMode===false || scope.$parent.portalMode===false ) && Empty(data.system_job) || if((scope.portalMode===false || scope.$parent.portalMode===false ) && Empty(data.system_job) ||
(base === 'home')){ (base === 'home')){
// use $state.go with reload: true option to re-instantiate sockets in // use $state.go with reload: true option to re-instantiate sockets in
$state.go('jobDetail', {id: job}, {reload: true}) $state.go('jobDetail', {id: job}, {reload: true});
} }
}); });

View File

@@ -60,14 +60,13 @@ function manageGroupsDirectiveController($filter, $location, $log,
$scope.parseType = 'yaml'; $scope.parseType = 'yaml';
var form_scope = generator.inject(GroupForm, {
generator.inject(GroupForm, { mode: mode,
mode: mode, id: 'properties-tab',
id: 'properties-tab', related: false,
related: false, scope: $scope,
scope: properties_scope, cancelButton: false,
cancelButton: false, });
});
generator.reset(); generator.reset();

View File

@@ -6,15 +6,15 @@
export default export default
['$stateParams', '$scope', '$state', 'Wait', 'JobDetailService', 'event', ['$stateParams', '$scope', '$state', 'Wait', 'JobDetailService', 'event', 'CodeMirror',
function($stateParams, $scope, $state, Wait, JobDetailService, event){ function($stateParams, $scope, $state, Wait, JobDetailService, event, CodeMirror){
$scope.processEventStatus = JobDetailService.processEventStatus; $scope.processEventStatus = JobDetailService.processEventStatus;
$scope.hostResults = []; $scope.hostResults = [];
// Avoid rendering objects in the details fieldset // Avoid rendering objects in the details fieldset
// ng-if="processResults(value)" via host-event-details.partial.html // ng-if="processResults(value)" via host-event-details.partial.html
$scope.processResults = function(value){ $scope.processResults = function(value){
if (typeof value == 'object'){return false;} if (typeof value === 'object'){return false;}
else {return true;} else {return true;}
}; };
@@ -24,19 +24,19 @@
lineNumbers: true, lineNumbers: true,
mode: {name: "javascript", json: true} mode: {name: "javascript", json: true}
}); });
editor.setSize("100%", 300) editor.setSize("100%", 300);
editor.getDoc().setValue(JSON.stringify(json, null, 4)); editor.getDoc().setValue(JSON.stringify(json, null, 4));
}; };
$scope.getActiveHostIndex = function(){ $scope.getActiveHostIndex = function(){
var result = $scope.hostResults.filter(function( obj ) { var result = $scope.hostResults.filter(function( obj ) {
return obj.id == $scope.event.id; return obj.id === $scope.event.id;
}); });
return $scope.hostResults.indexOf(result[0]); return $scope.hostResults.indexOf(result[0]);
}; };
$scope.showPrev = function(){ $scope.showPrev = function(){
return $scope.getActiveHostIndex() != 0; return $scope.getActiveHostIndex() !== 0;
}; };
$scope.showNext = function(){ $scope.showNext = function(){
@@ -52,7 +52,7 @@
$scope.goPrev = function(){ $scope.goPrev = function(){
var index = $scope.getActiveHostIndex() - 1; var index = $scope.getActiveHostIndex() - 1;
var id = $scope.hostResults[index].id; var id = $scope.hostResults[index].id;
$state.go('jobDetail.host-event.details', {eventId: id}); $state.go('jobDetail.host-event.details', {eventId: id});
}; };
var init = function(){ var init = function(){
@@ -61,12 +61,13 @@
$scope.hostResults = res.results; $scope.hostResults = res.results;
}); });
$scope.json = JobDetailService.processJson($scope.event); $scope.json = JobDetailService.processJson($scope.event);
if ($state.current.name == 'jobDetail.host-event.json'){ if ($state.current.name === 'jobDetail.host-event.json'){
codeMirror('#HostEvent-json', $scope.json); codeMirror('#HostEvent-json', $scope.json);
} }
try { try {
$scope.stdout = JobDetailService.processJson($scope.event.event_data.res) $scope.stdout = JobDetailService
if ($state.current.name == 'jobDetail.host-event.stdout'){ .processJson($scope.event.event_data.res);
if ($state.current.name === 'jobDetail.host-event.stdout'){
codeMirror('#HostEvent-stdout', $scope.stdout); codeMirror('#HostEvent-stdout', $scope.stdout);
} }
} }

View File

@@ -71,9 +71,8 @@
} }
if (filter === 'ok'){ if (filter === 'ok'){
return JobDetailService.getRelatedJobEvents($stateParams.id, { return JobDetailService.getRelatedJobEvents($stateParams.id, {
host_name: $stateParams.hostName, host_name: $stateParams.hostName,
or__field__event: 'runner_on_ok', or__field__event: 'runner_on_ok',
or__field__event: 'runner_on_ok_async',
changed: false changed: false
}) })
.success(function(res){ .success(function(res){

View File

@@ -12,6 +12,20 @@
$scope.filter = 'all'; $scope.filter = 'all';
$scope.search = null; $scope.search = null;
var init = function(){
Wait('start');
JobDetailService.getJobHostSummaries($stateParams.id, {page_size: page_size})
.success(function(res){
$scope.hosts = res.results;
$scope.next = res.next;
Wait('stop');
});
JobDetailService.getJob({id: $stateParams.id})
.success(function(res){
$scope.status = res.results[0].status;
});
};
var buildGraph = function(hosts){ var buildGraph = function(hosts){
// status waterfall: unreachable > failed > changed > ok > skipped // status waterfall: unreachable > failed > changed > ok > skipped
var count; var count;
@@ -30,23 +44,23 @@
}), }),
changed : _.filter(hosts, function(o){ changed : _.filter(hosts, function(o){
return o.changed > 0; return o.changed > 0;
}) })
}; };
return count; return count;
}; };
var socketListener = function(){ var socketListener = function(){
// emitted by the API in the same function used to persist host summary data // emitted by the API in the same function used to persist host summary data
// JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py // JobEvent.update_host_summary_from_stats() from /awx/main.models.jobs.py
jobSocket.on('summary_complete', function(data) { jobSocket.on('summary_complete', function(data) {
// discard socket msgs we don't care about in this context // discard socket msgs we don't care about in this context
if ($stateParams.id == data['unified_job_id']){ if ($stateParams.id === data.unified_job_id){
init(); init();
} }
}); });
// UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py // UnifiedJob.def socketio_emit_status() from /awx/main.models.unified_jobs.py
jobSocket.on('status_changed', function(data) { jobSocket.on('status_changed', function(data) {
if ($stateParams.id == data['unified_job_id']){ if ($stateParams.id === data.unified_job_id){
$scope.status = data['status']; $scope.status = data.status;
} }
}); });
}; };
@@ -69,14 +83,14 @@
text[key] = grammar(value.length, key); text[key] = grammar(value.length, key);
}); });
*/ */
return grammar(n, status) return grammar(n, status);
}; };
$scope.getNextPage = function(){ $scope.getNextPage = function(){
if ($scope.next){ if ($scope.next){
JobDetailService.getNextPage($scope.next).success(function(res){ JobDetailService.getNextPage($scope.next).success(function(res){
res.results.forEach(function(key, index){ res.results.forEach(function(key, index){
$scope.hosts.push(res.results[index]); $scope.hosts.push(res.results[index]);
}) });
$scope.hosts.push(res.results); $scope.hosts.push(res.results);
$scope.next = res.next; $scope.next = res.next;
}); });
@@ -91,7 +105,7 @@
$scope.hosts = res.results; $scope.hosts = res.results;
$scope.next = res.next; $scope.next = res.next;
Wait('stop'); Wait('stop');
}) });
}; };
$scope.setFilter = function(filter){ $scope.setFilter = function(filter){
$scope.filter = filter; $scope.filter = filter;
@@ -100,7 +114,7 @@
JobDetailService.getJobHostSummaries($stateParams.id, { JobDetailService.getJobHostSummaries($stateParams.id, {
page_size: page_size page_size: page_size
}).success(function(res){ }).success(function(res){
Wait('stop') Wait('stop');
$scope.hosts = res.results; $scope.hosts = res.results;
$scope.next = res.next; $scope.next = res.next;
}); });
@@ -111,32 +125,18 @@
page_size: page_size, page_size: page_size,
failed: true failed: true
}).success(function(res){ }).success(function(res){
Wait('stop') Wait('stop');
$scope.hosts = res.results; $scope.hosts = res.results;
$scope.next = res.next; $scope.next = res.next;
}); });
} };
var get = filter == 'all' ? getAll() : getFailed(); $scope.get = filter === 'all' ? getAll() : getFailed();
}; };
$scope.$watchCollection('hosts', function(curr, prev){ $scope.$watchCollection('hosts', function(curr){
$scope.count = buildGraph(curr); $scope.count = buildGraph(curr);
DrawGraph({count: $scope.count, resize:true}); DrawGraph({count: $scope.count, resize:true});
}); });
var init = function(){
Wait('start');
JobDetailService.getJobHostSummaries($stateParams.id, {page_size: page_size})
.success(function(res){
$scope.hosts = res.results;
$scope.next = res.next;
Wait('stop');
});
JobDetailService.getJob({id: $stateParams.id})
.success(function(res){
$scope.status = res.results[0].status;
});
};
socketListener(); socketListener();
init(); init();
}]; }];

View File

@@ -13,7 +13,7 @@
export default export default
[ '$location', '$rootScope', '$filter', '$scope', '$compile', [ '$location', '$rootScope', '$filter', '$scope', '$compile',
'$stateParams', '$log', 'ClearScope', 'GetBasePath', 'Wait', '$stateParams', '$log', 'ClearScope', 'GetBasePath', 'Wait',
'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed',
'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'DeleteJob', 'PlaybookRun', 'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'DeleteJob', 'PlaybookRun',
'LoadPlays', 'LoadTasks', 'HostsEdit', 'LoadPlays', 'LoadTasks', 'HostsEdit',
'ParseVariableString', 'GetChoices', 'fieldChoices', 'fieldLabels', 'ParseVariableString', 'GetChoices', 'fieldChoices', 'fieldLabels',
@@ -243,7 +243,7 @@ export default
event: 'playbook_on_stats' event: 'playbook_on_stats'
}; };
JobDetailService.getRelatedJobEvents(scope.job.id, params) JobDetailService.getRelatedJobEvents(scope.job.id, params)
.success(function(data) { .success(function() {
UpdateDOM({ scope: scope }); UpdateDOM({ scope: scope });
}) })
.error(function(data, status) { .error(function(data, status) {
@@ -278,7 +278,6 @@ export default
}; };
JobDetailService.getRelatedJobEvents(scope.job.id, params) JobDetailService.getRelatedJobEvents(scope.job.id, params)
.success(function(data) { .success(function(data) {
var event, status, item, msg;
if (data.results.length > 0) { if (data.results.length > 0) {
lastEventId = data.results[0].id; lastEventId = data.results[0].id;
} }
@@ -502,7 +501,7 @@ export default
}); });
} }
}); });
if (scope.removeLoadJob) { if (scope.removeLoadJob) {
scope.removeLoadJob(); scope.removeLoadJob();
@@ -518,7 +517,7 @@ export default
// Load the job record // Load the job record
JobDetailService.getJob({id: job_id}) JobDetailService.getJob({id: job_id})
.success(function(res) { .success(function(res) {
var i, var i,
data = res.results[0]; data = res.results[0];
scope.job = data; scope.job = data;
scope.job_template_name = data.name; scope.job_template_name = data.name;
@@ -802,6 +801,7 @@ export default
}; };
scope.searchTasks = function() { scope.searchTasks = function() {
var params;
if (scope.search_task_name) { if (scope.search_task_name) {
scope.searchTasksEnabled = false; scope.searchTasksEnabled = false;
} }
@@ -826,6 +826,7 @@ export default
}; };
scope.searchHosts = function() { scope.searchHosts = function() {
var params;
if (scope.search_host_name) { if (scope.search_host_name) {
scope.searchHostsEnabled = false; scope.searchHostsEnabled = false;
} }
@@ -834,12 +835,12 @@ export default
} }
if (!scope.liveEventProcessing || scope.pauseLiveEvents) { if (!scope.liveEventProcessing || scope.pauseLiveEvents) {
scope.hostResultsLoading = true; scope.hostResultsLoading = true;
var params = { params = {
parent: scope.selectedTask, parent: scope.selectedTask,
event__startswith: 'runner', event__startswith: 'runner',
page_size: scope.hostResultsMaxRows, page_size: scope.hostResultsMaxRows,
order: 'host_name,counter', order: 'host_name,counter',
host_name__icontains: scope.search_host_name host_name__icontains: scope.search_host_name
}; };
if (scope.search_host_status === 'failed'){ if (scope.search_host_status === 'failed'){
params.failed = true; params.failed = true;

View File

@@ -5,7 +5,6 @@
*************************************************/ *************************************************/
import {templateUrl} from '../shared/template-url/template-url.factory'; import {templateUrl} from '../shared/template-url/template-url.factory';
import HostSummaryController from './host-summary/host-summary.controller';
export default { export default {
name: 'jobDetail', name: 'jobDetail',

View File

@@ -3,7 +3,8 @@ export default
return { return {
stringifyParams: function(params){ stringifyParams: function(params){
return _.reduce(params, (result, value, key) => { return _.reduce(params, (result, value, key) => {
return result + key + '=' + value + '&'}, ''); return result + key + '=' + value + '&';
}, '');
}, },
// the the API passes through Ansible's event_data response // the the API passes through Ansible's event_data response
@@ -45,7 +46,7 @@ export default
}, },
// Return Ansible's passed-through response msg on a job_event // Return Ansible's passed-through response msg on a job_event
processEventMsg: function(event){ processEventMsg: function(event){
return typeof event.event_data.res === 'object' ? event.event_data.res.msg : event.event_data.res; return typeof event.event_data.res === 'object' ? event.event_data.res.msg : event.event_data.res;
}, },
// Return only Ansible's passed-through response item on a job_event // Return only Ansible's passed-through response item on a job_event
processEventItem: function(event){ processEventItem: function(event){
@@ -58,7 +59,7 @@ export default
// Generate a helper class for job_event statuses // Generate a helper class for job_event statuses
// the stack for which status to display is // the stack for which status to display is
// unreachable > failed > changed > ok // unreachable > failed > changed > ok
// uses the API's runner events and convenience properties .failed .changed to determine status. // uses the API's runner events and convenience properties .failed .changed to determine status.
// see: job_event_callback.py for more filters to support // see: job_event_callback.py for more filters to support
processEventStatus: function(event){ processEventStatus: function(event){
if (event.event === 'runner_on_unreachable'){ if (event.event === 'runner_on_unreachable'){
@@ -72,7 +73,7 @@ export default
return { return {
class: 'HostEvents-status--failed', class: 'HostEvents-status--failed',
status: 'failed' status: 'failed'
} };
} }
// catch the changed case before ok, because both can be true // catch the changed case before ok, because both can be true
if (event.changed){ if (event.changed){
@@ -120,7 +121,7 @@ export default
return results; return results;
}, },
// GET events related to a job run // GET events related to a job run
// e.g. // e.g.
// ?event=playbook_on_stats // ?event=playbook_on_stats
// ?parent=206&event__startswith=runner&page_size=200&order=host_name,counter // ?parent=206&event__startswith=runner&page_size=200&order=host_name,counter
getRelatedJobEvents: function(id, params){ getRelatedJobEvents: function(id, params){
@@ -134,7 +135,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
getJobEventChildren: function(id){ getJobEventChildren: function(id){
var url = GetBasePath('job_events'); var url = GetBasePath('job_events');
@@ -142,12 +143,12 @@ export default
Rest.setUrl(url); Rest.setUrl(url);
return Rest.get() return Rest.get()
.success(function(data){ .success(function(data){
return data return data;
}) })
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
// GET job host summaries related to a job run // GET job host summaries related to a job run
// e.g. ?page_size=200&order=host_name // e.g. ?page_size=200&order=host_name
@@ -162,7 +163,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
// GET job plays related to a job run // GET job plays related to a job run
// e.g. ?page_size=200 // e.g. ?page_size=200
@@ -177,7 +178,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
getJobTasks: function(id, params){ getJobTasks: function(id, params){
var url = GetBasePath('jobs'); var url = GetBasePath('jobs');
@@ -190,7 +191,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
getJob: function(params){ getJob: function(params){
var url = GetBasePath('unified_jobs') + '?' + this.stringifyParams(params); var url = GetBasePath('unified_jobs') + '?' + this.stringifyParams(params);
@@ -202,7 +203,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
}, },
// GET next set of paginated results // GET next set of paginated results
// expects 'next' param returned by the API e.g. // expects 'next' param returned by the API e.g.
@@ -216,7 +217,7 @@ export default
.error(function(data, status) { .error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status }); msg: 'Call to ' + url + '. GET returned: ' + status });
}); });
} }
}; };
}]; }];

View File

@@ -165,7 +165,7 @@ export default
}); });
}; };
$scope.submitJob = function (id, name, card) { $scope.submitJob = function (id, name) {
Wait('start'); Wait('start');
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/'; defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
CreateDialog({ CreateDialog({

View File

@@ -36,8 +36,8 @@ angular.module('ApiLoader', ['Utilities'])
data.base = base; data.base = base;
$rootScope.defaultUrls = data; $rootScope.defaultUrls = data;
// tiny hack to side-step api/v1/job_events not being a visible endpoint @ GET api/v1/ // tiny hack to side-step api/v1/job_events not being a visible endpoint @ GET api/v1/
if (!$rootScope.defaultUrls['job_events']){ if (!$rootScope.defaultUrls.job_events){
$rootScope.defaultUrls['job_events'] = '/api/v1/job_events/'; $rootScope.defaultUrls.job_events = '/api/v1/job_events/';
} }
Store('api', data); Store('api', data);
}) })