1 import { Injectable } from "@angular/core";
2 import { TopologyTemplateService } from "../../../services/component-services/topology-template.service";
3 import { Store } from "@ngxs/store";
4 import { SdcUiServices } from "onap-ui-angular";
5 import { CapabilityTypeModel } from "../../../../models/capability-types";
6 import { RelationshipTypeModel } from "../../../../models/relationship-types";
7 import { NodeTypeModel } from "../../../../models/node-types";
8 import { WorkspaceService } from "../workspace.service";
9 import { ToscaTypesServiceNg2 } from "../../../services/tosca-types.service";
14 export class ReqAndCapabilitiesService {
16 private capabilityTypesList: CapabilityTypeModel[];
17 private relationshipTypesList: RelationshipTypeModel[];
18 private nodeTypesList: NodeTypeModel[];
20 readonly INPUTS_FOR_REQUIREMENTS: string = 'INPUTS_FOR_REQUIREMENTS';
21 readonly INPUTS_FOR_CAPABILITIES: string = 'INPUTS_FOR_CAPABILITIES';
24 private workspaceService: WorkspaceService,
25 private modalService: SdcUiServices.ModalService,
26 private loaderService: SdcUiServices.LoaderService,
27 private topologyTemplateService: TopologyTemplateService,
29 private toscaTypesServiceNg2: ToscaTypesServiceNg2){}
31 public isViewOnly = (): boolean => {
32 return this.store.selectSnapshot((state) => state.workspace.isViewOnly);
35 public isDesigner = (): boolean => {
36 return this.store.selectSnapshot((state) => state.workspace.isDesigner);
39 public async initInputs(initInputsFor: string) {
41 // -- COMMON for both --
42 this.capabilityTypesList = [];
43 let capabilityTypesResult = await this.toscaTypesServiceNg2.fetchCapabilityTypes(this.workspaceService.metadata.model);
44 Object.keys(capabilityTypesResult).forEach(key => {this.capabilityTypesList.push(capabilityTypesResult[key])})
46 if (initInputsFor === 'INPUTS_FOR_REQUIREMENTS') {
47 this.relationshipTypesList = [];
48 let relationshipTypesResult = await this.toscaTypesServiceNg2.fetchRelationshipTypes(this.workspaceService.metadata.model);
49 Object.keys(relationshipTypesResult).forEach(key => {this.relationshipTypesList.push(relationshipTypesResult[key])});
51 this.nodeTypesList = [];
52 let nodeTypesResult = await this.toscaTypesServiceNg2.fetchNodeTypes(this.workspaceService.metadata.model);
53 Object.keys(nodeTypesResult).forEach(key => {this.nodeTypesList.push(nodeTypesResult[key])})
57 getCapabilityTypesList() {
58 return this.capabilityTypesList;
61 getRelationsShipeTypeList() {
62 return this.relationshipTypesList;
66 return this.nodeTypesList;