@ -30,6 +30,7 @@ import {
ChangeDetectorRef ,
ChangeDetectorRef ,
Component ,
Component ,
DestroyRef ,
DestroyRef ,
inject ,
OnInit
OnInit
} from '@angular/core' ;
} from '@angular/core' ;
import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
@ -84,33 +85,33 @@ import ms, { StringValue } from 'ms';
templateUrl : './admin-overview.html'
templateUrl : './admin-overview.html'
} )
} )
export class GfAdminOverviewComponent implements OnInit {
export class GfAdminOverviewComponent implements OnInit {
public activitiesCount : number ;
protected activitiesCount : number ;
public couponDuration : StringValue = '14 days' ;
protected couponDuration : StringValue = '14 days' ;
public couponsDataSource = new MatTableDataSource < Coupon > ( ) ;
protected readonly couponsDataSource = new MatTableDataSource < Coupon > ( ) ;
public couponsDisplayedColumns = [ 'code' , 'duration' , 'actions' ] ;
protected readonly couponsDisplayedColumns = [ 'code' , 'duration' , 'actions' ] ;
public hasPermissionForSubscription : boolean ;
protected hasPermissionForSubscription : boolean ;
public hasPermissionForSystemMessage : boolean ;
protected hasPermissionForSystemMessage : boolean ;
public hasPermissionToSyncDemoUserAccount : boolean ;
protected hasPermissionToSyncDemoUserAccount : boolean ;
public hasPermissionToToggleReadOnlyMode : boolean ;
protected hasPermissionToToggleReadOnlyMode : boolean ;
public info : InfoItem ;
protected readonly info : InfoItem ;
public isDataGatheringEnabled : boolean ;
protected isDataGatheringEnabled : boolean ;
public permissions = permissions ;
protected readonly permissions = permissions ;
public systemMessage : SystemMessage ;
protected systemMessage : SystemMessage ;
public userCount : number ;
protected userCount : number ;
public user : User ;
protected user : User ;
public version : string ;
protected version : string ;
public constructor (
private readonly adminService = inject ( AdminService ) ;
private adminService : AdminService ,
private readonly cacheService = inject ( CacheService ) ;
private cacheService : CacheService ,
private readonly changeDetectorRef = inject ( ChangeDetectorRef ) ;
private changeDetectorRef : ChangeDetectorRef ,
private readonly clipboard = inject ( Clipboard ) ;
private clipboard : Clipboard ,
private readonly dataService = inject ( DataService ) ;
private dataService : DataService ,
private readonly destroyRef = inject ( DestroyRef ) ;
private destroyRef : DestroyRef ,
private readonly notificationService = inject ( NotificationService ) ;
private notificationService : NotificationService ,
private readonly snackBar = inject ( MatSnackBar ) ;
private snackBar : MatSnackBar ,
private readonly userService = inject ( UserService ) ;
private userService : UserService
) {
public constructor ( ) {
this . info = this . dataService . fetchInfo ( ) ;
this . info = this . dataService . fetchInfo ( ) ;
this . userService . stateChanged
this . userService . stateChanged
@ -150,7 +151,7 @@ export class GfAdminOverviewComponent implements OnInit {
} ) ;
} ) ;
}
}
public get activitiesCountPerUser() {
protected get activitiesCountPerUser() {
if ( ! this . activitiesCount || ! this . userCount ) {
if ( ! this . activitiesCount || ! this . userCount ) {
return undefined ;
return undefined ;
}
}
@ -169,7 +170,7 @@ export class GfAdminOverviewComponent implements OnInit {
this . fetchAdminData ( ) ;
this . fetchAdminData ( ) ;
}
}
public formatDistanceToNow ( aDateString : string ) {
protected formatDistanceToNow ( aDateString : string ) {
if ( aDateString ) {
if ( aDateString ) {
const distanceString = formatDistanceToNowStrict ( parseISO ( aDateString ) , {
const distanceString = formatDistanceToNowStrict ( parseISO ( aDateString ) , {
addSuffix : true
addSuffix : true
@ -184,7 +185,7 @@ export class GfAdminOverviewComponent implements OnInit {
return '' ;
return '' ;
}
}
public formatStringValue ( aStringValue : StringValue ) {
protected formatStringValue ( aStringValue : StringValue ) {
return formatDistanceToNowStrict (
return formatDistanceToNowStrict (
addMilliseconds ( new Date ( ) , ms ( aStringValue ) ) ,
addMilliseconds ( new Date ( ) , ms ( aStringValue ) ) ,
{
{
@ -193,7 +194,7 @@ export class GfAdminOverviewComponent implements OnInit {
) ;
) ;
}
}
public onAddCoupon() {
protected onAddCoupon() {
const newCoupon : Coupon = {
const newCoupon : Coupon = {
code : ` ${ ghostfolioPrefix } ${ this . generateCouponCode ( 14 ) } ` ,
code : ` ${ ghostfolioPrefix } ${ this . generateCouponCode ( 14 ) } ` ,
duration : this.couponDuration
duration : this.couponDuration
@ -204,11 +205,11 @@ export class GfAdminOverviewComponent implements OnInit {
this . saveCoupons ( { coupons , codeToCopy : newCoupon.code } ) ;
this . saveCoupons ( { coupons , codeToCopy : newCoupon.code } ) ;
}
}
public onChangeCouponDuration ( aCouponDuration : StringValue ) {
protected onChangeCouponDuration ( aCouponDuration : StringValue ) {
this . couponDuration = aCouponDuration ;
this . couponDuration = aCouponDuration ;
}
}
public onDeleteCoupon ( aCouponCode : string ) {
protected onDeleteCoupon ( aCouponCode : string ) {
this . notificationService . confirm ( {
this . notificationService . confirm ( {
confirmFn : ( ) = > {
confirmFn : ( ) = > {
const coupons = this . couponsDataSource . data . filter ( ( { code } ) = > {
const coupons = this . couponsDataSource . data . filter ( ( { code } ) = > {
@ -222,7 +223,7 @@ export class GfAdminOverviewComponent implements OnInit {
} ) ;
} ) ;
}
}
public onDeleteSystemMessage() {
protected onDeleteSystemMessage() {
this . notificationService . confirm ( {
this . notificationService . confirm ( {
confirmFn : ( ) = > {
confirmFn : ( ) = > {
this . putAdminSetting ( {
this . putAdminSetting ( {
@ -235,14 +236,14 @@ export class GfAdminOverviewComponent implements OnInit {
} ) ;
} ) ;
}
}
public onEnableDataGatheringChange ( aEvent : MatSlideToggleChange ) {
protected onEnableDataGatheringChange ( aEvent : MatSlideToggleChange ) {
this . putAdminSetting ( {
this . putAdminSetting ( {
key : PROPERTY_IS_DATA_GATHERING_ENABLED ,
key : PROPERTY_IS_DATA_GATHERING_ENABLED ,
value : aEvent.checked ? undefined : false
value : aEvent.checked ? undefined : false
} ) ;
} ) ;
}
}
public onFlushCache() {
protected onFlushCache() {
this . notificationService . confirm ( {
this . notificationService . confirm ( {
confirmFn : ( ) = > {
confirmFn : ( ) = > {
this . cacheService
this . cacheService
@ -259,21 +260,21 @@ export class GfAdminOverviewComponent implements OnInit {
} ) ;
} ) ;
}
}
public onEnableUserSignupModeChange ( aEvent : MatSlideToggleChange ) {
protected onEnableUserSignupModeChange ( aEvent : MatSlideToggleChange ) {
this . putAdminSetting ( {
this . putAdminSetting ( {
key : PROPERTY_IS_USER_SIGNUP_ENABLED ,
key : PROPERTY_IS_USER_SIGNUP_ENABLED ,
value : aEvent.checked ? undefined : false
value : aEvent.checked ? undefined : false
} ) ;
} ) ;
}
}
public onReadOnlyModeChange ( aEvent : MatSlideToggleChange ) {
protected onReadOnlyModeChange ( aEvent : MatSlideToggleChange ) {
this . putAdminSetting ( {
this . putAdminSetting ( {
key : PROPERTY_IS_READ_ONLY_MODE ,
key : PROPERTY_IS_READ_ONLY_MODE ,
value : aEvent.checked ? true : undefined
value : aEvent.checked ? true : undefined
} ) ;
} ) ;
}
}
public onSetSystemMessage() {
protected onSetSystemMessage() {
const systemMessage = prompt (
const systemMessage = prompt (
$localize ` Please set your system message: ` ,
$localize ` Please set your system message: ` ,
JSON . stringify (
JSON . stringify (
@ -293,7 +294,7 @@ export class GfAdminOverviewComponent implements OnInit {
}
}
}
}
public onSyncDemoUserAccount() {
protected onSyncDemoUserAccount() {
this . adminService
this . adminService
. syncDemoUserAccount ( )
. syncDemoUserAccount ( )
. pipe ( takeUntilDestroyed ( this . destroyRef ) )
. pipe ( takeUntilDestroyed ( this . destroyRef ) )