From b74d45c303d5052379b345313192c1df9a7781ca Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 31 May 2018 18:45:40 +0900 Subject: [PATCH] probe / discovery module refactoring --- .../discovery/discovery.component.html | 1 + .../discovery/discovery.component.ts | 12 +-- .../discovery-container.component.html | 3 - .../discovery-container.component.ts | 34 -------- @overflow/discovery/container/index.ts | 5 -- @overflow/discovery/discovery.module.ts | 3 - .../component/detail/detail.component.spec.ts | 25 ------ .../download/download.component.spec.ts | 25 ------ @overflow/probe/component/index.ts | 10 +-- .../component/list/list.component.spec.ts | 25 ------ .../probe/component/list/list.component.ts | 36 -------- ...onent.html => probe-detail.component.html} | 15 +--- ...component.ts => probe-detail.component.ts} | 65 +++++++------- ...ent.html => probe-download.component.html} | 0 ...mponent.ts => probe-download.component.ts} | 2 +- ...mponent.html => probe-list.component.html} | 6 +- .../probe/component/probe-list.component.ts | 70 +++++++++++++++ .../component/probe-selector.component.html | 4 + .../component/probe-selector.component.ts | 85 +++++++++++++++++++ ...nent.html => probe-summary.component.html} | 0 ...omponent.ts => probe-summary.component.ts} | 2 +- .../selector/selector.component.html | 4 - .../component/selector/selector.component.ts | 43 ---------- @overflow/probe/container/index.ts | 9 -- .../probe-detail-container.component.html | 1 - .../probe-detail-container.component.ts | 44 ---------- .../probe-list-container.component.html | 1 - .../probe-list-container.component.ts | 42 --------- .../probe-selector-container.component.html | 1 - .../probe-selector-container.component.ts | 33 ------- @overflow/probe/probe.module.ts | 3 - .../discovery/discovery-page.component.html | 5 +- .../noauth-probe-page-routing.module.ts | 2 - .../probes/probe/probe-page.component.html | 7 +- 34 files changed, 219 insertions(+), 404 deletions(-) delete mode 100644 @overflow/discovery/container/discovery/discovery-container.component.html delete mode 100644 @overflow/discovery/container/discovery/discovery-container.component.ts delete mode 100644 @overflow/discovery/container/index.ts delete mode 100644 @overflow/probe/component/detail/detail.component.spec.ts delete mode 100644 @overflow/probe/component/download/download.component.spec.ts delete mode 100644 @overflow/probe/component/list/list.component.spec.ts delete mode 100644 @overflow/probe/component/list/list.component.ts rename @overflow/probe/component/{detail/detail.component.html => probe-detail.component.html} (92%) rename @overflow/probe/component/{detail/detail.component.ts => probe-detail.component.ts} (60%) rename @overflow/probe/component/{download/download.component.html => probe-download.component.html} (100%) rename @overflow/probe/component/{download/download.component.ts => probe-download.component.ts} (87%) rename @overflow/probe/component/{list/list.component.html => probe-list.component.html} (76%) create mode 100644 @overflow/probe/component/probe-list.component.ts create mode 100644 @overflow/probe/component/probe-selector.component.html create mode 100644 @overflow/probe/component/probe-selector.component.ts rename @overflow/probe/component/{summary/summary.component.html => probe-summary.component.html} (100%) rename @overflow/probe/component/{summary/summary.component.ts => probe-summary.component.ts} (90%) delete mode 100644 @overflow/probe/component/selector/selector.component.html delete mode 100644 @overflow/probe/component/selector/selector.component.ts delete mode 100644 @overflow/probe/container/index.ts delete mode 100644 @overflow/probe/container/probe-detail-container.component.html delete mode 100644 @overflow/probe/container/probe-detail-container.component.ts delete mode 100644 @overflow/probe/container/probe-list-container.component.html delete mode 100644 @overflow/probe/container/probe-list-container.component.ts delete mode 100644 @overflow/probe/container/probe-selector-container.component.html delete mode 100644 @overflow/probe/container/probe-selector-container.component.ts diff --git a/@overflow/discovery/component/discovery/discovery.component.html b/@overflow/discovery/component/discovery/discovery.component.html index 064d758..a0a6da7 100644 --- a/@overflow/discovery/component/discovery/discovery.component.html +++ b/@overflow/discovery/component/discovery/discovery.component.html @@ -1,3 +1,4 @@ +
diff --git a/@overflow/discovery/component/discovery/discovery.component.ts b/@overflow/discovery/component/discovery/discovery.component.ts index 784b73d..2118120 100644 --- a/@overflow/discovery/component/discovery/discovery.component.ts +++ b/@overflow/discovery/component/discovery/discovery.component.ts @@ -12,12 +12,12 @@ import { Anim } from './animation'; }) export class DiscoveryComponent { - @Input() selectedProbe: ProbeHost; - @Output() requestDiscovery = new EventEmitter(); - @Output() requestStop = new EventEmitter(); + @Input() probeHostID; + selectedProbe: ProbeHost; + // @Output() requestDiscovery = new EventEmitter(); + // @Output() requestStop = new EventEmitter(); discoverZone: DiscoverZone; - requested: boolean; constructor( @@ -27,12 +27,12 @@ export class DiscoveryComponent { onRequestDiscovery(dz: DiscoverZone) { this.requested = true; this.discoverZone = dz; - this.requestDiscovery.emit(dz); + // this.requestDiscovery.emit(dz); } onRequestDiscoveryStop() { this.requested = false; this.discoverZone = null; - this.requestStop.emit(); + // this.requestStop.emit(); } } diff --git a/@overflow/discovery/container/discovery/discovery-container.component.html b/@overflow/discovery/container/discovery/discovery-container.component.html deleted file mode 100644 index f9bacbd..0000000 --- a/@overflow/discovery/container/discovery/discovery-container.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - \ No newline at end of file diff --git a/@overflow/discovery/container/discovery/discovery-container.component.ts b/@overflow/discovery/container/discovery/discovery-container.component.ts deleted file mode 100644 index 0858e0d..0000000 --- a/@overflow/discovery/container/discovery/discovery-container.component.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { - Component, - Input, -} from '@angular/core'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { DiscoverZone } from '@overflow/commons-typescript/model/discovery'; - -@Component({ - selector: 'of-discovery-container', - templateUrl: './discovery-container.component.html', -}) -export class DiscoveryContainerComponent { - - @Input() probeHostID; - selectedProbe: ProbeHost; - - constructor( - ) { - } - - onProbeSelect(probe: ProbeHost) { - this.selectedProbe = probe; - } - - onRequestDiscovery(dz: DiscoverZone) { - console.log(dz); - // this.discoverStore.dispatch(new DiscoverStore.DiscoverZone( - // { probeID: this.selectedProbe.probeKey, discoverZone: discoverZone })); - } - - onRequestStop() { - console.log('onRequestStop'); - } -} diff --git a/@overflow/discovery/container/index.ts b/@overflow/discovery/container/index.ts deleted file mode 100644 index 75facd2..0000000 --- a/@overflow/discovery/container/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {DiscoveryContainerComponent} from './discovery/discovery-container.component'; - -export const CONTAINER_COMPONENTS = [ - DiscoveryContainerComponent, -]; diff --git a/@overflow/discovery/discovery.module.ts b/@overflow/discovery/discovery.module.ts index 53fb4de..754abaa 100644 --- a/@overflow/discovery/discovery.module.ts +++ b/@overflow/discovery/discovery.module.ts @@ -8,7 +8,6 @@ import { DiscoveryLoggerModule } from './discovery-logger.module'; import { COMPONENTS } from './component'; import { SERVICES } from './service'; -import { CONTAINER_COMPONENTS } from './container'; import { UIModule } from '@overflow/shared/ui/ui.module'; import { ProbeModule } from '@overflow/probe/probe.module'; @@ -28,11 +27,9 @@ import { MetaModule } from '@overflow/meta/meta.module'; ], declarations: [ COMPONENTS, - CONTAINER_COMPONENTS ], exports: [ COMPONENTS, - CONTAINER_COMPONENTS ], providers: [ SERVICES, diff --git a/@overflow/probe/component/detail/detail.component.spec.ts b/@overflow/probe/component/detail/detail.component.spec.ts deleted file mode 100644 index 149b9be..0000000 --- a/@overflow/probe/component/detail/detail.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { DetailComponent } from './detail.component'; - -describe('DetailComponent', () => { - let component: DetailComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ DetailComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DetailComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/@overflow/probe/component/download/download.component.spec.ts b/@overflow/probe/component/download/download.component.spec.ts deleted file mode 100644 index ad71a7c..0000000 --- a/@overflow/probe/component/download/download.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { DownloadComponent } from './download.component'; - -describe('DownloadComponent', () => { - let component: DownloadComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ DownloadComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DownloadComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/@overflow/probe/component/index.ts b/@overflow/probe/component/index.ts index 1694027..2b7f95d 100644 --- a/@overflow/probe/component/index.ts +++ b/@overflow/probe/component/index.ts @@ -1,8 +1,8 @@ -import { ProbeDetailComponent } from './detail/detail.component'; -import { ProbeListComponent } from './list/list.component'; -import { ProbeDownloadComponent } from './download/download.component'; -import { ProbeSelectorComponent } from './selector/selector.component'; -import { ProbeSummaryComponent } from './summary/summary.component'; +import { ProbeListComponent } from './probe-list.component'; +import { ProbeDetailComponent } from './probe-detail.component'; +import { ProbeDownloadComponent } from './probe-download.component'; +import { ProbeSelectorComponent } from './probe-selector.component'; +import { ProbeSummaryComponent } from './probe-summary.component'; export const COMPONENTS = [ ProbeListComponent, diff --git a/@overflow/probe/component/list/list.component.spec.ts b/@overflow/probe/component/list/list.component.spec.ts deleted file mode 100644 index 28e4fe4..0000000 --- a/@overflow/probe/component/list/list.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ProbeListComponent } from './list.component'; - -describe('ListComponent', () => { - let component: ProbeListComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ ProbeListComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ProbeListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/@overflow/probe/component/list/list.component.ts b/@overflow/probe/component/list/list.component.ts deleted file mode 100644 index e69c493..0000000 --- a/@overflow/probe/component/list/list.component.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; -import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; - -@Component({ - selector: 'of-probe-list', - templateUrl: './list.component.html', -}) -export class ProbeListComponent { - @Output() select = new EventEmitter(); - @Input() pending: boolean; - @Input() probeHosts: ProbeHost[]; - @Input() error: any; - - constructor() { - } - - onProbeSelect(event) { - this.select.emit(event.data); - } - - getUptime(probe: Probe) { - if (!probe.connectDate) { - return 'Not Connected.'; - } - const hours = Math.abs(new Date().getTime() - probe.connectDate.getTime()); - return this.convertUptimeString(hours); - } - - convertUptimeString(hours: number) { - if (hours === 0) { - return 'Less than an hour.'; - } else { - return 'About ' + hours; - } - } -} diff --git a/@overflow/probe/component/detail/detail.component.html b/@overflow/probe/component/probe-detail.component.html similarity index 92% rename from @overflow/probe/component/detail/detail.component.html rename to @overflow/probe/component/probe-detail.component.html index 0a95311..5f3be42 100644 --- a/@overflow/probe/component/detail/detail.component.html +++ b/@overflow/probe/component/probe-detail.component.html @@ -1,5 +1,5 @@ - - + + @@ -14,7 +14,6 @@
-
@@ -54,20 +53,16 @@
- - +
-
@@ -83,7 +78,6 @@
- @@ -92,9 +86,8 @@
- +
- diff --git a/@overflow/probe/component/detail/detail.component.ts b/@overflow/probe/component/probe-detail.component.ts similarity index 60% rename from @overflow/probe/component/detail/detail.component.ts rename to @overflow/probe/component/probe-detail.component.ts index bb2e127..3748b38 100644 --- a/@overflow/probe/component/detail/detail.component.ts +++ b/@overflow/probe/component/probe-detail.component.ts @@ -1,21 +1,26 @@ -import { Component, Input, Output, EventEmitter, ViewChild, OnInit, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core'; import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { MessageService } from 'primeng/components/common/messageservice'; -import { Message } from 'primeng/primeng'; +import { Store, select } from '@ngrx/store'; +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; +import { ProbeHostService } from '../service/probe-host.service'; @Component({ selector: 'of-probe-detail', - templateUrl: './detail.component.html', - providers: [MessageService] + templateUrl: './probe-detail.component.html', }) -export class ProbeDetailComponent implements OnChanges { +export class ProbeDetailComponent implements OnInit { + + @Input() probeHostID; + pending$: Observable; + probeHost: ProbeHost; + error$: Observable; - @Input() pending: boolean; - @Input() probeHost: ProbeHost; @Output() modify = new EventEmitter(); @Output() discovery = new EventEmitter(); - connectionStatus: Message[] = []; editMode = false; displayNameErrMsg: string; @@ -23,27 +28,31 @@ export class ProbeDetailComponent implements OnChanges { displayName: string; description: string; - constructor(private messageService: MessageService) { + constructor( + private store: Store, + private probeHostService: ProbeHostService + ) { } - ngOnChanges(changes: SimpleChanges): void { - if (changes['probeHost'].currentValue) { - this.checkConnectStatus(); - } + ngOnInit() { + this.probeHostService.read(this.probeHostID) + .pipe( + tap(() => { + this.pending$ = of(true); + }), + map((probeHost: ProbeHost) => { + this.probeHost = probeHost; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }), + tap(() => { + this.pending$ = of(false); + }), + ).take(1).subscribe(); } - checkConnectStatus() { - this.connectionStatus = []; - const msg = this.probeHost.probe.connectDate ? { - severity: 'success', - summary: 'Connected', - detail: this.probeHost.probe.connectAddress - } : { - severity: 'warn', // info, warn, error - summary: 'Not Connected', - }; - this.connectionStatus.push(msg); - } onDisplayNameEditing(value: string) { const msg: string = this.checkValidDisplayName(value); @@ -72,10 +81,6 @@ export class ProbeDetailComponent implements OnChanges { this.editMode = false; } - onDiscoveryClick() { - this.discovery.emit(this.probeHost.id); - } - checkValidDisplayName(value: string): string | null { if (value.length <= 2 || value.length > 20) { return 'displayname length : 3 ~ 20'; diff --git a/@overflow/probe/component/download/download.component.html b/@overflow/probe/component/probe-download.component.html similarity index 100% rename from @overflow/probe/component/download/download.component.html rename to @overflow/probe/component/probe-download.component.html diff --git a/@overflow/probe/component/download/download.component.ts b/@overflow/probe/component/probe-download.component.ts similarity index 87% rename from @overflow/probe/component/download/download.component.ts rename to @overflow/probe/component/probe-download.component.ts index 2368cc1..0e2d714 100644 --- a/@overflow/probe/component/download/download.component.ts +++ b/@overflow/probe/component/probe-download.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'of-download', - templateUrl: './download.component.html', + templateUrl: './probe-download.component.html', }) export class ProbeDownloadComponent implements OnInit { diff --git a/@overflow/probe/component/list/list.component.html b/@overflow/probe/component/probe-list.component.html similarity index 76% rename from @overflow/probe/component/list/list.component.html rename to @overflow/probe/component/probe-list.component.html index 3db7737..a3a28c1 100644 --- a/@overflow/probe/component/list/list.component.html +++ b/@overflow/probe/component/probe-list.component.html @@ -1,9 +1,9 @@

Probes

- - + + - + Probe Name diff --git a/@overflow/probe/component/probe-list.component.ts b/@overflow/probe/component/probe-list.component.ts new file mode 100644 index 0000000..1edf27f --- /dev/null +++ b/@overflow/probe/component/probe-list.component.ts @@ -0,0 +1,70 @@ +import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { Store, select } from '@ngrx/store'; +import { Observable, of } from 'rxjs'; +import { ProbeHostService } from '../service/probe-host.service'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; + +@Component({ + selector: 'of-probe-list', + templateUrl: './probe-list.component.html', +}) +export class ProbeListComponent implements OnInit { + + probeHosts$: Observable; + pending$: Observable; + error$: Observable; + @Output() select = new EventEmitter(); + + constructor( + private store: Store, + private probeHostService: ProbeHostService, + ) { + } + + ngOnInit(): void { + this.store.pipe( + tap(() => { + this.pending$ = of(true); + }), + select(AuthContainerSelector.selectDomainMember), + exhaustMap((domainMember: DomainMember) => + this.probeHostService.readAllByDomainID(domainMember.domain.id) + .pipe( + map((probeHosts: ProbeHost[]) => { + this.probeHosts$ = of(probeHosts); + }), + catchError(error => { + this.error$ = of(error); + return of(); + }) + ) + ), + tap(() => { + this.pending$ = of(false); + }), + ).take(1).subscribe(); + } + + onProbeSelect(event) { + this.select.emit(event.data); + } + + getUptime(probe: Probe) { + if (!probe.connectDate) { + return 'Not Connected.'; + } + const hours = Math.abs(new Date().getTime() - probe.connectDate.getTime()); + return this.convertUptimeString(hours); + } + + convertUptimeString(hours: number) { + if (hours === 0) { + return 'Less than an hour.'; + } else { + return 'About ' + hours; + } + } +} diff --git a/@overflow/probe/component/probe-selector.component.html b/@overflow/probe/component/probe-selector.component.html new file mode 100644 index 0000000..4bfd632 --- /dev/null +++ b/@overflow/probe/component/probe-selector.component.html @@ -0,0 +1,4 @@ +
+ +
\ No newline at end of file diff --git a/@overflow/probe/component/probe-selector.component.ts b/@overflow/probe/component/probe-selector.component.ts new file mode 100644 index 0000000..1df5647 --- /dev/null +++ b/@overflow/probe/component/probe-selector.component.ts @@ -0,0 +1,85 @@ +import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges, OnInit } from '@angular/core'; +import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; +import { Store, select } from '@ngrx/store'; +import { Observable, of, Subscription } from 'rxjs'; +import { catchError, exhaustMap, map, tap } from 'rxjs/operators'; +import { AuthContainerSelector } from '@overflow/shared/auth/store'; +import { DomainMember } from '@overflow/commons-typescript/model/domain'; +import { ProbeHostService } from '../service/probe-host.service'; + + +@Component({ + selector: 'of-probe-selector', + templateUrl: './probe-selector.component.html', +}) +export class ProbeSelectorComponent implements OnInit, OnChanges { + + @Input() probeHostID: number; + probeHosts: ProbeHost[]; + pending$: Observable; + error$: Observable; + @Output() select = new EventEmitter(); + + options: Probe[]; + selected: Probe; + + constructor( + private store: Store, + private probeHostService: ProbeHostService, + + ) { + } + + ngOnInit() { + this.store.pipe( + tap(() => { + this.pending$ = of(true); + }), + select(AuthContainerSelector.selectDomainMember), + exhaustMap((domainMember: DomainMember) => + this.probeHostService.readAllByDomainID(domainMember.domain.id) + .pipe( + map((probeHosts: ProbeHost[]) => { + this.probeHosts = probeHosts; + }), + catchError(error => { + this.error$ = of(error); + return of(); + }) + ) + ), + tap(() => { + this.generate(); + this.pending$ = of(false); + }), + ).take(1).subscribe(); + } + + ngOnChanges(changes: SimpleChanges): void { + + } + + generate() { + this.checkPreselected(); + this.options = []; + for (const ph of this.probeHosts) { + this.options.push(ph.probe); + } + } + + checkPreselected() { + if (!this.probeHosts || !this.probeHostID) { + return; + } + setTimeout(() => { + const preselected = this.probeHosts.find(probeHost => probeHost.id === Number(this.probeHostID)); + this.select.emit(preselected); + }); + } + + onSelect() { + const optionselected = this.probeHosts.find(probeHost => probeHost.probe.id === this.selected.id); + this.select.emit(optionselected); + } + +} diff --git a/@overflow/probe/component/summary/summary.component.html b/@overflow/probe/component/probe-summary.component.html similarity index 100% rename from @overflow/probe/component/summary/summary.component.html rename to @overflow/probe/component/probe-summary.component.html diff --git a/@overflow/probe/component/summary/summary.component.ts b/@overflow/probe/component/probe-summary.component.ts similarity index 90% rename from @overflow/probe/component/summary/summary.component.ts rename to @overflow/probe/component/probe-summary.component.ts index 9685846..0c3e3bd 100644 --- a/@overflow/probe/component/summary/summary.component.ts +++ b/@overflow/probe/component/probe-summary.component.ts @@ -3,7 +3,7 @@ import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe'; @Component({ selector: 'of-probe-summary', - templateUrl: './summary.component.html', + templateUrl: './probe-summary.component.html', }) export class ProbeSummaryComponent implements OnChanges { diff --git a/@overflow/probe/component/selector/selector.component.html b/@overflow/probe/component/selector/selector.component.html deleted file mode 100644 index a6072a3..0000000 --- a/@overflow/probe/component/selector/selector.component.html +++ /dev/null @@ -1,4 +0,0 @@ -
- -
\ No newline at end of file diff --git a/@overflow/probe/component/selector/selector.component.ts b/@overflow/probe/component/selector/selector.component.ts deleted file mode 100644 index ae91577..0000000 --- a/@overflow/probe/component/selector/selector.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; -import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; - -@Component({ - selector: 'of-probe-selector', - templateUrl: './selector.component.html', -}) -export class ProbeSelectorComponent implements OnChanges { - - @Output() select = new EventEmitter(); - @Input() probeHosts: ProbeHost[]; - @Input() probeHostID: number; - - options: Probe[]; - selected: Probe; - - constructor() { - } - - ngOnChanges(changes: SimpleChanges): void { - this.checkPreselected(); - this.options = []; - for (const ph of this.probeHosts) { - this.options.push(ph.probe); - } - } - - checkPreselected() { - if (!this.probeHosts || !this.probeHostID) { - return; - } - setTimeout(() => { - const preselected = this.probeHosts.find(probeHost => probeHost.id === Number(this.probeHostID)); - this.select.emit(preselected); - }); - } - - onSelect() { - const optionselected = this.probeHosts.find(probeHost => probeHost.probe.id === this.selected.id); - this.select.emit(optionselected); - } - -} diff --git a/@overflow/probe/container/index.ts b/@overflow/probe/container/index.ts deleted file mode 100644 index bbe719c..0000000 --- a/@overflow/probe/container/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ProbeListContainerComponent } from '../container/probe-list-container.component'; -import { ProbeDetailContainerComponent } from '../container/probe-detail-container.component'; -import { ProbeSelectorContainerComponent } from './probe-selector-container.component'; - -export const CONTAINER_COMPONENTS = [ - ProbeListContainerComponent, - ProbeDetailContainerComponent, - ProbeSelectorContainerComponent -]; diff --git a/@overflow/probe/container/probe-detail-container.component.html b/@overflow/probe/container/probe-detail-container.component.html deleted file mode 100644 index 664b2df..0000000 --- a/@overflow/probe/container/probe-detail-container.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/@overflow/probe/container/probe-detail-container.component.ts b/@overflow/probe/container/probe-detail-container.component.ts deleted file mode 100644 index 843fa58..0000000 --- a/@overflow/probe/container/probe-detail-container.component.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core'; -import { Observable } from 'rxjs'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { Store, select } from '@ngrx/store'; -import * as ProbeStore from '../store/entity/probe'; -import { ProbeDetailContainerSelector } from '../store'; -import { ActivatedRoute } from '@angular/router'; - -@Component({ - selector: 'of-probe-detail-container', - templateUrl: './probe-detail-container.component.html', -}) -export class ProbeDetailContainerComponent implements OnInit, OnChanges { - - @Input() probeHostID: number; - @Output() discovery = new EventEmitter(); - probeHost$: Observable; - pending$: Observable; - error$: Observable; - - constructor( - private store: Store, - private route: ActivatedRoute, - ) { - } - - ngOnInit() { - this.pending$ = this.store.pipe(select(ProbeDetailContainerSelector.selectPending)); - this.error$ = this.store.pipe(select(ProbeDetailContainerSelector.selectError)); - this.probeHost$ = this.store.pipe(select(ProbeDetailContainerSelector.selectOne(this.probeHostID))); - } - - ngOnChanges(changes: SimpleChanges): void { - this.store.dispatch(new ProbeStore.Read(this.probeHostID)); - } - - onModify(probeHost: ProbeHost) { - this.store.dispatch(new ProbeStore.Modify(probeHost.probe)); - } - - onDiscovery(probeHostID: number) { - this.discovery.emit(probeHostID); - } -} diff --git a/@overflow/probe/container/probe-list-container.component.html b/@overflow/probe/container/probe-list-container.component.html deleted file mode 100644 index 802589c..0000000 --- a/@overflow/probe/container/probe-list-container.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/@overflow/probe/container/probe-list-container.component.ts b/@overflow/probe/container/probe-list-container.component.ts deleted file mode 100644 index eb53923..0000000 --- a/@overflow/probe/container/probe-list-container.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Component, EventEmitter, Output, OnInit } from '@angular/core'; -import { ProbeHost } from '@overflow/commons-typescript/model/probe'; -import { Observable } from 'rxjs'; -import { Store, select } from '@ngrx/store'; -import * as ProbeEntityStore from '../store/entity/probe'; -import { ProbeListContainerSelector } from '../store'; -import { AuthContainerSelector } from '../../shared/auth/store'; -import { DomainMember } from '@overflow/commons-typescript/model/domain'; - -@Component({ - selector: 'of-probe-list-container', - templateUrl: './probe-list-container.component.html', -}) -export class ProbeListContainerComponent implements OnInit { - - probeHosts$: Observable; - pending$: Observable; - error$: Observable; - @Output() select = new EventEmitter(); - - constructor( - private store: Store, - ) { - } - - ngOnInit() { - this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll)); - this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending)); - this.error$ = this.store.pipe(select(ProbeListContainerSelector.selectError)); - - this.store.select(AuthContainerSelector.selectDomainMember).subscribe( - (domainMember: DomainMember) => { - this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id)); - } - ); - } - - onSelect(probeHost: ProbeHost) { - this.select.emit(probeHost); - } - -} diff --git a/@overflow/probe/container/probe-selector-container.component.html b/@overflow/probe/container/probe-selector-container.component.html deleted file mode 100644 index 0e7e571..0000000 --- a/@overflow/probe/container/probe-selector-container.component.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/@overflow/probe/container/probe-selector-container.component.ts b/@overflow/probe/container/probe-selector-container.component.ts deleted file mode 100644 index 4a8fcab..0000000 --- a/@overflow/probe/container/probe-selector-container.component.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Component, EventEmitter, Output, OnInit, Input } from '@angular/core'; -import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; -import { Observable } from 'rxjs'; -import { Store, select } from '@ngrx/store'; -import * as ProbeEntityStore from '@overflow/probe/store/entity/probe'; -import { ProbeSelectorContainerSelector } from '@overflow/probe/store'; -import { AuthContainerSelector } from '@overflow/shared/auth/store'; -import { DomainMember } from '@overflow/commons-typescript/model/domain'; - -@Component({ - selector: 'of-probe-selector-container', - templateUrl: './probe-selector-container.component.html', -}) -export class ProbeSelectorContainerComponent implements OnInit { - - probeHosts$: Observable; - @Output() select = new EventEmitter(); - @Input() probeHostID: number; - - constructor( - private store: Store, - ) { - } - - ngOnInit() { - this.probeHosts$ = this.store.pipe(select(ProbeSelectorContainerSelector.selectAll)); - this.store.select(AuthContainerSelector.selectDomainMember).subscribe( - (domainMember: DomainMember) => { - this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id)); - } - ); - } -} diff --git a/@overflow/probe/probe.module.ts b/@overflow/probe/probe.module.ts index 54db7c0..cf91ec6 100644 --- a/@overflow/probe/probe.module.ts +++ b/@overflow/probe/probe.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { COMPONENTS } from './component'; -import { CONTAINER_COMPONENTS } from './container'; import { ProbeStoreModule } from './probe-store.module'; import { SERVICES } from './service'; import { FormsModule } from '@angular/forms'; @@ -18,11 +17,9 @@ import { UIModule } from '@overflow/shared/ui/ui.module'; MetaModule, ], declarations: [ - CONTAINER_COMPONENTS, COMPONENTS, ], exports: [ - CONTAINER_COMPONENTS, COMPONENTS, ], providers: [ diff --git a/src/app/pages/discovery/discovery-page.component.html b/src/app/pages/discovery/discovery-page.component.html index f7fa9b0..b6cc073 100644 --- a/src/app/pages/discovery/discovery-page.component.html +++ b/src/app/pages/discovery/discovery-page.component.html @@ -2,9 +2,8 @@
- - +
- + \ No newline at end of file diff --git a/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts b/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts index 5babd78..b6c06f7 100644 --- a/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts +++ b/src/app/pages/probes/noauth-probe/noauth-probe-page-routing.module.ts @@ -1,8 +1,6 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { NoAuthProbePageComponent } from './noauth-probe-page.component'; -import { ProbeListComponent } from '@overflow/probe/component/list/list.component'; -import { ProbeDownloadComponent } from '@overflow/probe/component/download/download.component'; const routes: Routes = [ { diff --git a/src/app/pages/probes/probe/probe-page.component.html b/src/app/pages/probes/probe/probe-page.component.html index 435ef72..9e08bd8 100644 --- a/src/app/pages/probes/probe/probe-page.component.html +++ b/src/app/pages/probes/probe/probe-page.component.html @@ -1,10 +1,7 @@
- +
- + \ No newline at end of file