diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index a931113e1c..b2164f037b 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -26,7 +26,7 @@ * */ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, DashboardCounts, DashboardJobs, - ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button, graphData){ + ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button, $window, graphData){ ClearScope('home'); @@ -64,7 +64,7 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, e.html(html); $compile(e)($scope); - waitCount = 4; + waitCount = 3; loadedCount = 0; if (!$routeParams.login) { @@ -83,10 +83,12 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, } loadedCount++; if (loadedCount === waitCount) { - $(window).resize(_.debounce(function() { - Wait('stop'); - }, 500)); - $(window).resize(); + // console.log('binding to resize'); + // angular.element($window).on('resize', _.debounce(function() { + // console.log('resize from controller'); + // Wait('stop'); + // }, 500)); + // $(window).resize(); } }); @@ -170,7 +172,7 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, } Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', '$log','Wait', 'DashboardCounts', 'DashboardJobs', - 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button', 'graphData' + 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button', '$window', 'graphData' ]; diff --git a/awx/ui/static/js/directives/host-count-graph.js b/awx/ui/static/js/directives/host-count-graph.js index 599890eb74..7981c88c9a 100644 --- a/awx/ui/static/js/directives/host-count-graph.js +++ b/awx/ui/static/js/directives/host-count-graph.js @@ -12,10 +12,16 @@ angular.module('DashboardGraphs'). url = getBasePath('config'); - $window.addEventListener('resize', function() { + angular.element($window).on('resize', function(e) { + if(!license_graph) return; adjustGraphSize(license_graph, element); }); + element.on('$destroy', function() { + angular.element($window).off('resize', adjustGraphSize); + }); + + Rest.setUrl(url); Rest.get() .success(function (data){ diff --git a/awx/ui/static/js/directives/host-status-graph.js b/awx/ui/static/js/directives/host-status-graph.js index 4f1704194a..f9b5a95d2f 100644 --- a/awx/ui/static/js/directives/host-status-graph.js +++ b/awx/ui/static/js/directives/host-status-graph.js @@ -29,10 +29,10 @@ angular.module('DashboardGraphs') host_pie_chart.update(); } - $window.addEventListener('resize', adjustGraphSize); + angular.element($window).on('resize', adjustGraphSize); element.on('$destroy', function() { - $window.removeEventListener('resize', adjustGraphSize); + angular.element($window).off('resize', adjustGraphSize); }); function buildGraph(data) { diff --git a/awx/ui/static/js/directives/job-status-graph.js b/awx/ui/static/js/directives/job-status-graph.js index 9d9f5d1849..af6271bda7 100644 --- a/awx/ui/static/js/directives/job-status-graph.js +++ b/awx/ui/static/js/directives/job-status-graph.js @@ -36,10 +36,14 @@ angular.module('DashboardGraphs') var w = angular.element($window); - $window.addEventListener('resize', function() { + angular.element($window).on('resize', function() { adjustGraphSize(job_status_chart, element); }); + element.on('$destroy', function() { + angular.element($window).off('resize', adjustGraphSize); + }); + if (scope.removeGraphDataReady) { scope.removeGraphDataReady(); }