summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts')
-rw-r--r--catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts80
1 files changed, 80 insertions, 0 deletions
diff --git a/catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts b/catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts
new file mode 100644
index 0000000000..470aac75a6
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/workspace/req-and-capabilities/req-and-capabilities.service.ts
@@ -0,0 +1,80 @@
+import { Injectable } from "@angular/core";
+import { TopologyTemplateService } from "../../../services/component-services/topology-template.service";
+import { Store } from "@ngxs/store";
+import { SdcUiServices } from "onap-ui-angular";
+import { CapabilityTypeModel } from "../../../../models/capability-types";
+import { RelationshipTypeModel } from "../../../../models/relationship-types";
+import { NodeTypeModel } from "../../../../models/node-types";
+import { WorkspaceService } from "../workspace.service";
+import { ToscaTypesServiceNg2 } from "../../../services/tosca-types.service";
+
+
+
+@Injectable()
+export class ReqAndCapabilitiesService {
+
+ private capabilityTypesList: CapabilityTypeModel[];
+ private relationshipTypesList: RelationshipTypeModel[];
+ private nodeTypesList: NodeTypeModel[];
+ private capabilitiesListUpdated: boolean = false;
+ private requirementsListUpdated: boolean = false;
+ private nodeTypeListUpdated: boolean = false;
+
+ readonly INPUTS_FOR_REQUIREMENTS: string = 'INPUTS_FOR_REQUIREMENTS';
+ readonly INPUTS_FOR_CAPABILITIES: string = 'INPUTS_FOR_CAPABILITIES';
+
+ constructor(
+ private workspaceService: WorkspaceService,
+ private modalService: SdcUiServices.ModalService,
+ private loaderService: SdcUiServices.LoaderService,
+ private topologyTemplateService: TopologyTemplateService,
+ private store: Store,
+ private toscaTypesServiceNg2: ToscaTypesServiceNg2){}
+
+ public isViewOnly = (): boolean => {
+ return this.store.selectSnapshot((state) => state.workspace.isViewOnly);
+ }
+
+ public isDesigner = (): boolean => {
+ return this.store.selectSnapshot((state) => state.workspace.isDesigner);
+ }
+
+ public async initInputs(initInputsFor: string) {
+
+ if (!this.capabilitiesListUpdated){
+ // -- COMMON for both --
+ this.capabilityTypesList = [];
+ let capabilityTypesResult = await this.toscaTypesServiceNg2.fetchCapabilityTypes();
+ Object.keys(capabilityTypesResult).forEach(key => {this.capabilityTypesList.push(capabilityTypesResult[key])})
+ this.capabilitiesListUpdated = true;
+ }
+
+ if (initInputsFor === 'INPUTS_FOR_REQUIREMENTS') {
+ if (!this.requirementsListUpdated){
+ this.relationshipTypesList = [];
+ let relationshipTypesResult = await this.toscaTypesServiceNg2.fetchRelationshipTypes();
+ Object.keys(relationshipTypesResult).forEach(key => {this.relationshipTypesList.push(relationshipTypesResult[key])});
+ this.requirementsListUpdated = true;
+ }
+
+ if (!this.nodeTypeListUpdated){
+ this.nodeTypesList = [];
+ let nodeTypesResult = await this.toscaTypesServiceNg2.fetchNodeTypes();
+ Object.keys(nodeTypesResult).forEach(key => {this.nodeTypesList.push(nodeTypesResult[key])})
+ this.nodeTypeListUpdated = true;
+ }
+ }
+ }
+
+ getCapabilityTypesList() {
+ return this.capabilityTypesList;
+ }
+
+ getRelationsShipeTypeList() {
+ return this.relationshipTypesList;
+ }
+
+ getNodeTypesList() {
+ return this.nodeTypesList;
+ }
+} \ No newline at end of file