test
This commit is contained in:
parent
9497df0ad9
commit
e571e54b36
|
@ -1,5 +1,5 @@
|
|||
<div *ngIf="showIntro" class="home-start">
|
||||
<div class="start-button" (click)="discoverHost($event)">
|
||||
<div class="start-button" (click)="startDiscovery($event)">
|
||||
<svg version="1.1" viewBox="0 0 200 210">
|
||||
<path d="M8.3,193.5c0.1,2.4,0.8,4.9,2.1,7.1c4.5,7.7,14.3,10.4,22.1,5.9l152.1-87.8c2-1.3,3.8-3.1,5.1-5.4
|
||||
c4.5-7.7,1.8-17.6-5.9-22.1L31.6,3.4c-2.2-1.1-4.6-1.7-7.2-1.7c-8.9,0-16.2,7.2-16.2,16.2V193.5z" />
|
||||
|
|
|
@ -4,8 +4,7 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectorRef
|
|||
|
||||
import { ProbeService, requesterID } from '../../../commons/service/probe.service';
|
||||
|
||||
import { Zone, Host, Port, Service } from '@overflow/model/discovery';
|
||||
import { toMetaIPType, MetaIPTypeEnum } from '@overflow/model/meta';
|
||||
import { Zone, Host, Port, Service, DiscoverHost } from '@overflow/model/discovery';
|
||||
import { RPCSubscriber } from '@overflow/commons/ui/decorator/RPCSubscriber';
|
||||
import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service';
|
||||
|
||||
|
@ -17,8 +16,12 @@ const vis = require('vis');
|
|||
styleUrls: ['./home-page.component.scss'],
|
||||
})
|
||||
export class HomePageComponent implements OnInit, OnDestroy {
|
||||
|
||||
private discoveryTargetRef: ElementRef;
|
||||
|
||||
zone: Zone;
|
||||
discoverHost: DiscoverHost;
|
||||
|
||||
@ViewChild('discoveryTarget') set discoveryTarget(content: ElementRef) {
|
||||
this.discoveryTargetRef = content;
|
||||
}
|
||||
|
@ -44,7 +47,18 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
|
||||
ngOnInit() {
|
||||
// this.probeService.subscribeNotification(this);
|
||||
// this.discoverHost("");
|
||||
// this.startDiscovery("");
|
||||
this.discoveryConfigService.zone.subscribe(res => {
|
||||
this.zone = res as Zone;
|
||||
});
|
||||
this.discoveryConfigService.discoverHost.subscribe(res => {
|
||||
this.discoverHost = res as DiscoverHost;
|
||||
});
|
||||
this.discoveryConfigService.started.subscribe(res => {
|
||||
if (res) {
|
||||
this.startDiscovery();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
@ -58,7 +72,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
}, 3000);
|
||||
}
|
||||
|
||||
discoverHost() {
|
||||
startDiscovery() {
|
||||
this.showIntro = false;
|
||||
this.changeDetector.detectChanges();
|
||||
|
||||
|
@ -97,12 +111,12 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
});
|
||||
|
||||
this.probeService.send(
|
||||
'DiscoveryService.DiscoverHost',
|
||||
requesterID,
|
||||
this.discoveryConfigService.getZone(),
|
||||
this.discoveryConfigService.getDiscoverHost()
|
||||
);
|
||||
// this.probeService.send(
|
||||
// 'DiscoveryService.DiscoverHost',
|
||||
// requesterID,
|
||||
// this.discoveryConfigService.getZone(),
|
||||
// this.discoveryConfigService.getDiscoverHost()
|
||||
// );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ import { CommonsUIModule } from '@overflow/commons/ui/commons-ui.module';
|
|||
import { HomePageComponent } from './home-page.component';
|
||||
import { HomePageRoutingModule } from './home-page-routing.module';
|
||||
import { CommonsModule } from '../../../commons/commons.module';
|
||||
import { DiscoveryConfigService } from '../../../commons/service/discovery-config.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -18,8 +17,5 @@ import { DiscoveryConfigService } from '../../../commons/service/discovery-confi
|
|||
entryComponents: [
|
||||
],
|
||||
declarations: [HomePageComponent],
|
||||
providers: [
|
||||
DiscoveryConfigService
|
||||
]
|
||||
})
|
||||
export class HomePageModule { }
|
||||
|
|
|
@ -363,10 +363,7 @@ export class PagesComponent implements AfterViewInit, OnDestroy, OnInit {
|
|||
}
|
||||
|
||||
onStart() {
|
||||
this.probeService.send('DiscoveryService.DiscoverHost',
|
||||
requesterID,
|
||||
this.discoveryConfigService.getZone(),
|
||||
this.discoveryConfigService.getDiscoverHost());
|
||||
this.discoveryConfigService.setStarted(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import { CommonsModule } from '../../commons/commons.module';
|
|||
import { PagesComponent } from './pages.component';
|
||||
import { PagesRoutingModule } from './pages-routing.module';
|
||||
import { DiscoveryConfigService } from '../../commons/service/discovery-config.service';
|
||||
import { ProbeService } from '../../commons/service/probe.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
|
@ -1,27 +1,37 @@
|
|||
import { Injectable } from "@angular/core";
|
||||
import { DiscoverHost, Zone } from "@overflow/model/discovery";
|
||||
import { Observable, BehaviorSubject } from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DiscoveryConfigService {
|
||||
|
||||
discoverHost: DiscoverHost;
|
||||
zone: Zone;
|
||||
private discoverHostSubject = new BehaviorSubject<DiscoverHost>(null);
|
||||
private zoneSubject = new BehaviorSubject<Zone>(null);
|
||||
private startSubject = new BehaviorSubject<boolean>(false);
|
||||
|
||||
public setZone(zone: Zone): void {
|
||||
this.zone = zone;
|
||||
discoverHost: Observable<DiscoverHost>;
|
||||
zone: Observable<Zone>;
|
||||
started: Observable<boolean>;
|
||||
|
||||
|
||||
constructor() {
|
||||
this.discoverHost = this.discoverHostSubject.asObservable();
|
||||
this.zone = this.zoneSubject.asObservable();
|
||||
this.started = this.startSubject.asObservable();
|
||||
}
|
||||
|
||||
public getZone(): Zone {
|
||||
return this.zone;
|
||||
public setZone(zone: Zone): void {
|
||||
this.zoneSubject.next(zone);
|
||||
}
|
||||
|
||||
public setDiscoverHost(discoverHost: DiscoverHost): void {
|
||||
this.discoverHost = discoverHost;
|
||||
this.discoverHostSubject.next(discoverHost);
|
||||
}
|
||||
|
||||
public getDiscoverHost(): DiscoverHost {
|
||||
return this.discoverHost;
|
||||
public setStarted(isStarted: boolean): void {
|
||||
this.startSubject.next(isStarted);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user