-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* including global dialog service, fixing unit test, and including shared module to core module * removing extra space * Update src/app/modules/core/components/global-dialog/global-dialog.component.ts Co-authored-by: Raul Jordan <[email protected]>
- Loading branch information
1 parent
7a21b87
commit 3a2d89b
Showing
10 changed files
with
124 additions
and
22 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/app/modules/core/components/global-dialog/global-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<h1 mat-dialog-title>{{title}}</h1> | ||
<div mat-dialog-content> | ||
<p> | ||
{{content}} | ||
</p> | ||
<div *ngIf="alert" class="rounded-lg bg-indigo-700 leading-normal p-5 overflow-auto"> | ||
<p *ngIf="!isInstanceOfError()"> | ||
{{alert.message}} | ||
</p> | ||
<pre *ngIf="isInstanceOfError()"> | ||
{{alert.message | json}} | ||
</pre> | ||
</div> | ||
</div> | ||
<mat-dialog-actions align="end"> | ||
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Close</button> | ||
</mat-dialog-actions> |
33 changes: 33 additions & 0 deletions
33
src/app/modules/core/components/global-dialog/global-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { Component, Inject, OnInit } from '@angular/core'; | ||
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { DialogConfig, DialogConfigMessage, DialogContentAlert } from './model/interfaces'; | ||
|
||
@Component({ | ||
selector: 'app-global-dialog', | ||
templateUrl: 'global-dialog.component.html' | ||
}) | ||
export class GlobalDialogComponent implements OnInit { | ||
constructor(@Inject(MAT_DIALOG_DATA) public data: DialogConfigMessage) { } | ||
|
||
title = ''; | ||
content = ''; | ||
|
||
alert: DialogContentAlert | null | undefined = null; | ||
|
||
ngOnInit(): void { | ||
const dialogConfig: DialogConfig = this.data.payload; | ||
this.title = dialogConfig.title; | ||
this.content = dialogConfig.content; | ||
this.alert = dialogConfig.alert; | ||
|
||
console.log(dialogConfig.alert); | ||
} | ||
|
||
isInstanceOfError(): boolean { | ||
if (this.alert){ | ||
return this.alert.message instanceof Error || this.alert.message instanceof HttpErrorResponse; | ||
} | ||
return false; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/app/modules/core/components/global-dialog/global-dialog.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { GlobalDialogComponent } from './global-dialog.component'; | ||
import { DialogConfigMessage } from './model/interfaces'; | ||
@Injectable() | ||
export class GlobalDialogService { | ||
|
||
constructor(public dialog: MatDialog) { } | ||
|
||
open(message: DialogConfigMessage): void { | ||
this.dialog.open(GlobalDialogComponent, { | ||
data: message | ||
}); | ||
} | ||
|
||
close(): void { | ||
this.dialog.closeAll(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/app/modules/core/components/global-dialog/model/interfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { DialogContentAlertType } from './types'; | ||
|
||
export interface DialogConfigMessage { | ||
payload: DialogConfig; | ||
} | ||
|
||
export interface DialogConfig { | ||
title: string; | ||
content: string; | ||
alert?: DialogContentAlert; | ||
} | ||
|
||
export interface DialogContentAlert { | ||
type: DialogContentAlertType; | ||
message: string | Error | HttpErrorResponse; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum DialogContentAlertType { | ||
ERROR = 'ERROR', | ||
WARNING = 'WARNING', | ||
INFO = 'INFO' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...pp/modules/dashboard/components/latest-gist-feature/latest-gist-feature.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters