Skip to content

Label Filter for Kubernetes Deployment History Tab #1845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions app/scripts/controllers/deployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ angular.module('openshiftConsole')
DeploymentsService,
HPAService,
ImageStreamResolver,
LabelFilter,
Logger,
ModalsService,
Navigate,
OwnerReferencesService,
Logger,
ProjectsService,
StorageService) {
var imageStreamImageRefByDockerReference = {}; // lets us determine if a particular container's docker image reference belongs to an imageStream

$scope.projectName = $routeParams.project;
$scope.name = $routeParams.deployment;
$scope.replicaSetsForDeployment = {};
$scope.unfilteredReplicaSetsForDeployment = {};
$scope.labelSuggestions = {};
$scope.emptyMessage = "Loading...";
$scope.forms = {};
$scope.alerts = {};
$scope.imagesByDockerReference = {};
Expand Down Expand Up @@ -91,10 +96,18 @@ angular.module('openshiftConsole')
group: 'extensions',
resource: 'replicasets'
}, context, function(replicaSetData) {
$scope.emptyMessage = "No deployments to show";

var replicaSets = replicaSetData.by('metadata.name');
replicaSets = OwnerReferencesService.filterForController(replicaSets, deployment);
$scope.inProgressDeployment = _.chain(replicaSets).filter('status.replicas').size() > 1;
$scope.replicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);

$scope.unfilteredReplicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);
$scope.replicaSetsForDeployment = LabelFilter.getLabelSelector().select($scope.unfilteredReplicaSetsForDeployment);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we fix keeping filters on page reload, I think we need a call to updateFilterWarning here?


updateFilterWarning();
LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredReplicaSetsForDeployment, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
}));
},
// failure
Expand Down Expand Up @@ -140,6 +153,25 @@ angular.module('openshiftConsole')
Logger.log("builds (subscribe)", $scope.builds);
}));

function updateFilterWarning() {
if (!LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.replicaSetsForDeployment) && !_.isEmpty($scope.unfilteredReplicaSetsForDeployment)) {
$scope.alerts["filter-hiding-all"] = {
type: "warning",
details: "The active filters are hiding all rollout history."
};
}
else {
delete $scope.alerts["filter-hiding-all"];
}
}

LabelFilter.onActiveFiltersChanged(function(labelSelector) {
$scope.$evalAsync(function() {
$scope.replicaSetsForDeployment = labelSelector.select($scope.unfilteredReplicaSetsForDeployment);
updateFilterWarning();
});
});

$scope.scale = function(replicas) {
var showScalingError = function(result) {
$scope.alerts = $scope.alerts || {};
Expand Down
74 changes: 41 additions & 33 deletions app/views/browse/deployment.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,48 @@ <h1 class="contains-actions">
<uib-tabset>
<uib-tab active="selectedTab.history">
<uib-tab-heading>History</uib-tab-heading>
<div ng-if="replicaSetsForDeployment | hashSize">
<table class="table table-bordered table-hover table-mobile table-layout-fixed">
<colgroup>
<col class="col-sm-2">
<col class="col-sm-4">
<col class="col-sm-3">
<col class="col-sm-3">
</colgroup>
<thead>
<tr>
<th>Version</th>
<th>Name</th>
<th>Replicas</th>
<th>Created</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="replicaSet in replicaSetsForDeployment">
<td data-title="Version">
#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}
</td>
<td data-title="Name">
<a ng-href="{{replicaSet | navigateResourceURL}}">{{replicaSet.metadata.name}}</a>
</td>
<td data-title="Replicas">
<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>
</td>
<td data-title="Created">
<span am-time-ago="replicaSet.metadata.creationTimestamp"></span>
</td>
</tr>
</tbody>
</table>
<div class="table-filter-extension">
<div class="data-toolbar">
<div class="data-toolbar-filter">
<project-filter></project-filter>
</div>
</div>
</div>
<table class="table table-bordered table-hover table-mobile table-layout-fixed">
<colgroup>
<col class="col-sm-2">
<col class="col-sm-4">
<col class="col-sm-3">
<col class="col-sm-3">
</colgroup>
<thead>
<tr>
<th>Version</th>
<th>Name</th>
<th>Replicas</th>
<th>Created</th>
</tr>
</thead>
<tbody ng-if="(replicaSetsForDeployment | size) == 0">
<tr><td colspan="4"><em>{{emptyMessage}}</em></td></tr>
</tbody>
<tbody ng-if="(replicaSetsForDeployment | size) > 0">
<tr ng-repeat="replicaSet in replicaSetsForDeployment">
<td data-title="Version">
#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}
</td>
<td data-title="Name">
<a ng-href="{{replicaSet | navigateResourceURL}}">{{replicaSet.metadata.name}}</a>
</td>
<td data-title="Replicas">
<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>
</td>
<td data-title="Created">
<span am-time-ago="replicaSet.metadata.creationTimestamp"></span>
</td>
</tr>
</tbody>
</table>
</uib-tab>
<uib-tab active="selectedTab.configuration">
<uib-tab-heading>Configuration</uib-tab-heading>
Expand Down
Loading