From 0926a88f45a69a5eed5f54325e6787231bc7ab6a Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sat, 6 May 2023 09:18:57 +0200 Subject: [PATCH] Minor refactoring --- .../components/platform/platform.component.ts | 33 +++++++++---------- .../components/platform/platform.module.ts | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/apps/client/src/app/components/platform/platform.component.ts b/apps/client/src/app/components/platform/platform.component.ts index 6e9ec8c3b..5d11a632f 100644 --- a/apps/client/src/app/components/platform/platform.component.ts +++ b/apps/client/src/app/components/platform/platform.component.ts @@ -28,20 +28,18 @@ import { AdminService } from '@ghostfolio/client/services/admin.service'; export class AdminPlatformComponent implements OnInit, OnDestroy { @ViewChild(MatSort) sort: MatSort; - public displayedColumns = ['id', 'name', 'url', 'actions']; - - public platforms: PlatformModel[]; + public dataSource: MatTableDataSource = new MatTableDataSource(); public deviceType: string; + public displayedColumns = ['id', 'name', 'url', 'actions']; public hasPermissionToCreatePlatform: boolean; public hasPermissionToDeletePlatform: boolean; - - public dataSource: MatTableDataSource = new MatTableDataSource(); + public platforms: PlatformModel[]; private unsubscribeSubject = new Subject(); public constructor( - private changeDetectorRef: ChangeDetectorRef, private adminService: AdminService, + private changeDetectorRef: ChangeDetectorRef, private deviceService: DeviceDetectorService, private dialog: MatDialog, private route: ActivatedRoute, @@ -92,17 +90,6 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { this.fetchPlatforms(); } - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } - - public onUpdatePlatform(aPlatform: PlatformModel) { - this.router.navigate([], { - queryParams: { platformId: aPlatform.id, editDialog: true } - }); - } - public deletePlatform(aId: string) { this.adminService .deletePlatform(aId) @@ -119,6 +106,17 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { }); } + public onUpdatePlatform(aPlatform: PlatformModel) { + this.router.navigate([], { + queryParams: { platformId: aPlatform.id, editDialog: true } + }); + } + + public ngOnDestroy() { + this.unsubscribeSubject.next(); + this.unsubscribeSubject.complete(); + } + private fetchPlatforms() { this.adminService .fetchPlatforms() @@ -128,6 +126,7 @@ export class AdminPlatformComponent implements OnInit, OnDestroy { this.dataSource = new MatTableDataSource(platforms); this.dataSource.sort = this.sort; this.dataSource.sortingDataAccessor = get; + this.changeDetectorRef.markForCheck(); }); } diff --git a/apps/client/src/app/components/platform/platform.module.ts b/apps/client/src/app/components/platform/platform.module.ts index bf604c45c..b5906234f 100644 --- a/apps/client/src/app/components/platform/platform.module.ts +++ b/apps/client/src/app/components/platform/platform.module.ts @@ -13,8 +13,8 @@ import { GfSymbolIconModule } from '@ghostfolio/client/components/symbol-icon/sy declarations: [AdminPlatformComponent], imports: [ CommonModule, - GfSymbolIconModule, GfCreateOrUpdatePlatformDialogModule, + GfSymbolIconModule, MatButtonModule, MatMenuModule, MatSortModule,