From 8f6ef2cdb275a646535dff1fbbdc5a763258d1c3 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 9 Dec 2020 21:45:44 +0000 Subject: [PATCH] Fixed #3907 --- .../usermanagement.component.html | 2 +- .../usermanagement/usermanagement.component.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html index 4b64e2f45..af789e168 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.html @@ -7,7 +7,7 @@ -
+
diff --git a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts index 4071c6b8f..b412091a8 100644 --- a/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts +++ b/src/Ombi/ClientApp/src/app/usermanagement/usermanagement.component.ts @@ -10,7 +10,7 @@ import { SelectionModel } from "@angular/cdk/collections"; templateUrl: "./usermanagement.component.html", styleUrls: ["./usermanagement.component.scss"], }) -export class UserManagementComponent implements OnInit, AfterViewInit { +export class UserManagementComponent implements OnInit { public displayedColumns: string[] = ['select', 'username', 'alias', 'email', 'roles', 'remainingRequests', 'nextRequestDue', 'lastLoggedIn', 'userType', 'actions', 'welcome']; @@ -32,13 +32,15 @@ export class UserManagementComponent implements OnInit, AfterViewInit { constructor(private identityService: IdentityService, private settingsService: SettingsService, private notificationService: NotificationService, - private plexSettings: SettingsService) { } + private plexSettings: SettingsService) { + this.dataSource = new MatTableDataSource(); + } public async ngOnInit() { this.users = await this.identityService.getUsers().toPromise(); - this.dataSource = new MatTableDataSource(this.users); + this.dataSource.sort = this.sort; this.plexSettings.getPlex().subscribe(x => this.plexEnabled = x.enable); @@ -47,10 +49,6 @@ export class UserManagementComponent implements OnInit, AfterViewInit { this.settingsService.getEmailNotificationSettings().subscribe(x => this.emailSettings = x); } - public ngAfterViewInit(): void { - this.dataSource.sort = this.sort; - } - public welcomeEmail(user: IUser) { if (!user.emailAddress) { this.notificationService.error("The user needs an email address."); @@ -103,6 +101,9 @@ export class UserManagementComponent implements OnInit, AfterViewInit { } public isAllSelected() { + if (!this.dataSource) { + return; + } const numSelected = this.selection.selected.length; const numRows = this.dataSource.data.length; return numSelected === numRows; @@ -110,6 +111,9 @@ export class UserManagementComponent implements OnInit, AfterViewInit { public masterToggle() { + if (!this.dataSource) { + return; + } this.isAllSelected() ? this.selection.clear() : this.dataSource.data.forEach(row => this.selection.select(row));