diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceBindings.mock.js b/src/plugins/cloud-foundry/api/hcf/ServiceBindings.mock.js
index f794263058..5697699dcd 100644
--- a/src/plugins/cloud-foundry/api/hcf/ServiceBindings.mock.js
+++ b/src/plugins/cloud-foundry/api/hcf/ServiceBindings.mock.js
@@ -6,6 +6,44 @@
mock.cloudFoundryAPI.ServiceBindings = {
+ CreateServiceBinding: function (newBindingSpec) {
+ return {
+ url: '/pp/v1/proxy/v2/service_bindings',
+ response: {
+ 200: {
+ body: {
+ guid: {
+ "metadata": {
+ "guid": "8ed4029b-251a-41d3-95ee-55cf3a1817d4",
+ "url": "/v2/service_bindings/8ed4029b-251a-41d3-95ee-55cf3a1817d4",
+ "created_at": "2016-05-12T00:45:16Z",
+ "updated_at": null
+ },
+ "entity": {
+ "app_guid": newBindingSpec.app_guid,
+ "service_instance_guid": newBindingSpec.service_instance_guid,
+ "credentials": {
+ "creds-key-32": "creds-val-32"
+ },
+ "binding_options": {},
+ "gateway_data": null,
+ "gateway_name": "",
+ "syslog_drain_url": null,
+ "volume_mounts": [],
+ "app_url": "/v2/apps/" + newBindingSpec.app_guid,
+ "service_instance_url": "/v2/user_provided_service_instances/" + newBindingSpec.service_instance_guid
+ }
+ }
+ }
+ },
+
+ 400: {
+ body: { guid: {} }
+ }
+ }
+ };
+ },
+
DeleteServiceBinding: function (guid) {
return {
url: '/pp/v1/proxy/v2/service_bindings/' + guid,
diff --git a/src/plugins/cloud-foundry/api/hcf/ServiceInstances.mock.js b/src/plugins/cloud-foundry/api/hcf/ServiceInstances.mock.js
new file mode 100644
index 0000000000..73f1cb7451
--- /dev/null
+++ b/src/plugins/cloud-foundry/api/hcf/ServiceInstances.mock.js
@@ -0,0 +1,100 @@
+(function (mock) {
+ 'use strict';
+
+ /* eslint-disable quote-props */
+ mock.cloudFoundryAPI = mock.cloudFoundryAPI || {};
+
+ mock.cloudFoundryAPI.ServiceInstances = {
+
+ CreateServiceInstance: function (newInstanceSpec) {
+ return {
+ url: '/pp/v1/proxy/v2/service_instances',
+ response: {
+ 200: {
+ body: {
+ guid: {
+ "metadata": {
+ "guid": "8efda023-ccd8-4cbb-b854-d56d7282fec3",
+ "url": "/v2/service_instances/8efda023-ccd8-4cbb-b854-d56d7282fec3",
+ "created_at": "2016-05-12T00:45:07Z",
+ "updated_at": null
+ },
+ "entity": {
+ "name": newInstanceSpec.name,
+ "credentials": {},
+ "service_plan_guid": newInstanceSpec.service_plan_guid,
+ "space_guid": newInstanceSpec.space_guid,
+ "gateway_data": null,
+ "dashboard_url": null,
+ "type": "managed_service_instance",
+ "last_operation": {
+ "type": "create",
+ "state": "in progress",
+ "description": "",
+ "updated_at": null,
+ "created_at": "2016-05-12T00:45:07Z"
+ },
+ "tags": [
+ "accounting",
+ "mongodb"
+ ],
+ "space_url": "/v2/spaces/" + newInstanceSpec.space_guid,
+ "service_plan_url": "/v2/service_plans/" + newInstanceSpec.service_plan_guid,
+ "service_bindings_url": "/v2/service_instances/8efda023-ccd8-4cbb-b854-d56d7282fec3/service_bindings",
+ "service_keys_url": "/v2/service_instances/8efda023-ccd8-4cbb-b854-d56d7282fec3/service_keys",
+ "routes_url": "/v2/service_instances/8efda023-ccd8-4cbb-b854-d56d7282fec3/routes"
+ }
+ }
+ }
+ },
+
+ 400: {
+ body: { guid: {} }
+ }
+ }
+ };
+ },
+
+ ListAllServicePlansForService: function (guid) {
+ return {
+ url: '/pp/v1/proxy/v2/services/' + guid + '/service_plans',
+ response: {
+ 200: {
+ body: {
+ guid: {
+ total_results: 1,
+ total_pages: 1,
+ prev_url: null,
+ next_url: null,
+ resources: [
+ {
+ metadata: {
+ guid: "d22b3754-d093-42a2-a294-5fda6c6db44c",
+ url: "/v2/service_plans/d22b3754-d093-42a2-a294-5fda6c6db44c",
+ created_at: "2016-05-12T00:45:19Z",
+ updated_at: null
+ },
+ entity: {
+ name: "name-1686",
+ free: false,
+ description: "desc-109",
+ service_guid: "67229bc6-8fc9-4fe1-b8bc-8790cdae5334",
+ extra: null,
+ unique_id: "e010ae61-ec46-433d-bdf6-136ead10828b",
+ public: true,
+ active: true,
+ service_url: "/v2/services/67229bc6-8fc9-4fe1-b8bc-8790cdae5334",
+ service_instances_url: "/v2/service_plans/d22b3754-d093-42a2-a294-5fda6c6db44c/service_instances"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ /* eslint-enable quote-props */
+})(this.mock = this.mock || {});
diff --git a/src/plugins/cloud-foundry/api/hcf/Services.mock.js b/src/plugins/cloud-foundry/api/hcf/Services.mock.js
index ce015eb534..8d8dc8c4a5 100644
--- a/src/plugins/cloud-foundry/api/hcf/Services.mock.js
+++ b/src/plugins/cloud-foundry/api/hcf/Services.mock.js
@@ -107,6 +107,46 @@
}
}
};
+ },
+
+ ListAllServicePlansForService: function (guid) {
+ return {
+ url: '/pp/v1/proxy/v2/services/' + guid + '/service_plans',
+ response: {
+ 200: {
+ body: {
+ guid: {
+ total_results: 1,
+ total_pages: 1,
+ prev_url: null,
+ next_url: null,
+ resources: [
+ {
+ metadata: {
+ guid: "a5ac915f-b746-42c5-8506-6d318bf21107",
+ url: "/v2/service_plans/a5ac915f-b746-42c5-8506-6d318bf21107",
+ created_at: "2016-05-12T00:45:19Z",
+ updated_at: null
+ },
+ entity: {
+ name: "name-1686",
+ free: false,
+ description: "desc-109",
+ service_guid: "b2728c78-1057-4021-9c84-d2158f8f20df",
+ extra: null,
+ unique_id: "e010ae61-ec46-433d-bdf6-136ead10828b",
+ public: true,
+ active: true,
+ service_url: "/v2/services/b2728c78-1057-4021-9c84-d2158f8f20df",
+ service_instances_url: "/v2/service_plans/a5ac915f-b746-42c5-8506-6d318bf21107/service_instances"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
}
};
diff --git a/src/plugins/cloud-foundry/api/hcf/Spaces.mock.js b/src/plugins/cloud-foundry/api/hcf/Spaces.mock.js
index 8f6822816c..ec4803dd84 100644
--- a/src/plugins/cloud-foundry/api/hcf/Spaces.mock.js
+++ b/src/plugins/cloud-foundry/api/hcf/Spaces.mock.js
@@ -129,6 +129,52 @@
}
}
};
+ },
+
+ ListAllServiceInstancesForSpace: function (guid) {
+ return {
+ url: '/pp/v1/proxy/v2/spaces/' + guid + '/service_instances',
+ response: {
+ 200: {
+ body: {
+ guid: {
+ "total_results": 1,
+ "total_pages": 1,
+ "prev_url": null,
+ "next_url": null,
+ "resources": [
+ {
+ "metadata": {
+ "guid": "4986ba9d-f537-4e37-9479-0abb8da7b216",
+ "url": "/v2/service_instances/4986ba9d-f537-4e37-9479-0abb8da7b216",
+ "created_at": "2016-05-12T00:45:18Z",
+ "updated_at": null
+ },
+ "entity": {
+ "name": "name-1621",
+ "credentials": {
+ "creds-key-41": "creds-val-41"
+ },
+ "service_plan_guid": "d22b3754-d093-42a2-a294-5fda6c6db44c",
+ "space_guid": guid,
+ "gateway_data": null,
+ "dashboard_url": null,
+ "type": "managed_service_instance",
+ "last_operation": null,
+ "tags": [],
+ "space_url": "/v2/spaces/" + guid,
+ "service_plan_url": "/v2/service_plans/d22b3754-d093-42a2-a294-5fda6c6db44c",
+ "service_bindings_url": "/v2/service_instances/4986ba9d-f537-4e37-9479-0abb8da7b216/service_bindings",
+ "service_keys_url": "/v2/service_instances/4986ba9d-f537-4e37-9479-0abb8da7b216/service_keys",
+ "routes_url": "/v2/service_instances/4986ba9d-f537-4e37-9479-0abb8da7b216/routes"
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ };
}
};
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.controller.js b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.controller.js
deleted file mode 100644
index 5c1aa1aadd..0000000000
--- a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.controller.js
+++ /dev/null
@@ -1,95 +0,0 @@
-(function () {
- 'use strict';
-
- angular
- .module('cloud-foundry.view.applications')
- .controller('manageServicesController', ManageServicesController);
-
- ManageServicesController.$inject = [
- 'app.model.modelManager',
- 'helion.framework.widgets.detailView',
- '$uibModalInstance',
- 'context'
- ];
-
- /**
- * @memberof cloud-foundry.view.applications
- * @name AddServiceWorkflowController
- * @constructor
- * @param {app.model.modelManager} modelManager - the Model management service
- * @param {helion.framework.widgets.detailView} detailView - the detail view service
- * @param {$uibModalInstance} $uibModalInstance - the modal instance
- * @param {object} context - the detail view context/data
- */
- function ManageServicesController(modelManager, detailView, $uibModalInstance, context) {
- this.detailView = detailView;
- this.$uibModalInstance = $uibModalInstance;
- this.bindingModel = modelManager.retrieve('cloud-foundry.model.service-binding');
- this.appModel = modelManager.retrieve('cloud-foundry.model.application');
- this.cnsiGuid = context.cnsiGuid;
- this.app = context.app;
- this.service = context.service;
- this.serviceInstances = [];
- this.serviceBindings = {};
-
- this.init();
- }
-
- angular.extend(ManageServicesController.prototype, {
- init: function () {
- var that = this;
- this.serviceInstances = _.filter(this.app.summary.services, function (o) {
- return o.service_plan.service.guid === that.service.metadata.guid;
- });
- if (this.serviceInstances.length > 0) {
- var guids = _.map(this.serviceInstances, 'guid');
- var q = 'service_instance_guid IN ' + guids.join(',');
- return this.appModel.listServiceBindings(this.cnsiGuid, this.app.summary.guid, { q: q })
- .then(function (bindings) {
- that.serviceBindings = _.keyBy(bindings, function (o) { return o.entity.service_instance_guid; });
- });
- }
- },
-
- detach: function (instance) {
- var that = this;
- var binding = this.serviceBindings[instance.guid];
- return this.bindingModel.deleteServiceBinding(this.cnsiGuid, binding.metadata.guid)
- .then(function (response) {
- if (response.data[that.cnsiGuid] === null) {
- _.pull(that.serviceInstances, instance);
- that.appModel.getAppSummary(that.cnsiGuid, that.app.summary.guid);
-
- if (that.serviceInstances.length === 0) {
- that.close();
- }
- }
- });
- },
-
- viewEnvVariables: function (instance) {
- var that = this;
- var serviceLabel = this.service.entity.label;
- return this.appModel.getEnv(this.cnsiGuid, this.app.summary.guid)
- .then(function (variables) {
- var vcap = variables.system_env_json.VCAP_SERVICES;
- if (angular.isDefined(vcap) && vcap[serviceLabel]) {
- var instanceVars = _.find(vcap[serviceLabel], { name: instance.name });
- var config = {
- templateUrl: 'plugins/cloud-foundry/view/applications/application/services/manage-services/env-variables.html',
- title: that.app.summary.name + ': ' + gettext('Environmental Variables')
- };
- var context = {
- variables: instanceVars
- };
- that.detailView(config, context);
- }
- });
- },
-
- close: function () {
- this.$uibModalInstance.dismiss('close');
- }
- });
-
-})();
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.directive.js b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.directive.js
new file mode 100644
index 0000000000..ab5ff09c9c
--- /dev/null
+++ b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.directive.js
@@ -0,0 +1,175 @@
+(function () {
+ 'use strict';
+
+ angular
+ .module('cloud-foundry.view.applications')
+ .directive('manageServices', manageServices);
+
+ manageServices.$inject = [];
+
+ /**
+ * @memberof cloud-foundry.view.applications
+ * @name manageServices
+ * @description An manage services detail view
+ * @returns {object} The manage-services directive definition object
+ */
+ function manageServices() {
+ return {
+ controller: ManageServicesController,
+ controllerAs: 'manageServicesCtrl',
+ restrict: 'E'
+ };
+ }
+
+ ManageServicesController.$inject = [
+ '$scope',
+ 'app.model.modelManager',
+ 'app.event.eventService',
+ 'helion.framework.widgets.detailView'
+ ];
+
+ /**
+ * @memberof cloud-foundry.view.applications
+ * @name ManageServicesController
+ * @constructor
+ * @param {object} $scope - the Angular $scope service
+ * @param {app.model.modelManager} modelManager - the model management service
+ * @param {app.event.eventService} eventService - the event management service
+ * @param {helion.framework.widgets.detailView} detailView - the detail view service
+ * @property {helion.framework.widgets.detailView} detailView - the detail view service
+ * @property {cloud-foundry.model.application} appModel - the CF application model
+ * @property {cloud-foundry.model.service-binding} bindingModel - the CF service binding model
+ * @property {object} modal - the detail view modal instance
+ * @property {array} serviceInstances - service instances associated with this service
+ * @property {object} serviceBindings - service bindings associated with this app
+ */
+ function ManageServicesController($scope, modelManager, eventService, detailView) {
+ var that = this;
+ this.detailView = detailView;
+ this.appModel = modelManager.retrieve('cloud-foundry.model.application');
+ this.bindingModel = modelManager.retrieve('cloud-foundry.model.service-binding');
+ this.modal = null;
+
+ this.serviceInstances = [];
+ this.serviceBindings = {};
+
+ var manageServicesEvent = eventService.$on('cf.events.START_MANAGE_SERVICES', function (event, config) {
+ that.reset(config).then(function () {
+ that.modal = that.startManageServices();
+ });
+ });
+ $scope.$on('$destroy', manageServicesEvent);
+ }
+
+ angular.extend(ManageServicesController.prototype, {
+ /**
+ * @function reset
+ * @memberof cloud-foundry.view.applications.ManageServicesController
+ * @description Reset the view to an initial state
+ * @param {object} config - data containing app, service, etc.
+ * @returns {promise} A promise object
+ */
+ reset: function (config) {
+ var that = this;
+ this.data = {
+ app: config.app,
+ service: config.service,
+ cnsiGuid: config.cnsiGuid
+ };
+ this.serviceInstances.length = 0;
+ this.serviceBindings = {};
+
+ var serviceInstances = _.filter(this.data.app.summary.services, function (o) {
+ return o.service_plan.service.guid === that.data.service.metadata.guid;
+ });
+ if (serviceInstances.length > 0) {
+ [].push.apply(this.serviceInstances, serviceInstances);
+
+ var guids = _.map(this.serviceInstances, 'guid');
+ return this.getServiceBindings(guids);
+ }
+ },
+
+ /**
+ * @function getServiceBindings
+ * @memberof cloud-foundry.view.applications.ManageServicesController
+ * @description Retrieve service bindings for service instances
+ * @param {array} serviceInstanceGuids - a list of service instance GUIDs
+ * @returns {promise} A promise object
+ */
+ getServiceBindings: function (serviceInstanceGuids) {
+ var that = this;
+ var q = 'service_instance_guid IN ' + serviceInstanceGuids.join(',');
+ return this.appModel.listServiceBindings(this.data.cnsiGuid, this.data.app.summary.guid, { q: q })
+ .then(function (bindings) {
+ that.serviceBindings = _.keyBy(bindings, function (o) { return o.entity.service_instance_guid; });
+ });
+ },
+
+ /**
+ * @function detach
+ * @memberof cloud-foundry.view.applications.ManageServicesController
+ * @description Detach service instance
+ * @param {object} instance - the service instance to detach
+ * @returns {promise} A promise object
+ */
+ detach: function (instance) {
+ var that = this;
+ var binding = this.serviceBindings[instance.guid];
+ return this.bindingModel.deleteServiceBinding(this.data.cnsiGuid, binding.metadata.guid)
+ .then(function (response) {
+ if (response.data[that.data.cnsiGuid] === null) {
+ _.pull(that.serviceInstances, instance);
+ that.appModel.getAppSummary(that.data.cnsiGuid, that.data.app.summary.guid);
+
+ if (that.serviceInstances.length === 0) {
+ that.modal.dismiss('close');
+ }
+ }
+ });
+ },
+
+ /**
+ * @function viewEnvVariables
+ * @memberof cloud-foundry.view.applications.ManageServicesController
+ * @description View environmental variables of service instance
+ * @param {object} instance - the service instance to view
+ * @returns {promise} A promise object
+ */
+ viewEnvVariables: function (instance) {
+ var that = this;
+ var serviceLabel = this.data.service.entity.label;
+ return this.appModel.getEnv(this.data.cnsiGuid, this.data.app.summary.guid)
+ .then(function (variables) {
+ var vcap = variables.system_env_json.VCAP_SERVICES;
+ if (angular.isDefined(vcap) && vcap[serviceLabel]) {
+ var instanceVars = _.find(vcap[serviceLabel], { name: instance.name });
+ var config = {
+ templateUrl: 'plugins/cloud-foundry/view/applications/application/services/manage-services/env-variables.html',
+ title: that.data.app.summary.name + ': ' + gettext('Environmental Variables')
+ };
+ var context = {
+ variables: instanceVars
+ };
+ that.detailView(config, context);
+ }
+ });
+ },
+
+ /**
+ * @function startManageService
+ * @memberof cloud-foundry.view.applications.ManageServicesController
+ * @description Show the manage services detail view
+ * @returns {promise} A promise object
+ */
+ startManageServices: function () {
+ var config = {
+ templateUrl: 'plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html',
+ title: gettext('Manage Service Instances')
+ };
+
+ return this.detailView(config, this);
+ }
+ });
+
+})();
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html
index 51b31383aa..263bfd4a2a 100644
--- a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html
+++ b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html
@@ -1,14 +1,9 @@
-
-
{{ manageServicesCtrl.service.entity.label }}
-
{{ manageServicesCtrl.service.entity.description }}
+
{{ detailViewCtrl.context.data.service.entity.label }}
+
{{ detailViewCtrl.context.data.service.entity.description }}
@@ -21,18 +16,18 @@ {{ manageServicesCtrl.service.entity.label }}
-
+
{{ instance.name }} |
{{ instance.service_plan.name }} |
|
+ ng-click="detailViewCtrl.context.detach(instance)" translate>Detach
|
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.scss b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.scss
index 4aa60a4e78..7d9678639a 100644
--- a/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.scss
+++ b/src/plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.scss
@@ -1,19 +1,4 @@
.manage-instances {
- padding: $hpe-unit-space*2 $hpe-unit-space*4;
-
- .manage-instances-header {
- display: flex;
- align-items: center;
-
- h3 {
- margin: 0;
- }
-
- .close {
- margin-left: auto;
- }
- }
-
.service-description {
display: flex;
padding: $hpe-unit-space 0;
@@ -39,7 +24,6 @@
}
.env-variables {
- margin-right: $hpe-unit-space * 4;
margin-top: $hpe-unit-space;
pre {
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.directive.js b/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.directive.js
index 7040e03047..02aedbccfb 100644
--- a/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.directive.js
+++ b/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.directive.js
@@ -32,7 +32,7 @@
ServiceCardController.$inject = [
'$scope',
'app.model.modelManager',
- 'helion.framework.widgets.detailView'
+ 'app.event.eventService'
];
/**
@@ -42,25 +42,23 @@
* @constructor
* @param {object} $scope - the Angular $scope service
* @param {app.model.modelManager} modelManager - the application model manager
- * @param {helion.framework.widgets.detailView} detailView - the detail view service
- * @property {helion.framework.widgets.detailView} detailView - the detail view service
+ * @param {app.event.eventService} eventService - the event management service
+ * @property {app.event.eventService} eventService - the event management service
* @property {cloud-foundry.model.application} appModel - the Cloud Foundry application model
* @property {cloud-foundry.model.service-binding} bindingModel - the Cloud Foundry service binding model
* @property {boolean} allowAddOnly - allow adding services only (no manage or detach)
* @property {array} serviceBindings - the service instances bound to specified app
* @property {number} numAttached - the number of service instances bound to specified app
- * @property {number} numAdded - the number of new service instances bound to specified app
* @property {array} actions - the actions that can be performed from this service card
*/
- function ServiceCardController($scope, modelManager, detailView) {
+ function ServiceCardController($scope, modelManager, eventService) {
var that = this;
- this.detailView = detailView;
+ this.eventService = eventService;
this.appModel = modelManager.retrieve('cloud-foundry.model.application');
this.bindingModel = modelManager.retrieve('cloud-foundry.model.service-binding');
this.allowAddOnly = angular.isDefined(this.addOnly) ? this.addOnly : false;
this.serviceBindings = [];
this.numAttached = 0;
- this.numAdded = 0;
this.actions = [
{
name: gettext('Add Service'),
@@ -94,9 +92,26 @@
* @function init
* @memberof cloud-foundry.view.applications.application.services.serviceCard.ServiceCardController
* @description Fetch service bindings for this app and update content
- * @returns {void}
+ * @returns {promise} A promise object
*/
init: function () {
+ this.serviceBindings.length = 0;
+
+ var serviceInstances = this.getServiceInstanceGuids();
+ if (serviceInstances.length > 0) {
+ return this.getServiceBindings(serviceInstances);
+ } else {
+ this.updateActions();
+ }
+ },
+
+ /**
+ * @function getServiceInstanceGuids
+ * @memberof cloud-foundry.view.applications.application.services.serviceCard.ServiceCardController
+ * @description Get service instances for app
+ * @returns {array} A list of service instance GUIDs
+ */
+ getServiceInstanceGuids: function () {
var that = this;
var serviceInstances = _.chain(this.app.summary.services)
.filter(function (o) {
@@ -104,20 +119,27 @@
})
.map('guid')
.value();
- if (serviceInstances.length > 0) {
- var q = 'service_instance_guid IN ' + serviceInstances.join(',');
- return this.bindingModel.listAllServiceBindings(this.cnsiGuid, { q: q })
- .then(function (bindings) {
- var appGuid = that.app.summary.guid;
- var appBindings = _.filter(bindings, function (o) { return o.entity.app_guid === appGuid; });
- that.serviceBindings.length = 0;
- [].push.apply(that.serviceBindings, appBindings);
- that.updateActions();
- });
- } else {
- this.serviceBindings.length = 0;
- this.updateActions();
- }
+ return serviceInstances;
+ },
+
+ /**
+ * @function getServiceBindings
+ * @memberof cloud-foundry.view.applications.application.services.serviceCard.ServiceCardController
+ * @description Get service bindings for specified service instances
+ * @param {array} serviceInstanceGuids A list of service instance GUIDs
+ * @returns {promise} A promise object
+ */
+ getServiceBindings: function (serviceInstanceGuids) {
+ var that = this;
+
+ var q = 'service_instance_guid IN ' + serviceInstanceGuids.join(',');
+ return this.bindingModel.listAllServiceBindings(this.cnsiGuid, { q: q })
+ .then(function (bindings) {
+ var appGuid = that.app.summary.guid;
+ var appBindings = _.filter(bindings, function (o) { return o.entity.app_guid === appGuid; });
+ [].push.apply(that.serviceBindings, appBindings);
+ that.updateActions();
+ });
},
/**
@@ -127,22 +149,14 @@
* @returns {void}
*/
addService: function () {
- var that = this;
var config = {
- controller: 'addServiceWorkflowController',
- controllerAs: 'addServiceWorkflowCtrl',
- detailViewTemplateUrl: 'plugins/cloud-foundry/view/applications/workflows/add-service-workflow/add-service-workflow.html'
- };
- var context = {
- cnsiGuid: this.cnsiGuid,
- service: this.service,
app: this.app,
- confirm: !this.allowAddOnly
+ cnsiGuid: this.cnsiGuid,
+ confirm: !this.allowAddOnly,
+ service: this.service
};
- return this.detailView(config, context).result
- .then(function () {
- that.numAdded++;
- });
+
+ this.eventService.$emit('cf.events.START_ADD_SERVICE_WORKFLOW', config);
},
/**
@@ -169,16 +183,12 @@
*/
manageInstances: function () {
var config = {
- controller: 'manageServicesController',
- controllerAs: 'manageServicesCtrl',
- detailViewTemplateUrl: 'plugins/cloud-foundry/view/applications/application/services/manage-services/manage-services.html'
- };
- var context = {
- cnsiGuid: this.cnsiGuid,
app: this.app,
+ cnsiGuid: this.cnsiGuid,
service: this.service
};
- return this.detailView(config, context);
+
+ this.eventService.$emit('cf.events.START_MANAGE_SERVICES', config);
},
/**
diff --git a/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.html b/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.html
index 55dc0bce4e..aa92a614b7 100644
--- a/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.html
+++ b/src/plugins/cloud-foundry/view/applications/application/services/service-card/service-card.html
@@ -23,7 +23,7 @@ {{ ::serviceCardCtrl.service.entity.label }}
- {{ serviceCardCtrl.numAdded }} Attached
+ {{ serviceCardCtrl.numAttached }} Attached