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