|
|
@ -10,12 +10,13 @@ import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectorRef, |
|
|
ChangeDetectorRef, |
|
|
Component, |
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
DOCUMENT, |
|
|
DOCUMENT, |
|
|
HostBinding, |
|
|
HostBinding, |
|
|
Inject, |
|
|
Inject, |
|
|
OnDestroy, |
|
|
|
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { Title } from '@angular/platform-browser'; |
|
|
import { Title } from '@angular/platform-browser'; |
|
|
import { |
|
|
import { |
|
|
@ -30,8 +31,7 @@ import { DataSource } from '@prisma/client'; |
|
|
import { addIcons } from 'ionicons'; |
|
|
import { addIcons } from 'ionicons'; |
|
|
import { openOutline } from 'ionicons/icons'; |
|
|
import { openOutline } from 'ionicons/icons'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { filter } from 'rxjs/operators'; |
|
|
import { filter, takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
import { GfFooterComponent } from './components/footer/footer.component'; |
|
|
import { GfFooterComponent } from './components/footer/footer.component'; |
|
|
import { GfHeaderComponent } from './components/header/header.component'; |
|
|
import { GfHeaderComponent } from './components/header/header.component'; |
|
|
@ -47,7 +47,7 @@ import { UserService } from './services/user/user.service'; |
|
|
styleUrls: ['./app.component.scss'], |
|
|
styleUrls: ['./app.component.scss'], |
|
|
templateUrl: './app.component.html' |
|
|
templateUrl: './app.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfAppComponent implements OnDestroy, OnInit { |
|
|
export class GfAppComponent implements OnInit { |
|
|
@HostBinding('class.has-info-message') get getHasMessage() { |
|
|
@HostBinding('class.has-info-message') get getHasMessage() { |
|
|
return this.hasInfoMessage; |
|
|
return this.hasInfoMessage; |
|
|
} |
|
|
} |
|
|
@ -68,11 +68,10 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
public showFooter = false; |
|
|
public showFooter = false; |
|
|
public user: User; |
|
|
public user: User; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private deviceService: DeviceDetectorService, |
|
|
private dialog: MatDialog, |
|
|
private dialog: MatDialog, |
|
|
@Inject(DOCUMENT) private document: Document, |
|
|
@Inject(DOCUMENT) private document: Document, |
|
|
@ -87,7 +86,7 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
this.user = undefined; |
|
|
this.user = undefined; |
|
|
|
|
|
|
|
|
this.route.queryParams |
|
|
this.route.queryParams |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((params) => { |
|
|
.subscribe((params) => { |
|
|
if ( |
|
|
if ( |
|
|
params['dataSource'] && |
|
|
params['dataSource'] && |
|
|
@ -110,7 +109,7 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
this.impersonationStorageService |
|
|
this.impersonationStorageService |
|
|
.onChangeHasImpersonation() |
|
|
.onChangeHasImpersonation() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((impersonationId) => { |
|
|
.subscribe((impersonationId) => { |
|
|
this.hasImpersonationId = !!impersonationId; |
|
|
this.hasImpersonationId = !!impersonationId; |
|
|
}); |
|
|
}); |
|
|
@ -199,7 +198,7 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
this.userService.stateChanged |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((state) => { |
|
|
.subscribe((state) => { |
|
|
this.user = state.user; |
|
|
this.user = state.user; |
|
|
|
|
|
|
|
|
@ -243,11 +242,6 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
document.location.href = `/${document.documentElement.lang}`; |
|
|
document.location.href = `/${document.documentElement.lang}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private initializeTheme(userPreferredColorScheme?: ColorScheme) { |
|
|
private initializeTheme(userPreferredColorScheme?: ColorScheme) { |
|
|
const isDarkTheme = userPreferredColorScheme |
|
|
const isDarkTheme = userPreferredColorScheme |
|
|
? userPreferredColorScheme === 'DARK' |
|
|
? userPreferredColorScheme === 'DARK' |
|
|
@ -271,7 +265,7 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
}) { |
|
|
}) { |
|
|
this.userService |
|
|
this.userService |
|
|
.get() |
|
|
.get() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((user) => { |
|
|
.subscribe((user) => { |
|
|
this.user = user; |
|
|
this.user = user; |
|
|
|
|
|
|
|
|
@ -317,7 +311,7 @@ export class GfAppComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
dialogRef |
|
|
dialogRef |
|
|
.afterClosed() |
|
|
.afterClosed() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.router.navigate([], { |
|
|
this.router.navigate([], { |
|
|
queryParams: { |
|
|
queryParams: { |
|
|
|