|
|
@ -84,21 +84,22 @@ 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 isDataGatheringEnabled: boolean; |
|
|
public isDataGatheringEnabled: boolean; |
|
|
protected readonly permissions = permissions; |
|
|
public permissions = permissions; |
|
|
protected systemMessage: SystemMessage; |
|
|
public systemMessage: SystemMessage; |
|
|
protected userCount: number; |
|
|
public userCount: number; |
|
|
protected user: User; |
|
|
public user: User; |
|
|
protected version: string; |
|
|
public version: string; |
|
|
|
|
|
|
|
|
private info: InfoItem; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private adminService: AdminService, |
|
|
private adminService: AdminService, |
|
|
@ -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)) |
|
|
|