diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index cd85f44f36..612d5dbfc6 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -10,7 +10,7 @@ 'use strict'; -function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, DashboardCounts, HostGraph, JobStatusGraph, DashboardJobs, +function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, DashboardCounts, HostGraph, JobStatusGraph, HostPieChart, DashboardJobs, ClearScope, Stream, Rest, GetBasePath, ProcessErrors, Button){ ClearScope('home'); @@ -96,6 +96,11 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb target: 'container4', dashboard: data }); + HostPieChart({ + scope: $scope, + target: 'container5', + dashboard: data + }); }); $scope.showActivity = function () { @@ -122,7 +127,7 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, Wait, Dashb } -Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', 'Wait', 'DashboardCounts', 'HostGraph','JobStatusGraph', 'DashboardJobs', +Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location', 'Wait', 'DashboardCounts', 'HostGraph','JobStatusGraph', 'HostPieChart', 'DashboardJobs', 'ClearScope', 'Stream', 'Rest', 'GetBasePath', 'ProcessErrors', 'Button' ]; diff --git a/awx/ui/static/js/widgets/DashboardCounts.js b/awx/ui/static/js/widgets/DashboardCounts.js index a151d32e06..6b070e2f5e 100644 --- a/awx/ui/static/js/widgets/DashboardCounts.js +++ b/awx/ui/static/js/widgets/DashboardCounts.js @@ -50,9 +50,9 @@ angular.module('DashboardCountsWidget', ['RestServices', 'Utilities']) html += "
" + dashboard.hosts.total+"
Hosts
\n"; html += "
"+dashboard.hosts.failed+"
Failed Hosts
\n"; html += "
"+dashboard.inventories.total+"
Inventories
\n"; - html += "
"+dashboard.inventories.inventory_failed+"
Inventory Sync Failure
\n"; + html += "
"+dashboard.inventories.inventory_failed+"
Inventory Sync Failures
\n"; html += "
"+dashboard.projects.total+"
Projects
\n"; - html += "
"+dashboard.projects.failed+"
Project Sync Failure
\n"; + html += "
"+dashboard.projects.failed+"
Project Sync Failures
\n"; // html += "
"+dashboard.users.total+"
\n"; html += "\n"; diff --git a/awx/ui/static/js/widgets/HostGraph.js b/awx/ui/static/js/widgets/HostGraph.js index 61931d3e01..b8b4f2bace 100644 --- a/awx/ui/static/js/widgets/HostGraph.js +++ b/awx/ui/static/js/widgets/HostGraph.js @@ -21,7 +21,7 @@ angular.module('HostGraphWidget', ['RestServices', 'Utilities']) html = "
\n"; html +="
\n"; - html += "
Hosts vs License Agreement
\n"; + html += "
Hosts Count
\n"; html += "
\n"; html += "
\n"; html += "
\n"; diff --git a/awx/ui/static/js/widgets/HostPieChart.js b/awx/ui/static/js/widgets/HostPieChart.js index 3727b12650..8fdbc96dc7 100644 --- a/awx/ui/static/js/widgets/HostPieChart.js +++ b/awx/ui/static/js/widgets/HostPieChart.js @@ -16,199 +16,93 @@ angular.module('HostPieChartWidget', ['RestServices', 'Utilities']) var scope = params.scope, target = params.target, - // dashboard = params.dashboard, - html, element, url, - period="month", - job_type="all"; + dashboard = params.dashboard, + html, element, url; html = "
\n"; html +="
\n"; html += "
Host Status
\n"; - + html += "
\n"; // html += "
\n"; // html += "
\n"; // html += "\n"; - // html += "Job Type\n"; + // html += "Filter\n"; // html += " \n"; // html += "\n"; // html += "
\n"; // html += "
\n"; //end of filter div - // html += "
\n"; - // html += "
\n"; - // html += "\n"; - // html += "Period\n"; - // html += " \n"; - // html += "\n"; - // html += "
\n"; - // html += "
\n"; //end of filter div - - // html += "
\n"; // end of row html +="
\n"; - html += "
\n"; + html += "
\n"; html += "
\n"; - // function success(){ - // alert('success'); - // } - // // - // // html += "\n"; + html += "\n"; - // html += "\n"; + function exampleData() { + return [ + { + "label": "Successful", + "value" : dashboard.hosts.total + } , + { + "label": "Failed", + "value" : dashboard.hosts.failed + } + ]; + + } - // function createGraph(){ - // url = GetBasePath('dashboard')+'graphs/?period='+period+'&type='+job_type; - // Rest.setUrl(url); - // Rest.get() - // .success(function (data){ - // scope.$emit('graphDataReady', data); - // return job_type, period; - // }) - // .error(function (data, status) { - // ProcessErrors(scope, data, status, null, { hdr: 'Error!', - // msg: 'Failed to get: ' + url + ' GET returned: ' + status }); - // }); - // } element = angular.element(document.getElementById(target)); element.html(html); $compile(element)(scope); - // createGraph(); + url = GetBasePath('dashboard')+'graphs/inventory/'; + Rest.setUrl(url); + Rest.get() + .success(function (data){ + scope.$emit('createHostPieChart', data.inventory); - // if (scope.removeGraphDataReady) { - // scope.removeGraphDataReady(); - // } - // scope.removeGraphDataReady = scope.$on('graphDataReady', function (e, data) { - // var timeFormat, graphData = [ - // { - // "color": "#1778c3", - // "key": "Successful", - // "values": data.jobs.successful - // }, - // { - // "key" : "Failed" , - // "color" : "#aa0000", - // "values": data.jobs.failed - // } - // ]; + }) + .error(function (data, status) { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed to get: ' + url + ' GET returned: ' + status }); + }); - // if(period==="day"){ - // timeFormat="%H:%M"; - // } - // else { - // timeFormat = '%m/%d'; - // } - // graphData.map(function(series) { - // series.values = series.values.map(function(d) { - // return { - // x: d[0], - // y: d[1] - // }; - // }); - // return series; - // }); - - // nv.addGraph({ - // generate: function() { - // var width = nv.utils.windowSize().width/3, - // height = nv.utils.windowSize().height/5, - // chart = nv.models.lineChart() - // .margin({top: 5, right: 75, bottom: 40, left: 85}) //Adjust chart margins to give the x-axis some breathing room. - // .x(function(d,i) { return i; }) - // .useInteractiveGuideline(true) //We want nice looking tooltips and a guideline! - // .transitionDuration(350) //how fast do you want the lines to transition? - // .showLegend(true) //Show the legend, allowing users to turn on/off line series. - // .showYAxis(true) //Show the y-axis - // .showXAxis(true) //Show the x-axis - // // .width(width) - // // .height(height) - // ; - - // chart.xAxis - // .axisLabel("Time").showMaxMin(true) - // .tickFormat(function(d) { - // var dx = graphData[0].values[d] && graphData[0].values[d].x || 0; - // return dx ? d3.time.format(timeFormat)(new Date(Number(dx+'000'))) : ''; - // }); - - // chart.yAxis //Chart y-axis settings - // .axisLabel('Jobs') - // .tickFormat(d3.format('.f')); - - // // d3.select('.job-status-graph svg') - // // .attr('width', width) - // // .attr('height', height) - // // .datum(data) - // // .call(chart); - - // d3.select('.job-status-graph svg') - // .datum(graphData).transition() - // .attr('width', width) - // .attr('height', height) - // .duration(500) - // .call(chart) - // .style({ - // // 'width': width, - // // 'height': height, - // "font-family": 'Open Sans', - // "font-style": "normal", - // "font-weight":400, - // "src": "url(/static/fonts/OpenSans-Regular.ttf)" - // }); - - - // nv.utils.windowResize(chart.update); - - - // //On click, update with new data - // d3.selectAll(".n") - // .on("click", function() { - // period = this.getAttribute("id"); - // // console.log(period); - // var title = $('#job-status-title').text(), - // str = title.slice(0,title.search(","))+", "+this.innerHTML; - // $('#job-status-title').html(""+str+" "); - // createGraph(); - // }); - - // //On click, update with new data - // d3.selectAll(".m") - // .on("click", function() { - // job_type = this.getAttribute("id"); - // //console.log(job_type); - // var title = $('#job-status-title').text(), - // str = title.slice(title.search(",")); - // $('#job-status-title').html("Job Status for "+this.innerHTML+" Jobs"+str+" "); - // createGraph(); - // }); - - scope.$emit('WidgetLoaded'); - // return chart; - - // }, - - // }); - - // }); + if (scope.removeCreateHostPieChart) { + scope.removeCreateHostPieChart(); + } + scope.removeCreateHostPieChart = scope.$on('createHostPieChart', function (e, data) { + data = exampleData(); + nv.addGraph(function() { + var width = nv.utils.windowSize().width/3, + height = nv.utils.windowSize().height/5, + chart = nv.models.pieChart() + .x(function(d) { return d.label; }) + .y(function(d) { return d.value; }) + .showLabels(true); + d3.select(".host-pie-chart svg") + .datum(data) + .attr('width', width) + .attr('height', height) + .transition().duration(350) + .call(chart); + nv.utils.windowResize(chart.update); + return chart; + }); + }); }; } - ]); \ No newline at end of file + ]); diff --git a/awx/ui/static/js/widgets/JobStatusGraph.js b/awx/ui/static/js/widgets/JobStatusGraph.js index e3d89704ad..80f9a602ca 100644 --- a/awx/ui/static/js/widgets/JobStatusGraph.js +++ b/awx/ui/static/js/widgets/JobStatusGraph.js @@ -62,12 +62,6 @@ angular.module('JobStatusGraphWidget', ['RestServices', 'Utilities']) html += "
\n"; html += "\n"; - function success(){ - alert('success'); - } - // - // html += "\n"; - html += "\n"; function createGraph(){ diff --git a/awx/ui/static/partials/home.html b/awx/ui/static/partials/home.html index d97590eb8b..29776d0a93 100644 --- a/awx/ui/static/partials/home.html +++ b/awx/ui/static/partials/home.html @@ -13,10 +13,11 @@
-
+
+
diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 57e900357f..082bcb774a 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -164,7 +164,7 @@ - +