Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame^] | 1 | import {Injectable} from '@angular/core'; |
| 2 | import {DefaultDataGeneratorService} from "../../../shared/services/defaultDataServiceGenerator/default.data.generator.service"; |
| 3 | import {NgRedux} from "@angular-redux/store"; |
| 4 | import {AppState} from "../../../shared/store/reducers"; |
| 5 | import {MessageBoxData} from "../../../shared/components/messageBox/messageBox.data"; |
| 6 | import {MessageBoxService} from "../../../shared/components/messageBox/messageBox.service"; |
| 7 | import * as _ from "lodash"; |
| 8 | import { SdcUiCommon} from "onap-ui-angular"; |
| 9 | import {SharedTreeService} from "../objectsToTree/shared.tree.service"; |
| 10 | |
| 11 | export 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() |
| 22 | export 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 | } |