2018-05-03 11:45:49 +00:00
|
|
|
import { Component, OnInit, AfterContentInit, Output, EventEmitter, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
|
|
|
import { Store, select, StateObservable } from '@ngrx/store';
|
2018-04-10 10:20:44 +00:00
|
|
|
import { RPCClientError } from '@loafer/ng-rpc/protocol';
|
|
|
|
import {
|
|
|
|
DiscoveryStartInfo,
|
2018-04-27 16:29:54 +00:00
|
|
|
DiscoverZone,
|
2018-04-10 10:20:44 +00:00
|
|
|
Zone,
|
2018-04-27 16:29:54 +00:00
|
|
|
DiscoverPort,
|
|
|
|
DiscoverService
|
2018-05-02 07:23:35 +00:00
|
|
|
} from '@overflow/commons-typescript/model/discovery';
|
2018-04-10 10:20:44 +00:00
|
|
|
import * as CIDR from 'ip-cidr';
|
|
|
|
import * as DiscoveredStore from '../../store/setting';
|
|
|
|
import { SettingSelector, DiscoverSelector } from '../../store';
|
|
|
|
import * as DiscoverStore from '../../store/discover';
|
|
|
|
import * as RegistStore from '../../store/regist';
|
2018-05-02 07:23:35 +00:00
|
|
|
import { Host } from '@overflow/commons-typescript/model/discovery';
|
|
|
|
import { Port } from '@overflow/commons-typescript/model/discovery';
|
|
|
|
import { Service } from '@overflow/commons-typescript/model/discovery';
|
2018-04-10 10:20:44 +00:00
|
|
|
import * as ProbeDetailStore from 'packages/probe/store';
|
2018-05-02 07:23:35 +00:00
|
|
|
import { Probe } from '@overflow/commons-typescript/model/probe';
|
2018-04-10 10:20:44 +00:00
|
|
|
import { TreeNode } from 'primeng/primeng';
|
2018-05-03 11:45:49 +00:00
|
|
|
import { ListSelector as ProbeListSelector } from 'packages/probe/store';
|
|
|
|
import * as ProbeListStore from 'packages/probe/store/list';
|
|
|
|
import { AuthSelector } from 'packages/member/store';
|
|
|
|
import { Domain } from '@overflow/commons-typescript/model/domain';
|
|
|
|
import { Subscription } from 'rxjs/Subscription';
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-discovery-setting',
|
|
|
|
templateUrl: './setting.component.html',
|
|
|
|
})
|
2018-05-03 11:45:49 +00:00
|
|
|
export class SettingComponent implements OnInit, AfterContentInit, OnDestroy, OnChanges {
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
@Input() probe: Probe;
|
2018-04-13 10:32:17 +00:00
|
|
|
@Output() close = new EventEmitter();
|
2018-05-03 11:45:49 +00:00
|
|
|
private requestStart = false;
|
|
|
|
private started = false;
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
private selectedProbe: Probe;
|
2018-04-10 10:20:44 +00:00
|
|
|
|
|
|
|
constructor(
|
2018-05-03 11:45:49 +00:00
|
|
|
private discoverStore: Store<DiscoverStore.State>,
|
2018-04-10 10:20:44 +00:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
|
|
|
}
|
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
|
if (changes['probe'] && this.probe) {
|
|
|
|
this.selectedProbe = this.probe;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-04-16 08:13:25 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
ngOnDestroy() {
|
2018-04-16 08:13:25 +00:00
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
onProbeSelect(probe: Probe) {
|
|
|
|
this.selectedProbe = probe;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
onDiscoveryStart(discoverZone: DiscoverZone) {
|
|
|
|
this.discoverStore.dispatch(new DiscoverStore.DiscoverZone(
|
|
|
|
{ probeID: this.selectedProbe.probeKey, discoverZone: discoverZone }));
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.started = true;
|
|
|
|
this.requestStart = false;
|
2018-04-10 10:20:44 +00:00
|
|
|
});
|
|
|
|
}
|
2018-04-06 11:02:18 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
onCancel() {
|
|
|
|
this.close.emit();
|
|
|
|
this.started = false;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
}
|