User and Client lists show the last logins.

This commit is contained in:
2020-12-05 09:03:11 +05:30
parent c2e8c0382a
commit 9aeb71d566
13 changed files with 102 additions and 61 deletions

View File

@ -33,13 +33,15 @@
<!-- Created Column -->
<ng-container matColumnDef="created">
<mat-header-cell *matHeaderCellDef mat-sort-header>Created</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.created | localTime }}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.creationDate | localTime }}</mat-cell>
</ng-container>
<!-- Last Login Column -->
<ng-container matColumnDef="lastLogin">
<ng-container matColumnDef="last">
<mat-header-cell *matHeaderCellDef mat-sort-header>Last Login</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.lastLogin | localTime }}</mat-cell>
<mat-cell *matCellDef="let row"
>{{ row.lastUser }} @ {{ row.lastDate ? (row.lastDate | localTime) : 'Never' }}</mat-cell
>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>

View File

@ -18,7 +18,7 @@ export class ClientListComponent implements OnInit {
list: Client[] = [];
dataSource: ClientListDataSource = new ClientListDataSource(this.list);
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['code', 'name', 'enabled', 'otp', 'created', 'lastLogin'];
displayedColumns = ['code', 'name', 'enabled', 'otp', 'created', 'last'];
constructor(private route: ActivatedRoute) {}

View File

@ -3,18 +3,18 @@ export class Client {
name: string;
code: number;
enabled: boolean;
otp: number;
otp?: number;
creationDate: string;
lastLogin: string;
lastUser: string;
lastDate?: string;
public constructor(init?: Partial<Client>) {
this.id = '';
this.name = '';
this.code = 0;
this.enabled = true;
this.otp = 0;
this.creationDate = '';
this.lastLogin = '';
this.lastUser = '';
Object.assign(this, init);
}
}

View File

@ -1,9 +1,9 @@
export class UserGroup {
export class UserRole {
id: string | undefined;
name: string;
enabled: boolean;
public constructor(init?: Partial<UserGroup>) {
public constructor(init?: Partial<UserRole>) {
this.name = '';
this.enabled = true;
Object.assign(this, init);

View File

@ -1,16 +1,18 @@
import { UserGroup } from './user-group';
import { UserRole } from './user-role';
export class User {
id: string | undefined;
name: string;
password: string;
lockedOut: boolean;
roles: UserGroup[];
roles: UserRole[];
perms: string[];
isAuthenticated: boolean;
access_token?: string;
exp: number;
ver: string;
lastDevice: string;
lastDate?: string;
public constructor(init?: Partial<User>) {
this.name = '';
@ -21,6 +23,7 @@ export class User {
this.isAuthenticated = false;
this.exp = 0;
this.ver = '';
this.lastDevice = '';
Object.assign(this, init);
}
}

View File

@ -22,16 +22,25 @@
<mat-cell *matCellDef="let row">{{ row.lockedOut }}</mat-cell>
</ng-container>
<!-- Groups Column -->
<ng-container matColumnDef="groups">
<mat-header-cell *matHeaderCellDef mat-sort-header>Groups</mat-header-cell>
<!-- Roles Column -->
<ng-container matColumnDef="roles">
<mat-header-cell *matHeaderCellDef>Roles</mat-header-cell>
<mat-cell *matCellDef="let row">
<ul>
<li *ngFor="let group of row.groups">{{ group }}</li>
<li *ngFor="let role of row.roles">{{ role }}</li>
</ul>
</mat-cell>
</ng-container>
<!-- Last Login Column -->
<ng-container matColumnDef="last">
<mat-header-cell *matHeaderCellDef>Last Login</mat-header-cell>
<mat-cell *matCellDef="let row"
>{{ row.lastDevice }} @
{{ row.lastDate ? (row.lastDate | localTime) : 'Never' }}</mat-cell
>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
</mat-table>

View File

@ -18,7 +18,7 @@ export class UserListComponent implements OnInit {
list: User[] = [];
dataSource: UserListDataSource = new UserListDataSource(this.list);
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'lockedOut', 'groups'];
displayedColumns = ['name', 'lockedOut', 'roles', 'last'];
constructor(private route: ActivatedRoute) {}