ing
This commit is contained in:
parent
7e94b5eb30
commit
356ed2c912
13548
package-lock.json
generated
13548
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,12 @@
|
|||
import { Component, Input, OnInit, EventEmitter, Output, ViewChild, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
Input,
|
||||
OnInit,
|
||||
EventEmitter,
|
||||
Output,
|
||||
ViewChild,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
|
||||
import { of } from 'rxjs';
|
||||
import { catchError, map, take } from 'rxjs/operators';
|
||||
|
@ -22,32 +30,34 @@ class NICInfo {
|
|||
@Component({
|
||||
selector: 'app-nic-dropdown',
|
||||
templateUrl: './nic-dropdown.component.html',
|
||||
styleUrls: ['./nic-dropdown.component.scss'],
|
||||
styleUrls: ['./nic-dropdown.component.scss']
|
||||
})
|
||||
export class NicDropdownComponent implements OnInit {
|
||||
|
||||
@Input() blockTarget: any;
|
||||
@Output() select = new EventEmitter<Zone>();
|
||||
@ViewChild('panel') panel: DropdownPanelComponent;
|
||||
@Input()
|
||||
blockTarget: any;
|
||||
@Output()
|
||||
select = new EventEmitter<Zone>();
|
||||
@ViewChild('panel')
|
||||
panel: DropdownPanelComponent;
|
||||
|
||||
nics: SelectItem[] = [];
|
||||
selected: NICInfo;
|
||||
|
||||
constructor(
|
||||
private probeService: ProbeService,
|
||||
) {
|
||||
|
||||
}
|
||||
constructor(private probeService: ProbeService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.probeService.call<Interface>('MachineService.Interfaces').pipe(
|
||||
this.probeService
|
||||
.call<Interface[]>('MachineService.Interfaces')
|
||||
.pipe(
|
||||
map((ifaces: Interface[]) => {
|
||||
ifaces.forEach(iface => {
|
||||
if (undefined === iface.addresses) {
|
||||
return;
|
||||
}
|
||||
iface.addresses.forEach(address => {
|
||||
if (address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key) {
|
||||
if (
|
||||
address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const nicInfo = {
|
||||
|
@ -56,27 +66,29 @@ export class NicDropdownComponent implements OnInit {
|
|||
metaIPType: address.metaIPType,
|
||||
mac: iface.mac,
|
||||
address: address.address,
|
||||
network: address.network,
|
||||
network: address.network
|
||||
};
|
||||
this.nics.push({
|
||||
label: iface.friendlyName + ' (' + address.network + ')',
|
||||
value: nicInfo,
|
||||
disabled: address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key ? true : false,
|
||||
disabled:
|
||||
address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key
|
||||
? true
|
||||
: false
|
||||
});
|
||||
if (address.gateway !== undefined && address.gateway.length > 0) {
|
||||
this.nicSelected(nicInfo);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
console.log(error);
|
||||
return of();
|
||||
}),
|
||||
take(1),
|
||||
).subscribe();
|
||||
|
||||
take(1)
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
nicSelected(nic: NICInfo) {
|
||||
|
@ -87,11 +99,10 @@ export class NicDropdownComponent implements OnInit {
|
|||
iface: this.selected.iface,
|
||||
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
||||
address: this.selected.address,
|
||||
mac: this.selected.mac,
|
||||
mac: this.selected.mac
|
||||
};
|
||||
this.select.emit(zone);
|
||||
|
||||
this.panel.hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user