summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/searchMembersModal/search-members-modal.component.ts
blob: 9c65d222d0b319195f8989459be6478f268fcb78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {DialogComponent, DialogService} from "ng2-bootstrap-modal";
import {IframeService} from "../../utils/iframe.service";
import {AaiService} from "../../services/aaiService/aai.service";
import {VnfMember} from "../../models/VnfMember";
import {VnfGroupModel} from "../../models/vnfGroupModel";
import {MembersTableService} from "./members-table/members-table.service";
import {VnfGroupInstance} from "../../models/vnfGroupInstance";


export interface PopupModel {
  title: string;
  serviceModelId : string;
  searchFields: ISearchField[];
  description : string;
  subscriberId: string,
  serviceType: string,
  node: VnfGroupInstance,
  vnfGroupModel: VnfGroupModel;

}

export interface ISearchField {
  title: string;
  value: any;
  dataTestId: string;
}

@Component({
  selector : 'search-members-modal',
  templateUrl : 'search-members-modal.component.html',
  styleUrls : ['search-members-modal.component.scss']
})

export class SearchMembersModalComponent extends DialogComponent<PopupModel, boolean> implements OnInit, OnDestroy {
  title: string;
  serviceModelId : string;
  parentElementClassName = 'content';
  membersData: VnfMember[];
  description : string;
  searchFields: ISearchField[];
  vnfGroupModel: VnfGroupModel;
  subscriberId: string;
  serviceType: string;
  node: VnfGroupInstance;
  disableSetMembers: boolean = true;
    constructor(dialogService:  DialogService ,
              private _iframeService : IframeService,
              private _aaiService : AaiService,
              private _membersTableService: MembersTableService){
    super(dialogService);

  }
  @ViewChild('MembersTableComponent') membersTable;

   ngOnInit() : void{
    this._aaiService.getOptionalGroupMembers(this.serviceModelId, this.subscriberId, this.serviceType, (Object.values(this.vnfGroupModel.members))[0].sourceModelInvariant, this.vnfGroupModel.properties.type, this.vnfGroupModel.properties.role)
      .subscribe((result: VnfMember[])=>{
        this.membersData = this._membersTableService.filterUsedVnfMembers(this.serviceModelId, result);
      });
    };


  closeDialog() : void{
    this._iframeService.removeClassCloseModal(this.parentElementClassName);
    this.dialogService.removeDialog(this);
    setTimeout(() => {
      window.parent.postMessage("closeIframe", "*");
    }, 15);
  }
  selectedMembersAmountChange(selectedMembersAmount: number) : void {
    this.disableSetMembers = selectedMembersAmount==0;
  }


  setMembers() : void {
    this._membersTableService.setMembers({serviceId : this.serviceModelId, vnfGroupStoreKey : this.node.vnfGroupStoreKey});
    this.closeDialog();
  }
}