mirror of https://github.com/ghostfolio/ghostfolio
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							68 lines
						
					
					
						
							2.2 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							68 lines
						
					
					
						
							2.2 KiB
						
					
					
				| import { UserService } from '@ghostfolio/client/services/user/user.service'; | |
| import { TabConfiguration, User } from '@ghostfolio/common/interfaces'; | |
| import { internalRoutes } from '@ghostfolio/common/routes/routes'; | |
| 
 | |
| import { CommonModule } from '@angular/common'; | |
| import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; | |
| import { MatTabsModule } from '@angular/material/tabs'; | |
| import { RouterModule } from '@angular/router'; | |
| import { IonIcon } from '@ionic/angular/standalone'; | |
| import { addIcons } from 'ionicons'; | |
| import { albumsOutline, analyticsOutline } from 'ionicons/icons'; | |
| import { DeviceDetectorService } from 'ngx-device-detector'; | |
| import { Subject } from 'rxjs'; | |
| import { takeUntil } from 'rxjs/operators'; | |
| 
 | |
| @Component({ | |
|   host: { class: 'page has-tabs' }, | |
|   imports: [CommonModule, IonIcon, MatTabsModule, RouterModule], | |
|   selector: 'gf-zen-page', | |
|   styleUrls: ['./zen-page.scss'], | |
|   templateUrl: './zen-page.html' | |
| }) | |
| export class GfZenPageComponent implements OnDestroy, OnInit { | |
|   public deviceType: string; | |
|   public tabs: TabConfiguration[] = []; | |
|   public user: User; | |
| 
 | |
|   private unsubscribeSubject = new Subject<void>(); | |
| 
 | |
|   public constructor( | |
|     private changeDetectorRef: ChangeDetectorRef, | |
|     private deviceService: DeviceDetectorService, | |
|     private userService: UserService | |
|   ) { | |
|     this.userService.stateChanged | |
|       .pipe(takeUntil(this.unsubscribeSubject)) | |
|       .subscribe((state) => { | |
|         if (state?.user) { | |
|           this.tabs = [ | |
|             { | |
|               iconName: 'analytics-outline', | |
|               label: internalRoutes.zen.title, | |
|               routerLink: internalRoutes.zen.routerLink | |
|             }, | |
|             { | |
|               iconName: 'albums-outline', | |
|               label: internalRoutes.zen.subRoutes.holdings.title, | |
|               routerLink: internalRoutes.zen.subRoutes.holdings.routerLink | |
|             } | |
|           ]; | |
|           this.user = state.user; | |
| 
 | |
|           this.changeDetectorRef.markForCheck(); | |
|         } | |
|       }); | |
| 
 | |
|     addIcons({ albumsOutline, analyticsOutline }); | |
|   } | |
| 
 | |
|   public ngOnInit() { | |
|     this.deviceType = this.deviceService.getDeviceInfo().deviceType; | |
|   } | |
| 
 | |
|   public ngOnDestroy() { | |
|     this.unsubscribeSubject.next(); | |
|     this.unsubscribeSubject.complete(); | |
|   } | |
| }
 | |
| 
 |