Skip to content

Commit bbb61aa

Browse files
committed
Label Filter for Kubernetes Deployment History Tab
Implementation of label filter for Kubernetes deployment history tab
1 parent 23ed4cc commit bbb61aa

File tree

4 files changed

+94
-44
lines changed

4 files changed

+94
-44
lines changed

app/scripts/controllers/deployment.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ angular.module('openshiftConsole')
2121
OwnerReferencesService,
2222
Logger,
2323
ProjectsService,
24-
StorageService) {
24+
StorageService,
25+
LabelFilter) {
2526
var imageStreamImageRefByDockerReference = {}; // lets us determine if a particular container's docker image reference belongs to an imageStream
2627

2728
$scope.projectName = $routeParams.project;
2829
$scope.name = $routeParams.deployment;
30+
$scope.replicaSetsForDeployment = {};
31+
$scope.unfilteredReplicaSetsForDeployment = {};
32+
$scope.emptyMessage = "Loading...";
2933
$scope.forms = {};
3034
$scope.alerts = {};
3135
$scope.imagesByDockerReference = {};
@@ -185,10 +189,15 @@ angular.module('openshiftConsole')
185189
group: 'extensions',
186190
resource: 'replicasets'
187191
}, context, function(replicaSetData) {
192+
$scope.emptyMessage = "No deployments to show";
193+
188194
var replicaSets = replicaSetData.by('metadata.name');
189195
replicaSets = OwnerReferencesService.filterForController(replicaSets, deployment);
190196
$scope.inProgressDeployment = _.chain(replicaSets).filter('status.replicas').size() > 1;
191-
$scope.replicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);
197+
198+
$scope.unfilteredReplicaSetsForDeployment = DeploymentsService.sortByRevision(replicaSets);
199+
$scope.replicaSetsForDeployment = LabelFilter.getLabelSelector().select($scope.unfilteredReplicaSetsForDeployment);
200+
$scope.orderedReplicaSetsForDeployment = $scope.replicaSetsForDeployment;
192201
}));
193202
},
194203
// failure
@@ -260,6 +269,28 @@ angular.module('openshiftConsole')
260269
Logger.log("builds (subscribe)", $scope.builds);
261270
}));
262271

