Skip to content

Commit cf9e5e9

Browse files
author
OpenShift Bot
committed
Merge pull request #7364 from spadgett/chart-timeout
Merged by openshift-bot
2 parents d57be27 + 9c2ad25 commit cf9e5e9

File tree

2 files changed

+57
-52
lines changed

2 files changed

+57
-52
lines changed

assets/app/scripts/directives/buildTrendsChart.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

33
angular.module('openshiftConsole')
4-
.directive('buildTrendsChart', function($filter, $location, $rootScope) {
4+
.directive('buildTrendsChart', function($filter, $location, $rootScope, $timeout) {
55
return {
66
restrict: 'E',
77
scope: {
@@ -268,7 +268,12 @@ angular.module('openshiftConsole')
268268

269269
if (!chart) {
270270
config.data = angular.extend(data, config.data);
271-
chart = c3.generate(config);
271+
// Allow the rest of the page to load so c3 calculates the correct
272+
// width for the chart based on the parent width.
273+
$timeout(function() {
274+
chart = c3.generate(config);
275+
updateAvgLine();
276+
});
272277
} else {
273278
data.unload = unload;
274279
// Call flush to work around a c3.js bug where the y-axis label
@@ -281,10 +286,8 @@ angular.module('openshiftConsole')
281286
}, animationDuration() + 25);
282287
};
283288
chart.load(data);
289+
updateAvgLine();
284290
}
285-
286-
// Update average line.
287-
updateAvgLine();
288291
};
289292

290293
$scope.$watch(numCompleteBuilds, update);

pkg/assets/bindata.go

+49-47
Original file line numberDiff line numberDiff line change
@@ -6645,23 +6645,23 @@ j ? j.load(d) :(_.assign(k.data, d), j = c3.generate(k));
66456645
c.$watchGroup([ "used", "total" ], _.debounce(l, 300));
66466646
}
66476647
};
6648-
} ]), angular.module("openshiftConsole").directive("buildTrendsChart", [ "$filter", "$location", "$rootScope", function(a, b, c) {
6648+
} ]), angular.module("openshiftConsole").directive("buildTrendsChart", [ "$filter", "$location", "$rootScope", "$timeout", function(a, b, c, d) {
66496649
return {
66506650
restrict:"E",
66516651
scope:{
66526652
builds:"="
66536653
},
66546654
templateUrl:"views/_build-trends-chart.html",
6655-
link:function(d) {
6656-
var e, f = [ "Complete", "Failed", "Cancelled", "Error" ], g = function(a) {
6655+
link:function(e) {
6656+
var f, g = [ "Complete", "Failed", "Cancelled", "Error" ], h = function(a) {
66576657
var b = [], c = moment.duration(a), d = Math.floor(c.asHours()), e = c.minutes(), f = c.seconds();
66586658
return d || e || f ? (d && b.push(d + "h"), e && b.push(e + "m"), d || b.push(f + "s"), b.join(" ")) :"";
6659-
}, h = function(a) {
6659+
}, i = function(a) {
66606660
return a.status.startTimestamp || a.metadata.creationTimestamp;
66616661
};
6662-
d.chartID = _.uniqueId("build-trends-chart-");
6663-
var i, j, k = _.constant(350), l = {
6664-
bindto:"#" + d.chartID,
6662+
e.chartID = _.uniqueId("build-trends-chart-");
6663+
var j, k, l = _.constant(350), m = {
6664+
bindto:"#" + e.chartID,
66656665
padding:{
66666666
right:30,
66676667
left:80
@@ -6694,7 +6694,7 @@ tick:{
66946694
count:5,
66956695
culling:!0,
66966696
fit:!0,
6697-
format:g
6697+
format:h
66986698
}
66996699
}
67006700
},
@@ -6714,13 +6714,13 @@ height:200
67146714
tooltip:{
67156715
format:{
67166716
title:function(a) {
6717-
var b = e[a], c = h(b);
6717+
var b = f[a], c = i(b);
67186718
return "#" + a + " (" + moment(c).fromNow() + ")";
67196719
}
67206720
}
67216721
},
67226722
transition:{
6723-
duration:k()
6723+
duration:l()
67246724
},
67256725
data:{
67266726
colors:{
@@ -6735,7 +6735,7 @@ text:"No Completed Builds"
67356735
}
67366736
},
67376737
onclick:function(d) {
6738-
var f = e[d.x], g = a("navigateResourceURL")(f);
6738+
var e = f[d.x], g = a("navigateResourceURL")(e);
67396739
g && c.$apply(function() {
67406740
b.path(g);
67416741
});
@@ -6745,66 +6745,68 @@ enabled:!0
67456745
},
67466746
type:"bar"
67476747
}
6748-
}, m = function() {
6749-
d.completeBuilds = [];
6748+
}, n = function() {
6749+
e.completeBuilds = [];
67506750
var b = a("isIncompleteBuild");
6751-
angular.forEach(d.builds, function(a) {
6752-
b(a) || d.completeBuilds.push(a);
6751+
angular.forEach(e.builds, function(a) {
6752+
b(a) || e.completeBuilds.push(a);
67536753
});
6754-
}, n = function() {
6755-
return m(), d.completeBuilds.length;
6756-
}, o = a("annotation"), p = function(a) {
6757-
var b = o(a, "buildNumber") || parseInt(a.metadata.name.match(/(\d+)$/), 10);
6754+
}, o = function() {
6755+
return n(), e.completeBuilds.length;
6756+
}, p = a("annotation"), q = function(a) {
6757+
var b = p(a, "buildNumber") || parseInt(a.metadata.name.match(/(\d+)$/), 10);
67586758
return isNaN(b) ? null :b;
6759-
}, q = function(a) {
6760-
var b = h(a), c = a.status.completionTimestamp;
6759+
}, r = function(a) {
6760+
var b = i(a), c = a.status.completionTimestamp;
67616761
return b && c ? moment(c).diff(moment(b)) :0;
6762-
}, r = !1, s = function() {
6763-
j && r ? i.ygrids([ {
6764-
value:j,
6762+
}, s = !1, t = function() {
6763+
k && s ? j.ygrids([ {
6764+
value:k,
67656765
"class":"build-trends-avg-line"
6766-
} ]) :i.ygrids.remove();
6766+
} ]) :j.ygrids.remove();
67676767
};
6768-
d.toggleAvgLine = function() {
6769-
r = !r, s();
6768+
e.toggleAvgLine = function() {
6769+
s = !s, t();
67706770
};
6771-
var t = function() {
6772-
e = {};
6771+
var u = function() {
6772+
f = {};
67736773
var a = {
67746774
json:[],
67756775
keys:{
67766776
x:"buildNumber"
67776777
}
67786778
}, b = 0, c = 0;
6779-
angular.forEach(d.completeBuilds, function(d) {
6780-
var f = p(d);
6781-
if (f) {
6782-
var g = q(d);
6779+
angular.forEach(e.completeBuilds, function(d) {
6780+
var e = q(d);
6781+
if (e) {
6782+
var g = r(d);
67836783
b += g, c++;
67846784
var h = {
6785-
buildNumber:f,
6785+
buildNumber:e,
67866786
phase:d.status.phase
67876787
};
6788-
h[d.status.phase] = g, a.json.push(h), e[f] = d;
6788+
h[d.status.phase] = g, a.json.push(h), f[e] = d;
67896789
}
67906790
}), a.json.length > 50 && (a.json.sort(function(a, b) {
67916791
return a.buildNumber - b.buildNumber;
67926792
}), a.json = a.json.slice(a.json.length - 50));
6793-
var h = {};
6793+
var i = {};
67946794
angular.forEach(a.json, function(a) {
6795-
h[a.phase] = !0;
6796-
}), c ? (j = b / c, d.averageDurationText = g(j)) :(j = null, d.averageDurationText = null);
6797-
var m = [], n = [];
6798-
angular.forEach(f, function(a) {
6799-
h[a] ? m.push(a) :n.push(a);
6800-
}), a.keys.value = m, a.groups = [ m ], i ? (a.unload = n, a.done = function() {
6795+
i[a.phase] = !0;
6796+
}), c ? (k = b / c, e.averageDurationText = h(k)) :(k = null, e.averageDurationText = null);
6797+
var n = [], o = [];
6798+
angular.forEach(g, function(a) {
6799+
i[a] ? n.push(a) :o.push(a);
6800+
}), a.keys.value = n, a.groups = [ n ], j ? (a.unload = o, a.done = function() {
68016801
setTimeout(function() {
6802-
i.flush();
6803-
}, k() + 25);
6804-
}, i.load(a)) :(l.data = angular.extend(a, l.data), i = c3.generate(l)), s();
6802+
j.flush();
6803+
}, l() + 25);
6804+
}, j.load(a), t()) :(m.data = angular.extend(a, m.data), d(function() {
6805+
j = c3.generate(m), t();
6806+
}));
68056807
};
6806-
d.$watch(n, t), d.$on("destroy", function() {
6807-
i && (i = i.destroy());
6808+
e.$watch(o, u), e.$on("destroy", function() {
6809+
j && (j = j.destroy());
68086810
});
68096811
}
68106812
};

0 commit comments

Comments
 (0)