2018-05-10 12:21:20 +00:00
|
|
|
import {
|
|
|
|
Component, OnInit, AfterContentInit, Output, EventEmitter,
|
|
|
|
Input, OnDestroy, OnChanges, SimpleChanges, ViewChild
|
|
|
|
} from '@angular/core';
|
2018-05-03 11:45:49 +00:00
|
|
|
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-05-04 04:11:59 +00:00
|
|
|
import { ResultComponent } from './result/result.component';
|
|
|
|
import { ProbeSelectorComponent } from './probe-selector/probe-selector.component';
|
|
|
|
import { FilterComponent } from './filter/filter.component';
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-05-10 12:21:20 +00:00
|
|
|
import { trigger, state, transition, style, animate } from '@angular/core';
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'of-discovery-setting',
|
|
|
|
templateUrl: './setting.component.html',
|
2018-05-10 12:21:20 +00:00
|
|
|
animations: [
|
|
|
|
trigger(
|
|
|
|
'discoveryFilter', [
|
|
|
|
state('summary', style({
|
|
|
|
height: '70px',
|
2018-05-14 09:02:48 +00:00
|
|
|
opacity: 0.9,
|
2018-05-10 12:21:20 +00:00
|
|
|
})),
|
|
|
|
state('full', style({
|
|
|
|
height: '500px',
|
2018-05-14 09:02:48 +00:00
|
|
|
opacity: 1,
|
2018-05-10 12:21:20 +00:00
|
|
|
})),
|
2018-05-14 09:02:48 +00:00
|
|
|
transition('* => *', animate('200ms ease-in')),
|
2018-05-10 12:21:20 +00:00
|
|
|
]),
|
2018-05-14 06:53:16 +00:00
|
|
|
trigger(
|
|
|
|
'result', [
|
|
|
|
state('show', style({
|
|
|
|
height: '300px',
|
2018-05-14 09:02:48 +00:00
|
|
|
opacity: 1,
|
2018-05-14 06:53:16 +00:00
|
|
|
})),
|
|
|
|
state('hidden', style({
|
|
|
|
height: '0px',
|
2018-05-14 09:02:48 +00:00
|
|
|
opacity: 0,
|
2018-05-14 06:53:16 +00:00
|
|
|
})),
|
2018-05-14 09:02:48 +00:00
|
|
|
transition('* => *', animate('200ms ease-in')),
|
2018-05-14 06:53:16 +00:00
|
|
|
]
|
|
|
|
)
|
2018-05-10 12:21:20 +00:00
|
|
|
]
|
2018-04-10 10:20:44 +00:00
|
|
|
})
|
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-04 02:20:07 +00:00
|
|
|
@Input() visible: boolean;
|
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-05-10 12:21:20 +00:00
|
|
|
private filterData: DiscoverZone;
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
private selectedProbe: Probe;
|
2018-05-03 13:27:11 +00:00
|
|
|
private height: number;
|
2018-04-10 10:20:44 +00:00
|
|
|
|
2018-05-04 04:11:59 +00:00
|
|
|
@ViewChild('probeSelectorComponent') probeSelectorComponent: ProbeSelectorComponent;
|
|
|
|
@ViewChild('filterComponent') filterComponent: FilterComponent;
|
|
|
|
@ViewChild('resultComponent') resultComponent: ResultComponent;
|
|
|
|
|
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
|
|
|
) {
|
2018-05-10 12:21:20 +00:00
|
|
|
this.height = window.innerHeight * 0.9;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-05-04 04:11:59 +00:00
|
|
|
this.selectedProbe = this.probe;
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
|
|
|
}
|
|
|
|
|
2018-05-03 11:45:49 +00:00
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
2018-05-04 04:11:59 +00:00
|
|
|
if (changes['visible']) {
|
|
|
|
const change = changes['visible'];
|
|
|
|
if (!change.previousValue && change.currentValue) {
|
|
|
|
this.initAll();
|
2018-05-10 12:21:20 +00:00
|
|
|
} else if (change.previousValue && !change.currentValue) {
|
2018-05-04 04:11:59 +00:00
|
|
|
this.destroyAll();
|
|
|
|
}
|
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-05-04 04:11:59 +00:00
|
|
|
this.selectedProbe = null;
|
|
|
|
this.started = false;
|
|
|
|
this.close.emit();
|
|
|
|
this.requestStart = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
initAll() {
|
|
|
|
this.ngOnInit();
|
|
|
|
if (this.probeSelectorComponent) {
|
|
|
|
this.probeSelectorComponent.ngOnInit();
|
|
|
|
}
|
|
|
|
if (this.filterComponent) {
|
|
|
|
this.filterComponent.ngOnInit();
|
|
|
|
}
|
|
|
|
if (this.resultComponent) {
|
|
|
|
this.resultComponent.ngOnInit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
destroyAll() {
|
|
|
|
this.ngOnDestroy();
|
|
|
|
if (this.probeSelectorComponent) {
|
|
|
|
this.probeSelectorComponent.ngOnDestroy();
|
|
|
|
}
|
|
|
|
if (this.filterComponent) {
|
|
|
|
this.filterComponent.ngOnDestroy();
|
|
|
|
}
|
|
|
|
if (this.resultComponent) {
|
|
|
|
this.resultComponent.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) {
|
2018-05-10 12:21:20 +00:00
|
|
|
this.filterData = discoverZone;
|
2018-05-14 06:53:16 +00:00
|
|
|
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;
|
2018-05-14 06:53:16 +00:00
|
|
|
// 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() {
|
2018-05-04 04:11:59 +00:00
|
|
|
this.destroyAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSave() {
|
|
|
|
this.resultComponent.save();
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|
2018-05-03 11:55:14 +00:00
|
|
|
|
2018-05-10 12:21:20 +00:00
|
|
|
onStop() {
|
|
|
|
this.started = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSummaryClick() {
|
|
|
|
if (this.started) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-14 06:53:16 +00:00
|
|
|
this.requestStart = false;
|
2018-05-10 12:21:20 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 10:20:44 +00:00
|
|
|
}
|