Added polling for campaign results - probably a waste since I'll move to d3 soon.

pull/24/head
unknown 2015-06-14 16:57:05 -05:00
parent e7a6a56584
commit 497fce25df
1 changed files with 19 additions and 7 deletions

View File

@ -11,9 +11,7 @@ app.controller('DashboardCtrl', function($scope, $filter, $location, CampaignSer
getData: function($defer, params) {
CampaignService.query(function(campaigns) {
$scope.campaigns = campaigns
var campaign_series = [];
var avg = 0;
angular.copy(campaigns, campaign_series)
angular.forEach(campaigns, function(campaign, key) {
campaign.x = new Date(campaign.created_date)
campaign.y = 0
@ -56,7 +54,6 @@ app.controller('DashboardCtrl', function($scope, $filter, $location, CampaignSer
},
xAxis: {
type: 'datetime',
max: Date.now(),
title: {
text: 'Date'
}
@ -271,7 +268,7 @@ var CampaignModalCtrl = function($scope, CampaignService, $modalInstance) {
}
};
app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService, GroupService, ngTableParams, $http, $window) {
app.controller('CampaignResultsCtrl', function($scope, $filter, $interval, CampaignService, GroupService, ngTableParams, $http, $window) {
id = $window.location.hash.split('/')[2];
$scope.errorFlash = function(message) {
$scope.flashes = {"main" : [], "modal" : []};
@ -356,12 +353,14 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
},
plotOptions: {
pie: {
innerSize: '60%',
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
showInLegend: true,
animation:false
}
}
},
@ -423,7 +422,6 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
second: '%l:%M:%S',
minute: '%l:%M'
},
max: Date.now(),
title: {
text: 'Date'
}
@ -431,7 +429,14 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
},
series: [{
name: "Events",
data: $scope.campaign.timeline
data: $scope.campaign.timeline,
marker: {
enabled: true,
radius: 3,
symbol: "circle",
fillColor: "#7cb5ec"
},
animation: false
}],
title: {
text: 'Campaign Timeline'
@ -449,6 +454,13 @@ app.controller('CampaignResultsCtrl', function($scope, $filter, CampaignService,
})
}
});
var promise = $interval($scope.mainTableParams.reload, 10000);
$scope.$on('$destroy', function(){
if (angular.isDefined(promise)) {
$interval.cancel(promise);
promise = undefined;
}
});
})
app.controller('GroupCtrl', function($scope, $modal, GroupService, ngTableParams) {