From 232d9446403cd8110ebb23292d2c24a4bf502f07 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 30 May 2018 14:24:19 +0900 Subject: [PATCH] test --- .../message/error-message.component.html | 1 + .../message/error-message.component.ts | 34 +++++++++++++++++++ .../component/message/message.component.html | 2 +- .../component/message/message.component.ts | 20 ++--------- .../component/message/message.module.ts | 7 ++-- .../noauth-probe-list.component.html | 7 ++-- .../component/noauth-probe-list.component.ts | 3 -- ...noauth-probe-list-container.component.html | 2 -- .../noauth-probe-list-container.component.ts | 21 +++--------- @overflow/noauth-probe/noauth-probe.module.ts | 4 +++ .../component/detail/detail.component.html | 5 ++- .../probe/component/list/list.component.html | 2 +- .../probe/component/list/list.component.ts | 2 +- 13 files changed, 59 insertions(+), 51 deletions(-) create mode 100644 @overflow/commons/component/message/error-message.component.html create mode 100644 @overflow/commons/component/message/error-message.component.ts diff --git a/@overflow/commons/component/message/error-message.component.html b/@overflow/commons/component/message/error-message.component.html new file mode 100644 index 0000000..45f9662 --- /dev/null +++ b/@overflow/commons/component/message/error-message.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/@overflow/commons/component/message/error-message.component.ts b/@overflow/commons/component/message/error-message.component.ts new file mode 100644 index 0000000..90878eb --- /dev/null +++ b/@overflow/commons/component/message/error-message.component.ts @@ -0,0 +1,34 @@ +import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { Message } from 'primeng/primeng'; + +@Component({ + selector: 'of-error-message', + templateUrl: './error-message.component.html', +}) +export class ErrorMessageComponent implements OnInit, OnChanges { + + @Input() error: any; + @Input() closeAfter: number; + @Input() closable: boolean; + msgs: Message[] = []; + + constructor( + ) { + } + + ngOnInit() { + } + + ngOnChanges(changes: SimpleChanges) { + if (changes['error'].currentValue) { + const detail = ' (' + this.error.response.code + ')'; + this.msgs = []; + this.msgs.push({ severity: 'error', summary: 'Sorry. An Error has occurred.', detail: detail }); + if (this.closeAfter) { + setTimeout(() => { + this.msgs = []; + }, this.closeAfter * 1000); + } + } + } +} diff --git a/@overflow/commons/component/message/message.component.html b/@overflow/commons/component/message/message.component.html index 45f9662..9fa5f65 100644 --- a/@overflow/commons/component/message/message.component.html +++ b/@overflow/commons/component/message/message.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/@overflow/commons/component/message/message.component.ts b/@overflow/commons/component/message/message.component.ts index 67def98..457ca36 100644 --- a/@overflow/commons/component/message/message.component.ts +++ b/@overflow/commons/component/message/message.component.ts @@ -5,30 +5,14 @@ import { Message } from 'primeng/primeng'; selector: 'of-message', templateUrl: './message.component.html', }) -export class MessageComponent implements OnInit, OnChanges { +export class MessageComponent { - @Input() error: any; + @Input() message: Message; @Input() closeAfter: number; @Input() closable: boolean; - msgs: Message[] = []; constructor( ) { } - ngOnInit() { - } - - ngOnChanges(changes: SimpleChanges) { - if (changes['error'].currentValue) { - const detail = ' (' + this.error.response.code + ')'; - this.msgs = []; - this.msgs.push({ severity: 'error', summary: 'Sorry. An Error has occurred.', detail: detail }); - if (this.closeAfter) { - setTimeout(() => { - this.msgs = []; - }, this.closeAfter * 1000); - } - } - } } diff --git a/@overflow/commons/component/message/message.module.ts b/@overflow/commons/component/message/message.module.ts index 2677049..5753e3d 100644 --- a/@overflow/commons/component/message/message.module.ts +++ b/@overflow/commons/component/message/message.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { PrimeNGModules } from '@overflow/commons/prime-ng/prime-ng.module'; import { MessageComponent } from './message.component'; +import { ErrorMessageComponent } from './error-message.component'; @NgModule({ imports: [ @@ -9,10 +10,12 @@ import { MessageComponent } from './message.component'; PrimeNGModules ], declarations: [ - MessageComponent + MessageComponent, + ErrorMessageComponent ], exports: [ - MessageComponent + MessageComponent, + ErrorMessageComponent ] }) export class MessageModule { } diff --git a/@overflow/noauth-probe/component/noauth-probe-list.component.html b/@overflow/noauth-probe/component/noauth-probe-list.component.html index b10e5ea..b01b0a1 100644 --- a/@overflow/noauth-probe/component/noauth-probe-list.component.html +++ b/@overflow/noauth-probe/component/noauth-probe-list.component.html @@ -1,6 +1,5 @@ - - - + +

Unauthorized

@@ -74,5 +73,5 @@ - +
\ No newline at end of file diff --git a/@overflow/noauth-probe/component/noauth-probe-list.component.ts b/@overflow/noauth-probe/component/noauth-probe-list.component.ts index 00a4b15..0a43d27 100644 --- a/@overflow/noauth-probe/component/noauth-probe-list.component.ts +++ b/@overflow/noauth-probe/component/noauth-probe-list.component.ts @@ -14,7 +14,6 @@ export class NoAuthProbeListComponent { @Output() accept = new EventEmitter(); @Output() deny = new EventEmitter(); - msgs: Message[]; constructor( private confirmationService: ConfirmationService, @@ -22,8 +21,6 @@ export class NoAuthProbeListComponent { } onAcceptOrDeny(isAccept: boolean, selected: NoAuthProbe) { - console.log(selected); - this.msgs = []; const title = isAccept ? 'Are you sure to accept this Probe?' : 'Are you sure to deny this Probe'; const message = isAccept ? diff --git a/@overflow/noauth-probe/container/noauth-probe-list-container.component.html b/@overflow/noauth-probe/container/noauth-probe-list-container.component.html index 814ba74..2cfccb0 100644 --- a/@overflow/noauth-probe/container/noauth-probe-list-container.component.html +++ b/@overflow/noauth-probe/container/noauth-probe-list-container.component.html @@ -1,5 +1,3 @@ - - ; pending$: Observable; - errorSubscription: Subscription; + error$: Observable; constructor( private store: Store, - private messageService: MessageService, ) { } ngOnInit() { this.pending$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectPending)); - this.errorSubscription = this.store.pipe(select(NoAuthProbeListContainerSelector.selectError)).subscribe( - (e: any) => { - this.messageService.add({severity: 'error', summary: 'Service Message', detail: 'Via MessageService'}); - } - ); + this.error$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectError)); this.noauthProbes$ = this.store.pipe(select(NoAuthProbeListContainerSelector.selectAll)).map((_noauthProbes: NoAuthProbe[]) => { if (null === _noauthProbes) { return null; @@ -53,10 +46,6 @@ export class NoAuthProbeListContainerComponent implements OnInit, OnDestroy { ); } - ngOnDestroy(): void { - this.errorSubscription.unsubscribe(); - } - accept(noAuthProbe: NoAuthProbe) { this.store.dispatch(new NoAuthProbeEntityStore.Accept({aa: noAuthProbe.id} as any)); } diff --git a/@overflow/noauth-probe/noauth-probe.module.ts b/@overflow/noauth-probe/noauth-probe.module.ts index 2cf8f3d..8869d6c 100644 --- a/@overflow/noauth-probe/noauth-probe.module.ts +++ b/@overflow/noauth-probe/noauth-probe.module.ts @@ -9,6 +9,8 @@ import { COMPONENTS } from './component'; import { CONTAINER_COMPONENTS } from './container'; import { SERVICES } from './service'; +import { MessageModule } from '@overflow/commons/component/message/message.module'; +import { BlockProgressbarModule } from '@overflow/commons/component/block-progressbar/block-progressbar.module'; @NgModule({ imports: [ @@ -17,6 +19,8 @@ import { SERVICES } from './service'; NoAuthProbeRPCModule, NoAuthProbeLoggerModule, PrimeNGModules, + MessageModule, + BlockProgressbarModule, ], declarations: [ COMPONENTS, diff --git a/@overflow/probe/component/detail/detail.component.html b/@overflow/probe/component/detail/detail.component.html index a2abeeb..610e0fb 100644 --- a/@overflow/probe/component/detail/detail.component.html +++ b/@overflow/probe/component/detail/detail.component.html @@ -1,6 +1,5 @@ - - - + + diff --git a/@overflow/probe/component/list/list.component.html b/@overflow/probe/component/list/list.component.html index c46b612..3db7737 100644 --- a/@overflow/probe/component/list/list.component.html +++ b/@overflow/probe/component/list/list.component.html @@ -1,5 +1,5 @@

Probes

- + diff --git a/@overflow/probe/component/list/list.component.ts b/@overflow/probe/component/list/list.component.ts index e96d262..e69c493 100644 --- a/@overflow/probe/component/list/list.component.ts +++ b/@overflow/probe/component/list/list.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, AfterViewInit, AfterContentInit, ViewChild, OnDestroy, Output, EventEmitter, Input } from '@angular/core'; +import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe'; @Component({