|
|
@ -22,7 +22,13 @@ import { AdminService, DataService } from '@ghostfolio/ui/services'; |
|
|
import { GfValueComponent } from '@ghostfolio/ui/value'; |
|
|
import { GfValueComponent } from '@ghostfolio/ui/value'; |
|
|
|
|
|
|
|
|
import { CommonModule } from '@angular/common'; |
|
|
import { CommonModule } from '@angular/common'; |
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
import { |
|
|
|
|
|
ChangeDetectorRef, |
|
|
|
|
|
Component, |
|
|
|
|
|
DestroyRef, |
|
|
|
|
|
OnInit |
|
|
|
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatCardModule } from '@angular/material/card'; |
|
|
import { MatCardModule } from '@angular/material/card'; |
|
|
@ -50,8 +56,6 @@ import { |
|
|
trashOutline |
|
|
trashOutline |
|
|
} from 'ionicons/icons'; |
|
|
} from 'ionicons/icons'; |
|
|
import ms, { StringValue } from 'ms'; |
|
|
import ms, { StringValue } from 'ms'; |
|
|
import { Subject } from 'rxjs'; |
|
|
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
imports: [ |
|
|
imports: [ |
|
|
@ -72,7 +76,7 @@ import { takeUntil } from 'rxjs/operators'; |
|
|
styleUrls: ['./admin-overview.scss'], |
|
|
styleUrls: ['./admin-overview.scss'], |
|
|
templateUrl: './admin-overview.html' |
|
|
templateUrl: './admin-overview.html' |
|
|
}) |
|
|
}) |
|
|
export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
export class GfAdminOverviewComponent implements OnInit { |
|
|
public activitiesCount: number; |
|
|
public activitiesCount: number; |
|
|
public couponDuration: StringValue = '14 days'; |
|
|
public couponDuration: StringValue = '14 days'; |
|
|
public coupons: Coupon[]; |
|
|
public coupons: Coupon[]; |
|
|
@ -88,13 +92,12 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
public user: User; |
|
|
public user: User; |
|
|
public version: string; |
|
|
public version: string; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private adminService: AdminService, |
|
|
private adminService: AdminService, |
|
|
private cacheService: CacheService, |
|
|
private cacheService: CacheService, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private dataService: DataService, |
|
|
private dataService: DataService, |
|
|
|
|
|
private destroyRef: DestroyRef, |
|
|
private notificationService: NotificationService, |
|
|
private notificationService: NotificationService, |
|
|
private snackBar: MatSnackBar, |
|
|
private snackBar: MatSnackBar, |
|
|
private userService: UserService |
|
|
private userService: UserService |
|
|
@ -102,7 +105,7 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
this.userService.stateChanged |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe((state) => { |
|
|
.subscribe((state) => { |
|
|
if (state?.user) { |
|
|
if (state?.user) { |
|
|
this.user = state.user; |
|
|
this.user = state.user; |
|
|
@ -219,7 +222,7 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
confirmFn: () => { |
|
|
confirmFn: () => { |
|
|
this.cacheService |
|
|
this.cacheService |
|
|
.flush() |
|
|
.flush() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
window.location.reload(); |
|
|
window.location.reload(); |
|
|
@ -268,7 +271,7 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
public onSyncDemoUserAccount() { |
|
|
public onSyncDemoUserAccount() { |
|
|
this.adminService |
|
|
this.adminService |
|
|
.syncDemoUserAccount() |
|
|
.syncDemoUserAccount() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.snackBar.open( |
|
|
this.snackBar.open( |
|
|
'✅ ' + $localize`Demo user account has been synced.`, |
|
|
'✅ ' + $localize`Demo user account has been synced.`, |
|
|
@ -280,15 +283,10 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fetchAdminData() { |
|
|
private fetchAdminData() { |
|
|
this.adminService |
|
|
this.adminService |
|
|
.fetchAdminData() |
|
|
.fetchAdminData() |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(({ activitiesCount, settings, userCount, version }) => { |
|
|
.subscribe(({ activitiesCount, settings, userCount, version }) => { |
|
|
this.activitiesCount = activitiesCount; |
|
|
this.activitiesCount = activitiesCount; |
|
|
this.coupons = (settings[PROPERTY_COUPONS] as Coupon[]) ?? []; |
|
|
this.coupons = (settings[PROPERTY_COUPONS] as Coupon[]) ?? []; |
|
|
@ -320,7 +318,7 @@ export class GfAdminOverviewComponent implements OnDestroy, OnInit { |
|
|
.putAdminSetting(key, { |
|
|
.putAdminSetting(key, { |
|
|
value: value || value === false ? JSON.stringify(value) : undefined |
|
|
value: value || value === false ? JSON.stringify(value) : undefined |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed(this.destroyRef)) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
window.location.reload(); |
|
|
window.location.reload(); |
|
|
|