Commit 0a392687 by Jeffrey Phillips

Show only bindable services for binding an application.

Also fixes a bug selecting applications when binding a service.
parent 273b7145
......@@ -1041,6 +1041,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
},
isServiceBindable: function(serviceInstance, serviceClasses) {
if (serviceClasses && serviceInstance) {
var serviceClass = serviceClasses[serviceInstance.spec.serviceClassName];
if (serviceClass) {
var plan = _.find(serviceClass.plans, {name: serviceInstance.spec.planName});
if (plan.bindable === false) {
return false;
} else if (plan.bindable === true) {
return true;
} else {
return serviceClass.bindable;
}
}
}
return !!serviceInstance;
}
};
});
......
......@@ -44,7 +44,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" You can create the binding later from your project.\n" +
" </span>\n" +
" </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" +
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
......@@ -61,6 +61,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" +
" </div>\n" +
" </div>\n" +
" <h4 ng-if=\"!ctrl.bindableServiceInstances.length\">\n" +
" <span class=\"pficon pficon-info\" aria-hidden=\"true\"></span>\n" +
" <span class=\"help-block service-instance-name\">\n" +
" There are no bindable services in this project\n" +
" </span>\n" +
" </h4>\n" +
" </div>\n" +
" </fieldset>\n" +
" </form>\n" +
......@@ -136,15 +142,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" +
" <div class=\"radio\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" +
" </label>\n" +
" <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"ctrl.shouldBindToApp === 'true'\">\n" +
" <ui-select-match placeholder=\"{{$ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <ui-select-match placeholder=\"{{ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <span>\n" +
" {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
......@@ -445,8 +451,17 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '='
},
templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () {
controller: function (BindingService) {
var ctrl = this;
ctrl.$onChanges = function (changeObj) {
if (changeObj.serviceInstances || changeObj.serviceClasses) {
ctrl.bindableServiceInstances = _.filter(ctrl.serviceInstances, isBindable);
}
};
function isBindable(serviceInstance) {
return BindingService.isServiceBindable(serviceInstance, ctrl.serviceClasses);
}
}
});
;'use strict';
......
......@@ -215,7 +215,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" You can create the binding later from your project.\n" +
" </span>\n" +
" </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" +
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
......@@ -232,6 +232,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" +
" </div>\n" +
" </div>\n" +
" <h4 ng-if=\"!ctrl.bindableServiceInstances.length\">\n" +
" <span class=\"pficon pficon-info\" aria-hidden=\"true\"></span>\n" +
" <span class=\"help-block service-instance-name\">\n" +
" There are no bindable services in this project\n" +
" </span>\n" +
" </h4>\n" +
" </div>\n" +
" </fieldset>\n" +
" </form>\n" +
......@@ -307,15 +313,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" +
" <div class=\"radio\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" +
" </label>\n" +
" <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"ctrl.shouldBindToApp === 'true'\">\n" +
" <ui-select-match placeholder=\"{{$ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <ui-select-match placeholder=\"{{ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <span>\n" +
" {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
......@@ -616,9 +622,18 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '='
},
templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () {
controller: ["BindingService", function (BindingService) {
var ctrl = this;
}
ctrl.$onChanges = function (changeObj) {
if (changeObj.serviceInstances || changeObj.serviceClasses) {
ctrl.bindableServiceInstances = _.filter(ctrl.serviceInstances, isBindable);
}
};
function isBindable(serviceInstance) {
return BindingService.isServiceBindable(serviceInstance, ctrl.serviceClasses);
}
}]
});
;'use strict';
......@@ -2633,6 +2648,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
},
isServiceBindable: function(serviceInstance, serviceClasses) {
if (serviceClasses && serviceInstance) {
var serviceClass = serviceClasses[serviceInstance.spec.serviceClassName];
if (serviceClass) {
var plan = _.find(serviceClass.plans, {name: serviceInstance.spec.planName});
if (plan.bindable === false) {
return false;
} else if (plan.bindable === true) {
return true;
} else {
return serviceClass.bindable;
}
}
}
return !!serviceInstance;
}
};
}]);
......
......@@ -26,7 +26,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" You can create the binding later from your project.\n" +
" </span>\n" +
" </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" +
" <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
......@@ -43,6 +43,12 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" </span>\n" +
" </div>\n" +
" </div>\n" +
" <h4 ng-if=\"!ctrl.bindableServiceInstances.length\">\n" +
" <span class=\"pficon pficon-info\" aria-hidden=\"true\"></span>\n" +
" <span class=\"help-block service-instance-name\">\n" +
" There are no bindable services in this project\n" +
" </span>\n" +
" </h4>\n" +
" </div>\n" +
" </fieldset>\n" +
" </form>\n" +
......@@ -118,15 +124,15 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" +
" <div class=\"radio\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!$ctrl.applications.length\">\n" +
" <label class=\"bind-choice\" ng-disabled=\"!ctrl.applications.length\">\n" +
" <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" +
" </label>\n" +
" <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"ctrl.shouldBindToApp === 'true'\">\n" +
" <ui-select-match placeholder=\"{{$ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <ui-select-match placeholder=\"{{ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}\">\n" +
" <span>\n" +
" {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
......
......@@ -22,7 +22,7 @@
You can create the binding later from your project.
</span>
</div>
<div ng-repeat="serviceInstance in ctrl.serviceInstances">
<div ng-repeat="serviceInstance in ctrl.bindableServiceInstances">
<label>
<input type="radio" ng-model="ctrl.serviceToBind" value="{{serviceInstance.metadata.name}}">
{{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}
......@@ -39,6 +39,12 @@
</span>
</div>
</div>
<h4 ng-if="!ctrl.bindableServiceInstances.length">
<span class="pficon pficon-info" aria-hidden="true"></span>
<span class="help-block service-instance-name">
There are no bindable services in this project
</span>
</h4>
</div>
</fieldset>
</form>
......
......@@ -12,7 +12,16 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '='
},
templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () {
controller: function (BindingService) {
var ctrl = this;
ctrl.$onChanges = function (changeObj) {
if (changeObj.serviceInstances || changeObj.serviceClasses) {
ctrl.bindableServiceInstances = _.filter(ctrl.serviceInstances, isBindable);
}
};
function isBindable(serviceInstance) {
return BindingService.isServiceBindable(serviceInstance, ctrl.serviceClasses);
}
}
});
......@@ -11,15 +11,15 @@
<form name="ctrl.formName" class="mar-bottom-lg">
<fieldset>
<div class="radio">
<label class="bind-choice" ng-disabled="!$ctrl.applications.length">
<input type="radio" ng-model="ctrl.shouldBindToApp" value="true" ng-disabled="!$ctrl.applications.length">
<label class="bind-choice" ng-disabled="!ctrl.applications.length">
<input type="radio" ng-model="ctrl.shouldBindToApp" value="true" ng-disabled="!ctrl.applications.length">
Bind to an application
</label>
<div class="application-select">
<ui-select ng-model="ctrl.appToBind"
ng-disabled="ctrl.shouldBindToApp !== 'true'"
ng-required="ctrl.shouldBindToApp === 'true'">
<ui-select-match placeholder="{{$ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}">
<ui-select-match placeholder="{{ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}">
<span>
{{$select.selected.metadata.name}}
<small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>
......
......@@ -32,6 +32,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context);
},
isServiceBindable: function(serviceInstance, serviceClasses) {
if (serviceClasses && serviceInstance) {
var serviceClass = serviceClasses[serviceInstance.spec.serviceClassName];
if (serviceClass) {
var plan = _.find(serviceClass.plans, {name: serviceInstance.spec.planName});
if (plan.bindable === false) {
return false;
} else if (plan.bindable === true) {
return true;
} else {
return serviceClass.bindable;
}
}
}
return !!serviceInstance;
}
};
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment