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 { of } from 'rxjs';
import { catchError, map, take } from 'rxjs/operators'; import { catchError, map, take } from 'rxjs/operators';
@ -22,32 +30,34 @@ class NICInfo {
@Component({ @Component({
selector: 'app-nic-dropdown', selector: 'app-nic-dropdown',
templateUrl: './nic-dropdown.component.html', templateUrl: './nic-dropdown.component.html',
styleUrls: ['./nic-dropdown.component.scss'], styleUrls: ['./nic-dropdown.component.scss']
}) })
export class NicDropdownComponent implements OnInit { export class NicDropdownComponent implements OnInit {
@Input()
@Input() blockTarget: any; blockTarget: any;
@Output() select = new EventEmitter<Zone>(); @Output()
@ViewChild('panel') panel: DropdownPanelComponent; select = new EventEmitter<Zone>();
@ViewChild('panel')
panel: DropdownPanelComponent;
nics: SelectItem[] = []; nics: SelectItem[] = [];
selected: NICInfo; selected: NICInfo;
constructor( constructor(private probeService: ProbeService) {}
private probeService: ProbeService,
) {
}
ngOnInit(): void { ngOnInit(): void {
this.probeService.call<Interface>('MachineService.Interfaces').pipe( this.probeService
.call<Interface[]>('MachineService.Interfaces')
.pipe(
map((ifaces: Interface[]) => { map((ifaces: Interface[]) => {
ifaces.forEach(iface => { ifaces.forEach(iface => {
if (undefined === iface.addresses) { if (undefined === iface.addresses) {
return; return;
} }
iface.addresses.forEach(address => { iface.addresses.forEach(address => {
if (address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key) { if (
address.metaIPType.key !== toMetaIPType(MetaIPTypeEnum.V4).key
) {
return; return;
} }
const nicInfo = { const nicInfo = {
@ -56,27 +66,29 @@ export class NicDropdownComponent implements OnInit {
metaIPType: address.metaIPType, metaIPType: address.metaIPType,
mac: iface.mac, mac: iface.mac,
address: address.address, address: address.address,
network: address.network, network: address.network
}; };
this.nics.push({ this.nics.push({
label: iface.friendlyName + ' (' + address.network + ')', label: iface.friendlyName + ' (' + address.network + ')',
value: nicInfo, 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) { if (address.gateway !== undefined && address.gateway.length > 0) {
this.nicSelected(nicInfo); this.nicSelected(nicInfo);
} }
}); });
}); });
}), }),
catchError(error => { catchError(error => {
console.log(error); console.log(error);
return of(); return of();
}), }),
take(1), take(1)
).subscribe(); )
.subscribe();
} }
nicSelected(nic: NICInfo) { nicSelected(nic: NICInfo) {
@ -87,11 +99,10 @@ export class NicDropdownComponent implements OnInit {
iface: this.selected.iface, iface: this.selected.iface,
metaIPType: toMetaIPType(MetaIPTypeEnum.V4), metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
address: this.selected.address, address: this.selected.address,
mac: this.selected.mac, mac: this.selected.mac
}; };
this.select.emit(zone); this.select.emit(zone);
this.panel.hide(); this.panel.hide();
} }
} }

1175
yarn.lock

File diff suppressed because it is too large Load Diff