-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implementación de la pantalla de carga.
- Loading branch information
Showing
8 changed files
with
91 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<router-outlet/> | ||
|
||
<app-spinner/> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.spinner-content { | ||
top: 0; | ||
min-width: 100%; | ||
min-height: 100%; | ||
left: 0; | ||
z-index: 1073; | ||
} |
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,7 @@ | ||
@if (show()) { | ||
<div class="spinner-content align-items-center d-flex justify-content-center position-fixed"> | ||
<p-progress-spinner ariaLabel="loading" | ||
strokeWidth="4"/> | ||
</div> | ||
<div class="modal-backdrop fade show"></div> | ||
} |
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,20 @@ | ||
import {Component, computed} from '@angular/core'; | ||
import {ProgressSpinner} from 'primeng/progressspinner'; | ||
import {SpinnerService} from '@app/services/layout/spinner.service'; | ||
|
||
@Component({ | ||
selector: 'app-spinner', | ||
imports: [ | ||
ProgressSpinner | ||
], | ||
templateUrl: './spinner.component.html', | ||
styleUrl: './spinner.component.css' | ||
}) | ||
export class SpinnerComponent { | ||
|
||
show = computed(() => this.spinnerService.getSpinner()); | ||
|
||
constructor(private spinnerService: SpinnerService) { | ||
} | ||
|
||
} |
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,32 @@ | ||
import {Injectable, signal} from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SpinnerService { | ||
|
||
private spinner = signal<boolean>(false); | ||
|
||
private timeout: any; | ||
|
||
constructor() { | ||
} | ||
|
||
show() { | ||
clearTimeout(this.timeout); | ||
|
||
this.timeout = setTimeout(() => { | ||
this.spinner.set(true); | ||
}, 500); | ||
} | ||
|
||
hide() { | ||
clearTimeout(this.timeout); | ||
this.spinner.set(false); | ||
} | ||
|
||
getSpinner() { | ||
return this.spinner(); | ||
} | ||
|
||
} |
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 {HttpInterceptorFn} from '@angular/common/http'; | ||
import {inject} from '@angular/core'; | ||
import {SpinnerService} from '@app/services/layout/spinner.service'; | ||
import {finalize} from 'rxjs'; | ||
|
||
export const spinnerInterceptor: HttpInterceptorFn = (req, next) => { | ||
const spinnerService = inject(SpinnerService); | ||
|
||
spinnerService.show(); | ||
|
||
return next(req) | ||
.pipe( | ||
finalize(() => { | ||
spinnerService.hide(); | ||
}) | ||
); | ||
}; |