Skip to content

Commit 872b724

Browse files
author
OpenShift Bot
authored
Merge pull request #1275 from spadgett/route-pie-legend-position
Merged by openshift-bot
2 parents a0d6ce8 + 50e0793 commit 872b724

File tree

4 files changed

+47
-25
lines changed

4 files changed

+47
-25
lines changed

app/scripts/directives/routeServicePie.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ angular.module('openshiftConsole')
1010
template: '<div ng-show="totalWeight" ng-attr-id="{{chartId}}"></div>',
1111
link: function($scope) {
1212
var chart, config;
13+
var mobile = window.matchMedia("(max-width: 400px)").matches;
1314

1415
$scope.chartId = _.uniqueId('route-service-chart-');
1516

@@ -20,16 +21,23 @@ angular.module('openshiftConsole')
2021
},
2122
legend: {
2223
show: true,
23-
position: 'right'
24+
position: mobile ? 'bottom' : 'right'
2425
},
2526
pie: {
2627
label: {
2728
show: false
2829
}
2930
},
3031
size: {
31-
height: 115,
32-
width: 260
32+
height: mobile ? 150 : 115
33+
},
34+
tooltip: {
35+
format: {
36+
name: function(name, ratio, id) {
37+
// Show the full name on hover, even if name is truncated for the legend.
38+
return id;
39+
}
40+
}
3341
},
3442
data: {
3543
type: "pie",
@@ -69,14 +77,17 @@ angular.module('openshiftConsole')
6977

7078
function updateChart() {
7179
var data = {
72-
columns: []
80+
columns: [],
81+
names: {}
7382
};
7483

7584
if ($scope.route) {
7685
data.columns.push(getData($scope.route.spec.to));
86+
data.names[$scope.route.spec.to.name] = _.trunc($scope.route.spec.to.name, { length: 30 });
7787
$scope.totalWeight = $scope.route.spec.to.weight;
7888
_.each($scope.route.spec.alternateBackends, function(routeTarget) {
7989
data.columns.push(getData(routeTarget));
90+
data.names[routeTarget.name] = _.trunc(routeTarget.name, { length: 30 });
8091
$scope.totalWeight += routeTarget.weight;
8192
});
8293
}

app/views/browse/route.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ <h4>Traffic</h4>
124124
This route splits traffic across multiple services.
125125
</div>
126126
</div>
127-
<div class="col-sm-5 col-sm-push-7 mar-bottom-lg">
127+
<div class="col-sm-12 col-md-5 col-md-push-7 mar-bottom-lg">
128128
<route-service-pie route="route"></route-service-pie>
129129
</div>
130-
<div class="col-sm-7 col-sm-pull-5">
130+
<div class="cold-sm-12 col-md-7 col-md-pull-5">
131131
<table class="table table-bordered">
132132
<thead>
133133
<tr>

dist/scripts/scripts.js

+28-17
Original file line numberDiff line numberDiff line change
@@ -12603,30 +12603,41 @@ template:'<div ng-show="totalWeight" ng-attr-id="{{chartId}}"></div>',
1260312603
link:function(a) {
1260412604
function b() {
1260512605
var b = {
12606-
columns:[]
12607-
};
12608-
a.route && (b.columns.push(f(a.route.spec.to)), a.totalWeight = a.route.spec.to.weight, _.each(a.route.spec.alternateBackends, function(c) {
12609-
b.columns.push(f(c)), a.totalWeight += c.weight;
12610-
})), a.totalWeight && (c ? (h(b), c.load(b)) :(d.data.columns = b.columns, c = c3.generate(d)), e = b);
12611-
}
12612-
var c, d;
12606+
columns:[],
12607+
names:{}
12608+
};
12609+
a.route && (b.columns.push(g(a.route.spec.to)), b.names[a.route.spec.to.name] = _.trunc(a.route.spec.to.name, {
12610+
length:30
12611+
}), a.totalWeight = a.route.spec.to.weight, _.each(a.route.spec.alternateBackends, function(c) {
12612+
b.columns.push(g(c)), b.names[c.name] = _.trunc(c.name, {
12613+
length:30
12614+
}), a.totalWeight += c.weight;
12615+
})), a.totalWeight && (c ? (i(b), c.load(b)) :(d.data.columns = b.columns, c = c3.generate(d)), f = b);
12616+
}
12617+
var c, d, e = window.matchMedia("(max-width: 400px)").matches;
1261312618
a.chartId = _.uniqueId("route-service-chart-"), d = {
1261412619
bindto:"#" + a.chartId,
1261512620
color:{
1261612621
pattern:[ $.pfPaletteColors.blue, $.pfPaletteColors.orange, $.pfPaletteColors.green, $.pfPaletteColors.red ]
1261712622
},
1261812623
legend:{
1261912624
show:!0,
12620-
position:"right"
12625+
position:e ? "bottom" :"right"
1262112626
},
1262212627
pie:{
1262312628
label:{
1262412629
show:!1
1262512630
}
1262612631
},
1262712632
size:{
12628-
height:115,
12629-
width:260
12633+
height:e ? 150 :115
12634+
},
12635+
tooltip:{
12636+
format:{
12637+
name:function(a, b, c) {
12638+
return c;
12639+
}
12640+
}
1263012641
},
1263112642
data:{
1263212643
type:"pie",
@@ -12636,21 +12647,21 @@ enabled:!1
1263612647
}
1263712648
}
1263812649
};
12639-
var e, f = function(a) {
12650+
var f, g = function(a) {
1264012651
return [ a.name, a.weight ];
12641-
}, g = function(a) {
12642-
return _.head(a);
1264312652
}, h = function(a) {
12653+
return _.head(a);
12654+
}, i = function(a) {
1264412655
var b = {};
1264512656
_.each(a.columns, function(a) {
12646-
var c = g(a);
12657+
var c = h(a);
1264712658
b[c] = !0;
1264812659
});
12649-
var c = _.get(e, "columns", []);
12660+
var c = _.get(f, "columns", []);
1265012661
a.unload = _.chain(c).reject(function(a) {
12651-
var c = g(a);
12662+
var c = h(a);
1265212663
return _.has(b, [ c ]);
12653-
}).map(g).value();
12664+
}).map(h).value();
1265412665
};
1265512666
a.$watch("route", b), a.$on("destroy", function() {
1265612667
c && (c = c.destroy());

dist/scripts/templates.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3629,10 +3629,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
36293629
"This route splits traffic across multiple services.\n" +
36303630
"</div>\n" +
36313631
"</div>\n" +
3632-
"<div class=\"col-sm-5 col-sm-push-7 mar-bottom-lg\">\n" +
3632+
"<div class=\"col-sm-12 col-md-5 col-md-push-7 mar-bottom-lg\">\n" +
36333633
"<route-service-pie route=\"route\"></route-service-pie>\n" +
36343634
"</div>\n" +
3635-
"<div class=\"col-sm-7 col-sm-pull-5\">\n" +
3635+
"<div class=\"cold-sm-12 col-md-7 col-md-pull-5\">\n" +
36363636
"<table class=\"table table-bordered\">\n" +
36373637
"<thead>\n" +
36383638
"<tr>\n" +

0 commit comments

Comments
 (0)