blob: dc72f8f125f514df1412a262fb786499fd36c26c [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {Injectable} from '@angular/core';
2import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataServiceGenerator/default.data.generator.service";
3import {NgRedux} from "@angular-redux/store";
4import {AppState} from "../../../shared/store/reducers";
5import {MessageBoxData} from "../../../shared/components/messageBox/messageBox.data";
6import {MessageBoxService} from "../../../shared/components/messageBox/messageBox.service";
7import * as _ from "lodash";
8import { SdcUiCommon} from "onap-ui-angular";
9import {SharedTreeService} from "../objectsToTree/shared.tree.service";
10
11export class AvailableNodeIcons {
12 addIcon: boolean;
13 vIcon: boolean;
14
15 constructor(addIcon: boolean, vIcon: boolean) {
16 this.addIcon = addIcon;
17 this.vIcon = vIcon;
18 }
19}
20
21@Injectable()
22export class AvailableModelsTreeService {
23 constructor(private _defaultDataGeneratorService: DefaultDataGeneratorService,
24 private store: NgRedux<AppState>,
25 public _shareTreeService : SharedTreeService) {
26 }
27
28
29
30 shouldOpenDialog(type: string, dynamicInputs: any, isEcompGeneratedNaming: boolean): boolean {
31 if (!isEcompGeneratedNaming || this._defaultDataGeneratorService.requiredFields[type].length > 0) {
32 return true;
33 }
34
35 if (dynamicInputs) {
36 for(let input of dynamicInputs) {
37 if (input.isRequired && _.isEmpty(input.value)) {
38 return true;
39 }
40 }
41 }
42 return false;
43 }
44
45 getOptionalVNFs(serviceUUID: string, vnfOriginalModelName : string) : any[] {
46 let result = [];
47 if(!_.isNil(this.store.getState().service.serviceInstance) && !_.isNil(this.store.getState().service.serviceInstance[serviceUUID])){
48 const serviceVNFsInstances = this.store.getState().service.serviceInstance[serviceUUID].vnfs;
49 for(let vnfKey in serviceVNFsInstances){
50 if(serviceVNFsInstances[vnfKey].originalName === vnfOriginalModelName){
51 serviceVNFsInstances[vnfKey].vnfStoreKey = vnfKey;
52 result.push(serviceVNFsInstances[vnfKey]);
53 }
54 }
55 }
56
57
58 return result;
59 }
60
61
62
63 addingAlertAddingNewVfModuleModal() : void {
64 let messageBoxData : MessageBoxData = new MessageBoxData(
65 "Select a parent", // modal title
66 "There are multiple instances on the right side that can contain this vf-module Please select the VNF instance, to add this vf-module to, on the right side and then click the + sign",
67 SdcUiCommon.ModalType.warning,
68 SdcUiCommon.ModalSize.medium,
69 [
70 {text:"Close", size:"medium", closeModal:true}
71 ]);
72
73 MessageBoxService.openModal.next(messageBoxData);
74 }
75
76}