1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

added websockets to dashboard

This commit is contained in:
Jared Tabor 2014-08-29 16:48:22 -04:00
parent c020e38a4a
commit 8d15d0ade7
7 changed files with 39 additions and 69 deletions

View File

@ -587,6 +587,10 @@ angular.module('Tower', [
$log.debug('Job summary_complete ' + data.unified_job_id);
$rootScope.$emit('JobSummaryComplete', data);
});
sock.on("schedule_change", function(data) {
$log.debug('schedule changed to ' + data.status);
$rootScope.$emit('ScheduleChange', data);
});
}
openSocket();

View File

@ -25,12 +25,12 @@
* Host count graph should only be loaded if the user is a super user
*
*/
function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, DashboardCounts, HostGraph, JobStatusGraph, HostPieChart, DashboardJobs,
function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, DashboardCounts, HostGraph, JobStatusGraph, HostPieChart, DashboardJobs,
ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button){
ClearScope('home');
var buttons, html, e, waitCount, loadedCount,borderStyles;
var buttons, html, e, waitCount, loadedCount,borderStyles, jobs_scope, schedule_scope;
// Add buttons to the top of the Home page. We're using lib/ansible/generator_helpers.js-> Buttons()
// to build buttons dynamically and insure all styling and icons match the rest of the application.
@ -77,8 +77,12 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb
if ($scope.removeWidgetLoaded) {
$scope.removeWidgetLoaded();
}
$scope.removeWidgetLoaded = $scope.$on('WidgetLoaded', function () {
$scope.removeWidgetLoaded = $scope.$on('WidgetLoaded', function (e, label, jobscope, schedulescope) {
// Once all the widgets report back 'loaded', turn off Wait widget
if(label==="dashboard_jobs"){
jobs_scope = jobscope;
schedule_scope = schedulescope;
}
loadedCount++;
if (loadedCount === waitCount) {
$(window).resize(_.debounce(function() {
@ -92,8 +96,6 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb
}
});
if ($scope.removeDashboardReady) {
$scope.removeDashboardReady();
}
@ -135,8 +137,6 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb
else{
$('#dash-host-count-graph').remove(); //replaceWith("<div id='dash-host-count-graph' class='left-side col-sm-12 col-xs-12'></div>");
}
DashboardJobs({
scope: $scope,
target: 'dash-jobs-list',
@ -150,6 +150,23 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb
});
if ($rootScope.removeJobStatusChange) {
$rootScope.removeJobStatusChange();
}
$rootScope.removeJobStatusChange = $rootScope.$on('JobStatusChange', function() {
jobs_scope.refreshJobs();
$scope.$emit('ReloadJobStatusGraph');
});
if ($rootScope.removeScheduleChange) {
$rootScope.removeScheduleChange();
}
$rootScope.removeScheduleChange = $rootScope.$on('ScheduleChange', function() {
schedule_scope.refreshSchedules();
$scope.$emit('ReloadJobStatusGraph');
});
$scope.showActivity = function () {
Stream({
scope: $scope
@ -174,7 +191,7 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb
}
Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', 'Wait', 'DashboardCounts', 'HostGraph','JobStatusGraph', 'HostPieChart', 'DashboardJobs',
Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', '$log','Wait', 'DashboardCounts', 'HostGraph','JobStatusGraph', 'HostPieChart', 'DashboardJobs',
'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button'
];

View File

@ -1,28 +0,0 @@
[
{
"key" : "Hosts" ,
"color" : "#1778c3",
"values" : [
[1340755200000 , 2] , [1340762400000 , 4] ,
[1340769600000 , 8] , [1340776800000 , 16] ,
[1340784000000 , 32] , [1340791200000 , 64] ,
[1340798400000 , 128] , [1340805600000 , 150] ,
[1340812800000 , 175] , [1340820000000 , 180] ,
[1340827200000 , 190] , [1340834400000 , 195] ,
[1343347200000 , 195]
]
},
{
"key" : "License" ,
"color" : "#171717",
"values" : [
[1340755200000 , 500] , [1340762400000 , 500] ,
[1340769600000 , 500] , [1340776800000 , 500] ,
[1340784000000 , 500] , [1340791200000 , 500] ,
[1340798400000 , 500] , [1340805600000 , 500] ,
[1340812800000 , 500] , [1340820000000 , 500] ,
[1340827200000 , 500] , [1340834400000 , 500] ,
[1343347200000 , 500]
]
}
]

View File

@ -1,30 +0,0 @@
[
{
"key" : "Successful" ,
"color" : "#1778c3",
"values" : [
[1340755200000 , 100] , [1340762400000 , 101] ,
[1340769600000 , 102] , [1340776800000 , 103] ,
[1340784000000 , 103] , [1340791200000 , 103] ,
[1340798400000 , 103] , [1340805600000 , 103] ,
[1340812800000 , 103] , [1340820000000 , 103] ,
[1340827200000 , 103] , [1340834400000 , 103] ,
[1343347200000 , 103]
]
},
{
"key" : "Failed" ,
"color" : "#aa0000",
"values" : [
[1340755200000 , 50] , [1340762400000 , 50] ,
[1340769600000 , 50] , [1340776800000 , 50] ,
[1340784000000 , 50] , [1340791200000 , 50] ,
[1340798400000 , 50] , [1340805600000 , 50] ,
[1340812800000 , 50] , [1340820000000 , 50] ,
[1340827200000 , 50] , [1340834400000 , 50] ,
[1343347200000 , 50]
]
}
]

View File

@ -55,7 +55,7 @@ angular.module('DashboardJobsWidget', ['RestServices', 'Utilities'])
listCount++;
if (listCount === 1) {
//api_complete = true;
scope.$emit('WidgetLoaded');
scope.$emit('WidgetLoaded', "dashboard_jobs", jobs_scope, scheduled_scope);
}
});

View File

@ -81,6 +81,13 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
});
}
if ($rootScope.removeReloadJobStatusGraph) {
$rootScope.removeReloadJobStatusGraph();
}
$rootScope.removeReloadJobStatusGraph = $rootScope.$on('ReloadJobStatusGraph', function() {
createGraph();
});
element = angular.element(document.getElementById(target));
element.html(html);
$compile(element)(scope);