diff --git a/src/app/pages/home/home-page.component.html b/src/app/pages/home/home-page.component.html index 8bf12ae..0fc5e54 100644 --- a/src/app/pages/home/home-page.component.html +++ b/src/app/pages/home/home-page.component.html @@ -1,5 +1,5 @@
-
+
diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index 7ca579b..e18c1e6 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -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() + // ); } /** diff --git a/src/app/pages/home/home-page.module.ts b/src/app/pages/home/home-page.module.ts index a6677a4..e13afff 100644 --- a/src/app/pages/home/home-page.module.ts +++ b/src/app/pages/home/home-page.module.ts @@ -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 { } diff --git a/src/app/pages/pages.component.ts b/src/app/pages/pages.component.ts index fd2dbee..9760b8a 100644 --- a/src/app/pages/pages.component.ts +++ b/src/app/pages/pages.component.ts @@ -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); } } diff --git a/src/app/pages/pages.module.ts b/src/app/pages/pages.module.ts index da519f2..eb1d66a 100644 --- a/src/app/pages/pages.module.ts +++ b/src/app/pages/pages.module.ts @@ -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: [ diff --git a/src/commons/service/discovery-config.service.ts b/src/commons/service/discovery-config.service.ts index 57678bf..cf8a673 100644 --- a/src/commons/service/discovery-config.service.ts +++ b/src/commons/service/discovery-config.service.ts @@ -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(null); + private zoneSubject = new BehaviorSubject(null); + private startSubject = new BehaviorSubject(false); - public setZone(zone: Zone): void { - this.zone = zone; + discoverHost: Observable; + zone: Observable; + started: Observable; + + + 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); } + } \ No newline at end of file