Skip to content

Commit 6c9d67f

Browse files
committed
DEV Clean Up
Comment and minor code clean up
1 parent ae50d6f commit 6c9d67f

File tree

6 files changed

+92
-267
lines changed

6 files changed

+92
-267
lines changed

app/scripts/controllers/provisionedService.js

+1-90
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ angular.module('openshiftConsole')
66
$routeParams,
77
DataService,
88
ProjectsService) {
9-
$scope.projectName = $routeParams.project;
109
$scope.displayName = null;
1110
$scope.serviceInstance = null;
1211
$scope.serviceInstances = null;
1312
$scope.serviceClasses = {};
1413
$scope.alerts = {};
15-
//$scope.renderOptions = $scope.renderOptions || {};
16-
//$scope.renderOptions.hideFilterWidget = true;
1714

1815
$scope.breadcrumbs = [
1916
{
@@ -25,54 +22,8 @@ angular.module('openshiftConsole')
2522
}
2623
];
2724

28-
$scope.podFailureReasons = {
29-
"Pending": "This pod will not receive traffic until all of its containers have been created."
30-
};
31-
32-
//var allPods = {};
3325
var watches = [];
3426

35-
// receives routes for the current service and maps service ports to each route name
36-
var getPortsByRoute = function() {
37-
if(!$scope.serviceInstance) {
38-
return;
39-
}
40-
41-
$scope.portsByRoute = {};
42-
43-
_.each($scope.serviceInstance.spec.ports, function(port) {
44-
var reachedByRoute = false;
45-
if(port.nodePort) {
46-
$scope.showNodePorts = true;
47-
}
48-
49-
_.each($scope.routesForService, function(route) {
50-
if(!route.spec.port || route.spec.port.targetPort === port.name ||
51-
route.spec.port.targetPort === port.targetPort) {
52-
$scope.portsByRoute[route.metadata.name] = $scope.portsByRoute[route.metadata.name] || [];
53-
$scope.portsByRoute[route.metadata.name].push(port);
54-
reachedByRoute = true;
55-
}
56-
});
57-
58-
if(!reachedByRoute) {
59-
$scope.portsByRoute[''] = $scope.portsByRoute[''] || [];
60-
$scope.portsByRoute[''].push(port);
61-
}
62-
});
63-
};
64-
65-
// receive pods for the current service scope only when the service object is available
66-
/*var getPodsForService = function() {
67-
$scope.podsForService = {};
68-
if (!$scope.serviceInstance) {
69-
return;
70-
}
71-
72-
var ls = new LabelSelector($scope.serviceInstance.spec.selector);
73-
$scope.podsForService = ls.select(allPods);
74-
};*/
75-
7627
var setDisplayName = function() {
7728
if(!$scope.serviceInstance || !$scope.serviceClasses) {
7829
return;
@@ -85,9 +36,6 @@ angular.module('openshiftConsole')
8536
$scope.loaded = true;
8637
$scope.serviceInstance = service;
8738

88-
//getPodsForService();
89-
getPortsByRoute();
90-
9139
if (action === "DELETED") {
9240
$scope.alerts["deleted"] = {
9341
type: "warning",
@@ -102,10 +50,6 @@ angular.module('openshiftConsole')
10250
$scope.project = project;
10351
$scope.projectContext = context;
10452

105-
//DataService.prototype.get = function(resource, name, context, opts) {
106-
//DataService.prototype.watch = function(resource, context, callback, opts) {
107-
//DataService.prototype.watchObject = function(resource, name, context, callback, opts) {
108-
10953
DataService
11054
.get({
11155
group: 'servicecatalog.k8s.io',
@@ -118,6 +62,7 @@ angular.module('openshiftConsole')
11862
group: 'servicecatalog.k8s.io',
11963
resource: 'instances'
12064
}, $routeParams.instance, context, serviceResolved));
65+
12166
}, function(error) {
12267
$scope.loaded = true;
12368
$scope.alerts["load"] = {
@@ -142,40 +87,6 @@ angular.module('openshiftConsole')
14287
$scope.serviceInstances = services.by("metadata.name");
14388
}));
14489

145-
/*watches.push(DataService.watch("pods", context, function(pods) {
146-
allPods = pods.by("metadata.name");
147-
getPodsForService();
148-
}));*/
149-
150-
/*watches.push(DataService.watch("endpoints", context, function(endpoints) {
151-
$scope.podsWithEndpoints = {};
152-
var svcEndpoint = endpoints.by("metadata.name")[$routeParams.instance];
153-
if (!svcEndpoint) {
154-
return;
155-
}
156-
157-
_.each(svcEndpoint.subsets, function(subset) {
158-
_.each(subset.addresses, function(address) {
159-
if (_.get(address, "targetRef.kind") === "Pod") {
160-
$scope.podsWithEndpoints[address.targetRef.name] = true;
161-
}
162-
});
163-
});
164-
}));*/
165-
166-
watches.push(DataService.watch("routes", context, function(routes) {
167-
$scope.routesForService = {};
168-
angular.forEach(routes.by("metadata.name"), function(route) {
169-
if (route.spec.to.kind === "Service" &&
170-
route.spec.to.name === $routeParams.instance) {
171-
$scope.routesForService[route.metadata.name] = route;
172-
}
173-
});
174-
175-
getPortsByRoute();
176-
Logger.log("routes (subscribe)", $scope.routesByService);
177-
}));
178-
17990
$scope.$on('$destroy', function(){
18091
DataService.unwatchAll(watches);
18192
});

app/scripts/controllers/provisionedServices.js

+44-72
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,11 @@ angular.module('openshiftConsole')
1111
LabelFilter,
1212
Logger,
1313
ProjectsService) {
14-
15-
//var overview = this;
16-
//var limitWatches = $filter('isIE')() || $filter('isEdge')();
17-
//var DEFAULT_POLL_INTERVAL = 60 * 1000; // milliseconds
18-
19-
// Enable service catalog features if the new experience is enabled and the
20-
// servicecatalog.k8s.io resources are available.
21-
var SERVICE_CATALOG_ENABLED =
22-
_.get(Constants, 'ENABLE_TECH_PREVIEW_FEATURE.service_catalog_landing_page') &&
23-
APIService.apiInfo({ group: 'servicecatalog.k8s.io', resource: 'serviceclasses' }) &&
24-
APIService.apiInfo({ group: 'servicecatalog.k8s.io', resource: 'instances' }) &&
25-
APIService.apiInfo({ group: 'servicecatalog.k8s.io', resource: 'bindings' });
26-
27-
$scope.projectName = $routeParams.project;
2814
$scope.serviceInstances = {};
2915
$scope.unfilteredServiceInstances = {};
30-
//$scope.routesByService = {};
31-
//$scope.routes = {};
3216
$scope.labelSuggestions = {};
3317
$scope.alerts = $scope.alerts || {};
3418
$scope.emptyMessage = "Loading...";
35-
$scope.emptyMessageRoutes = "Loading...";
3619

3720
var watches = [];
3821

@@ -176,68 +159,57 @@ angular.module('openshiftConsole')
176159
.then(_.spread(function(project, context) {
177160
$scope.project = project;
178161

179-
var canI = $filter('canI');
180-
181-
if (SERVICE_CATALOG_ENABLED && canI({resource: 'instances', group: 'servicecatalog.k8s.io'}, 'watch')) {
182-
watches.push(DataService.watch({
183-
group: 'servicecatalog.k8s.io',
184-
resource: 'instances'
185-
}, context, function(serviceInstances) {
186-
$scope.emptyMessage = "No provisioned services to show";
187-
state.unfilteredServiceInstances = serviceInstances.by('metadata.name');
188-
189-
//_.each(state.unfilteredServiceInstances, function (instance) {
190-
// var notifications = ResourceAlertsService.getServiceInstanceAlerts(instance);
191-
// setNotifications(instance, notifications);
192-
//});
193-
194-
sortServiceInstances();
195-
updateFilter();
196-
updateFilterWarning();
197-
198-
//updateLabelSuggestions(state.serviceInstances);
199-
LabelFilter.addLabelSuggestionsFromResources(state.unfilteredServiceInstances, $scope.labelSuggestions);
200-
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
201-
202-
Logger.log("provisioned services (subscribe)", state.unfilteredServiceInstances);
203-
204-
//}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));
205-
}));
206-
}
207-
208-
if (SERVICE_CATALOG_ENABLED && canI({resource: 'bindings', group: 'servicecatalog.k8s.io'}, 'watch')) {
209-
watches.push(DataService.watch({
210-
group: 'servicecatalog.k8s.io',
211-
resource: 'bindings'
212-
}, context, function(bindings) {
213-
state.bindings = bindings.by('metadata.name');
214-
state.bindingsByInstanceRef = _.groupBy(state.bindings, 'spec.instanceRef.name');
215-
groupBindings();
216-
//refreshSecrets(context);
217-
//}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));
218-
}));
219-
}
220-
221-
if (SERVICE_CATALOG_ENABLED && canI({resource: 'instances', group: 'servicecatalog.k8s.io'}, 'watch')) {
222-
DataService.list({
223-
group: 'servicecatalog.k8s.io',
224-
resource: 'serviceclasses'
225-
}, context, function(serviceClasses) {
226-
state.serviceClasses = serviceClasses.by('metadata.name');
227-
sortServiceInstances();
228-
updateFilter();
229-
});
230-
}
162+
watches.push(DataService.watch({
163+
group: 'servicecatalog.k8s.io',
164+
resource: 'instances'
165+
}, context, function(serviceInstances) {
166+
$scope.emptyMessage = "No provisioned services to show";
167+
state.unfilteredServiceInstances = serviceInstances.by('metadata.name');
168+
169+
//_.each(state.unfilteredServiceInstances, function (instance) {
170+
// var notifications = ResourceAlertsService.getServiceInstanceAlerts(instance);
171+
// setNotifications(instance, notifications);
172+
//});
173+
174+
sortServiceInstances();
175+
updateFilter();
176+
updateFilterWarning();
177+
178+
//updateLabelSuggestions(state.serviceInstances);
179+
LabelFilter.addLabelSuggestionsFromResources(state.unfilteredServiceInstances, $scope.labelSuggestions);
180+
LabelFilter.setLabelSuggestions($scope.labelSuggestions);
181+
182+
Logger.log("provisioned services (subscribe)", state.unfilteredServiceInstances);
183+
}));
184+
185+
watches.push(DataService.watch({
186+
group: 'servicecatalog.k8s.io',
187+
resource: 'bindings'
188+
}, context, function(bindings) {
189+
state.bindings = bindings.by('metadata.name');
190+
state.bindingsByInstanceRef = _.groupBy(state.bindings, 'spec.instanceRef.name');
191+
groupBindings();
192+
//refreshSecrets(context);
193+
}));
194+
195+
DataService.list({
196+
group: 'servicecatalog.k8s.io',
197+
resource: 'serviceclasses'
198+
}, context, function(serviceClasses) {
199+
state.serviceClasses = serviceClasses.by('metadata.name');
200+
sortServiceInstances();
201+
updateFilter();
202+
});
231203

232204
function updateFilterWarning() {
233205
if (!LabelFilter.getLabelSelector().isEmpty() && _.isEmpty($scope.serviceInstances) && !_.isEmpty($scope.unfilteredServiceInstances)) {
234-
$scope.alerts["services"] = {
206+
$scope.alerts["all-instances-filtered"] = {
235207
type: "warning",
236-
details: "The active filters are hiding all services."
208+
details: "The active filters are hiding all provisioned services."
237209
};
238210
}
239211
else {
240-
delete $scope.alerts["services"];
212+
delete $scope.alerts["all-instances-filtered"];
241213
}
242214
}
243215

app/views/browse/provisioned-service.html

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ <h1 class="contains-actions">
2020
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
2121
data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
2222
<ul class="dropdown-menu dropdown-menu-right actions action-button">
23-
<li ng-if="'routes' | canI : 'create'">
24-
<a ng-href="project/{{project.metadata.name}}/create-route?instance={{serviceInstance.metadata.name}}"
25-
role="button">Create Route</a>
26-
</li>
2723
<li ng-if="{resource: 'instances', group: 'servicecatalog.k8s.io'} | canI : 'update'">
2824
<a ng-href="{{serviceInstance | editYamlURL}}" role="button">Edit YAML</a>
2925
</li>

app/views/provisioned.html

+8-15
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<div class="page-header page-header-bleed-right page-header-bleed-left">
1010
<h1>
1111
Provisioned Services
12-
<span class="page-header-link">
13-
<a ng-href="{{'services' | helpLink}}" target="_blank">
12+
<!--<span class="page-header-link">
13+
<a ng-href="{{'service-catalog' | helpLink}}" target="_blank">
1414
Learn More <i class="fa fa-external-link" aria-hidden="true"></i>
1515
</a>
16-
</span>
16+
</span>-->
1717
</h1>
1818
</div>
1919
<div class="data-toolbar">
@@ -38,31 +38,24 @@ <h1>
3838
<th>Status</th>
3939
<th>Created</th>
4040
<th>Bindings</th>
41-
42-
<!--<th>Name</th>
43-
<th>Cluster IP</th>
44-
<th>External IP</th>
45-
<th>Ports</th>
46-
<th>Selector</th>
47-
<th>Age</th>-->
4841
</tr>
4942
</thead>
50-
<tbody ng-if="(serviceInstances | hashSize) === 0">
43+
<tbody ng-if="(serviceInstances | size) === 0">
5144
<tr>
5245
<td colspan="4"><em>{{emptyMessage}}</em></td>
5346
</tr>
5447
</tbody>
55-
<tbody ng-if="(serviceInstances | hashSize) > 0">
56-
<tr ng-repeat="serviceInstance in serviceInstances | orderObjectsByDate : true">
48+
<tbody ng-if="(serviceInstances | size) > 0">
49+
<tr ng-repeat="serviceInstance in serviceInstances track by (serviceInstance | uid)">
5750
<td data-title="Name"><a ng-href="{{serviceInstance | navigateResourceURL}}">{{serviceInstance | serviceInstanceDisplayName:serviceClasses}}</a></td>
5851

5952
<td data-title="Status">
60-
<div row class="status">
53+
<!--<div row class="status">
6154
<status-icon status="serviceInstance | deploymentStatus" disable-animation></status-icon>
6255
<span flex>
6356
{{serviceInstance | deploymentStatus}}
6457
</span>
65-
</div>
58+
</div>-->
6659
</td>
6760
<td data-title="Created">
6861
<span am-time-ago="serviceInstance.metadata.creationTimestamp" am-without-suffix="true"></span> ago

0 commit comments

Comments
 (0)