Spaces:
Running
Running
File size: 7,447 Bytes
97d64d5 8959b4c 97f2998 5c8915e 8959b4c 01672a3 d56361d 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 9f145bf 97f2998 8959b4c 97f2998 8959b4c 97f2998 ccad225 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 b30e34b d068004 b30e34b 07c1f3c 5f965ab b30e34b 97f2998 9f145bf 97f2998 8959b4c 9f145bf ccad225 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97f2998 8959b4c 97d64d5 8959b4c 5f965ab d56361d 5f965ab 8959b4c 5f965ab 8959b4c d56361d 5f965ab d56361d 5f965ab d56361d 5f965ab d56361d 5f965ab 8959b4c 3b93905 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
import { Component, inject, OnInit, OnDestroy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTabsModule } from '@angular/material/tabs';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatBadgeModule } from '@angular/material/badge';
import { MatDividerModule } from '@angular/material/divider';
import { Subscription } from 'rxjs';
import { AuthService } from '../../services/auth.service';
import { ActivityLogComponent } from '../activity-log/activity-log.component';
import { ApiService } from '../../services/api.service';
import { EnvironmentService } from '../../services/environment.service';
@Component({
selector: 'app-main',
standalone: true,
imports: [
CommonModule,
RouterLink,
RouterLinkActive,
RouterOutlet,
MatToolbarModule,
MatTabsModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
MatBadgeModule,
MatDividerModule,
ActivityLogComponent
],
template: `
<div class="main-layout">
<mat-toolbar color="primary" class="header-toolbar">
<mat-toolbar-row>
<span class="logo">
<mat-icon>dashboard</mat-icon>
Flare Administration
</span>
<span class="spacer"></span>
<div class="header-actions">
<span class="username">
<mat-icon>person</mat-icon>
{{ username }}
</span>
<button mat-icon-button
(click)="toggleActivityLog()"
matTooltip="Activity Log">
<mat-icon>notifications</mat-icon>
</button>
@if (showActivityLog) {
<div class="activity-log-wrapper" (click)="$event.stopPropagation()">
<app-activity-log (close)="toggleActivityLog()"></app-activity-log>
</div>
}
<button mat-icon-button [matMenuTriggerFor]="userMenu" matTooltip="User Menu">
<mat-icon>account_circle</mat-icon>
</button>
<mat-menu #userMenu="matMenu">
<button mat-menu-item routerLink="/user-info">
<mat-icon>settings</mat-icon>
<span>User Settings</span>
</button>
<mat-divider></mat-divider>
<button mat-menu-item (click)="logout()">
<mat-icon>exit_to_app</mat-icon>
<span>Logout</span>
</button>
</mat-menu>
</div>
</mat-toolbar-row>
</mat-toolbar>
<nav mat-tab-nav-bar class="nav-tabs" #navBar="matTabNavBar" [tabPanel]="tabPanel">
<a mat-tab-link
routerLink="/user-info"
routerLinkActive #rla1="routerLinkActive"
[active]="rla1.isActive">
<mat-icon>person</mat-icon>
User Info
</a>
<a mat-tab-link
routerLink="/environment"
routerLinkActive #rla2="routerLinkActive"
[active]="rla2.isActive">
<mat-icon>settings</mat-icon>
Environment
</a>
<a mat-tab-link
routerLink="/apis"
routerLinkActive #rla3="routerLinkActive"
[active]="rla3.isActive">
<mat-icon>api</mat-icon>
APIs
</a>
<a mat-tab-link
routerLink="/projects"
routerLinkActive #rla4="routerLinkActive"
[active]="rla4.isActive">
<mat-icon>folder_special</mat-icon>
Projects
</a>
<a mat-tab-link
routerLink="/chat"
routerLinkActive #rla5="routerLinkActive"
[active]="rla5.isActive">
<mat-icon>chat_bubble_outline</mat-icon>
Chat
</a>
@if (!isGPTMode) {
<a mat-tab-link
routerLink="/spark"
routerLinkActive #rla6="routerLinkActive"
[active]="rla6.isActive">
<mat-icon>flash_on</mat-icon>
Spark Integration
</a>
}
<a mat-tab-link
routerLink="/test"
routerLinkActive #rla5="routerLinkActive"
[active]="rla5.isActive">
<mat-icon>bug_report</mat-icon>
Test
</a>
</nav>
<mat-tab-nav-panel #tabPanel>
<main class="content">
<router-outlet></router-outlet>
</main>
</mat-tab-nav-panel>
</div>
`,
styles: [`
.main-layout {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #fafafa;
}
.header-toolbar {
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
z-index: 100;
position: relative;
.logo {
display: flex;
align-items: center;
gap: 8px;
font-size: 20px;
font-weight: 500;
mat-icon {
font-size: 28px;
width: 28px;
height: 28px;
}
}
.spacer {
flex: 1 1 auto;
}
.header-actions {
display: flex;
align-items: center;
gap: 8px;
position: relative;
.username {
display: flex;
align-items: center;
gap: 4px;
margin-right: 16px;
mat-icon {
font-size: 20px;
width: 20px;
height: 20px;
}
}
.activity-log-wrapper {
position: absolute;
top: 56px;
right: 0;
z-index: 1000;
}
}
}
.nav-tabs {
background-color: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.08);
::ng-deep {
.mat-mdc-tab-link {
min-width: 120px;
opacity: 0.8;
mat-icon {
margin-right: 8px;
}
&.mdc-tab--active {
opacity: 1;
}
}
}
}
.content {
flex: 1;
overflow-y: auto;
padding: 24px;
}
`]
})
export class MainComponent implements OnInit, OnDestroy {
private authService = inject(AuthService);
private apiService = inject(ApiService);
private environmentService = inject(EnvironmentService);
username = this.authService.getUsername() || '';
showActivityLog = false;
isGPTMode = false;
private subscription?: Subscription;
ngOnInit() {
// Environment değişikliklerini dinle
this.subscription = this.environmentService.environment$.subscribe(env => {
if (env) {
this.isGPTMode = env.work_mode?.startsWith('gpt4o') || false;
}
});
// Environment bilgisini al
this.loadEnvironment();
}
ngOnDestroy() {
this.subscription?.unsubscribe();
}
private loadEnvironment() {
this.apiService.getEnvironment().subscribe({
next: (env) => {
this.environmentService.updateEnvironment(env);
},
error: (err) => {
console.error('Failed to load environment:', err);
}
});
}
logout() {
this.authService.logout();
}
toggleActivityLog() {
this.showActivityLog = !this.showActivityLog;
}
} |