From 465518a2bc4a223229521ff73d4433367eabafbc Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Fri, 29 May 2015 13:32:34 -0400 Subject: [PATCH] made dashboard graphs live and fixed url checking of sockets --- awx/ui/static/js/app.js | 21 +++++++++++++-------- awx/ui/static/js/config.js | 2 +- awx/ui/static/js/controllers/Home.js | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 64e684fa11..c6be10ed8b 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -990,24 +990,29 @@ var tower = angular.module('Tower', [ ' status changed to ' + data.status + ' send to ' + $location.$$url); + var urlToCheck = $location.$$url; + if (urlToCheck.indexOf("?") !== -1) { + urlToCheck = urlToCheck.substr(0, urlToCheck.indexOf("?")); + } + // this acts as a router...it emits the proper // value based on what URL the user is currently // accessing. - if ($location.$$url === '/jobs') { + if (urlToCheck === '/jobs') { $rootScope.$emit('JobStatusChange-jobs', data); - } else if (/\/jobs\/(\d)+\/stdout/.test($location.$$url) || - /\/ad_hoc_commands\/(\d)+/.test($location.$$url)) { + } else if (/\/jobs\/(\d)+\/stdout/.test(urlToCheck) || + /\/ad_hoc_commands\/(\d)+/.test(urlToCheck)) { $log.debug("sending status to standard out"); $rootScope.$emit('JobStatusChange-jobStdout', data); - } else if (/\/jobs\/(\d)+/.test($location.$$url)) { + } else if (/\/jobs\/(\d)+/.test(urlToCheck)) { $rootScope.$emit('JobStatusChange-jobDetails', data); - } else if ($location.$$url === '/home') { + } else if (urlToCheck === '/home') { $rootScope.$emit('JobStatusChange-home', data); - } else if ($location.$$url === '/portal') { + } else if (urlToCheck === '/portal') { $rootScope.$emit('JobStatusChange-portal', data); - } else if ($location.$$url === '/projects') { + } else if (urlToCheck === '/projects') { $rootScope.$emit('JobStatusChange-projects', data); - } else if (/\/inventory\/(\d)+\/manage/.test($location.$$url)) { + } else if (/\/inventory\/(\d)+\/manage/.test(urlToCheck)) { $rootScope.$emit('JobStatusChange-inventory', data); } }); diff --git a/awx/ui/static/js/config.js b/awx/ui/static/js/config.js index 6c3a3d687e..879d379630 100644 --- a/awx/ui/static/js/config.js +++ b/awx/ui/static/js/config.js @@ -25,7 +25,7 @@ tooltip_delay: {show: 500, hide: 100}, // Default number of milliseconds to delay displaying/hiding tooltips - debug_mode: false, // Enable console logging messages + debug_mode: true, // Enable console logging messages password_length: 8, // Minimum user password length. Set to 0 to not set a limit password_hasLowercase: true, // require a lowercase letter in the password diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 5ed11aa665..c4af3b875a 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -33,6 +33,25 @@ export function Home($scope, $compile, $routeParams, $rootScope, $location, $log var dataCount = 0; + $rootScope.$on('JobStatusChange-home', function () { + Rest.setUrl(GetBasePath("jobs") + "?order_by=-finished&page_size=5&finished__isnull=false"); + Rest.get() + .success(function (data) { + $scope.dashboardJobsListData = data.results; + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); + }); + Rest.setUrl(GetBasePath("job_templates") + "?order_by=-last_job_run&page_size=5&last_job_run__isnull=false"); + Rest.get() + .success(function (data) { + $scope.dashboardJobTemplatesListData = data.results; + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard jobs list: ' + status }); + }); + }); + if ($scope.removeDashboardDataLoadComplete) { $scope.removeDashboardDataLoadComplete(); }