Websockets live updating portal mode

fixed issue with websockets not updating view in portal mode
This commit is contained in:
Jared Tabor 2014-11-05 13:07:23 -05:00
parent 43f46f830f
commit ae55f1c0d3
8 changed files with 43 additions and 79 deletions

View File

@ -19,7 +19,7 @@
tooltip_delay: {show: 500, hide: 100}, // Default number of milliseconds to delay displaying/hiding tooltips
debug_mode: true, // Enable console logging messages
debug_mode: false, // Enable console logging messages
password_strength: 45, // User password strength. Integer between 0 and 100, 100 being impossibly strong.
// This value controls progress bar colors:

View File

@ -77,10 +77,9 @@ function JobsListController ($rootScope, $log, $scope, $compile, $routeParams, C
case 'pending':
case 'waiting':
queued_scope.search('queued_job');
break;
case 'successful':
completed_scope.search('completed_job');
break;
case 'successful':
case 'failed':
case 'error':
case 'canceled':

View File

@ -79,7 +79,6 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location,
searchSize: 'col-lg-6 col-md-6'
});
$rootScope.flashMessage = null;
SearchInit({
scope: $scope,
@ -120,48 +119,40 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location,
$('.list-well:eq(1)').css('margin-top' , '0px');
});
// function processEvent(event) {
// switch(event.status) {
// case 'running':
// jobs_scope.search('running_job');
// jobs_scope.search('queued_job');
// break;
// case 'new':
// case 'pending':
// case 'waiting':
// jobs_scope.search('queued_job');
// break;
// case 'successful':
// jobs_scope.search('completed_job');
// case 'failed':
// case 'error':
// case 'canceled':
// jobs_scope.search('completed_job');
// jobs_scope.search('running_job');
// jobs_scope.search('queued_job');
// }
// }
function processEvent(event) {
switch(event.status) {
case 'running':
jobs_scope.search('portal_job');
// queued_scope.search('queued_job');
break;
case 'new':
case 'pending':
jobs_scope.search('portal_job');
break;
case 'waiting':
jobs_scope.search('portal_job');
// completed_scope.search('completed_job');
break;
case 'successful':
// // console.log('successful');
// running_scope.search('running_job');
// completed_scope.search('completed_job');
// break;
case 'failed':
case 'error':
case 'canceled':
jobs_scope.search('portal_job');
// running_scope.search('running_job');
// queued_scope.search('queued_job');
}
}
if ($rootScope.removeJobStatusChange) {
$rootScope.removeJobStatusChange();
}
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function() {
jobs_scope.refreshJobs();
// if(data.status==='pending'){
// // $scope.refresh();
// $('#portal-jobs').empty();
// // $rootScope.flashMessage = null;
// PortalJobsWidget({
// scope: $scope,
// target: 'portal-jobs',
// searchSize: 'col-lg-6 col-md-6'
// });
// }
//x`processEvent(data);
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function(e, event) {
// jobs_scope.search('portal_job');
processEvent(event);
});

View File

@ -53,7 +53,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
$('#password-modal').dialog('close');
}
scope.$emit(callback, data);
scope.$destroy();
// scope.$destroy();
})
.error(function(data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
@ -764,7 +764,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
}
scope.removePlaybookLaunchFinished = scope.$on('PlaybookLaunchFinished', function(e, data) {
//var base = $location.path().replace(/^\//, '').split('/')[0];
if(scope.portalMode===false ){
if(scope.portalMode===false || scope.$parent.portalMode===false ){
$location.path('/jobs/' + data.job);
}

View File

@ -405,6 +405,9 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
JobsControllerInit({ scope: scope, parent_scope: parent_scope });
JobsListUpdate({ scope: scope, parent_scope: parent_scope, list: list });
parent_scope.$emit('listLoaded');
// setTimeout(function(){
// scope.$apply();
// }, 300);
});
if (base === 'jobs' && list.name === 'completed_jobs') {

View File

@ -14,8 +14,8 @@
angular.module('PortalJobsListDefinition', [])
.value( 'PortalJobsList', {
name: 'jobs',
iterator: 'job',
name: 'portal_jobs',
iterator: 'portal_job',
editTitle: 'Jobs',
'class': 'table-condensed',
index: false,
@ -39,8 +39,8 @@ angular.module('PortalJobsListDefinition', [])
columnClass: 'col-lg-1 col-md-2 col-sm-2 col-xs-2',
// awToolTip: "{{ job.status_tip }}",
// awTipPlacement: "top",
dataTitle: "{{ job.status_popover_title }}",
icon: 'icon-job-{{ job.status }}',
dataTitle: "{{ portal_job.status_popover_title }}",
icon: 'icon-job-{{ portal_job.status }}',
iconOnly: true,
// ngClick:"viewJobLog(job.id)",
searchable: true,
@ -73,7 +73,7 @@ angular.module('PortalJobsListDefinition', [])
fieldActions: {
job_details: {
mode: 'all',
ngClick: "viewJobLog(job.id)",
ngClick: "viewJobLog(portal_job.id)",
awToolTip: 'View job details',
dataPlacement: 'top'
}

View File

@ -76,39 +76,11 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities'])
scope: jobs_scope,
list: PortalJobsList,
id: 'active-jobs',
url: GetBasePath('unified_jobs') + '?status__in=running,completed,failed,successful,error,canceled',
url: GetBasePath('jobs'), //+ '?type__in=job' , //&status__in=running,completed,failed,successful,error,canceled',
pageSize: max_rows,
spinner: true
});
// completed_scope.showJobType = true;
// LoadJobsScope({
// parent_scope: scope,
// scope: completed_scope,
// list: PortalJobsList,
// id: 'active-jobs',
// url: GetBasePath('unified_jobs') + '?or__status=successful&or__status=failed&or__status=error&or__status=canceled',
// // searchParams: search_params,
// pageSize: max_rows
// });
// LoadJobsScope({
// parent_scope: scope,
// scope: running_scope,
// list: PortalJobsList,
// id: 'active-jobs',
// url: GetBasePath('unified_jobs') + '?status=running',
// pageSize: max_rows
// });
// LoadJobsScope({
// parent_scope: scope,
// scope: queued_scope,
// list: PortalJobsList,
// id: 'active-jobs',
// url: GetBasePath('unified_jobs') + '?or__status=pending&or__status=waiting&or__status=new',
// pageSize: max_rows
// });
$(window).resize(_.debounce(function() {
resizePortalJobsWidget();

View File

@ -28,7 +28,6 @@ angular.module('SocketIO', ['AuthService', 'Utilities'])
endpoint = params.endpoint,
protocol = $location.protocol(),
config, socketPort,
// handshakeData,
url;
// Since some pages are opened in a new tab, we might get here before AnsibleConfig is available.