merge from ecomp a88f0072 - Modern UI
[vid.git] / vid-webpack-master / src / app / vlanTagging / form-async / form-async.component.ts
@@ -1,16 +1,20 @@
 import {Component, Input, OnInit, ViewChild} from '@angular/core';
-import { NgRedux, select } from '@angular-redux/store';
-import { Observable } from "rxjs/Observable";
-import { updateProductFamilies } from "../../service.actions";
-import { AppState } from "../../store/reducers";
+import {NgRedux, select} from '@angular-redux/store';
+import {Observable} from "rxjs";
+import {AppState} from "../../shared/store/reducers";
 import {
-  loadProductFamiliesAction, loadLcpTenant, loadAicZones,
-  loadCategoryParameters
-} from '../../services/aaiService/aai.actions';
-import { LcpRegionsAndTenants } from "../../shared/models/lcpRegionsAndTenants";
+  loadAicZones,
+  loadCategoryParameters,
+  loadLcpTenant,
+  loadProductFamiliesAction
+} from '../../shared/services/aaiService/aai.actions';
+import {LcpRegionsAndTenants} from "../../shared/models/lcpRegionsAndTenants";
 import {NgForm} from "@angular/forms";
 import {SelectOption} from "../../shared/models/selectOption";
 import {VNFModel} from "../../shared/models/vnfModel";
+import {Tenant} from "../../shared/models/tenant";
+import {FormAsyncService} from "./form-async.service";
+import {AaiService} from "../../shared/services/aaiService/aai.service";
 
 @Component({
   selector: "formasync",
@@ -19,16 +23,21 @@ import {VNFModel} from "../../shared/models/vnfModel";
 
 })
 
-export class formasync implements OnInit {
+export class Formasync implements OnInit {
 
-  constructor(private store: NgRedux<AppState>) { }
+  constructor(private store: NgRedux<AppState>, private _formAsyncService: FormAsyncService) { }
 
   @ViewChild('form') form: NgForm;
-
+  @Input()
+  set params(params: any) {
+    if (params) {
+      this.paramsInfo = params;
+    }
+  }
   @Input()
   set model(model: VNFModel) {
     if (model) {
-      this.isUserProvidedNaming = model.isUserProvidedNaming;
+      this.isEcompGeneratedNaming = model.isEcompGeneratedNaming;
     }
   };
 
@@ -54,26 +63,39 @@ export class formasync implements OnInit {
     new SelectOption({id: 'true', name: 'Rollback'}),
     new SelectOption({id: 'false', name: 'Don\'t Rollback'})
   ];
-  tenants = [];
+  tenants: Tenant[] = [];
 
   serviceInstance: any = {
+    cloudOwner: null,
     rollback:'true'
   };
 
-  isUserProvidedNaming: boolean = false;
+  isEcompGeneratedNaming: boolean = true;
+  paramsInfo : any;
 
   onLcpSelect(newValue: string) {
     let value: LcpRegionsAndTenants = undefined;
     this.lcpRegionsAndTenants.subscribe(data => value = data);
     this.tenants = value.lcpRegionsTenantsMap[newValue];
+    this.serviceInstance.tenantId = undefined;
+  }
+
+
+
+  onTenantSelect(newValue: string) {
+    this.serviceInstance.cloudOwner = this._formAsyncService.onTenantSelect(this.tenants, newValue);
   }
 
   ngOnInit() {
     this.store.dispatch(loadProductFamiliesAction());
-    this.store.dispatch(loadLcpTenant());
+    this.store.dispatch(loadLcpTenant(this.paramsInfo['globalCustomerId'], this.paramsInfo['serviceType']));
     this.store.dispatch(loadAicZones());
     this.store.dispatch(loadCategoryParameters());
   }
+
+  public formatCloudOwnerTrailer(cloudOwner: string):string {
+    return AaiService.formatCloudOwnerTrailer(cloudOwner);
+  }
 }