Skip to content

Commit 150bd60

Browse files
committed
add route / pod table directives to svc page
This patch replaces single-line descriptions, for listing routes and pods related to the current service, with route and pod table directives. It adds warning tooltips to the pod table directive to rows displaying pods with no endpoints. This patch further adds an optional field to pod and route directives for setting a custom 'Name' column header value.
1 parent 8c5e11c commit 150bd60

File tree

7 files changed

+191
-84
lines changed

7 files changed

+191
-84
lines changed

app/scripts/controllers/service.js

+45
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ angular.module('openshiftConsole')
1414
$filter) {
1515
$scope.projectName = $routeParams.project;
1616
$scope.service = null;
17+
$scope.services = null;
1718
$scope.alerts = {};
1819
$scope.renderOptions = $scope.renderOptions || {};
1920
$scope.renderOptions.hideFilterWidget = true;
@@ -60,6 +61,50 @@ angular.module('openshiftConsole')
6061
}
6162
);
6263

64+
watches.push(DataService.watch("services", context, function(services) {
65+
$scope.services = services.by("metadata.name");
66+
}));
67+
68+
watches.push(DataService.watch("pods", context, function(pods) {
69+
var service = $scope.service;
70+
if (!service) {
71+
DataService
72+
.get("services", $routeParams.service, context)
73+
.then(function(service) {
74+
getPodsForService(service, pods);
75+
});
76+
return;
77+
}
78+
getPodsForService(service, pods);
79+
}));
80+
81+
// receive pods for the current service scope only when the service object is available
82+
function getPodsForService(service, pods) {
83+
$scope.podsForService = [];
84+
var ls = new LabelSelector(service.spec.selector);
85+
angular.forEach(pods.by("metadata.name"), function(pod) {
86+
if (ls.matches(pod)) {
87+
$scope.podsForService.push(pod);
88+
}
89+
});
90+
}
91+
92+
watches.push(DataService.watch("endpoints", context, function(endpoints) {
93+
$scope.podsWithEndpoints = {};
94+
angular.forEach(endpoints.by("metadata.name"), function(endpoint) {
95+
if (endpoint.metadata.name === $routeParams.service) {
96+
endpoint.subsets.forEach(function(subset) {
97+
subset.addresses.forEach(function(address) {
98+
if (address.targetRef !== undefined &&
99+
address.targetRef.kind === "Pod") {
100+
$scope.podsWithEndpoints[address.targetRef.name] = true;
101+
}
102+
});
103+
});
104+
}
105+
});
106+
}));
107+
63108
watches.push(DataService.watch("routes", context, function(routes) {
64109
$scope.routesForService = [];
65110
angular.forEach(routes.by("metadata.name"), function(route) {

app/scripts/directives/resources.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,27 @@ angular.module('openshiftConsole')
165165
restrict: 'E',
166166
scope: {
167167
pods: '=',
168+
// Optional active pods map to display whether or not pods have endpoints
169+
activePods: '=?',
168170
// Optional empty message to display when there are no pods.
169-
emptyMessage: '=?'
171+
emptyMessage: '=?',
172+
// Alternative header text to display in the 'Name' column.
173+
customNameHeader: '=?'
170174
},
171175
templateUrl: 'views/directives/pods-table.html'
172176
};
177+
})
178+
.directive('routesTable', function() {
179+
return {
180+
restrict: 'E',
181+
scope: {
182+
routes: '=',
183+
services: '=',
184+
// Optional empty message to display when there are no pods.
185+
emptyMessage: '=?',
186+
// Alternative header text to display in the 'Name' column.
187+
customNameHeader: '=?'
188+
},
189+
templateUrl: 'views/directives/routes-table.html'
190+
};
173191
});

app/views/browse/service.html

+8-13
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,19 @@ <h1>
7474
<span ng-repeat="externalIP in service.spec.externalIPs"
7575
>{{externalIP}}<span ng-if="!$last">, </span></span>
7676
</dd>
77-
<dt>Routes:</dt>
78-
<dd>
77+
<dt ng-if="!routesForService.length">Routes:</dt>
78+
<dd ng-if="!routesForService.length">
7979
<span ng-if="!routesForService.length">
8080
<a ng-href="project/{{project.metadata.name}}/create-route?service={{service.metadata.name}}" ng-if="'routes' | canI : 'create'">Create route</a>
8181
</span>
82-
<span ng-repeat="route in routesForService">
83-
<span ng-if="route | isWebRoute"><a ng-href="{{route | routeWebURL}}">{{route | routeLabel}}</a></span>
84-
<span ng-if="!(route | isWebRoute)">{{route | routeLabel}}</span>
85-
<span ng-show="!$last">, </span>
86-
</span>
8782
</dd>
8883
</dl>
84+
<div ng-if="routesForService.length" class="table-responsive small service-table">
85+
<routes-table routes="routesForService" services="services" custom-name-header="routesForService[0].kind"></routes-table>
86+
</div>
87+
<div ng-if="podsForService.length" class="table-responsive small service-table">
88+
<pods-table pods="podsForService" active-pods="podsWithEndpoints" custom-name-header="podsForService[0].kind"></pods-table>
89+
</div>
8990
<div ng-if="service.spec.ports.length" class="table-responsive">
9091
<table class="table table-bordered small service-table">
9192
<thead>
@@ -112,12 +113,6 @@ <h1>
112113
</tbody>
113114
</table>
114115
</div>
115-
<div ng-if="podsForService.length" class="table-responsive">
116-
<pods-table pods="podsForService"></pods-table>
117-
<!--<span ng-repeat="pod in podsForService"-->
118-
<!--&gt;{{pod.metadata.name}} ({{podsReceivingTraffic[pod.metadata.name]}})<span ng-if="!$last">, </span>-->
119-
<!--</span>-->
120-
</div>
121116
<annotations annotations="service.metadata.annotations"></annotations>
122117
</div>
123118
</uib-tab>

app/views/directives/pods-table.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<table class="table table-bordered table-hover table-mobile">
22
<thead>
33
<tr>
4-
<th>Name</th>
4+
<th>{{customNameHeader || 'Name'}}</th>
55
<th>Status</th>
66
<th>Containers Ready</th>
77
<th>Container Restarts</th>
@@ -15,6 +15,10 @@
1515
<tr>
1616
<td data-title="Name">
1717
<a href="{{pod | navigateResourceURL}}">{{pod.metadata.name}}</a>
18+
<span ng-if="!activePods[pod.metadata.name]" data-toggle="popover" data-trigger="hover" data-content="This pod has no endpoints and is not accepting traffic." style="cursor: help; padding-left: 5px;">
19+
<span class="pficon pficon-warning-triangle-o" aria-hidden="true" data-toggle="tooltip" style="cursor: help;"></span>
20+
<span class="sr-only">{{pod.status.phase}}</span>
21+
</span>
1822
<span ng-if="pod | isTroubledPod">
1923
<pod-warnings pod="pod"></pod-warnings>
2024
</span>

app/views/directives/routes-table.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<table class="table table-bordered table-hover table-mobile">
22
<thead>
33
<tr>
4-
<th>Name</th>
4+
<th>{{customNameHeader || 'Name'}}</th>
55
<th>Hostname</th>
66
<th>Routes To</th>
77
<th>Target Port</th>
88
<th>TLS Termination</th>
99
</tr>
1010
</thead>
1111
<tbody ng-if="(routes | hashSize) == 0">
12-
<tr><td colspan="5"><em>{{emptyMessage}}</em></td></tr>
12+
<tr><td colspan="5"><em>{{emptyMessage || 'No routes to show'}}</em></td></tr>
1313
</tbody>
1414
<tbody ng-repeat="route in routes | orderObjectsByDate : true">
1515
<tr>

dist/scripts/scripts.js

+38-3
Original file line numberDiff line numberDiff line change
@@ -6179,7 +6179,7 @@ d.unwatchAll(i);
61796179
});
61806180
}));
61816181
} ]), angular.module("openshiftConsole").controller("ServiceController", [ "$scope", "$routeParams", "DataService", "ProjectsService", "$filter", function(a, b, c, d, e) {
6182-
a.projectName = b.project, a.service = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ {
6182+
a.projectName = b.project, a.service = null, a.services = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ {
61836183
title:"Services",
61846184
link:"project/" + b.project + "/browse/services"
61856185
}, {
@@ -6192,6 +6192,13 @@ message:"This service has been deleted."
61926192
});
61936193
};
61946194
d.get(b.project).then(_.spread(function(d, h) {
6195+
function i(b, c) {
6196+
a.podsForService = [];
6197+
var d = new LabelSelector(b.spec.selector);
6198+
angular.forEach(c.by("metadata.name"), function(b) {
6199+
d.matches(b) && a.podsForService.push(b);
6200+
});
6201+
}
61956202
a.project = d, a.projectContext = h, c.get("services", b.service, h).then(function(a) {
61966203
g(a), f.push(c.watchObject("services", b.service, h, g));
61976204
}, function(b) {
@@ -6200,7 +6207,22 @@ type:"error",
62006207
message:"The service details could not be loaded.",
62016208
details:"Reason: " + e("getErrorDetails")(b)
62026209
};
6203-
}), f.push(c.watch("routes", h, function(c) {
6210+
}), f.push(c.watch("services", h, function(b) {
6211+
a.services = b.by("metadata.name");
6212+
})), f.push(c.watch("pods", h, function(d) {
6213+
var e = a.service;
6214+
return e ? void i(e, d) :void c.get("services", b.service, h).then(function(a) {
6215+
i(a, d);
6216+
});
6217+
})), f.push(c.watch("endpoints", h, function(c) {
6218+
a.podsWithEndpoints = {}, angular.forEach(c.by("metadata.name"), function(c) {
6219+
c.metadata.name === b.service && c.subsets.forEach(function(b) {
6220+
b.addresses.forEach(function(b) {
6221+
void 0 !== b.targetRef && "Pod" === b.targetRef.kind && (a.podsWithEndpoints[b.targetRef.name] = !0);
6222+
});
6223+
});
6224+
});
6225+
})), f.push(c.watch("routes", h, function(c) {
62046226
a.routesForService = [], angular.forEach(c.by("metadata.name"), function(c) {
62056227
"Service" === c.spec.to.kind && c.spec.to.name === b.service && a.routesForService.push(c);
62066228
}), Logger.log("routes (subscribe)", a.routesByService);
@@ -9885,10 +9907,23 @@ return {
98859907
restrict:"E",
98869908
scope:{
98879909
pods:"=",
9888-
emptyMessage:"=?"
9910+
activePods:"=?",
9911+
emptyMessage:"=?",
9912+
customNameHeader:"=?"
98899913
},
98909914
templateUrl:"views/directives/pods-table.html"
98919915
};
9916+
}).directive("routesTable", function() {
9917+
return {
9918+
restrict:"E",
9919+
scope:{
9920+
routes:"=",
9921+
services:"=",
9922+
emptyMessage:"=?",
9923+
customNameHeader:"=?"
9924+
},
9925+
templateUrl:"views/directives/routes-table.html"
9926+
};
98929927
}), angular.module("openshiftConsole").directive("topologyDeployment", function() {
98939928
return {
98949929
restrict:"E",

0 commit comments

Comments
 (0)