This commit is contained in:
crusader 2018-09-18 09:28:53 +09:00
parent 7e94b5eb30
commit 356ed2c912
3 changed files with 689 additions and 14137 deletions

13548
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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,61 +30,65 @@ 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(
map((ifaces: Interface[]) => {
ifaces.forEach(iface => {
if (undefined === iface.addresses) {
return;
}
iface.addresses.forEach(address => {
if (address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key) {
this.probeService
.call<Interface[]>('MachineService.Interfaces')
.pipe(
map((ifaces: Interface[]) => {
ifaces.forEach(iface => {
if (undefined === iface.addresses) {
return;
}
const nicInfo = {
iface: iface.iface,
friendlyName: iface.friendlyName,
metaIPType: address.metaIPType,
mac: iface.mac,
address: address.address,
network: address.network,
};
this.nics.push({
label: iface.friendlyName + ' (' + address.network + ')',
value: nicInfo,
disabled: address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key ? true : false,
iface.addresses.forEach(address => {
if (
address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key
) {
return;
}
const nicInfo = {
iface: iface.iface,
friendlyName: iface.friendlyName,
metaIPType: address.metaIPType,
mac: iface.mac,
address: address.address,
network: address.network
};
this.nics.push({
label: iface.friendlyName + ' (' + address.network + ')',
value: nicInfo,
disabled:
address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key
? true
: false
});
if (address.gateway !== undefined && address.gateway.length > 0) {
this.nicSelected(nicInfo);
}
});
if (address.gateway !== undefined && address.gateway.length > 0) {
this.nicSelected(nicInfo);
}
});
});
}),
catchError(error => {
console.log(error);
return of();
}),
take(1),
).subscribe();
}),
catchError(error => {
console.log(error);
return of();
}),
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();
}
}

1175
yarn.lock

File diff suppressed because it is too large Load Diff