Browse Source

Minor refactoring

pull/1922/head
Thomas 2 years ago
parent
commit
0926a88f45
  1. 33
      apps/client/src/app/components/platform/platform.component.ts
  2. 2
      apps/client/src/app/components/platform/platform.module.ts

33
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<Platform> = new MatTableDataSource();
public deviceType: string;
public displayedColumns = ['id', 'name', 'url', 'actions'];
public hasPermissionToCreatePlatform: boolean;
public hasPermissionToDeletePlatform: boolean;
public dataSource: MatTableDataSource<Platform> = new MatTableDataSource();
public platforms: PlatformModel[];
private unsubscribeSubject = new Subject<void>();
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();
});
}

2
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,

Loading…
Cancel
Save