From 3e9a9769dd21f0b16b3f238e42349cba3b1a78de Mon Sep 17 00:00:00 2001 From: vasraz Date: Fri, 4 Sep 2020 15:27:00 +0100 Subject: Enable selection of requirements Instead of all requirements of the component instances in a component being exposed outside the component, this change will enable the component designer to specifiy which should be exposed outside the component and which are to be internal to the component Change-Id: Ib063f7b8b0aca94896e78a46f069725bae3d494d Issue-ID: SDC-2771 Signed-off-by: MichaelMorris Signed-off-by: Vasyl Razinkov --- catalog-ui/src/app/models/requirement.ts | 2 ++ .../req-capabilities-tab.component.html | 4 ++-- .../req-capabilities-tab.component.ts | 10 ++++++---- .../requirement-list.component.html | 11 +++++++++++ .../requirement-list/requirement-list.component.ts | 21 ++++++++++++++++++--- .../component-instance.service.ts | 7 ++++++- 6 files changed, 45 insertions(+), 10 deletions(-) (limited to 'catalog-ui') diff --git a/catalog-ui/src/app/models/requirement.ts b/catalog-ui/src/app/models/requirement.ts index d58aabd457..ade2f3cee1 100644 --- a/catalog-ui/src/app/models/requirement.ts +++ b/catalog-ui/src/app/models/requirement.ts @@ -53,6 +53,7 @@ export class Requirement implements RequirementCapabilityModel{ leftOccurrences:string; minOccurrences:string | number; maxOccurrences:string; + external:boolean; //custom filterTerm:string; @@ -70,6 +71,7 @@ export class Requirement implements RequirementCapabilityModel{ this.leftOccurrences = requirement.leftOccurrences; this.minOccurrences = requirement.minOccurrences; this.maxOccurrences = requirement.maxOccurrences; + this.external = requirement.external; this.initFilterTerm(); } diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html index 27e05ec1f0..c73f69734f 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html @@ -10,7 +10,7 @@
- +
@@ -28,7 +28,7 @@ - + diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts index 03697b38f2..7c91cbc4b8 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts @@ -122,10 +122,12 @@ export class ReqAndCapabilitiesTabComponent implements OnInit, OnDestroy { this.requirementsInstancesMap = new InstanceRequirementsMap(); _.forEach(this.requirements, (requirement:Requirement) => { - if (this.requirementsInstancesMap[requirement.ownerName]) { - this.requirementsInstancesMap[requirement.ownerName] = this.requirementsInstancesMap[requirement.ownerName].concat(requirement); - } else { - this.requirementsInstancesMap[requirement.ownerName] = new Array(requirement); + if(this.isComponentInstanceSelected || requirement.external){ + if (this.requirementsInstancesMap[requirement.ownerName]) { + this.requirementsInstancesMap[requirement.ownerName] = this.requirementsInstancesMap[requirement.ownerName].concat(requirement); + } else { + this.requirementsInstancesMap[requirement.ownerName] = new Array(requirement); + } } }); } diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html index 8292729cf8..291b103344 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html @@ -13,6 +13,17 @@ +
+ + +
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts index e167c47dcc..3716ef0af0 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts @@ -2,6 +2,8 @@ import { Component, Input } from '@angular/core'; import { Component as TopologyTemplate, RelationshipModel, Relationship, Requirement } from "app/models"; import { CompositionService } from "app/ng2/pages/composition/composition.service"; import { ResourceNamePipe } from "app/ng2/pipes/resource-name.pipe"; +import { ComponentInstanceServiceNg2 } from "app/ng2/services/component-instance-services/component-instance.service"; +import { WorkspaceService } from "app/ng2/pages/workspace/workspace.service"; @Component({ selector: 'requirement-list', @@ -11,10 +13,12 @@ export class RequirementListComponent { @Input() component: TopologyTemplate; @Input() requirements: Array; @Input() isInstanceSelected:boolean; + @Input() isViewOnly: boolean; + readonly:boolean; - - constructor(private compositionService: CompositionService) { } - + constructor(private compositionService: CompositionService, + private workspaceService: WorkspaceService, + private componentInstanceServiceNg2: ComponentInstanceServiceNg2) {} public getRelation = (requirement:any):any => { if (this.isInstanceSelected && this.component.componentInstancesRelations) { @@ -36,5 +40,16 @@ export class RequirementListComponent { return null; }; + onMarkAsExternal(requirement:Requirement) { + if (requirement.external){ + requirement.external = false; + } else { + requirement.external = true; + } + this.componentInstanceServiceNg2.updateInstanceRequirement(this.workspaceService.metadata.getTypeUrl(), this.workspaceService.metadata.uniqueId, this.component.uniqueId, requirement).subscribe((response:any) => { + }, (error) => { console.log("An error has occured setting external: ", error); });; + + } + }; diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts index af6ed9d4b0..74ced7d4bf 100644 --- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts +++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts @@ -20,7 +20,7 @@ import {Injectable, Inject} from '@angular/core'; import { Observable } from 'rxjs/Observable'; -import {PropertyFEModel, PropertyBEModel} from "app/models"; +import {PropertyFEModel, PropertyBEModel, Requirement} from "app/models"; import {CommonUtils, ComponentType, ServerTypeUrl, ComponentInstanceFactory} from "app/utils"; import {Component, ComponentInstance, Capability, PropertyModel, ArtifactGroupModel, ArtifactModel, AttributeModel, IFileDownload} from "app/models"; import {SdcConfigToken, ISdcConfig} from "../../config/sdc-config.config"; @@ -125,6 +125,11 @@ export class ComponentInstanceServiceNg2 { }) } + updateInstanceRequirement(componentType: string, componentId: string, componentInstanceId: string, requirement: Requirement): Observable { + return this.http.put(this.baseUrl + componentType + componentId + '/componentInstances/' + componentInstanceId + '/requirement/' + requirement.capability + + '/requirementName/' + requirement.name, requirement); + } + updateInstanceInputs(component: Component, componentInstanceId: string, inputs: PropertyBEModel[]): Observable { return this.http.post>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/inputs', inputs) -- cgit 1.2.3-korg