272+
function updateFilterWarning() {
273+
if (!LabelFilter.getLabelSelector().isEmpty() && $.isArray($scope.replicaSetsForDeployment) && !$scope.replicaSetsForDeployment.length && !$.isEmptyObject($scope.unfilteredReplicaSetsForDeployment)) {
274+
$scope.alerts["deployments"] = {
275+
type: "warning",
276+
details: "The active filters are hiding all deployments."
277+
};
278+
}
279+
else {
280+
delete $scope.alerts["deployments"];
281+
}
282+
}
283+
284+
LabelFilter.onActiveFiltersChanged(function(labelSelector) {
285+
// trigger a digest loop
286+
$scope.$apply(function() {
287+
$scope.replicaSetsForDeployment = labelSelector.select($scope.unfilteredReplicaSetsForDeployment);
288+
$scope.orderedReplicaSetsForDeployment = $scope.replicaSetsForDeployment;
289+
290+
updateFilterWarning();
291+
});
292+
});
293+
263294
$scope.scale = function(replicas) {
264295
var showScalingError = function(result) {
265296
$scope.alerts = $scope.alerts || {};

app/views/browse/deployment.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ <h1 class="contains-actions">
9292
<uib-tabset>
9393
<uib-tab active="selectedTab.history">
9494
<uib-tab-heading>History</uib-tab-heading>
95-
<div ng-if="replicaSetsForDeployment | hashSize">
95+
<div class="table-filter-wrapper">
96+
<project-filter></project-filter>
97+
</div>
9698
<table class="table table-bordered table-hover table-mobile table-layout-fixed">
9799
<colgroup>
98100
<col class="col-sm-2">
@@ -108,8 +110,11 @@ <h1 class="contains-actions">
108110
<th>Created</th>
109111
</tr>
110112
</thead>
111-
<tbody>
112-
<tr ng-repeat="replicaSet in replicaSetsForDeployment">
113+
<tbody ng-if="(replicaSetsForDeployment | hashSize) == 0">
114+
<tr><td colspan="4"><em>{{emptyMessage}}</em></td></tr>
115+
</tbody>
116+
<tbody ng-if="(replicaSetsForDeployment | hashSize) > 0">
117+
<tr ng-repeat="replicaSet in orderedReplicaSetsForDeployment">
113118
<td data-title="Version">
114119
#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}
115120
</td>
@@ -125,7 +130,6 @@ <h1 class="contains-actions">
125130
</tr>
126131
</tbody>
127132
</table>
128-
</div>
129133
</uib-tab>
130134
<uib-tab active="selectedTab.configuration">
131135
<uib-tab-heading>Configuration</uib-tab-heading>

dist/scripts/scripts.js

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5355,19 +5355,19 @@ a.deploymentConfigs = b.select(a.unfilteredDeploymentConfigs), a.replicationCont
53555355
d.unwatchAll(n);
53565356
});
53575357
}));
5358-
} ]), angular.module("openshiftConsole").controller("DeploymentController", [ "$scope", "$filter", "$routeParams", "DataService", "DeploymentsService", "EnvironmentService", "HPAService", "ImageStreamResolver", "ModalsService", "Navigate", "OwnerReferencesService", "Logger", "ProjectsService", "StorageService", function(a, b, c, d, e, f, g, h, i, j, k, l, m, n) {
5359-
var o = {};
5360-
a.projectName = c.project, a.name = c.deployment, a.forms = {}, a.alerts = {}, a.imagesByDockerReference = {}, a.breadcrumbs = [ {
5358+
} ]), angular.module("openshiftConsole").controller("DeploymentController", [ "$scope", "$filter", "$routeParams", "DataService", "DeploymentsService", "EnvironmentService", "HPAService", "ImageStreamResolver", "ModalsService", "Navigate", "OwnerReferencesService", "Logger", "ProjectsService", "StorageService", "LabelFilter", function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) {
5359+
var p = {};
5360+
a.projectName = c.project, a.name = c.deployment, a.replicaSetsForDeployment = {}, a.unfilteredReplicaSetsForDeployment = {}, a.emptyMessage = "Loading...", a.forms = {}, a.alerts = {}, a.imagesByDockerReference = {}, a.breadcrumbs = [ {
53615361
title:"Deployments",
53625362
link:"project/" + c.project + "/browse/deployments"
53635363
}, {
53645364
title:c.deployment
53655365
} ], a.healthCheckURL = j.healthCheckURL(c.project, "Deployment", c.deployment, "extensions");
5366-
var p = !1, q = function(b, c) {
5367-
if (!p) {
5366+
var q = !1, r = function(b, c) {
5367+
if (!q) {
53685368
if (!a.forms.deploymentEnvVars || a.forms.deploymentEnvVars.$pristine) return void (a.updatedDeployment = f.copyAndNormalize(b));
53695369
if (f.isEnvironmentEqual(b, c)) return void (a.updatedDeployment = f.mergeEdits(a.updatedDeployment, b));
5370-
p = !0, a.alerts["env-conflict"] = {
5370+
q = !0, a.alerts["env-conflict"] = {
53715371
type:"warning",
53725372
message:"The environment variables for the deployment have been updated in the background. Saving your changes may create a conflict or cause loss of data.",
53735373
links:[ {
@@ -5378,17 +5378,23 @@ return a.clearEnvVarUpdates(), !0;
53785378
} ]
53795379
};
53805380
}
5381-
}, r = b("orderByDisplayName"), s = b("getErrorDetails"), t = function(b, c) {
5381+
}, s = b("orderByDisplayName"), t = b("getErrorDetails"), u = function(b, c) {
53825382
a.alerts["from-value-objects"] = {
53835383
type:"error",
53845384
message:b,
53855385
details:c
53865386
};
5387-
}, u = [];
5387+
}, v = [];
53885388
m.get(c.project).then(_.spread(function(j, m) {
5389+
function w() {
5390+
o.getLabelSelector().isEmpty() || !$.isArray(a.replicaSetsForDeployment) || a.replicaSetsForDeployment.length || $.isEmptyObject(a.unfilteredReplicaSetsForDeployment) ? delete a.alerts.deployments :a.alerts.deployments = {
5391+
type:"warning",
5392+
details:"The active filters are hiding all deployments."
5393+
};
5394+
}
53895395
a.project = j, a.projectContext = m;
5390-
var v, w = {}, x = function() {
5391-
g.getHPAWarnings(a.deployment, a.autoscalers, w, j).then(function(b) {
5396+
var x, y = {}, z = function() {
5397+
g.getHPAWarnings(a.deployment, a.autoscalers, y, j).then(function(b) {
53925398
a.hpaWarnings = b;
53935399
});
53945400
};
@@ -5398,11 +5404,11 @@ resource:"deployments"
53985404
}, c.deployment, m, {
53995405
errorNotification:!1
54005406
}).then(function(g) {
5401-
a.loaded = !0, a.deployment = g, x(), a.saveEnvVars = function() {
5402-
f.compact(a.updatedDeployment), v = d.update({
5407+
a.loaded = !0, a.deployment = g, z(), a.saveEnvVars = function() {
5408+
f.compact(a.updatedDeployment), x = d.update({
54035409
group:"extensions",
54045410
resource:"deployments"
5405-
}, c.deployment, a.updatedDeployment, m), v.then(function() {
5411+
}, c.deployment, a.updatedDeployment, m), x.then(function() {
54065412
a.alerts.saveEnvSuccess = {
54075413
type:"success",
54085414
message:c.deployment + " was updated."
@@ -5414,11 +5420,11 @@ message:c.deployment + " was not updated.",
54145420
details:b("getErrorDetails")(d)
54155421
};
54165422
})["finally"](function() {
5417-
v = null;
5423+
x = null;
54185424
});
54195425
}, a.clearEnvVarUpdates = function() {
5420-
a.updatedDeployment = f.copyAndNormalize(a.deployment), a.forms.deploymentEnvVars.$setPristine(), p = !1;
5421-
}, u.push(d.watchObject({
5426+
a.updatedDeployment = f.copyAndNormalize(a.deployment), a.forms.deploymentEnvVars.$setPristine(), q = !1;
5427+
}, v.push(d.watchObject({
54225428
group:"extensions",
54235429
resource:"deployments"
54245430
}, c.deployment, m, function(b, c) {
@@ -5427,15 +5433,16 @@ type:"warning",
54275433
message:"This deployment has been deleted."
54285434
});
54295435
var d = a.deployment;
5430-
a.deployment = b, a.updatingPausedState = !1, x(), q(b, d), v ? v["finally"](function() {
5431-
q(b, d);
5432-
}) :q(b, d), h.fetchReferencedImageStreamImages([ b.spec.template ], a.imagesByDockerReference, o, m);
5433-
})), u.push(d.watch({
5436+
a.deployment = b, a.updatingPausedState = !1, z(), r(b, d), x ? x["finally"](function() {
5437+
r(b, d);
5438+
}) :r(b, d), h.fetchReferencedImageStreamImages([ b.spec.template ], a.imagesByDockerReference, p, m);
5439+
})), v.push(d.watch({
54345440
group:"extensions",
54355441
resource:"replicasets"
54365442
}, m, function(b) {
5443+
a.emptyMessage = "No deployments to show";
54375444
var c = b.by("metadata.name");
5438-
c = k.filterForController(c, g), a.inProgressDeployment = _.chain(c).filter("status.replicas").size() > 1, a.replicaSetsForDeployment = e.sortByRevision(c);
5445+
c = k.filterForController(c, g), a.inProgressDeployment = _.chain(c).filter("status.replicas").size() > 1, a.unfilteredReplicaSetsForDeployment = e.sortByRevision(c), a.replicaSetsForDeployment = o.getLabelSelector().select(a.unfilteredReplicaSetsForDeployment), a.orderedReplicaSetsForDeployment = a.replicaSetsForDeployment;
54395446
}));
54405447
}, function(c) {
54415448
a.loaded = !0, a.alerts.load = {
@@ -5444,33 +5451,37 @@ message:404 === c.status ? "This deployment can not be found, it may have been d
54445451
details:b("getErrorDetails")(c)
54455452
};
54465453
}), d.list("limitranges", m).then(function(a) {
5447-
w = a.by("metadata.name"), x();
5454+
y = a.by("metadata.name"), z();
54485455
});
5449-
var y = [], z = [];
5456+
var A = [], B = [];
54505457
a.valueFromObjects = [], d.list("configmaps", m, null, {
54515458
errorNotification:!1
54525459
}).then(function(b) {
5453-
y = r(b.by("metadata.name")), a.valueFromObjects = y.concat(z);
5460+
A = s(b.by("metadata.name")), a.valueFromObjects = A.concat(B);
54545461
}, function(a) {
5455-
403 !== a.code && t("Could not load config maps", s(a));
5462+
403 !== a.code && u("Could not load config maps", t(a));
54565463
}), d.list("secrets", m, null, {
54575464
errorNotification:!1
54585465
}).then(function(b) {
5459-
z = r(b.by("metadata.name")), a.valueFromObjects = z.concat(y);
5466+
B = s(b.by("metadata.name")), a.valueFromObjects = B.concat(A);
54605467
}, function(a) {
5461-
403 !== a.code && t("Could not load secrets", s(a));
5462-
}), u.push(d.watch("imagestreams", m, function(b) {
5468+
403 !== a.code && u("Could not load secrets", t(a));
5469+
}), v.push(d.watch("imagestreams", m, function(b) {
54635470
var c = b.by("metadata.name");
5464-
h.buildDockerRefMapForImageStreams(c, o), a.deployment && h.fetchReferencedImageStreamImages([ a.deployment.spec.template ], a.imagesByDockerReference, o, m), l.log("imagestreams (subscribe)", a.imageStreams);
5465-
})), u.push(d.watch({
5471+
h.buildDockerRefMapForImageStreams(c, p), a.deployment && h.fetchReferencedImageStreamImages([ a.deployment.spec.template ], a.imagesByDockerReference, p, m), l.log("imagestreams (subscribe)", a.imageStreams);
5472+
})), v.push(d.watch({
54665473
group:"autoscaling",
54675474
resource:"horizontalpodautoscalers",
54685475
version:"v1"
54695476
}, m, function(b) {
5470-
a.autoscalers = g.filterHPA(b.by("metadata.name"), "Deployment", c.deployment), x();
5471-
})), u.push(d.watch("builds", m, function(b) {
5477+
a.autoscalers = g.filterHPA(b.by("metadata.name"), "Deployment", c.deployment), z();
5478+
})), v.push(d.watch("builds", m, function(b) {
54725479
a.builds = b.by("metadata.name"), l.log("builds (subscribe)", a.builds);
5473-
})), a.scale = function(c) {
5480+
})), o.onActiveFiltersChanged(function(b) {
5481+
a.$apply(function() {
5482+
a.replicaSetsForDeployment = b.select(a.unfilteredReplicaSetsForDeployment), a.orderedReplicaSetsForDeployment = a.replicaSetsForDeployment, w();
5483+
});
5484+
}), a.scale = function(c) {
54745485
var d = function(c) {
54755486
a.alerts = a.alerts || {}, a.alerts.scale = {
54765487
type:"error",
@@ -5501,7 +5512,7 @@ n.removeVolume(a.deployment, b, m);
55015512
};
55025513
d.then(e);
55035514
}, a.$on("$destroy", function() {
5504-
d.unwatchAll(u);
5515+
d.unwatchAll(v);
55055516
});
55065517
}));
55075518
} ]), angular.module("openshiftConsole").controller("DeploymentConfigController", [ "$scope", "$filter", "$routeParams", "BreadcrumbsService", "DataService", "DeploymentsService", "EnvironmentService", "HPAService", "ImageStreamResolver", "ModalsService", "Navigate", "NotificationsService", "Logger", "ProjectsService", "StorageService", "LabelFilter", "labelNameFilter", function(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) {

dist/scripts/templates.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,7 +2711,9 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
27112711
"<uib-tabset>\n" +
27122712
"<uib-tab active=\"selectedTab.history\">\n" +
27132713
"<uib-tab-heading>History</uib-tab-heading>\n" +
2714-
"<div ng-if=\"replicaSetsForDeployment | hashSize\">\n" +
2714+
"<div class=\"table-filter-wrapper\">\n" +
2715+
"<project-filter></project-filter>\n" +
2716+
"</div>\n" +
27152717
"<table class=\"table table-bordered table-hover table-mobile table-layout-fixed\">\n" +
27162718
"<colgroup>\n" +
27172719
"<col class=\"col-sm-2\">\n" +
@@ -2727,8 +2729,11 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
27272729
"<th>Created</th>\n" +
27282730
"</tr>\n" +
27292731
"</thead>\n" +
2730-
"<tbody>\n" +
2731-
"<tr ng-repeat=\"replicaSet in replicaSetsForDeployment\">\n" +
2732+
"<tbody ng-if=\"(replicaSetsForDeployment | hashSize) == 0\">\n" +
2733+
"<tr><td colspan=\"4\"><em>{{emptyMessage}}</em></td></tr>\n" +
2734+
"</tbody>\n" +
2735+
"<tbody ng-if=\"(replicaSetsForDeployment | hashSize) > 0\">\n" +
2736+
"<tr ng-repeat=\"replicaSet in orderedReplicaSetsForDeployment\">\n" +
27322737
"<td data-title=\"Version\">\n" +
27332738
"#{{replicaSet | annotation : 'deployment.kubernetes.io/revision'}}\n" +
27342739
"</td>\n" +
@@ -2744,7 +2749,6 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
27442749
"</tr>\n" +
27452750
"</tbody>\n" +
27462751
"</table>\n" +
2747-
"</div>\n" +
27482752
"</uib-tab>\n" +
27492753
"<uib-tab active=\"selectedTab.configuration\">\n" +
27502754
"<uib-tab-heading>Configuration</uib-tab-heading>\n" +

0 commit comments

Comments
 (0)