Commit 038b0fff by Sam Padgett Committed by GitHub

Merge pull request #85 from jeff-phillips-18/bind

Show only bindable services for binding an application.
parents 273b7145 0a392687
...@@ -1041,6 +1041,22 @@ angular.module("openshiftCommonServices") ...@@ -1041,6 +1041,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application // TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context); 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'); ...@@ -44,7 +44,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" You can create the binding later from your project.\n" + " You can create the binding later from your project.\n" +
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
...@@ -61,6 +61,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -61,6 +61,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\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" + " </div>\n" +
" </fieldset>\n" + " </fieldset>\n" +
" </form>\n" + " </form>\n" +
...@@ -136,15 +142,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -136,15 +142,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" + " <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" + " <fieldset>\n" +
" <div class=\"radio\">\n" + " <div class=\"radio\">\n" +
" <label class=\"bind-choice\" 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" + " <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" + " Bind to an application\n" +
" </label>\n" + " </label>\n" +
" <div class=\"application-select\">\n" + " <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" + " <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" + " ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"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" + " <span>\n" +
" {{$select.selected.metadata.name}}\n" + " {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" + " <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
...@@ -445,8 +451,17 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', { ...@@ -445,8 +451,17 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '=' serviceToBind: '='
}, },
templateUrl: 'src/components/binding/bindApplicationForm.html', templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () { controller: function (BindingService) {
var ctrl = this; 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'; ;'use strict';
......
...@@ -215,7 +215,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -215,7 +215,7 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" You can create the binding later from your project.\n" + " You can create the binding later from your project.\n" +
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
...@@ -232,6 +232,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -232,6 +232,12 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\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" + " </div>\n" +
" </fieldset>\n" + " </fieldset>\n" +
" </form>\n" + " </form>\n" +
...@@ -307,15 +313,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI'); ...@@ -307,15 +313,15 @@ hawtioPluginLoader.addModule('openshiftCommonUI');
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" + " <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" + " <fieldset>\n" +
" <div class=\"radio\">\n" + " <div class=\"radio\">\n" +
" <label class=\"bind-choice\" 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" + " <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" + " Bind to an application\n" +
" </label>\n" + " </label>\n" +
" <div class=\"application-select\">\n" + " <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" + " <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" + " ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"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" + " <span>\n" +
" {{$select.selected.metadata.name}}\n" + " {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" + " <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
...@@ -616,9 +622,18 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', { ...@@ -616,9 +622,18 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '=' serviceToBind: '='
}, },
templateUrl: 'src/components/binding/bindApplicationForm.html', templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () { controller: ["BindingService", function (BindingService) {
var ctrl = this; 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'; ;'use strict';
...@@ -2633,6 +2648,22 @@ angular.module("openshiftCommonServices") ...@@ -2633,6 +2648,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application // TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context); 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 ...@@ -26,7 +26,7 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" You can create the binding later from your project.\n" + " You can create the binding later from your project.\n" +
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\n" +
" <div ng-repeat=\"serviceInstance in ctrl.serviceInstances\">\n" + " <div ng-repeat=\"serviceInstance in ctrl.bindableServiceInstances\">\n" +
" <label>\n" + " <label>\n" +
" <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" + " <input type=\"radio\" ng-model=\"ctrl.serviceToBind\" value=\"{{serviceInstance.metadata.name}}\">\n" +
" {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" + " {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}\n" +
...@@ -43,6 +43,12 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -43,6 +43,12 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" </span>\n" + " </span>\n" +
" </div>\n" + " </div>\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" + " </div>\n" +
" </fieldset>\n" + " </fieldset>\n" +
" </form>\n" + " </form>\n" +
...@@ -118,15 +124,15 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac ...@@ -118,15 +124,15 @@ angular.module('openshiftCommonUI').run(['$templateCache', function($templateCac
" <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" + " <form name=\"ctrl.formName\" class=\"mar-bottom-lg\">\n" +
" <fieldset>\n" + " <fieldset>\n" +
" <div class=\"radio\">\n" + " <div class=\"radio\">\n" +
" <label class=\"bind-choice\" 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" + " <input type=\"radio\" ng-model=\"ctrl.shouldBindToApp\" value=\"true\" ng-disabled=\"!ctrl.applications.length\">\n" +
" Bind to an application\n" + " Bind to an application\n" +
" </label>\n" + " </label>\n" +
" <div class=\"application-select\">\n" + " <div class=\"application-select\">\n" +
" <ui-select ng-model=\"ctrl.appToBind\"\n" + " <ui-select ng-model=\"ctrl.appToBind\"\n" +
" ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" + " ng-disabled=\"ctrl.shouldBindToApp !== 'true'\"\n" +
" ng-required=\"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" + " <span>\n" +
" {{$select.selected.metadata.name}}\n" + " {{$select.selected.metadata.name}}\n" +
" <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" + " <small class=\"text-muted\">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>\n" +
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
You can create the binding later from your project. You can create the binding later from your project.
</span> </span>
</div> </div>
<div ng-repeat="serviceInstance in ctrl.serviceInstances"> <div ng-repeat="serviceInstance in ctrl.bindableServiceInstances">
<label> <label>
<input type="radio" ng-model="ctrl.serviceToBind" value="{{serviceInstance.metadata.name}}"> <input type="radio" ng-model="ctrl.serviceToBind" value="{{serviceInstance.metadata.name}}">
{{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}} {{ctrl.serviceClasses[serviceInstance.spec.serviceClassName].osbMetadata.displayName || serviceInstance.spec.serviceClassName}}
...@@ -39,6 +39,12 @@ ...@@ -39,6 +39,12 @@
</span> </span>
</div> </div>
</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> </div>
</fieldset> </fieldset>
</form> </form>
......
...@@ -12,7 +12,16 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', { ...@@ -12,7 +12,16 @@ angular.module('openshiftCommonUI').component('bindApplicationForm', {
serviceToBind: '=' serviceToBind: '='
}, },
templateUrl: 'src/components/binding/bindApplicationForm.html', templateUrl: 'src/components/binding/bindApplicationForm.html',
controller: function () { controller: function (BindingService) {
var ctrl = this; 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 @@ ...@@ -11,15 +11,15 @@
<form name="ctrl.formName" class="mar-bottom-lg"> <form name="ctrl.formName" class="mar-bottom-lg">
<fieldset> <fieldset>
<div class="radio"> <div class="radio">
<label class="bind-choice" 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"> <input type="radio" ng-model="ctrl.shouldBindToApp" value="true" ng-disabled="!ctrl.applications.length">
Bind to an application Bind to an application
</label> </label>
<div class="application-select"> <div class="application-select">
<ui-select ng-model="ctrl.appToBind" <ui-select ng-model="ctrl.appToBind"
ng-disabled="ctrl.shouldBindToApp !== 'true'" ng-disabled="ctrl.shouldBindToApp !== 'true'"
ng-required="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> <span>
{{$select.selected.metadata.name}} {{$select.selected.metadata.name}}
<small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small> <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>
......
...@@ -32,6 +32,22 @@ angular.module("openshiftCommonServices") ...@@ -32,6 +32,22 @@ angular.module("openshiftCommonServices")
// TODO: Use appToBind to bind the service to the application // TODO: Use appToBind to bind the service to the application
return DataService.create(bindingResource, null, newBinding, context); 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