Skip to content

Commit d3293b3

Browse files
Fix the binding list update failure in service instance rows on the overview
1 parent a230883 commit d3293b3

File tree

12 files changed

+226
-150
lines changed

12 files changed

+226
-150
lines changed

app/scripts/controllers/newOverview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function OverviewController($scope,
9494
routesByService: {},
9595
servicesByObjectUID: {},
9696
serviceInstances: {},
97+
bindingsByInstanceRef: {},
9798
// Set to true below when metrics are available.
9899
showMetrics: false
99100
};
@@ -1072,7 +1073,7 @@ function OverviewController($scope,
10721073
}, 300);
10731074

10741075
// TODO: code duplicated from directives/bindService.js
1075-
// extract & share
1076+
// extract & share
10761077
var sortServiceInstances = function() {
10771078
if(!state.serviceInstances && !state.serviceClasses) {
10781079
return;
@@ -1252,6 +1253,10 @@ function OverviewController($scope,
12521253
resource: 'instances'
12531254
}, context, function(serviceInstances) {
12541255
state.serviceInstances = serviceInstances.by('metadata.name');
1256+
_.each(state.serviceInstances, function(instance) {
1257+
var notifications = ResourceAlertsService.getServiceInstanceAlerts(instance);
1258+
setNotifications(instance, notifications);
1259+
});
12551260
sortServiceInstances();
12561261
updateFilter();
12571262
}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));
@@ -1263,6 +1268,7 @@ function OverviewController($scope,
12631268
resource: 'bindings'
12641269
}, context, function(bindings) {
12651270
state.bindings = bindings.by('metadata.name');
1271+
overview.bindingsByInstanceRef = _.groupBy(state.bindings, 'spec.instanceRef.name');
12661272
refreshSecrets(context);
12671273
updateFilter();
12681274
}, {poll: limitWatches, pollInterval: DEFAULT_POLL_INTERVAL}));

app/scripts/directives/overview/serviceInstanceRow.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ angular.module('openshiftConsole').component('serviceInstanceRow', {
1111
controllerAs: 'row',
1212
bindings: {
1313
apiObject: '<',
14-
state: '<'
14+
state: '<',
15+
bindings: '<'
1516
},
1617
templateUrl: 'views/overview/_service-instance-row.html'
1718
});
@@ -21,7 +22,7 @@ function ServiceInstanceRow($filter, DataService, rowMethods, $uibModal) {
2122
_.extend(row, rowMethods.ui);
2223

2324
var getErrorDetails = $filter('getErrorDetails');
24-
25+
2526
var getDisplayName = function() {
2627
var serviceClassName = row.apiObject.spec.serviceClassName;
2728
var instanceName = row.apiObject.metadata.name;
@@ -34,17 +35,10 @@ function ServiceInstanceRow($filter, DataService, rowMethods, $uibModal) {
3435
return _.get(row, ['state','serviceClasses', serviceClassName, 'description']);
3536
};
3637

37-
var getBindings = function() {
38-
return _.filter(row.state.bindings, function(binding) {
39-
return binding.spec.instanceRef.name === row.apiObject.metadata.name;
40-
});
41-
};
42-
4338
row.$onChanges = function() {
4439
row.notifications = rowMethods.getNotifications(row.apiObject, row.state);
4540
row.displayName = getDisplayName();
4641
row.description = getDescription();
47-
row.instanceBindings = getBindings();
4842
};
4943

5044
row.getSecretForBinding = function(binding) {

app/scripts/filters/resources.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ angular.module('openshiftConsole')
10841084
return lastFinishTime;
10851085
};
10861086
})
1087+
// gets the status condition that matches provided type
1088+
// statusCondition(object, 'Ready')
10871089
.filter('statusCondition', function() {
10881090
return function(apiObject, type) {
10891091
if (!apiObject) {
@@ -1093,6 +1095,14 @@ angular.module('openshiftConsole')
10931095
return _.find(_.get(apiObject, 'status.conditions'), {type: type});
10941096
};
10951097
})
1098+
.filter('isServiceInstanceReady', function(statusConditionFilter) {
1099+
return function(apiObject) {
1100+
return _.get(statusConditionFilter(apiObject, 'Ready'), 'status') === 'True';
1101+
};
1102+
})
1103+
.filter('isBindingReady', function(isServiceInstanceReadyFilter) {
1104+
return isServiceInstanceReadyFilter;
1105+
})
10961106
.filter('routeIngressCondition', function() {
10971107
return function(ingress, type) {
10981108
if (!ingress) {

app/scripts/services/resourceAlerts.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,46 @@ angular.module("openshiftConsole")
147147
return alerts;
148148
};
149149

150+
var makeConditionAlert = function(alerts, uid, condition, type) {
151+
alerts[uid+'-'+condition.reason] = {
152+
type: type,
153+
message: condition.message
154+
};
155+
};
156+
157+
var getServiceInstanceAlerts = function(instance) {
158+
var alerts = {};
159+
if(!instance) {
160+
return alerts;
161+
}
162+
var uid = instance.metadata.uid;
163+
// filter may be overkill here, probably will be only 1 per reason?
164+
var namespaceErrors = _.filter(instance.status.conditions, {reason: 'ErrorFindingNamespaceForInstance'});
165+
var provisionFails = _.filter(instance.status.conditions, {reason: 'ProvisionFailed'});
166+
var deprovisionFails = _.filter(instance.status.conditions, {reason: 'DeprovisioningFailed'});
167+
168+
if(namespaceErrors.length) {
169+
_.each(namespaceErrors, function(condition) {
170+
makeConditionAlert(alerts, uid, condition, 'warning');
171+
});
172+
}
173+
if(provisionFails.length) {
174+
_.each(provisionFails, function(condition) {
175+
makeConditionAlert(alerts, uid, condition, 'error');
176+
});
177+
}
178+
if(deprovisionFails.length) {
179+
_.each(deprovisionFails, function(condition) {
180+
makeConditionAlert(alerts, uid, condition, 'error');
181+
});
182+
}
183+
return alerts;
184+
};
185+
150186
return {
151187
getPodAlerts: getPodAlerts,
152188
setGenericQuotaWarning: setGenericQuotaWarning,
153-
getDeploymentStatusAlerts: getDeploymentStatusAlerts
189+
getDeploymentStatusAlerts: getDeploymentStatusAlerts,
190+
getServiceInstanceAlerts: getServiceInstanceAlerts
154191
};
155192
});
156-

app/views/directives/bind-service/results.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div>
22
<div ng-if="!ctrl.error">
3-
<div ng-if="(ctrl.binding | statusCondition : 'Ready').status !== 'True'">
3+
<div ng-if="!(ctrl.binding | isBindingReady)">
44
<h3 class="mar-top-none center">
55
<span class="fa fa-spinner fa-pulse fa-3x fa-fw" aria-hidden="true"></span>
66
<span class="sr-only">Pending</span>
77
<div class="mar-top-lg">The binding was created but is not ready yet.</div>
88
</h3>
99
</div>
10-
<div ng-if="(ctrl.binding | statusCondition : 'Ready').status === 'True'">
10+
<div ng-if="(ctrl.binding | isBindingReady)">
1111
<h3 class="mar-top-none">
1212
<strong>{{ctrl.serviceToBind}}</strong> has been bound to <strong>{{ctrl.target.metadata.name}}</strong> successfully
1313
</h3>

app/views/directives/bind-service/select-service.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h3 class="mar-top-none">Select a service to bind to <strong>{{ctrl.target.metad
88
<label>
99
<input type="radio" ng-model="ctrl.serviceToBind" value="{{serviceInstance.metadata.name}}">
1010
{{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}
11-
<span ng-if="(serviceInstance | statusCondition : 'Ready').status !== 'True'" class="mar-left-sm">
11+
<span ng-if="!(serviceInstance | isServiceInstanceReady)" class="mar-left-sm">
1212
<span class="pficon pficon-info" data-content="This service is not yet ready. If you bind to it, then the binding will be pending until the service is ready." data-toggle="popover" data-trigger="hover"></span>
1313
</span>
1414
<div class="help-block mar-top-none">

app/views/new-overview.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ <h2 ng-if="overview.state.serviceInstances">
365365
<service-instance-row
366366
ng-repeat="serviceInstance in overview.state.orderedServiceInstances"
367367
api-object="serviceInstance"
368+
bindings="overview.bindingsByInstanceRef[serviceInstance.metadata.name]"
368369
state="overview.state"></service-instance-row>
369370
</div>
370371
</div>

app/views/overview/_service-instance-row.html

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ <h3>
1919
</div>
2020
</div>
2121

22-
<div
23-
class="list-pf-content hidden-xs hidden-sm">
22+
<div class="list-pf-content hidden-xs hidden-sm">
2423
<div class="list-pf-content-right">
2524
<div>
2625
<strong ng-if="!row.instanceBindings.length">No Bindings</strong>
@@ -68,62 +67,68 @@ <h3>
6867
ng-class="{ in: row.expanded }">
6968

7069
<div class="list-pf-container">
71-
72-
<!--
73-
TODO: follow-on PR
7470
<div class="expanded-section">
75-
<div class="section-title">
76-
Configuration Details
77-
</div>
78-
<div class="row" ng-repeat="item in [{
79-
name: 'password',
80-
value: '*****'
81-
}, {
82-
name: 'lorem ipsum',
83-
value: 'dolor sit amet'
84-
}]">
85-
<div class="col-sm-5">{{item.name}}</div>
86-
<div class="col-sm-7">{{item.value}}</div>
71+
<alerts alerts="row.notifications"></alerts>
72+
<!--
73+
TODO: follow-on PR
74+
<div class="expanded-section">
75+
<div class="section-title">
76+
Configuration Details
77+
</div>
78+
<div class="row" ng-repeat="item in [{
79+
name: 'password',
80+
value: '*****'
81+
}, {
82+
name: 'lorem ipsum',
83+
value: 'dolor sit amet'
84+
}]">
85+
<div class="col-sm-5">{{item.name}}</div>
86+
<div class="col-sm-7">{{item.value}}</div>
87+
</div>
8788
</div>
88-
</div>
89-
-->
89+
-->
9090

91-
<div class="row">
92-
<div class="col-sm-12" ng-if="row.description">
93-
<p class="pre-wrap" ng-bind-html="row.description | linky"></p>
91+
<div class="row">
92+
<div class="col-sm-12" ng-if="row.description">
93+
<p class="pre-wrap" ng-bind-html="row.description | linky"></p>
94+
</div>
9495
</div>
95-
</div>
96-
<div class="section-title">
97-
Bindings
98-
</div>
99-
<span ng-if="!row.instanceBindings.length">There are no bindings.</span>
100-
<div
101-
ng-if="row.instanceBindings.length"
102-
class="row"
103-
ng-repeat="binding in row.instanceBindings">
104-
<div class="col-sm-4">
105-
<span>{{binding.metadata.name}}</span>
96+
<div class="section-title">
97+
Bindings
10698
</div>
107-
<div class="col-sm-8">
108-
<!-- TODO: follow-on PR
109-
<a ng-href="{{binding | navigateResourceURL}}">View configuration details</a>
110-
-->
111-
<a href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
112-
View secret
113-
</a>
99+
<span ng-if="!row.bindings">There are no bindings.</span>
100+
<div
101+
ng-if="row.bindings"
102+
class="row"
103+
ng-repeat="(name, binding) in row.bindings">
104+
<div class="col-sm-5">
105+
<span>{{binding.metadata.name}}</span>
106+
</div>
107+
<div class="col-sm-7">
108+
<!-- TODO: follow-on PR
109+
<a ng-href="{{binding | navigateResourceURL}}">View configuration details</a>
110+
-->
111+
<span ng-if="!(binding | isBindingReady)">
112+
<status-icon status="'Pending'"></status-icon> Pending
113+
</span>
114+
<a
115+
ng-if="(binding | isBindingReady) && ('secrets' | canI : 'get')"
116+
href="{{row.getSecretForBinding(binding) | navigateResourceURL}}">
117+
View secret
118+
</a>
119+
</div>
114120
</div>
115-
</div>
116-
<!-- TODO: follow-on PR
117-
<div class="row">
118-
<div class="col-sm-12">
119-
<a href="#">
120-
<i class="fa fa-plus-circle"></i> Create binding
121-
</a>
121+
<!-- TODO: follow-on PR
122+
<div class="row">
123+
<div class="col-sm-12">
124+
<a href="#">
125+
<i class="fa fa-plus-circle"></i> Create binding
126+
</a>
127+
</div>
122128
</div>
129+
-->
123130
</div>
124-
-->
125131
</div>
126-
127132
</div>
128133

129134
</div>

0 commit comments

Comments
 (0)