-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathconfigMaps.js
63 lines (55 loc) · 2 KB
/
configMaps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
/**
* @ngdoc function
* @name openshiftConsole.controller:ConfigMapsController
* @description
* # ConfigMapsController
* Controller of the openshiftConsole
*/
angular.module('openshiftConsole')
.controller('ConfigMapsController',
function ($scope,
$routeParams,
APIService,
DataService,
LabelFilter,
ProjectsService) {
$scope.projectName = $routeParams.project;
$scope.loaded = false;
$scope.labelSuggestions = {};
$scope.configMapsVersion = APIService.getPreferredVersion('configmaps');
$scope.clearFilter = function () {
LabelFilter.clear();
};
var watches = [];
var configMaps;
var updateFilterMessage = function() {
$scope.filterWithZeroResults = !LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.configMaps) && !_.isEmpty(configMaps);
};
var updateLabelSuggestions = function() {
LabelFilter.addLabelSuggestionsFromResources(configMaps, $scope.labelSuggestions);
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
};
var updateConfigMaps = function() {
var filteredConfigMaps = LabelFilter.getLabelSelector().select(configMaps);
$scope.configMaps = _.sortBy(filteredConfigMaps, 'metadata.name');
updateFilterMessage();
};
ProjectsService
.get($routeParams.project)
.then(_.spread(function(project, context) {
$scope.project = project;
watches.push(DataService.watch($scope.configMapsVersion, context, function(configMapData) {
configMaps = configMapData.by('metadata.name');
updateLabelSuggestions();
updateConfigMaps();
$scope.loaded = true;
}));
LabelFilter.onActiveFiltersChanged(function() {
$scope.$evalAsync(updateConfigMaps);
});
$scope.$on('$destroy', function(){
DataService.unwatchAll(watches);
});
}));
});