Skip to content

Commit a5cbee0

Browse files
committed
add loading
1 parent 5f70a32 commit a5cbee0

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const authConfig = {
2-
clientId: 'YOUR_CLIENT_ID', // Your client ID
2+
clientId:
3+
'60528208097-0m6p833tdtob9gcgvmr01iqi8d6c5bsn.apps.googleusercontent.com', // Your client ID
34
responseType: 'code',
45
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div *ngIf="loadingService.loading$ | async">
2+
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
3+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.progress-spinner {
2+
position: absolute;
3+
top: 0;
4+
bottom: 0;
5+
left: 0;
6+
right: 0;
7+
display: flex;
8+
justify-content: center;
9+
align-items: center;
10+
background: rgba(0, 0, 0, 0.32);
11+
z-index: 20000;
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { LoadingService } from '../../services/loading.service';
3+
4+
@Component({
5+
selector: 'app-loading',
6+
templateUrl: './loading.component.html',
7+
styleUrls: ['./loading.component.scss'],
8+
})
9+
export class LoadingComponent implements OnInit {
10+
constructor(public loadingService: LoadingService) {}
11+
12+
ngOnInit() {}
13+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Injectable } from '@angular/core';
2+
import { BehaviorSubject, Observable, Subject, of } from 'rxjs';
3+
import { concatMap, finalize, tap } from 'rxjs/operators';
4+
5+
@Injectable({
6+
providedIn: 'root',
7+
})
8+
export class LoadingService {
9+
private loadingSubject = new BehaviorSubject<boolean>(false);
10+
11+
loading$: Observable<boolean> = this.loadingSubject.asObservable();
12+
13+
constructor() {}
14+
/**
15+
*
16+
* @param obs$ passed any Obsrable
17+
* @returns same obs$
18+
* Methode use to manage loader on API call
19+
*/
20+
showLoaderUntilCompleted<T>(obs$: Observable<T>): Observable<T> {
21+
return of(null).pipe(
22+
tap(() => this.loadingOn()),
23+
concatMap(() => obs$),
24+
finalize(() => this.loadingOff())
25+
);
26+
}
27+
/**
28+
* loadingOn method will use for emit loader ON
29+
*/
30+
loadingOn() {
31+
this.loadingSubject.next(true);
32+
}
33+
/**
34+
* loadingOff method will use for emit loader OFF
35+
*/
36+
loadingOff() {
37+
this.loadingSubject.next(false);
38+
}
39+
}

0 commit comments

Comments
 (0)