Skip to content

Commit ab5f706

Browse files
author
OpenShift Bot
authored
Merge pull request #1845 from cdcabrera/issue-labelfilter
Merged by openshift-bot
2 parents e839e15 + 5bbf8ab commit ab5f706

File tree

4 files changed

+184
-125
lines changed

4 files changed

+184
-125
lines changed

app/scripts/controllers/deployment.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ angular.module('openshiftConsole')
1515
DeploymentsService,
1616
HPAService,
1717
ImageStreamResolver,
18+
LabelFilter,
19+
Logger,
1820
ModalsService,
1921
Navigate,
2022
OwnerReferencesService,
21-
Logger,
2223
ProjectsService,
2324
StorageService) {
2425
var imageStreamImageRefByDockerReference = {}; // lets us determine if a particular container's docker image reference belongs to an imageStream
2526

2627
$scope.projectName = $routeParams.project;
2728
$scope.name = $routeParams.deployment;
29+
$scope.replicaSetsForDeployment = {};
30+
$scope.unfilteredReplicaSetsForDeployment = {};
31+
$scope.labelSuggestions = {};
32+
$scope.emptyMessage = "Loading...";
2833
$scope.forms = {};
2934
$scope.alerts = {};
3035
$scope.imagesByDockerReference = {};
@@ -91,10 +96,18 @@ angular.module('openshiftConsole')
9196
group: 'extensions',
9297
resource: 'replicasets'
9398
}, context, function(replicaSetData) {
99+
$scope.emptyMessage = "No deployments to show";
100+
94101
var replicaSets = replicaSetData.by('metadata.name');
95102
replicaSets = OwnerReferencesService.filterForController(replicaSets, deployment);
96103
$scope.inProgressDeployment = _.chain(replicaSets).filter('status.replicas').size() > 1;
97-
$scope.replicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);
104+
105+
$scope.unfilteredReplicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);
106+
$scope.replicaSetsForDeployment = LabelFilter.getLabelSelector().select($scope.unfilteredReplicaSetsForDeployment);
107+
108+
updateFilterWarning();
109+
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredReplicaSetsForDeployment, $scope.labelSuggestions);
110+
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
98111
}));
99112
},
100113
// failure
@@ -140,6 +153,25 @@ angular.module('openshiftConsole')
140153
Logger.log("builds (subscribe)", $scope.builds);
141154
}));
142155

156+
function updateFilterWarning() {
157+
if (!LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.replicaSetsForDeployment) && !_.isEmpty($scope.unfilteredReplicaSetsForDeployment)) {
158+
$scope.alerts["filter-hiding-all"] = {
159+
type: "warning",
160+
details: "The active filters are hiding all rollout history."
161+
};
162+
}
163+
else {
164+
delete $scope.alerts["filter-hiding-all"];
165+
}
166+
}
167+
168+
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
169+
$scope.$evalAsync(function() {
170+
$scope.replicaSetsForDeployment = labelSelector.select($scope.unfilteredReplicaSetsForDeployment);
171+
updateFilterWarning();
172+
});
173+
});
174+
143175
$scope.scale = function(replicas) {
144176
var showScalingError = function(result) {
145177
$scope.alerts = $scope.alerts || {};

app/views/browse/deployment.html

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -87,40 +87,48 @@ <h1 class="contains-actions">
8787
<uib-tabset>
8888
<uib-tab active="selectedTab.history">
8989
<uib-tab-heading>History</uib-tab-heading>
90-
<div ng-if="replicaSetsForDeployment | hashSize">
91-
<table class="table table-bordered table-hover table-mobile table-layout-fixed">
92-
<colgroup>
93-
<col class="col-sm-2">
94-
<col class="col-sm-4">
95-
<col class="col-sm-3">
96-
<col class="col-sm-3">
97-
</colgroup>
98-
<thead>
99-
<tr>
100-
<th>Version</th>
101-
<th>Name</th>
102-
<th>Replicas</th>
103-
<th>Created</th>
104-
</tr>
105-
</thead>
106-
<tbody>
107-
<tr ng-repeat="replicaSet in replicaSetsForDeployment">
108-
<td data-title="Version">
109-
#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}
110-
</td>
111-
<td data-title="Name">
112-
<a ng-href="{{replicaSet | navigateResourceURL}}">{{replicaSet.metadata.name}}</a>
113-
</td>
114-
<td data-title="Replicas">
115-
<span ng-if="replicaSet.status.replicas !== replicaSet.spec.replicas">{{replicaSet.status.replicas}}/</span>{{replicaSet.spec.replicas}} replica<span ng-if="replicaSet.spec.replicas != 1">s</span>
116-
</td>
117-
<td data-title="Created">
118-
<span am-time-ago="replicaSet.metadata.creationTimestamp"></span>
119-
</td>
120-
</tr>
121-
</tbody>
122-
</table>
90+
<div class="table-filter-extension">
91+
<div class="data-toolbar">
92+
<div class="data-toolbar-filter">
93+
<project-filter></project-filter>
94+
</div>
95+
</div>
12396
</div>
97+
<table class="table table-bordered table-hover table-mobile table-layout-fixed">
98+
<colgroup>
99+
<col class="col-sm-2">
100+
<col class="col-sm-4">
101+
<col class="col-sm-3">
102+
<col class="col-sm-3">
103+
</colgroup>
104+
<thead>
105+
<tr>
106+
<th>Version</th>
107+
<th>Name</th>
108+
<th>Replicas</th>
109+
<th>Created</th>
110+
</tr>
111+
</thead>
112+
<tbody ng-if="(replicaSetsForDeployment | size) == 0">
113+
<tr><td colspan="4"><em>{{emptyMessage}}</em></td></tr>
114+
</tbody>
115+
<tbody ng-if="(replicaSetsForDeployment | size) > 0">
116+
<tr ng-repeat="replicaSet in replicaSetsForDeployment">
117+
<td data-title="Version">
118+
#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}
119+
</td>
120+
<td data-title="Name">
121+
<a ng-href="{{replicaSet | navigateResourceURL}}">{{replicaSet.metadata.name}}</a>
122+
</td>
123+
<td data-title="Replicas">
124+
<span ng-if="replicaSet.status.replicas !== replicaSet.spec.replicas">{{replicaSet.status.replicas}}/</span>{{replicaSet.spec.replicas}} replica<span ng-if="replicaSet.spec.replicas != 1">s</span>
125+
</td>
126+
<td data-title="Created">
127+
<span am-time-ago="replicaSet.metadata.creationTimestamp"></span>
128+
</td>
129+
</tr>
130+
</tbody>
131+
</table>
124132
</uib-tab>
125133
<uib-tab active="selectedTab.configuration">
126134
<uib-tab-heading>Configuration</uib-tab-heading>

0 commit comments

Comments
 (0)