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
83
84
85
86
87
|
import {Component, Input, 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 {VnfGroupModel} from "../../models/vnfGroupModel";
import {ElementsTableService} from "./members-table/elements-table.service";
import {Level1Instance} from "../../models/level1Instance";
import {ModalInformation} from "./members-table/element-table-row.model";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../store/reducers";
import {FormGroup} from "@angular/forms";
import * as _ from "lodash";
import {clearAllGenericModalhelper} from "../../storeUtil/utils/global/global.actions";
@Component({
selector: 'search-members-modal',
templateUrl: 'search-elements-modal.component.html',
styleUrls: ['search-elements-modal.component.scss']
})
export class SearchElementsModalComponent extends DialogComponent<{ modalInformation: ModalInformation }, boolean> implements OnInit, OnDestroy {
modalInformation: ModalInformation;
parentElementClassName = 'content';
elementsData: Level1Instance[];
vnfGroupModel: VnfGroupModel;
disableSetElements: boolean = true;
disableSearchByNetworkRole: boolean = false;
dynamicFormGroup: FormGroup = null;
constructor(dialogService: DialogService,
private _iframeService: IframeService,
private _aaiService: AaiService,
private _membersTableService: ElementsTableService,
private _store: NgRedux<AppState>) {
super(dialogService);
ElementsTableService.changeFnTableDataTrigger.subscribe((triggerRes) => {
this._membersTableService.resetAll(this.modalInformation.uniqObjectField, this.modalInformation.maxSelectRow);
this.elementsData = triggerRes;
});
ElementsTableService.changeModalInformationDataTrigger.subscribe(({modalInformation, selectedRowsIds}) => {
this.disableSetElements = true;
this.modalInformation = modalInformation;
this.ngOnInit(selectedRowsIds);
})
}
@ViewChild('ElementsTableComponent', {static: false}) membersTable;
ngOnInit(selectedRowsIds?: string[]): void {
const genericModalHelper = this._store.getState().global.genericModalHelper;
if(!_.isNil(genericModalHelper) && !_.isNil(genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`]) && !_.isNil(genericModalHelper[`selected${this.modalInformation.type}`])){
this.elementsData = this._store.getState().global.genericModalHelper[`${this.modalInformation.type}_TABLE_DATA`];
} else {
this.modalInformation.getElements()
.subscribe((result) => {
this.elementsData = result;
});
}
};
closeDialog(): void {
this._iframeService.removeFullScreen();
this._iframeService.closeIframe(this.dialogService, this);
}
selectedMembersAmountChange(selectedMembersAmount: number): void {
this.disableSetElements = selectedMembersAmount == 0;
}
doneAction(): void {
this.modalInformation.topButton.action.call(this, this);
}
searchByCriteriaAction(): void {
this.modalInformation.searchButton.action.call(this, this);
}
backAction(): void {
if (this.modalInformation.backAction) {
this.modalInformation.backAction.call(this, this);
} else {
this.closeDialog();
}
}
}
|