-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: Added notifications components and services
- Loading branch information
Showing
11 changed files
with
192 additions
and
2 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
frontend/projects/shared-call-components/src/lib/components/dialog/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,6 @@ | ||
<h2 mat-dialog-title>Delete file</h2> | ||
<mat-dialog-content> Would you like to delete? </mat-dialog-content> | ||
<mat-dialog-actions> | ||
<button mat-button mat-dialog-close>No</button> | ||
<button mat-button mat-dialog-close cdkFocusInitial>Ok</button> | ||
</mat-dialog-actions> |
3 changes: 3 additions & 0 deletions
3
frontend/projects/shared-call-components/src/lib/components/dialog/dialog.component.scss
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,3 @@ | ||
button { | ||
margin-right: 8px; | ||
} |
23 changes: 23 additions & 0 deletions
23
frontend/projects/shared-call-components/src/lib/components/dialog/dialog.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DialogComponent } from './dialog.component'; | ||
|
||
describe('DialogComponent', () => { | ||
let component: DialogComponent; | ||
let fixture: ComponentFixture<DialogComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [DialogComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
frontend/projects/shared-call-components/src/lib/components/dialog/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,24 @@ | ||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatDialogActions, MatDialogContent, MatDialogRef } from '@angular/material/dialog'; | ||
|
||
@Component({ | ||
selector: 'ov-dialog', | ||
standalone: true, | ||
imports: [MatButtonModule, MatDialogActions, MatDialogContent], | ||
template: `<h2 mat-dialog-title>Delete file</h2> | ||
<mat-dialog-content> Would you like to delete? </mat-dialog-content> | ||
<mat-dialog-actions> | ||
<button mat-button mat-dialog-close (click)="close()">No</button> | ||
<button mat-button mat-dialog-close cdkFocusInitial (click)="close()">Ok</button> | ||
</mat-dialog-actions>`, | ||
styleUrl: './dialog.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class DialogComponent { | ||
readonly dialogRef = inject(MatDialogRef<DialogComponent>); | ||
|
||
close(): void { | ||
this.dialogRef.close(); | ||
} | ||
} |
Empty file.
23 changes: 23 additions & 0 deletions
23
...tend/projects/shared-call-components/src/lib/components/spinner/spinner.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SpinnerComponent } from './spinner.component'; | ||
|
||
describe('SpinnerComponent', () => { | ||
let component: SpinnerComponent; | ||
let fixture: ComponentFixture<SpinnerComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SpinnerComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SpinnerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
frontend/projects/shared-call-components/src/lib/components/spinner/spinner.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,11 @@ | ||
import { Component } from '@angular/core'; | ||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; | ||
|
||
@Component({ | ||
selector: 'ov-spinner', | ||
standalone: true, | ||
imports: [MatProgressSpinnerModule], | ||
template: `<mat-spinner></mat-spinner>`, | ||
styleUrl: './spinner.component.scss' | ||
}) | ||
export class SpinnerComponent {} |
1 change: 1 addition & 0 deletions
1
frontend/projects/shared-call-components/src/lib/services/index.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './context/context.service'; | ||
export * from './http/http.service'; | ||
export * from './global-preferences/global-preferences.service'; | ||
export * from './notification/notification.service'; |
16 changes: 16 additions & 0 deletions
16
...rojects/shared-call-components/src/lib/services/notification/notification.service.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { NotificationService } from './notification.service'; | ||
|
||
describe('NotificationService', () => { | ||
let service: NotificationService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(NotificationService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
75 changes: 75 additions & 0 deletions
75
...end/projects/shared-call-components/src/lib/services/notification/notification.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,75 @@ | ||
import { Overlay } from '@angular/cdk/overlay'; | ||
import { ComponentPortal } from '@angular/cdk/portal'; | ||
import { Injectable } from '@angular/core'; | ||
import { MatDialog } from '@angular/material/dialog'; | ||
import { MatSnackBar } from '@angular/material/snack-bar'; | ||
import { SpinnerComponent } from '../../components/spinner/spinner.component'; | ||
import { DialogComponent } from '../../components/dialog/dialog.component'; | ||
|
||
export interface DialogOptions { | ||
title?: string; | ||
message: string; | ||
confirmText?: string; | ||
cancelText?: string; | ||
} | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class NotificationService { | ||
private spinnerRef: any; // Referencia al spinner | ||
|
||
constructor( | ||
private snackBar: MatSnackBar, | ||
private dialog: MatDialog, | ||
private overlay: Overlay | ||
) {} | ||
|
||
showSpinner() { | ||
if (!this.spinnerRef) { | ||
const overlayRef = this.overlay.create({ | ||
positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(), | ||
panelClass: 'spinner-overlay' | ||
}); | ||
|
||
this.spinnerRef = overlayRef.attach(new ComponentPortal(SpinnerComponent)); | ||
} | ||
} | ||
hideSpinner(): void { | ||
if (this.spinnerRef) { | ||
this.spinnerRef.detach(); | ||
this.spinnerRef = null; | ||
} | ||
} | ||
|
||
// Método para mostrar un snackbar | ||
showSnackbar(message: string, duration: number = 3000): void { | ||
this.snackBar.open(message, 'Cerrar', { | ||
duration, | ||
verticalPosition: 'top', | ||
horizontalPosition: 'right', | ||
panelClass: 'custom-snackbar' // Añade tus estilos para el snackbar | ||
}); | ||
} | ||
|
||
// Método para mostrar un diálogo | ||
showDialog(options: DialogOptions): void { | ||
this.dialog.open(DialogComponent, { | ||
data: options, // Pasa las opciones al componente del diálogo | ||
width: '400px', | ||
disableClose: true // Evita que se cierre haciendo clic fuera del diálogo | ||
}); | ||
} | ||
|
||
// Método para mostrar una alerta | ||
showAlert(message: string): void { | ||
// this.dialog.open(AlertDialogComponent, { | ||
// data: { | ||
// message, | ||
// confirmText: 'OK' | ||
// }, | ||
// width: '300px', | ||
// disableClose: true | ||
// }); | ||
} | ||
} |
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