fixed auth error introduced by earlier changes to dashboard

This commit is contained in:
Jared Tabor
2014-07-03 15:22:29 -04:00
parent d34bf8675d
commit 90423db9b7
2 changed files with 57 additions and 17 deletions

View File

@@ -36,7 +36,7 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities'])
//$scope.$emit('dashboardReady', data); //$scope.$emit('dashboardReady', data);
// console.log(data); // console.log(data);
license = data.license_info.available_instances; license = data.license_info.available_instances;
makeHostCountGraph(license); createGraph(license);
}) })
.error(function (data, status) { .error(function (data, status) {
@@ -47,15 +47,33 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities'])
//return license; //return license;
} }
function createGraph(license){
Rest.setUrl(GetBasePath('dashboard')+'graphs/');
Rest.get()
.success(function (data) {
//$scope.$emit('dashboardReady', data);
// console.log(data);
//license = data.license_info.available_instances;
function makeHostCountGraph(license){ makeHostCountGraph(license, data);
})
.error(function (data, status) {
//Wait('stWaitop');
ProcessErrors(null, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard graph data: ' + status });
});
//return license;
}
function makeHostCountGraph(license, data){
url = GetBasePath('dashboard')+'graphs/'; url = GetBasePath('dashboard')+'graphs/';
var graphData = []; var graphData = [];
//d3.json("static/js/jobstatusdata.json",function(error,data) { //d3.json("static/js/jobstatusdata.json",function(error,data) {
d3.json(url, function(error,data) { //d3.json(url, function(error,data) {
graphData = [ graphData = [
{ {
"key" : "Hosts" , "key" : "Hosts" ,
"color" : "#1778c3", "color" : "#1778c3",
@@ -68,7 +86,7 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities'])
} }
]; ];
graphData.map(function(series) { graphData.map(function(series) {
if(series.key==="Hosts"){ if(series.key==="Hosts"){
series.values = series.values.map(function(d) { series.values = series.values.map(function(d) {
return { return {
@@ -90,7 +108,7 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities'])
}); });
nv.addGraph({ nv.addGraph({
generate: function() { generate: function() {
var width = nv.utils.windowSize().width/3, var width = nv.utils.windowSize().width/3,
height = nv.utils.windowSize().height/5, height = nv.utils.windowSize().height/5,
@@ -139,7 +157,7 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities'])
}, },
}); });
}); //});
} }
element = angular.element(document.getElementById(target)); element = angular.element(document.getElementById(target));

View File

@@ -11,7 +11,7 @@
angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities']) angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
.factory('JobStatusGraph', ['$rootScope', '$compile', '$location' , 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', .factory('JobStatusGraph', ['$rootScope', '$compile', '$location' , 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait',
function ($rootScope, $compile , $location, Rest, GetBasePath) { function ($rootScope, $compile , $location, Rest, GetBasePath, ProcessErrors) {
return function (params) { return function (params) {
var scope = params.scope, var scope = params.scope,
@@ -47,7 +47,7 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
html += " </a>\n"; html += " </a>\n";
html += "<ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\">\n"; html += "<ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\">\n";
html += "<li><a href=\"#\">Past Day</a></li>\n"; html += "<li><a href=\"#\">Past 24 Hours</a></li>\n";
html += "<li><a href=\"#\">Past Week</a></li>\n"; html += "<li><a href=\"#\">Past Week</a></li>\n";
html += "<li><a href=\"#\">Past Month</a></li>\n"; html += "<li><a href=\"#\">Past Month</a></li>\n";
html += "</ul>\n"; html += "</ul>\n";
@@ -65,15 +65,36 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
html += "</div>\n"; html += "</div>\n";
function createGraph(){
url = GetBasePath('dashboard')+'graphs/';
Rest.setUrl(url);
Rest.get()
.success(function (data) {
//$scope.$emit('dashboardReady', data);
// console.log(data);
// license = data.license_info.available_instances;
makeJobStatusGraph(data);
})
.error(function (data, status) {
//Wait('stWaitop');
ProcessErrors(null, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard graph data: ' + status });
});
//return license;
}
//function makeHostCountGraph(license){
function makeJobStatusGraph(data){
function makeJobStatusGraph(){
url = GetBasePath('dashboard')+'graphs/';
var graphData = []; var graphData = [];
//d3.json("static/js/jobstatusdata.json",function(error,data) { //d3.json("static/js/jobstatusdata.json",function(error,data) {
d3.json(url, function(error,data) { // d3.json(url, function(error,data) {
//console.log(data); //console.log(data);
graphData = [ graphData = [
{ {
"color": "#1778c3", "color": "#1778c3",
"key": "Successful", "key": "Successful",
@@ -86,7 +107,7 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
} }
]; ];
graphData.map(function(series) { graphData.map(function(series) {
series.values = series.values.map(function(d) { series.values = series.values.map(function(d) {
return { return {
x: d[0], x: d[0],
@@ -96,7 +117,7 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
return series; return series;
}); });
nv.addGraph({ nv.addGraph({
generate: function() { generate: function() {
var width = nv.utils.windowSize().width/3, var width = nv.utils.windowSize().width/3,
height = nv.utils.windowSize().height/5, height = nv.utils.windowSize().height/5,
@@ -150,14 +171,15 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities'])
}, },
}); });
}); // });
} }
element = angular.element(document.getElementById(target)); element = angular.element(document.getElementById(target));
element.html(html); element.html(html);
$compile(element)(scope); $compile(element)(scope);
makeJobStatusGraph(); createGraph();
//makeJobStatusGraph();
scope.$emit('WidgetLoaded'); scope.$emit('WidgetLoaded');
}; };