Skip to content

Commit eb360d2

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 226b883 commit eb360d2

File tree

7 files changed

+190
-83
lines changed

7 files changed

+190
-83
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
@@ -163,9 +163,27 @@ angular.module('openshiftConsole')
163163
restrict: 'E',
164164
scope: {
165165
pods: '=',
166+
// Optional active pods map to display whether or not pods have endpoints
167+
activePods: '=?',
166168
// Optional empty message to display when there are no pods.
167-
emptyMessage: '=?'
169+
emptyMessage: '=?',
170+
// Alternative header text to display in the 'Name' column.
171+
customNameHeader: '=?'
168172
},
169173
templateUrl: 'views/directives/pods-table.html'
170174
};
175+
})
176+
.directive('routesTable', function() {
177+
return {
178+
restrict: 'E',
179+
scope: {
180+
routes: '=',
181+
services: '=',
182+
// Optional empty message to display when there are no pods.
183+
emptyMessage: '=?',
184+
// Alternative header text to display in the 'Name' column.
185+
customNameHeader: '=?'
186+
},
187+
templateUrl: 'views/directives/routes-table.html'
188+
};
171189
});

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
@@ -5979,7 +5979,7 @@ d.unwatchAll(i);
59795979
});
59805980
}));
59815981
} ]), angular.module("openshiftConsole").controller("ServiceController", [ "$scope", "$routeParams", "DataService", "ProjectsService", "$filter", function(a, b, c, d, e) {
5982-
a.projectName = b.project, a.service = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ {
5982+
a.projectName = b.project, a.service = null, a.services = null, a.alerts = {}, a.renderOptions = a.renderOptions || {}, a.renderOptions.hideFilterWidget = !0, a.breadcrumbs = [ {
59835983
title:"Services",
59845984
link:"project/" + b.project + "/browse/services"
59855985
}, {
@@ -5992,6 +5992,13 @@ message:"This service has been deleted."
59925992
});
59935993
};
59945994
d.get(b.project).then(_.spread(function(d, h) {
5995+
function i(b, c) {
5996+
a.podsForService = [];
5997+
var d = new LabelSelector(b.spec.selector);
5998+
angular.forEach(c.by("metadata.name"), function(b) {
5999+
d.matches(b) && a.podsForService.push(b);
6000+
});
6001+
}
59956002
a.project = d, a.projectContext = h, c.get("services", b.service, h).then(function(a) {
59966003
g(a), f.push(c.watchObject("services", b.service, h, g));
59976004
}, function(b) {
@@ -6000,7 +6007,22 @@ type:"error",
60006007
message:"The service details could not be loaded.",
60016008
details:"Reason: " + e("getErrorDetails")(b)
60026009
};
6003-
}), f.push(c.watch("routes", h, function(c) {
6010+
}), f.push(c.watch("services", h, function(b) {
6011+
a.services = b.by("metadata.name");
6012+
})), f.push(c.watch("pods", h, function(d) {
6013+
var e = a.service;
6014+
return e ? void i(e, d) :void c.get("services", b.service, h).then(function(a) {
6015+
i(a, d);
6016+
});
6017+
})), f.push(c.watch("endpoints", h, function(c) {
6018+
a.podsWithEndpoints = {}, angular.forEach(c.by("metadata.name"), function(c) {
6019+
c.metadata.name === b.service && c.subsets.forEach(function(b) {
6020+
b.addresses.forEach(function(b) {
6021+
void 0 !== b.targetRef && "Pod" === b.targetRef.kind && (a.podsWithEndpoints[b.targetRef.name] = !0);
6022+
});
6023+
});
6024+
});
6025+
})), f.push(c.watch("routes", h, function(c) {
60046026
a.routesForService = [], angular.forEach(c.by("metadata.name"), function(c) {
60056027
"Service" === c.spec.to.kind && c.spec.to.name === b.service && a.routesForService.push(c);
60066028
}), Logger.log("routes (subscribe)", a.routesByService);
@@ -9439,10 +9461,23 @@ return {
94399461
restrict:"E",
94409462
scope:{
94419463
pods:"=",
9442-
emptyMessage:"=?"
9464+
activePods:"=?",
9465+
emptyMessage:"=?",
9466+
customNameHeader:"=?"
94439467
},
94449468
templateUrl:"views/directives/pods-table.html"
94459469
};
9470+
}).directive("routesTable", function() {
9471+
return {
9472+
restrict:"E",
9473+
scope:{
9474+
routes:"=",
9475+
services:"=",
9476+
emptyMessage:"=?",
9477+
customNameHeader:"=?"
9478+
},
9479+
templateUrl:"views/directives/routes-table.html"
9480+
};
94469481
}), angular.module("openshiftConsole").directive("topologyDeployment", function() {
94479482
return {
94489483
restrict:"E",

0 commit comments

Comments
 (0)