mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 00:57:48 -02:30
Fix errors resizing job status graph
This commit is contained in:
@@ -8,48 +8,26 @@ angular.module('DashboardGraphs')
|
|||||||
};
|
};
|
||||||
|
|
||||||
function link(scope, element, attr) {
|
function link(scope, element, attr) {
|
||||||
var html, url, job_status_chart,
|
var html;
|
||||||
period="month",
|
var url;
|
||||||
job_type="all";
|
var job_status_chart;
|
||||||
|
var job_status_chart;
|
||||||
var cleanup = angular.noop;
|
var cleanup = angular.noop;
|
||||||
|
|
||||||
|
scope.period="month";
|
||||||
|
scope.jobType="all";
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
scope.$watch(attr.data, function(value) {
|
scope.$watch(attr.data, function(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
scope.$emit('graphDataReady', value);
|
createGraph(value, scope.period, scope.jobType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on('$destroy', cleanup);
|
function createGraph(data, period, jobtype){
|
||||||
|
|
||||||
cleanup = _.compose(
|
scope.period = period;
|
||||||
[ cleanup,
|
scope.jobType = jobtype;
|
||||||
]);
|
|
||||||
|
|
||||||
function createGraph(period, jobtype){
|
|
||||||
jobStatusGraphData.get(period, jobtype).then(function(data) {
|
|
||||||
scope.$emit('graphDataReady', data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var w = angular.element($window);
|
|
||||||
|
|
||||||
|
|
||||||
angular.element($window).on('resize', function() {
|
|
||||||
adjustGraphSize(job_status_chart, element);
|
|
||||||
});
|
|
||||||
|
|
||||||
element.on('$destroy', function() {
|
|
||||||
angular.element($window).off('resize', adjustGraphSize);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (scope.removeGraphDataReady) {
|
|
||||||
scope.removeGraphDataReady();
|
|
||||||
}
|
|
||||||
|
|
||||||
var job_status_chart;
|
|
||||||
scope.removeGraphDataReady = scope.$on('graphDataReady', function (e, data) {
|
|
||||||
|
|
||||||
var timeFormat, graphData = [
|
var timeFormat, graphData = [
|
||||||
{
|
{
|
||||||
@@ -127,7 +105,7 @@ angular.module('DashboardGraphs')
|
|||||||
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(period, job_type);
|
createGraph(data, period, job_type);
|
||||||
});
|
});
|
||||||
|
|
||||||
//On click, update with new data
|
//On click, update with new data
|
||||||
@@ -136,11 +114,30 @@ angular.module('DashboardGraphs')
|
|||||||
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(period, job_type);
|
createGraph(data, period, job_type);
|
||||||
});
|
});
|
||||||
|
|
||||||
adjustGraphSize(job_status_chart, element);
|
adjustGraphSize(job_status_chart, element);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var w = angular.element($window);
|
||||||
|
|
||||||
|
|
||||||
|
angular.element($window).on('resize', function() {
|
||||||
|
adjustGraphSize(job_status_chart, element);
|
||||||
|
});
|
||||||
|
|
||||||
|
element.on('$destroy', function() {
|
||||||
|
angular.element($window).off('resize', adjustGraphSize);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scope.removeGraphDataReady) {
|
||||||
|
scope.removeGraphDataReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.removeGraphDataReady = scope.$on('graphDataReady', function (e, data) {
|
||||||
|
|
||||||
return job_status_chart;
|
return job_status_chart;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user