Fix filtering job status graph

This commit is contained in:
Joe Fiorini
2015-03-04 14:16:58 -05:00
parent f8c3fd11da
commit 92e643d60d

View File

@@ -9,7 +9,7 @@ export default
JobStatusGraph JobStatusGraph
]; ];
function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustGraphSize) { function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustGraphSize, graphDataService) {
return { return {
restrict: 'E', restrict: 'E',
scope: { scope: {
@@ -27,12 +27,20 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG
scope.$watch('data', function(value) { scope.$watch('data', function(value) {
if (value) { if (value) {
createGraph(value, scope.period, scope.jobType); createGraph(scope.period, scope.jobType, value);
} }
}, true); }, true);
function recreateGraph(period, jobType) {
graphDataService.get(period, jobType)
.then(function(data) {
scope.data = data;
scope.period = period;
scope.jobType = jobType;
});
}
function createGraph(data, period, jobtype){ function createGraph(period, jobtype, data){
scope.period = period; scope.period = period;
scope.jobType = jobtype; scope.jobType = jobtype;
@@ -100,7 +108,7 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG
period = this.getAttribute("id"); period = this.getAttribute("id");
$('#period-dropdown').replaceWith("<a id=\"period-dropdown\" role=\"button\" data-toggle=\"dropdown\" data-target=\"#\" href=\"/page.html\">"+this.text+"<span class=\"caret\"><span>\n"); $('#period-dropdown').replaceWith("<a id=\"period-dropdown\" role=\"button\" data-toggle=\"dropdown\" data-target=\"#\" href=\"/page.html\">"+this.text+"<span class=\"caret\"><span>\n");
createGraph(data, period, job_type); recreateGraph(period, job_type);
}); });
//On click, update with new data //On click, update with new data
@@ -109,7 +117,7 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG
job_type = this.getAttribute("id"); job_type = this.getAttribute("id");
$('#type-dropdown').replaceWith("<a id=\"type-dropdown\" role=\"button\" data-toggle=\"dropdown\" data-target=\"#\" href=\"/page.html\">"+this.text+"<span class=\"caret\"><span>\n"); $('#type-dropdown').replaceWith("<a id=\"type-dropdown\" role=\"button\" data-toggle=\"dropdown\" data-target=\"#\" href=\"/page.html\">"+this.text+"<span class=\"caret\"><span>\n");
createGraph(data, period, job_type); recreateGraph(period, job_type);
}); });
adjustGraphSize(job_status_chart, element); adjustGraphSize(job_status_chart, element);