ciyidogan commited on
Commit
99aaad8
·
verified ·
1 Parent(s): 7a8c2cd

Update flare-ui/src/app/app.component.ts

Browse files
Files changed (1) hide show
  1. flare-ui/src/app/app.component.ts +75 -20
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
- @Component({
6
- selector: 'app-root',
7
- standalone: true,
8
- imports: [CommonModule, RouterOutlet],
9
- template: `
10
- <router-outlet></router-outlet>
11
- `,
12
- styles: [`
13
- :host {
14
- display: block;
15
- height: 100vh;
16
- }
17
- `]
18
- })
19
- export class AppComponent {
20
- title = 'Flare Administration';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
  }