1 import {Component, Input, OnInit, ViewChild} from "@angular/core";
2 import {NgRedux, select} from "@angular-redux/store";
3 import {AppState} from "../../store/reducers";
4 import {ModelInformationItem} from "../../shared/components/model-information/model-information.component";
5 import {Observable} from "rxjs/Observable";
6 import {NgForm} from "@angular/forms";
7 import * as _ from 'lodash';
10 selector: "app-network-selector",
11 templateUrl: "./network-selector.component.html",
12 styleUrls: ["./network-selector.component.scss"]
14 export class NetworkSelectorComponent implements OnInit {
15 private localStore: NgRedux<AppState>;
16 networkSelection: any;
18 @Input() groups: Array<string>;
19 @Input() cloudOwner : string;
20 @Input() cloudRegionId : string;
21 @select(['service', 'networkFunctions'])
22 readonly networkFunctions: Observable<any>;
24 @ViewChild('form') form: NgForm;
26 constructor(store: NgRedux<AppState>) {
27 this.localStore = store;
28 this.groupSelection = {};
32 getValueOfLabelInGroup(group: any, label: string){
33 let item = _.find(group, {"label": label});
35 return item["values"][0];
39 getNetworksByNetworkFunctionRole(group: any): Observable<string[]> {
40 let filteredItem = this.getValueOfLabelInGroup(group,"Network Collection Function");
41 return this.networkFunctions.map(data => {
42 return (data && data[filteredItem]) || [];
46 getGroupName(group: ModelInformationItem[]) {
47 return this.getValueOfLabelInGroup(group,"Group Name");
52 * groups => groupsModel
56 let store = this.localStore;
57 this.networkSelection = {};
65 Info inside redux = {ncfNetworkMap }