|
@ -1,4 +1,5 @@ |
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; |
|
|
|
|
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { CacheService } from '@ghostfolio/client/services/cache.service'; |
|
|
import { CacheService } from '@ghostfolio/client/services/cache.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
|
import { DataService } from '@ghostfolio/client/services/data.service'; |
|
@ -6,6 +7,7 @@ import { UserService } from '@ghostfolio/client/services/user/user.service'; |
|
|
import { |
|
|
import { |
|
|
DEFAULT_DATE_FORMAT, |
|
|
DEFAULT_DATE_FORMAT, |
|
|
PROPERTY_CURRENCIES, |
|
|
PROPERTY_CURRENCIES, |
|
|
|
|
|
PROPERTY_IS_READ_ONLY_MODE, |
|
|
PROPERTY_SYSTEM_MESSAGE |
|
|
PROPERTY_SYSTEM_MESSAGE |
|
|
} from '@ghostfolio/common/config'; |
|
|
} from '@ghostfolio/common/config'; |
|
|
import { InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
|
import { InfoItem, User } from '@ghostfolio/common/interfaces'; |
|
@ -32,6 +34,7 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public exchangeRates: { label1: string; label2: string; value: number }[]; |
|
|
public exchangeRates: { label1: string; label2: string; value: number }[]; |
|
|
public hasPermissionForSystemMessage: boolean; |
|
|
public hasPermissionForSystemMessage: boolean; |
|
|
|
|
|
public hasPermissionToToggleReadOnlyMode: boolean; |
|
|
public info: InfoItem; |
|
|
public info: InfoItem; |
|
|
public lastDataGathering: string; |
|
|
public lastDataGathering: string; |
|
|
public transactionCount: number; |
|
|
public transactionCount: number; |
|
@ -52,10 +55,23 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { |
|
|
) { |
|
|
) { |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
this.info = this.dataService.fetchInfo(); |
|
|
|
|
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((state) => { |
|
|
|
|
|
if (state?.user) { |
|
|
|
|
|
this.user = state.user; |
|
|
|
|
|
|
|
|
this.hasPermissionForSystemMessage = hasPermission( |
|
|
this.hasPermissionForSystemMessage = hasPermission( |
|
|
this.info.globalPermissions, |
|
|
this.info.globalPermissions, |
|
|
permissions.enableSystemMessage |
|
|
permissions.enableSystemMessage |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
this.hasPermissionToToggleReadOnlyMode = hasPermission( |
|
|
|
|
|
this.user.permissions, |
|
|
|
|
|
permissions.toggleReadOnlyMode |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -63,14 +79,6 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { |
|
|
*/ |
|
|
*/ |
|
|
public ngOnInit() { |
|
|
public ngOnInit() { |
|
|
this.fetchAdminData(); |
|
|
this.fetchAdminData(); |
|
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((state) => { |
|
|
|
|
|
if (state?.user) { |
|
|
|
|
|
this.user = state.user; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public formatDistanceToNow(aDateString: string) { |
|
|
public formatDistanceToNow(aDateString: string) { |
|
@ -147,6 +155,10 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { |
|
|
.subscribe(() => {}); |
|
|
.subscribe(() => {}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onReadOnlyModeChange(aEvent: MatSlideToggleChange) { |
|
|
|
|
|
this.setReadOnlyMode(aEvent.checked); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public onSetSystemMessage() { |
|
|
public onSetSystemMessage() { |
|
|
const systemMessage = prompt('Please set your system message:'); |
|
|
const systemMessage = prompt('Please set your system message:'); |
|
|
|
|
|
|
|
@ -223,4 +235,13 @@ export class AdminOverviewComponent implements OnDestroy, OnInit { |
|
|
}, 300); |
|
|
}, 300); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private setReadOnlyMode(aValue: boolean) { |
|
|
|
|
|
this.dataService |
|
|
|
|
|
.putAdminSetting(PROPERTY_IS_READ_ONLY_MODE, { |
|
|
|
|
|
value: aValue ? 'true' : '' |
|
|
|
|
|
}) |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe(() => {}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|