From 5a5398664a6be4aa77cb5773d9ed615814cf9d4d Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Sat, 16 Aug 2014 00:39:07 -0400 Subject: [PATCH] Jobs page Fix for https://trello.com/c/tWDz8Jd7/320-js-failure-when-attempting-to-delete-a-queued-job. Plus cleaned up the prompting around job delete. Job delete and cancel should behave the same except for the request method sent to the API. Also, removed 'On' from date titles to help keep the tiles from breaking as the viewport shrinks. --- awx/ui/static/js/app.js | 3 ++- awx/ui/static/js/controllers/Jobs.js | 9 +++++++-- awx/ui/static/js/helpers/Jobs.js | 13 ++++++++----- awx/ui/static/js/lists/CompletedJobs.js | 2 +- awx/ui/static/js/lists/Jobs.js | 2 +- awx/ui/static/js/lists/QueuedJobs.js | 2 +- awx/ui/static/js/lists/RunningJobs.js | 2 +- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 0fd5283f62..4d0c185c73 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -524,8 +524,9 @@ angular.module('Tower', [ if ($rootScope.current_user === undefined || $rootScope.current_user === null) { Authorization.restoreUserInfo(); //user must have hit browser refresh } - if (!/^\/(login|logout)/.test(next.$$route.originalPath)) { + if (next && next.$$route && (!/^\/(login|logout)/.test(next.$$route.originalPath))) { // if not headed to /login or /logout, then check the license + console.log(next); CheckLicense.test(); } } diff --git a/awx/ui/static/js/controllers/Jobs.js b/awx/ui/static/js/controllers/Jobs.js index 19401eb876..a22e7917ce 100644 --- a/awx/ui/static/js/controllers/Jobs.js +++ b/awx/ui/static/js/controllers/Jobs.js @@ -31,7 +31,11 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C job_socket.init(); job_socket.on("status_changed", function(data) { if (api_complete) { + console.log('here'); + console.log(data); processEvent(data); + } else { + console.log('api not completed!'); } }); schedule_socket = Socket({ @@ -45,7 +49,6 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C } }); } - openSockets(); $rootScope.checkSocketConnectionInterval = setInterval(function() { if (job_socket.checkStatus() === 'error' || checkCount > 2) { @@ -65,6 +68,7 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C }, 3000); function processEvent(event) { + console.log(event); switch(event.status) { case 'running': running_scope.search('running_job'); @@ -81,7 +85,7 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C case 'canceled': completed_scope.search('completed_job'); running_scope.search('running_job'); - break; + queued_scope.search('queued_job'); } } @@ -94,6 +98,7 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C listCount++; if (listCount === 4) { api_complete = true; + openSockets(); } }); diff --git a/awx/ui/static/js/helpers/Jobs.js b/awx/ui/static/js/helpers/Jobs.js index df8d0851df..2c3f5e356a 100644 --- a/awx/ui/static/js/helpers/Jobs.js +++ b/awx/ui/static/js/helpers/Jobs.js @@ -466,6 +466,7 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt, Alert){ } }) .error(function() { + Wait('stop'); $('#prompt-modal').modal('hide'); // Ignore the error. The job most likely already finished. // ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + @@ -479,13 +480,15 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt, Alert){ scope.$emit(callback, action_label); } else { - scope.refreshJobs(); + scope.search(scope.iterator); } }) .error(function (data, status) { + Wait('stop'); $('#prompt-modal').modal('hide'); - ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + - ' failed. DELETE returned status: ' + status }); + // Ignore the error. The job most likely already finished. + //ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + + // ' failed. DELETE returned status: ' + status }); }); } }; @@ -494,8 +497,8 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt, Alert){ scope.removeCancelNotAllowed(); } scope.removeCancelNotAllowed = scope.$on('CancelNotAllowed', function() { - Alert('Job Completed', 'The job completed. Click the button to view ' + - 'the latest status.', 'alert-info'); + Wait('stop'); + Alert('Job Completed', 'The request to cancel the job could not be submitted. The job already completed.', 'alert-info'); }); if (scope.removeCancelJob) { diff --git a/awx/ui/static/js/lists/CompletedJobs.js b/awx/ui/static/js/lists/CompletedJobs.js index 1977534f75..4828081e9b 100644 --- a/awx/ui/static/js/lists/CompletedJobs.js +++ b/awx/ui/static/js/lists/CompletedJobs.js @@ -46,7 +46,7 @@ angular.module('CompletedJobsDefinition', []) ] }, finished: { - label: 'Finished On', + label: 'Finished', noLink: true, searchable: false, filter: "date:'MM/dd HH:mm:ss'", diff --git a/awx/ui/static/js/lists/Jobs.js b/awx/ui/static/js/lists/Jobs.js index 208046714a..b474a045b3 100644 --- a/awx/ui/static/js/lists/Jobs.js +++ b/awx/ui/static/js/lists/Jobs.js @@ -46,7 +46,7 @@ angular.module('JobsListDefinition', []) nosort: true }, started: { - label: 'Started On', + label: 'Started', noLink: true, searchable: false, filter: "date:'MM/dd HH:mm:ss'", diff --git a/awx/ui/static/js/lists/QueuedJobs.js b/awx/ui/static/js/lists/QueuedJobs.js index 157539f719..2cede92695 100644 --- a/awx/ui/static/js/lists/QueuedJobs.js +++ b/awx/ui/static/js/lists/QueuedJobs.js @@ -43,7 +43,7 @@ angular.module('QueuedJobsDefinition', []) nosort: true }, created: { - label: 'Created On', + label: 'Created', noLink: true, searchable: false, filter: "date:'MM/dd HH:mm:ss'", diff --git a/awx/ui/static/js/lists/RunningJobs.js b/awx/ui/static/js/lists/RunningJobs.js index c0ce32df30..bff6c22102 100644 --- a/awx/ui/static/js/lists/RunningJobs.js +++ b/awx/ui/static/js/lists/RunningJobs.js @@ -43,7 +43,7 @@ angular.module('RunningJobsDefinition', []) nosort: true }, started: { - label: 'Started On', + label: 'Started', noLink: true, searchable: false, filter: "date:'MM/dd HH:mm:ss'",