app/src/app/pages/home/home-page.component.ts
crusader 19dda63c8a ing
2018-09-05 15:29:06 +09:00

90 lines
2.3 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { Observable, Subscription, of } from 'rxjs';
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
import { ProbeService, requesterID } from '../../../commons/service/probe.service';
import { Interface } from '@overflow/model/net/nic';
import { Zone, DiscoverHost } from '@overflow/model/discovery';
import { toMetaIPType, MetaIPTypeEnum } from '@overflow/model/meta';
import { Address } from '../../../commons/component/nic-dropdown.component';
@Component({
selector: 'app-pages-home',
templateUrl: './home-page.component.html',
styleUrls: ['./home-page.component.scss'],
})
export class HomePageComponent implements OnInit {
blockedPanel = false;
blockedDocument = false;
addresses: Address[];
constructor(
private probeService: ProbeService,
) { }
ngOnInit() {
}
blockDocument() {
this.blockedDocument = true;
setTimeout(() => {
this.blockedDocument = false;
}, 3000);
}
discoverHost() {
const zone: Zone = {
network: '192.168.1.0/24',
iface: 'enp3s0',
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
address: '192.168.1.101',
mac: '44:8a:5b:f1:f1:f3',
};
const discoverHost: DiscoverHost = {
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
firstScanRange: '192.168.1.1',
lastScanRange: '192.168.1.254',
discoveryConfig: {
},
discoverPort: {
firstScanRange: 1,
lastScanRange: 65535,
includeTCP: true,
includeUDP: true,
discoverService: {
}
}
};
this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost);
// this.probeService.call<Interface>('MachineService.Interfaces').pipe(
// map((ifaces: Interface[]) => {
// console.log(ifaces);
// this.addresses = [];
// ifaces.forEach(iface => {
// iface.addresses.forEach(address => {
// this.addresses.push({
// label: address.address,
// value: address.address,
// });
// });
// });
// }),
// catchError(error => {
// console.log(error);
// return of();
// }),
// take(1),
// ).subscribe();
}
}