Add list of users from public keys.
This commit is contained in:
parent
03be46e169
commit
6dc44be4eb
@ -1,2 +1,7 @@
|
||||
export interface Staff {
|
||||
comment: string;
|
||||
email: string;
|
||||
name: string;
|
||||
tag: number;
|
||||
userid: string;
|
||||
}
|
||||
|
@ -138,6 +138,12 @@ export class AuthService {
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
getTrustedUsers(): any {
|
||||
let trustedUsers = [];
|
||||
this.mutableKeyStore.getPublicKeys().forEach(key => trustedUsers.push(key.users[0].userId));
|
||||
return trustedUsers;
|
||||
}
|
||||
|
||||
async getPublicKeys(): Promise<void> {
|
||||
this.httpWrapperService.get(`${environment.publicKeysUrl}`).pipe(first()).subscribe(async res => {
|
||||
await this.mutableKeyStore.importPublicKey(res.body);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {ChangeDetectionStrategy, Component, HostListener} from '@angular/core';
|
||||
import {AuthService, LoggingService, TokenService, TransactionService} from '@app/_services';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -18,10 +17,9 @@ export class AppComponent {
|
||||
private authService: AuthService,
|
||||
private tokenService: TokenService,
|
||||
private transactionService: TransactionService,
|
||||
private logger: NGXLogger,
|
||||
private loggingService: LoggingService,
|
||||
) {
|
||||
this.authService.mutableKeyStore.loadKeyring().then(r => this.authService.getPublicKeys().then());
|
||||
this.authService.mutableKeyStore.loadKeyring().then(() => this.authService.getPublicKeys().then());
|
||||
this.tokenService.getTokens().then(async r => loggingService.sendInfoLevelMessage(await r));
|
||||
this.mediaQuery.addListener(this.onResize);
|
||||
this.onResize(this.mediaQuery);
|
||||
|
@ -58,8 +58,7 @@
|
||||
<div class="card mb-3">
|
||||
<mat-card-title class="card-header">
|
||||
<div class="row">
|
||||
USERS
|
||||
<button mat-raised-button color="primary" routerLink="/settings/invite" type="button" class="btn btn-outline-primary ml-auto"><i class="fa fa-plus"> NEW USER </i></button>
|
||||
TRUSTED USERS
|
||||
</div>
|
||||
</mat-card-title>
|
||||
<div class="card-body">
|
||||
@ -70,46 +69,24 @@
|
||||
</mat-form-field>
|
||||
<mat-table class="mat-elevation-z10" [dataSource]="dataSource" matSort matSortActive="name"
|
||||
matSortDirection="asc" matSortDisableClear>
|
||||
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> NAME </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user"> {{user.name}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="accountType">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> ACCOUNT TYPE </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user"> {{user.accountType}} </mat-cell>
|
||||
<ng-container matColumnDef="email">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> EMAIL </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user"> {{user.email}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="created">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> CREATED </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user"> {{user.created}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> STATUS </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user">
|
||||
<span *ngIf="user.status === 'activated'" class="badge badge-success badge-pill"> {{user.status}} </span>
|
||||
<span *ngIf="user.status === 'deactivated'" class="badge badge-danger badge-pill"> {{user.status}} </span>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="options">
|
||||
<mat-header-cell *matHeaderCellDef> OPTIONS </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user" class="dropdown">
|
||||
<button mat-raised-button color="warn" [matMenuTriggerFor]="menu" class="btn btn-outline-danger ml-1"><i class="fa fa-ellipsis-h"></i></button>
|
||||
<mat-menu #menu='matMenu'>
|
||||
<button mat-menu-item (click)="changeStaffType(user.id, 'SuperAdmin')">Change to Super Admin</button>
|
||||
<button mat-menu-item (click)="changeStaffType(user.id, 'Admin')">Change to Admin</button>
|
||||
<button mat-menu-item (click)="changeStaffType(user.id, 'Enroller')">Change to Enroller</button>
|
||||
<button mat-menu-item (click)="changeStaffType(user.id, 'View')">Change to View Only</button>
|
||||
<button *ngIf="user.status === 'activated'" mat-menu-item (click)="deactivateStaff(user.id)">Deactivate User</button>
|
||||
<button *ngIf="user.status === 'deactivated'" mat-menu-item (click)="activateStaff(user.id)">Activate User</button>
|
||||
</mat-menu>
|
||||
</mat-cell>
|
||||
<ng-container matColumnDef="userId">
|
||||
<mat-header-cell *matHeaderCellDef mat-sort-header> USER ID </mat-header-cell>
|
||||
<mat-cell *matCellDef="let user"> {{user.userid}} </mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let transaction; columns: displayedColumns"></mat-row>
|
||||
<mat-row *matRowDef="let user; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
|
||||
<mat-paginator [pageSize]="5" [pageSizeOptions]="[5, 10, 20, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
@ -2,8 +2,8 @@ import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/co
|
||||
import {MatTableDataSource} from '@angular/material/table';
|
||||
import {MatPaginator} from '@angular/material/paginator';
|
||||
import {MatSort} from '@angular/material/sort';
|
||||
import {UserService} from '@app/_services';
|
||||
import {first} from 'rxjs/operators';
|
||||
import {AuthService} from '@app/_services';
|
||||
import {Staff} from '@app/_models/staff';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@ -14,43 +14,26 @@ import {first} from 'rxjs/operators';
|
||||
export class SettingsComponent implements OnInit {
|
||||
date: string;
|
||||
dataSource: MatTableDataSource<any>;
|
||||
displayedColumns = ['name', 'accountType', 'created', 'status', 'options'];
|
||||
displayedColumns = ['name', 'email', 'userId'];
|
||||
trustedUsers: Staff[];
|
||||
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor(
|
||||
private userService: UserService
|
||||
) {
|
||||
this.userService.getStaff();
|
||||
}
|
||||
private authService: AuthService
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userService.staffSubject.subscribe(staff => {
|
||||
this.dataSource = new MatTableDataSource<any>(staff);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
});
|
||||
const d = new Date();
|
||||
this.date = `${d.getDate()}/${d.getMonth()}/${d.getFullYear()}`;
|
||||
this.trustedUsers = this.authService.getTrustedUsers();
|
||||
this.dataSource = new MatTableDataSource<any>(this.trustedUsers);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
doFilter(value: string): void {
|
||||
this.dataSource.filter = value.trim().toLocaleLowerCase();
|
||||
}
|
||||
|
||||
activateStaff(id: string): void {
|
||||
this.userService.activateStaff(id).pipe(first()).subscribe(res => console.log(res.body));
|
||||
this.userService.getStaff();
|
||||
}
|
||||
|
||||
deactivateStaff(id: string): void {
|
||||
this.userService.deactivateStaff(id).pipe(first()).subscribe(res => console.log(res.body));
|
||||
this.userService.getStaff();
|
||||
}
|
||||
|
||||
changeStaffType(id: string, type: string): void {
|
||||
this.userService.changeStaffType(id, type).pipe(first()).subscribe(res => console.log(res.body));
|
||||
this.userService.getStaff();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user