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) {
var scope = params.scope,
failed = params.failed,
modified = params.modified,
started = params.started;
started = params.started,
finished = params.finished;
if (failed && scope.job_status.status !== 'failed' && scope.job_status.status !== 'error' &&
scope.job_status.status !== 'canceled') {
scope.job_status.status = 'failed';
}
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)) {
scope.job_status.started = longDateFilter(modified)
scope.job_status.started = longDateFilter(modified);
}
if (!Empty(scope.job_status.finished) && !Empty(scope.job_status.started)) {
scope.job_status.elapsed = GetElapsed({
start: started,
end: finished
});
}
}
};
}])
@ -900,8 +901,7 @@ export default
.factory('SelectTask', ['JobDetailService', function(JobDetailService) {
return function(params) {
var scope = params.scope,
id = params.id,
callback = params.callback;
id = params.id;
scope.selectedTask = id;
scope.tasks.forEach(function(task, idx) {
@ -912,11 +912,11 @@ export default
scope.tasks[idx].taskActiveClass = '';
}
});
var params = {
params = {
parent: scope.selectedTask,
event__startswith: 'runner',
page_size: scope.hostResultsMaxRows,
order: 'host_name,counter',
order: 'host_name,counter',
};
JobDetailService.getRelatedJobEvents(scope.job.id, params).success(function(res){
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) ||
(base === 'home')){
// 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';
var form_scope =
generator.inject(GroupForm, {
mode: mode,
id: 'properties-tab',
related: false,
scope: properties_scope,
cancelButton: false,
});
generator.inject(GroupForm, {
mode: mode,
id: 'properties-tab',
related: false,
scope: $scope,
cancelButton: false,
});
generator.reset();

View File

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

View File

@ -71,9 +71,8 @@
}
if (filter === 'ok'){
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_async',
changed: false
})
.success(function(res){

View File

@ -12,6 +12,20 @@
$scope.filter = 'all';
$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){
// status waterfall: unreachable > failed > changed > ok > skipped
var count;
@ -30,23 +44,23 @@
}),
changed : _.filter(hosts, function(o){
return o.changed > 0;
})
})
};
return count;
};
var socketListener = function(){
// 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) {
// 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();
}
});
// 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) {
if ($stateParams.id == data['unified_job_id']){
$scope.status = data['status'];
if ($stateParams.id === data.unified_job_id){
$scope.status = data.status;
}
});
};
@ -69,14 +83,14 @@
text[key] = grammar(value.length, key);
});
*/
return grammar(n, status)
return grammar(n, status);
};
$scope.getNextPage = function(){
if ($scope.next){
JobDetailService.getNextPage($scope.next).success(function(res){
res.results.forEach(function(key, index){
$scope.hosts.push(res.results[index]);
})
$scope.hosts.push(res.results[index]);
});
$scope.hosts.push(res.results);
$scope.next = res.next;
});
@ -91,7 +105,7 @@
$scope.hosts = res.results;
$scope.next = res.next;
Wait('stop');
})
});
};
$scope.setFilter = function(filter){
$scope.filter = filter;
@ -100,7 +114,7 @@
JobDetailService.getJobHostSummaries($stateParams.id, {
page_size: page_size
}).success(function(res){
Wait('stop')
Wait('stop');
$scope.hosts = res.results;
$scope.next = res.next;
});
@ -111,32 +125,18 @@
page_size: page_size,
failed: true
}).success(function(res){
Wait('stop')
Wait('stop');
$scope.hosts = res.results;
$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);
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();
init();
}];
}];

View File

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

View File

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

View File

@ -3,7 +3,8 @@ export default
return {
stringifyParams: function(params){
return _.reduce(params, (result, value, key) => {
return result + key + '=' + value + '&'}, '');
return result + key + '=' + value + '&';
}, '');
},
// 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
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
processEventItem: function(event){
@ -58,7 +59,7 @@ export default
// Generate a helper class for job_event statuses
// the stack for which status to display is
// 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
processEventStatus: function(event){
if (event.event === 'runner_on_unreachable'){
@ -72,7 +73,7 @@ export default
return {
class: 'HostEvents-status--failed',
status: 'failed'
}
};
}
// catch the changed case before ok, because both can be true
if (event.changed){
@ -120,7 +121,7 @@ export default
return results;
},
// GET events related to a job run
// e.g.
// e.g.
// ?event=playbook_on_stats
// ?parent=206&event__startswith=runner&page_size=200&order=host_name,counter
getRelatedJobEvents: function(id, params){
@ -134,7 +135,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
getJobEventChildren: function(id){
var url = GetBasePath('job_events');
@ -142,12 +143,12 @@ export default
Rest.setUrl(url);
return Rest.get()
.success(function(data){
return data
return data;
})
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
// GET job host summaries related to a job run
// e.g. ?page_size=200&order=host_name
@ -162,7 +163,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
// GET job plays related to a job run
// e.g. ?page_size=200
@ -177,7 +178,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
getJobTasks: function(id, params){
var url = GetBasePath('jobs');
@ -190,7 +191,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
getJob: function(params){
var url = GetBasePath('unified_jobs') + '?' + this.stringifyParams(params);
@ -202,7 +203,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
msg: 'Call to ' + url + '. GET returned: ' + status });
});
});
},
// GET next set of paginated results
// expects 'next' param returned by the API e.g.
@ -216,7 +217,7 @@ export default
.error(function(data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!',
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');
defaultUrl = GetBasePath('system_job_templates')+id+'/launch/';
CreateDialog({

View File

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