aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-09-04 15:27:00 +0100
committerSébastien Determe <sebastien.determe@intl.att.com>2020-09-07 13:28:22 +0000
commit3e9a9769dd21f0b16b3f238e42349cba3b1a78de (patch)
tree1517e5266d5b9ae8e5c386d06937eb503d59d431 /catalog-ui
parent84a51513bca9c41c8757db017eb45b2d801da195 (diff)
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 <michael.morris@est.tech> Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/models/requirement.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.html4
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/req-capabilities-tab.component.ts10
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.html11
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/req-capabilities-tab/requirement-list/requirement-list.component.ts21
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts7
6 files changed, 45 insertions, 10 deletions
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 @@
</div>
<div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations">
<sdc-accordion [title]="'Requirements'" [arrow-direction]="'right'" [testId]="'Requirements-accordion'">
- <requirement-list [component]='component' [requirements]="requirements" [isInstanceSelected]="isComponentInstanceSelected"></requirement-list>
+ <requirement-list [component]='component' [requirements]="requirements" [isInstanceSelected]="isComponentInstanceSelected" [isViewOnly]='isViewOnly'></requirement-list>
</sdc-accordion>
</div>
@@ -28,7 +28,7 @@
<sdc-accordion *ngIf="requirementsInstancesMap" [title]="'Requirements'" [arrow-direction]="'right'" [testId]="'Requirements-accordion'">
<sdc-accordion *ngFor="let key of objectKeys(requirementsInstancesMap); let i = index" [title]="key">
- <requirement-list [component]='component' [requirements]="requirementsInstancesMap[key]" [isInstanceSelected]="isComponentInstanceSelected"></requirement-list>
+ <requirement-list [component]='component' [requirements]="requirementsInstancesMap[key]" [isInstanceSelected]="isComponentInstanceSelected" [isViewOnly]='isViewOnly'></requirement-list>
</sdc-accordion>
</sdc-accordion>
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>(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>(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 @@
</div>
</div>
</div>
+ <div class="checkbox-label-mark-as-external"
+ *ngIf="isInstanceSelected">
+ <checkbox
+ class="checkbox-label"
+ data-tests-id="checkbox-mark-as-external"
+ [label]="'External'"
+ (checkedChange)="onMarkAsExternal(requirement)"
+ [(checked)]="requirement.external"
+ [disabled]="isViewOnly">
+ </checkbox>
+ </div>
</div>
</div>
</div>
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<Requirement>;
@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<Requirement> {
+ return this.http.put<Requirement>(this.baseUrl + componentType + componentId + '/componentInstances/' + componentInstanceId + '/requirement/' + requirement.capability +
+ '/requirementName/' + requirement.name, requirement);
+ }
+
updateInstanceInputs(component: Component, componentInstanceId: string, inputs: PropertyBEModel[]): Observable<PropertyBEModel[]> {
return this.http.post<Array<PropertyModel>>(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/inputs', inputs)