-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
951a55f
commit cea4f02
Showing
7 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
src/app/components/table/table-inspect-message-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,9 @@ | ||
<h2 mat-dialog-title>{{ label }}</h2> | ||
|
||
<mat-dialog-content> | ||
<mat-card>{{ message }}</mat-card> | ||
</mat-dialog-content> | ||
|
||
<mat-dialog-actions align="end"> | ||
<button mat-flat-button (click)="onNoClick()" color="primary">Close</button> | ||
</mat-dialog-actions> |
53 changes: 53 additions & 0 deletions
53
src/app/components/table/table-inspect-message-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,53 @@ | ||
import { Clipboard } from '@angular/cdk/clipboard'; | ||
import { Component, Inject, inject } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; | ||
import { IconsService } from '@services/icons.service'; | ||
import { NotificationService } from '@services/notification.service'; | ||
|
||
export interface TableInspectMessageDialogData { | ||
label: string; | ||
message: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-inspect-message-dialog', | ||
templateUrl: 'table-inspect-message-dialog.component.html', | ||
standalone: true, | ||
imports: [ | ||
MatCardModule, | ||
MatButtonModule, | ||
MatDialogModule, | ||
], | ||
providers: [ | ||
NotificationService, | ||
] | ||
}) | ||
export class TableInspectMessageDialogComponent { | ||
get label() { | ||
return this.data.label; | ||
} | ||
|
||
get message() { | ||
return this.data.message; | ||
} | ||
|
||
constructor( | ||
public dialogRef: MatDialogRef<TableInspectMessageDialogComponent>, | ||
@Inject(MAT_DIALOG_DATA) private data: TableInspectMessageDialogData | ||
) {} | ||
|
||
private readonly iconsService = inject(IconsService); | ||
private readonly clipboard = inject(Clipboard); | ||
private readonly notificationService = inject(NotificationService); | ||
|
||
copy() { | ||
this.clipboard.copy(this.message); | ||
this.notificationService.success('Message copied'); | ||
} | ||
|
||
onNoClick(): void { | ||
this.dialogRef.close(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/app/components/table/table-inspect-message.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,13 @@ | ||
@if (message) { | ||
<span>{{croppedMessage}}...</span> | ||
<button mat-icon-button (click)="copy()"> | ||
<mat-icon [fontIcon]="getIcon('copy')" /> | ||
</button> | ||
@if (displayEye) { | ||
<button mat-icon-button (click)="onView()"> | ||
<mat-icon [fontIcon]="getIcon('view')" /> | ||
</button> | ||
} | ||
} @else { | ||
<span>-</span> | ||
} |
81 changes: 81 additions & 0 deletions
81
src/app/components/table/table-inspect-message.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,81 @@ | ||
import { Clipboard } from '@angular/cdk/clipboard'; | ||
import { Component, Input, inject } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatDialog, MatDialogModule } from '@angular/material/dialog'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { IconsService } from '@services/icons.service'; | ||
import { NotificationService } from '@services/notification.service'; | ||
import { TableInspectMessageDialogComponent, TableInspectMessageDialogData } from './table-inspect-message-dialog.component'; | ||
|
||
@Component({ | ||
selector: 'app-table-inspect-message', | ||
templateUrl: 'table-inspect-message.component.html', | ||
standalone: true, | ||
imports: [ | ||
MatDialogModule, | ||
MatButtonModule, | ||
MatIconModule, | ||
], | ||
providers: [ | ||
NotificationService | ||
] | ||
}) | ||
export class TableInspectMessageComponent { | ||
@Input({ required: true }) label: string; | ||
|
||
@Input({ required: true }) set message(entry: string | undefined) { | ||
|
||
if (entry && entry !== '') { | ||
if (entry.length > 5) { | ||
this._croppedMessage = entry.substring(0, 30); | ||
this._message = entry; | ||
this._displayEye = true; | ||
} else { | ||
this._croppedMessage = entry; | ||
} | ||
} | ||
} | ||
|
||
private readonly iconsService = inject(IconsService); | ||
private readonly dialog = inject(MatDialog); | ||
private readonly clipboard = inject(Clipboard); | ||
private readonly notificationService = inject(NotificationService); | ||
|
||
private _croppedMessage: string | undefined; | ||
private _message: string |undefined; | ||
private _displayEye = false; | ||
|
||
get message() { | ||
return this._message; | ||
} | ||
|
||
get croppedMessage() { | ||
return this._croppedMessage; | ||
} | ||
|
||
get displayEye() { | ||
return this._displayEye; | ||
} | ||
|
||
getIcon(name: string) { | ||
return this.iconsService.getIcon(name); | ||
} | ||
|
||
onView() { | ||
if (this._message) { | ||
this.dialog.open<TableInspectMessageDialogComponent, TableInspectMessageDialogData>(TableInspectMessageDialogComponent, { | ||
data: { | ||
label: this.label, | ||
message: this._message | ||
} | ||
}); | ||
} | ||
} | ||
|
||
copy() { | ||
if (this._message) { | ||
this.clipboard.copy(this._message); | ||
this.notificationService.success('Message copied'); | ||
} | ||
} | ||
} |
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