diff --git a/src/app/app.component.html b/src/app/app.component.html index 0d18937..925d7b2 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -5,4 +5,42 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f6cbd06..2c9420b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,17 +1,29 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core'; + +import { of, Subscription } from 'rxjs'; +import { map, catchError, take } from 'rxjs/operators'; + import { ElectronProxyService } from '../commons/service/electron-proxy.service'; import { ProbeService } from '../commons/service/probe.service'; +import { MenuEvent } from '../commons/type'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) -export class AppComponent implements OnInit { +export class AppComponent implements OnInit, OnDestroy { title = 'scanner-app'; showTitleBar: boolean; + menuSubscription: Subscription; + displayAbout: boolean; + displayExportCSV: boolean; + displayPreferences: boolean; + displayPrint: boolean; + public constructor( + private changeDetector: ChangeDetectorRef, private electronProxyService: ElectronProxyService, private probeService: ProbeService, ) { @@ -22,5 +34,40 @@ export class AppComponent implements OnInit { ngOnInit(): void { // this.probeService.connect(); this.electronProxyService.sendReady(performance.now()); + this.menuSubscription = this.electronProxyService.menuObservable() + .pipe( + map((name: MenuEvent) => { + switch (name) { + case 'show-about': + this.displayAbout = true; + break; + case 'show-export-csv': + this.displayExportCSV = true; + break; + case 'show-preferences': + this.displayPreferences = true; + break; + case 'show-print': + this.displayPrint = true; + break; + default: + break; + } + this.changeDetector.detectChanges(); + }), + catchError(error => { + return of(); + }), + ) + .subscribe(); + } + + ngOnDestroy(): void { + this.menuSubscription.unsubscribe(); + } + + // onMenuClosed(event) { + // this.changeDetector.markForCheck(); + // } } diff --git a/src/commons/component/host-detail.component.ts b/src/commons/component/host-detail.component.ts index 1e64938..91bcb13 100644 --- a/src/commons/component/host-detail.component.ts +++ b/src/commons/component/host-detail.component.ts @@ -1,9 +1,12 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { Host } from '@overflow/model/discovery'; -import { ProbeService } from '../service/probe.service'; -import { map, catchError, take } from 'rxjs/operators'; -import { PingResult } from '@overflow/model/ping'; + import { of } from 'rxjs'; +import { map, catchError, take } from 'rxjs/operators'; + +import { Host } from '@overflow/model/discovery'; +import { PingResult } from '@overflow/model/ping'; + +import { ProbeService } from '../service/probe.service'; @Component({ diff --git a/src/commons/component/index.ts b/src/commons/component/index.ts index 610547e..c6ef5a2 100644 --- a/src/commons/component/index.ts +++ b/src/commons/component/index.ts @@ -5,11 +5,24 @@ import { ZoneDetailComponent } from './zone-detail.component'; import { HostDetailComponent } from './host-detail.component'; import { ServiceDetailComponent } from './service-detail.component'; +import { + AboutComponent, + ExportCSVComponent, + PreferencesComponent, + PrintComponent, +} from './menu'; + + export const COMPONENTS = [ NicDropdownComponent, ScannerSettingDropdownComponent, NodeDetailComponent, ZoneDetailComponent, HostDetailComponent, - ServiceDetailComponent + ServiceDetailComponent, + AboutComponent, + ExportCSVComponent, + PreferencesComponent, + PrintComponent, + ]; diff --git a/src/commons/component/menu/about.component.html b/src/commons/component/menu/about.component.html new file mode 100644 index 0000000..6797d7e --- /dev/null +++ b/src/commons/component/menu/about.component.html @@ -0,0 +1,3 @@ +
+ About +
\ No newline at end of file diff --git a/src/commons/component/menu/about.component.scss b/src/commons/component/menu/about.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/commons/component/menu/about.component.ts b/src/commons/component/menu/about.component.ts new file mode 100644 index 0000000..6656e63 --- /dev/null +++ b/src/commons/component/menu/about.component.ts @@ -0,0 +1,15 @@ +import { Component, } from '@angular/core'; + +@Component({ + selector: 'app-menu-about', + templateUrl: './about.component.html', + styleUrls: ['./about.component.scss'], +}) +export class AboutComponent { + + constructor( + ) { + } + + +} diff --git a/src/commons/component/menu/export-csv.component.html b/src/commons/component/menu/export-csv.component.html new file mode 100644 index 0000000..1797c1d --- /dev/null +++ b/src/commons/component/menu/export-csv.component.html @@ -0,0 +1,3 @@ +
+ Export CSV +
\ No newline at end of file diff --git a/src/commons/component/menu/export-csv.component.scss b/src/commons/component/menu/export-csv.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/commons/component/menu/export-csv.component.ts b/src/commons/component/menu/export-csv.component.ts new file mode 100644 index 0000000..70bbd82 --- /dev/null +++ b/src/commons/component/menu/export-csv.component.ts @@ -0,0 +1,15 @@ +import { Component, } from '@angular/core'; + +@Component({ + selector: 'app-menu-export-csv', + templateUrl: './export-csv.component.html', + styleUrls: ['./export-csv.component.scss'], +}) +export class ExportCSVComponent { + + constructor( + ) { + } + + +} diff --git a/src/commons/component/menu/index.ts b/src/commons/component/menu/index.ts new file mode 100644 index 0000000..7d9c457 --- /dev/null +++ b/src/commons/component/menu/index.ts @@ -0,0 +1,4 @@ +export * from './about.component'; +export * from './export-csv.component'; +export * from './preferences.component'; +export * from './print.component'; diff --git a/src/commons/component/menu/preferences.component.html b/src/commons/component/menu/preferences.component.html new file mode 100644 index 0000000..cf1f440 --- /dev/null +++ b/src/commons/component/menu/preferences.component.html @@ -0,0 +1,3 @@ +
+ Preferences +
\ No newline at end of file diff --git a/src/commons/component/menu/preferences.component.scss b/src/commons/component/menu/preferences.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/commons/component/menu/preferences.component.ts b/src/commons/component/menu/preferences.component.ts new file mode 100644 index 0000000..c2a908d --- /dev/null +++ b/src/commons/component/menu/preferences.component.ts @@ -0,0 +1,15 @@ +import { Component, } from '@angular/core'; + +@Component({ + selector: 'app-menu-preferences', + templateUrl: './preferences.component.html', + styleUrls: ['./preferences.component.scss'], +}) +export class PreferencesComponent { + + constructor( + ) { + } + + +} diff --git a/src/commons/component/menu/print.component.html b/src/commons/component/menu/print.component.html new file mode 100644 index 0000000..6014f5c --- /dev/null +++ b/src/commons/component/menu/print.component.html @@ -0,0 +1,3 @@ +
+ Print +
\ No newline at end of file diff --git a/src/commons/component/menu/print.component.scss b/src/commons/component/menu/print.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/commons/component/menu/print.component.ts b/src/commons/component/menu/print.component.ts new file mode 100644 index 0000000..1515649 --- /dev/null +++ b/src/commons/component/menu/print.component.ts @@ -0,0 +1,15 @@ +import { Component, } from '@angular/core'; + +@Component({ + selector: 'app-menu-print', + templateUrl: './print.component.html', + styleUrls: ['./print.component.scss'], +}) +export class PrintComponent { + + constructor( + ) { + } + + +} diff --git a/src/commons/service/electron-proxy.service.ts b/src/commons/service/electron-proxy.service.ts index 20550c0..46bb2a2 100644 --- a/src/commons/service/electron-proxy.service.ts +++ b/src/commons/service/electron-proxy.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; +import { Observable, Subject, of } from 'rxjs'; import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { ipcRenderer } from 'electron'; @@ -12,18 +12,27 @@ import { LaunchService } from './launch.service'; providedIn: 'root' }) export class ElectronProxyService { + private menuSubject: Subject; + public constructor( private store: Store, private launchService: LaunchService ) { + this.menuSubject = new Subject(); + this.bindIpcEventHandlers(); } + public menuObservable(): Observable { + return this.menuSubject.asObservable(); + } + private bindIpcEventHandlers(): void { ipcRenderer.on( 'menu-event', (event: Electron.IpcMessageEvent, { name }: { name: MenuEvent }) => { console.log(`menu: ${name}`); + this.menuSubject.next(name); } );