ciyidogan commited on
Commit
8959b4c
Β·
verified Β·
1 Parent(s): daaab38

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

Browse files
flare-ui/src/app/components/main/main.component.ts CHANGED
@@ -1,164 +1,189 @@
1
- import { Component, inject } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
4
- import { AuthService } from '../../services/auth.service';
5
- import { ActivityLogComponent } from '../activity-log/activity-log.component';
6
-
7
- @Component({
8
- selector: 'app-main',
9
- standalone: true,
10
- imports: [CommonModule, RouterLink, RouterLinkActive, RouterOutlet, ActivityLogComponent],
11
- template: `
12
- <div class="main-layout">
13
- <header class="header">
14
- <div class="header-content">
15
- <h1>Flare Administration</h1>
16
- <div class="header-actions">
17
- <span class="username">{{ username }}</span>
18
- <button class="notification-btn" (click)="toggleActivityLog()">
19
- πŸ””
20
- @if (showActivityLog) {
21
- <app-activity-log (close)="toggleActivityLog()"></app-activity-log>
22
- }
23
- </button>
24
- <button class="btn btn-secondary" (click)="logout()">Logout</button>
25
- </div>
26
- </div>
27
- </header>
28
-
29
- <nav class="tabs">
30
- <a
31
- routerLink="/user-info"
32
- routerLinkActive="active"
33
- class="tab"
34
- >
35
- User Info
36
- </a>
37
- <a
38
- routerLink="/environment"
39
- routerLinkActive="active"
40
- class="tab"
41
- >
42
- Environment
43
- </a>
44
- <a
45
- routerLink="/apis"
46
- routerLinkActive="active"
47
- class="tab"
48
- >
49
- APIs
50
- </a>
51
- <a
52
- routerLink="/projects"
53
- routerLinkActive="active"
54
- class="tab"
55
- >
56
- Projects
57
- </a>
58
- <a
59
- routerLink="/test"
60
- routerLinkActive="active"
61
- class="tab"
62
- >
63
- Test
64
- </a>
65
- </nav>
66
-
67
- <main class="content">
68
- <router-outlet></router-outlet>
69
- </main>
70
- </div>
71
- `,
72
- styles: [`
73
- .main-layout {
74
- height: 100vh;
75
- display: flex;
76
- flex-direction: column;
77
- }
78
-
79
- .header {
80
- background-color: #fff;
81
- border-bottom: 1px solid #dee2e6;
82
- padding: 1rem 0;
83
-
84
- .header-content {
85
- max-width: 1200px;
86
- margin: 0 auto;
87
- padding: 0 20px;
88
- display: flex;
89
- justify-content: space-between;
90
- align-items: center;
91
-
92
- h1 {
93
- font-size: 1.5rem;
94
- color: #333;
95
- margin: 0;
96
- }
97
- }
98
-
99
- .header-actions {
100
- display: flex;
101
- align-items: center;
102
- gap: 1rem;
103
-
104
- .username {
105
- font-weight: 500;
106
- color: #495057;
107
- }
108
-
109
- .notification-btn {
110
- position: relative;
111
- background: none;
112
- border: none;
113
- font-size: 1.25rem;
114
- cursor: pointer;
115
- padding: 0.25rem;
116
-
117
- &:hover {
118
- opacity: 0.7;
119
- }
120
- }
121
- }
122
- }
123
-
124
- .tabs {
125
- background-color: #fff;
126
- border-bottom: 2px solid #dee2e6;
127
- max-width: 1200px;
128
- width: 100%;
129
- margin: 0 auto;
130
- padding: 0 20px;
131
- display: flex;
132
-
133
- a {
134
- text-decoration: none;
135
- }
136
- }
137
-
138
- .content {
139
- flex: 1;
140
- overflow-y: auto;
141
- padding: 2rem 0;
142
-
143
- > * {
144
- max-width: 1200px;
145
- margin: 0 auto;
146
- padding: 0 20px;
147
- }
148
- }
149
- `]
150
- })
151
- export class MainComponent {
152
- private authService = inject(AuthService);
153
-
154
- username = this.authService.getUsername() || '';
155
- showActivityLog = false;
156
-
157
- logout() {
158
- this.authService.logout();
159
- }
160
-
161
- toggleActivityLog() {
162
- this.showActivityLog = !this.showActivityLog;
163
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
 
1
+ import { Component, inject } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
4
+ import { AuthService } from '../../services/auth.service';
5
+ import { ActivityLogComponent } from '../activity-log/activity-log.component';
6
+
7
+ @Component({
8
+ selector: 'app-main',
9
+ standalone: true,
10
+ imports: [CommonModule, RouterLink, RouterLinkActive, RouterOutlet, ActivityLogComponent],
11
+ template: `
12
+ <div class="main-layout">
13
+ <header class="header">
14
+ <div class="header-content">
15
+ <h1>Flare Administration</h1>
16
+ <div class="header-actions">
17
+ <span class="username">{{ username }}</span>
18
+ <button class="notification-btn" (click)="toggleActivityLog()">
19
+ πŸ””
20
+ @if (showActivityLog) {
21
+ <app-activity-log (close)="toggleActivityLog()"></app-activity-log>
22
+ }
23
+ </button>
24
+ <button class="btn btn-secondary" (click)="logout()">Logout</button>
25
+ </div>
26
+ </div>
27
+ </header>
28
+
29
+ <nav class="tabs">
30
+ <a
31
+ routerLink="/user-info"
32
+ routerLinkActive="active"
33
+ class="tab"
34
+ >
35
+ User Info
36
+ </a>
37
+ <a
38
+ routerLink="/environment"
39
+ routerLinkActive="active"
40
+ class="tab"
41
+ >
42
+ Environment
43
+ </a>
44
+ <a
45
+ routerLink="/apis"
46
+ routerLinkActive="active"
47
+ class="tab"
48
+ >
49
+ APIs
50
+ </a>
51
+ <a
52
+ routerLink="/projects"
53
+ routerLinkActive="active"
54
+ class="tab"
55
+ >
56
+ Projects
57
+ </a>
58
+ <a
59
+ routerLink="/test"
60
+ routerLinkActive="active"
61
+ class="tab"
62
+ >
63
+ Test
64
+ </a>
65
+ </nav>
66
+
67
+ <main class="content">
68
+ <router-outlet></router-outlet>
69
+ </main>
70
+ </div>
71
+ `,
72
+ styles: [`
73
+ .main-layout {
74
+ height: 100vh;
75
+ display: flex;
76
+ flex-direction: column;
77
+ }
78
+
79
+ .header {
80
+ background-color: #fff;
81
+ border-bottom: 1px solid #dee2e6;
82
+ padding: 1rem 0;
83
+
84
+ .header-content {
85
+ max-width: 1200px;
86
+ margin: 0 auto;
87
+ padding: 0 20px;
88
+ display: flex;
89
+ justify-content: space-between;
90
+ align-items: center;
91
+
92
+ h1 {
93
+ font-size: 1.5rem;
94
+ color: #333;
95
+ margin: 0;
96
+ }
97
+ }
98
+
99
+ .header-actions {
100
+ display: flex;
101
+ align-items: center;
102
+ gap: 1rem;
103
+
104
+ .username {
105
+ font-weight: 500;
106
+ color: #495057;
107
+ }
108
+
109
+ .notification-btn {
110
+ position: relative;
111
+ background: none;
112
+ border: 1px solid #dee2e6;
113
+ border-radius: 4px;
114
+ font-size: 1.25rem;
115
+ cursor: pointer;
116
+ padding: 0.5rem;
117
+ transition: all 0.2s;
118
+
119
+ &:hover {
120
+ background-color: #f8f9fa;
121
+ border-color: #adb5bd;
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ .tabs {
128
+ background-color: #fff;
129
+ border-bottom: 2px solid #dee2e6;
130
+ max-width: 1200px;
131
+ width: 100%;
132
+ margin: 0 auto;
133
+ padding: 0 20px;
134
+ display: flex;
135
+
136
+ a {
137
+ text-decoration: none;
138
+ }
139
+
140
+ .tab {
141
+ padding: 0.75rem 1.25rem;
142
+ cursor: pointer;
143
+ border: none;
144
+ background: none;
145
+ font-weight: 500;
146
+ color: #6c757d;
147
+ transition: all 0.3s ease;
148
+ border-bottom: 2px solid transparent;
149
+ margin-bottom: -2px;
150
+
151
+ &.active {
152
+ color: #007bff;
153
+ border-bottom-color: #007bff;
154
+ }
155
+
156
+ &:hover:not(.active) {
157
+ color: #495057;
158
+ background-color: #f8f9fa;
159
+ }
160
+ }
161
+ }
162
+
163
+ .content {
164
+ flex: 1;
165
+ overflow-y: auto;
166
+ padding: 2rem 0;
167
+
168
+ > * {
169
+ max-width: 1200px;
170
+ margin: 0 auto;
171
+ padding: 0 20px;
172
+ }
173
+ }
174
+ `]
175
+ })
176
+ export class MainComponent {
177
+ private authService = inject(AuthService);
178
+
179
+ username = this.authService.getUsername() || '';
180
+ showActivityLog = false;
181
+
182
+ logout() {
183
+ this.authService.logout();
184
+ }
185
+
186
+ toggleActivityLog() {
187
+ this.showActivityLog = !this.showActivityLog;
188
+ }
189
  }