Spaces:
Building
Building
Update flare-ui/src/app/app.component.ts
Browse files
flare-ui/src/app/app.component.ts
CHANGED
@@ -1,21 +1,76 @@
|
|
1 |
-
import { Component } from '@angular/core';
|
2 |
-
import { CommonModule } from '@angular/common';
|
3 |
-
import { RouterOutlet } from '@angular/router';
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
|
|
1 |
+
import { Component, OnInit } from '@angular/core';
|
2 |
+
import { CommonModule } from '@angular/common';
|
3 |
+
import { Router, NavigationStart, NavigationEnd, NavigationCancel, NavigationError, RouterOutlet } from '@angular/router';
|
4 |
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
5 |
+
|
6 |
+
@Component({
|
7 |
+
selector: 'app-root',
|
8 |
+
standalone: true,
|
9 |
+
imports: [CommonModule, RouterOutlet, MatProgressSpinnerModule],
|
10 |
+
template: `
|
11 |
+
<div class="app-container">
|
12 |
+
<!-- Global Loading Spinner -->
|
13 |
+
<div class="global-spinner" *ngIf="loading">
|
14 |
+
<mat-spinner diameter="60"></mat-spinner>
|
15 |
+
<p>Loading...</p>
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<!-- Main Content -->
|
19 |
+
<router-outlet></router-outlet>
|
20 |
+
</div>
|
21 |
+
`,
|
22 |
+
styles: [`
|
23 |
+
.app-container {
|
24 |
+
position: relative;
|
25 |
+
min-height: 100vh;
|
26 |
+
}
|
27 |
+
|
28 |
+
.global-spinner {
|
29 |
+
position: fixed;
|
30 |
+
top: 0;
|
31 |
+
left: 0;
|
32 |
+
width: 100%;
|
33 |
+
height: 100%;
|
34 |
+
background: rgba(255, 255, 255, 0.9);
|
35 |
+
display: flex;
|
36 |
+
flex-direction: column;
|
37 |
+
align-items: center;
|
38 |
+
justify-content: center;
|
39 |
+
z-index: 9999;
|
40 |
+
}
|
41 |
+
|
42 |
+
.global-spinner p {
|
43 |
+
margin-top: 20px;
|
44 |
+
color: #666;
|
45 |
+
font-size: 16px;
|
46 |
+
}
|
47 |
+
`]
|
48 |
+
})
|
49 |
+
export class AppComponent implements OnInit {
|
50 |
+
loading = true;
|
51 |
+
|
52 |
+
constructor(private router: Router) {}
|
53 |
+
|
54 |
+
ngOnInit() {
|
55 |
+
// Initial loading
|
56 |
+
setTimeout(() => {
|
57 |
+
this.loading = false;
|
58 |
+
}, 100);
|
59 |
+
|
60 |
+
// Router events
|
61 |
+
this.router.events.subscribe(event => {
|
62 |
+
if (event instanceof NavigationStart) {
|
63 |
+
this.loading = true;
|
64 |
+
} else if (
|
65 |
+
event instanceof NavigationEnd ||
|
66 |
+
event instanceof NavigationCancel ||
|
67 |
+
event instanceof NavigationError
|
68 |
+
) {
|
69 |
+
// Small delay to prevent flicker
|
70 |
+
setTimeout(() => {
|
71 |
+
this.loading = false;
|
72 |
+
}, 300);
|
73 |
+
}
|
74 |
+
});
|
75 |
+
}
|
76 |
}
|