From bee75d368cef771412f260e1f727f05c00de730f Mon Sep 17 00:00:00 2001 From: Jessica Forrester Date: Thu, 19 Jan 2017 16:01:16 -0500 Subject: [PATCH] Bug 1414709 - stateful sets page has no label filter --- app/scripts/controllers/statefulSets.js | 29 +++++++++++++++++++++++-- app/views/browse/stateful-sets.html | 7 +++++- dist/scripts/scripts.js | 24 ++++++++++++++------ dist/scripts/templates.js | 7 +++++- 4 files changed, 56 insertions(+), 11 deletions(-) diff --git a/app/scripts/controllers/statefulSets.js b/app/scripts/controllers/statefulSets.js index 623673a349..9c08bd6a9b 100644 --- a/app/scripts/controllers/statefulSets.js +++ b/app/scripts/controllers/statefulSets.js @@ -1,9 +1,10 @@ 'use strict'; angular.module('openshiftConsole') - .controller('StatefulSetsController', function($scope, $routeParams, AlertMessageService, DataService, ProjectsService) { + .controller('StatefulSetsController', function($scope, $routeParams, AlertMessageService, DataService, ProjectsService, LabelFilter) { $scope.projectName = $routeParams.project; $scope.alerts = $scope.alerts || {}; + $scope.labelSuggestions = {}; $scope.emptyMessage = "Loading..."; // get and clear any alerts @@ -25,10 +26,34 @@ angular.module('openshiftConsole') }, context, function(statefulSets) { angular.extend($scope, { loaded: true, - statefulSets: statefulSets.by('metadata.name') + unfilteredStatefulSets: statefulSets.by('metadata.name') }); + $scope.statefulSets = LabelFilter.getLabelSelector().select($scope.unfilteredStatefulSets); + LabelFilter.addLabelSuggestionsFromResources($scope.unfilteredStatefulSets, $scope.labelSuggestions); + LabelFilter.setLabelSuggestions($scope.labelSuggestions); + updateFilterWarning(); })); + function updateFilterWarning() { + if (!LabelFilter.getLabelSelector().isEmpty() && $.isEmptyObject($scope.statefulSets) && !$.isEmptyObject($scope.unfilteredStatefulSets)) { + $scope.alerts["statefulsets"] = { + type: "warning", + details: "The active filters are hiding all stateful sets." + }; + } + else { + delete $scope.alerts["statefulsets"]; + } + } + + LabelFilter.onActiveFiltersChanged(function(labelSelector) { + // trigger a digest loop + $scope.$apply(function() { + $scope.statefulSets = labelSelector.select($scope.unfilteredStatefulSets); + updateFilterWarning(); + }); + }); + $scope.$on('$destroy', function(){ DataService.unwatchAll(watches); }); diff --git a/app/views/browse/stateful-sets.html b/app/views/browse/stateful-sets.html index 04ca352da1..a4d64b8ed2 100644 --- a/app/views/browse/stateful-sets.html +++ b/app/views/browse/stateful-sets.html @@ -7,7 +7,6 @@
- +
+
+ +
+
+
Loading...
diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js index cc95370366..e526ce8518 100644 --- a/dist/scripts/scripts.js +++ b/dist/scripts/scripts.js @@ -6483,23 +6483,33 @@ e.then(g); g.unwatchAll(w); }); })); -} ]), angular.module("openshiftConsole").controller("StatefulSetsController", [ "$scope", "$routeParams", "AlertMessageService", "DataService", "ProjectsService", function(a, b, c, d, e) { -a.projectName = b.project, a.alerts = a.alerts || {}, a.emptyMessage = "Loading...", c.getAlerts().forEach(function(b) { +} ]), angular.module("openshiftConsole").controller("StatefulSetsController", [ "$scope", "$routeParams", "AlertMessageService", "DataService", "ProjectsService", "LabelFilter", function(a, b, c, d, e, f) { +a.projectName = b.project, a.alerts = a.alerts || {}, a.labelSuggestions = {}, a.emptyMessage = "Loading...", c.getAlerts().forEach(function(b) { a.alerts[b.name] = b.data; }), c.clearAlerts(); -var f = []; +var g = []; e.get(b.project).then(_.spread(function(b, c) { -a.project = b, f.push(d.watch({ +function e() { +f.getLabelSelector().isEmpty() || !$.isEmptyObject(a.statefulSets) || $.isEmptyObject(a.unfilteredStatefulSets) ? delete a.alerts.statefulsets :a.alerts.statefulsets = { +type:"warning", +details:"The active filters are hiding all stateful sets." +}; +} +a.project = b, g.push(d.watch({ resource:"statefulsets", group:"apps", version:"v1beta1" }, c, function(b) { angular.extend(a, { loaded:!0, -statefulSets:b.by("metadata.name") +unfilteredStatefulSets:b.by("metadata.name") +}), a.statefulSets = f.getLabelSelector().select(a.unfilteredStatefulSets), f.addLabelSuggestionsFromResources(a.unfilteredStatefulSets, a.labelSuggestions), f.setLabelSuggestions(a.labelSuggestions), e(); +})), f.onActiveFiltersChanged(function(b) { +a.$apply(function() { +a.statefulSets = b.select(a.unfilteredStatefulSets), e(); }); -})), a.$on("$destroy", function() { -d.unwatchAll(f); +}), a.$on("$destroy", function() { +d.unwatchAll(g); }); })); } ]), angular.module("openshiftConsole").controller("StatefulSetController", [ "$filter", "$scope", "$routeParams", "AlertMessageService", "BreadcrumbsService", "DataService", "ProjectsService", function(a, b, c, d, e, f, g) { diff --git a/dist/scripts/templates.js b/dist/scripts/templates.js index a4419ca4a5..2df83ee307 100644 --- a/dist/scripts/templates.js +++ b/dist/scripts/templates.js @@ -4179,17 +4179,22 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function( "
\n" + "
\n" + "\n" + - "\n" + "
\n" + "

\n" + "Stateful Sets\n" + "\n" + "

\n" + "
\n" + + "
\n" + + "
\n" + + "\n" + + "
\n" + + "
\n" + "
\n" + "
\n" + "
\n" + "
\n" + + "\n" + "
Loading...
\n" + "
\n" + "
\n" +