Merge branch 'master' into spencer/refactor-environments

# Conflicts:
#	src/app/_services/auth.service.ts
This commit is contained in:
Spencer Ofwiti 2021-03-18 19:31:22 +03:00
commit 6e4c632283
13 changed files with 91 additions and 129 deletions

View File

@ -1,2 +1,7 @@
export interface Staff { export interface Staff {
comment: string;
email: string;
name: string;
tag: number;
userid: string;
} }

View File

@ -76,11 +76,11 @@ export class AuthService {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer'; xhr.responseType = 'arraybuffer';
xhr.open('GET', environment.cicMetaUrl + window.location.search.substring(1)); xhr.open('GET', environment.cicMetaUrl + window.location.search.substring(1));
xhr.onload = (e) => { xhr.onload = async (e) => {
if (xhr.status === 401) { if (xhr.status === 401) {
const authHeader = xhr.getResponseHeader('WWW-Authenticate'); const authHeader = xhr.getResponseHeader('WWW-Authenticate');
const o = hobaParseChallengeHeader(authHeader); const o = hobaParseChallengeHeader(authHeader);
this.loginResponse(o).then(); await this.loginResponse(o);
} }
}; };
xhr.send(); xhr.send();
@ -138,6 +138,12 @@ export class AuthService {
window.location.reload(true); 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> { async getPublicKeys(): Promise<void> {
this.httpWrapperService.get(`${environment.publicKeysUrl}`).pipe(first()).subscribe(async res => { this.httpWrapperService.get(`${environment.publicKeysUrl}`).pipe(first()).subscribe(async res => {
await this.mutableKeyStore.importPublicKey(res.body); await this.mutableKeyStore.importPublicKey(res.body);

View File

@ -1,6 +1,5 @@
import {ChangeDetectionStrategy, Component, HostListener} from '@angular/core'; import {ChangeDetectionStrategy, Component, HostListener} from '@angular/core';
import {AuthService, LoggingService, TokenService, TransactionService} from '@app/_services'; import {AuthService, LoggingService, TokenService, TransactionService} from '@app/_services';
import {NGXLogger} from 'ngx-logger';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -18,11 +17,13 @@ export class AppComponent {
private authService: AuthService, private authService: AuthService,
private tokenService: TokenService, private tokenService: TokenService,
private transactionService: TransactionService, private transactionService: TransactionService,
private logger: NGXLogger,
private loggingService: LoggingService, private loggingService: LoggingService,
) { ) {
this.authService.mutableKeyStore.loadKeyring().then(r => this.authService.getPublicKeys().then()); (async () => {
this.tokenService.getTokens().then(async r => loggingService.sendInfoLevelMessage(await r)); await this.authService.mutableKeyStore.loadKeyring();
await this.authService.getPublicKeys();
this.loggingService.sendInfoLevelMessage(await this.tokenService.getTokens());
})();
this.mediaQuery.addListener(this.onResize); this.mediaQuery.addListener(this.onResize);
this.onResize(this.mediaQuery); this.onResize(this.mediaQuery);
} }
@ -53,14 +54,14 @@ export class AppComponent {
} }
@HostListener('window:cic_transfer', ['$event']) @HostListener('window:cic_transfer', ['$event'])
cicTransfer(event: CustomEvent): void { async cicTransfer(event: CustomEvent): Promise<void> {
const transaction = event.detail.tx; const transaction = event.detail.tx;
this.transactionService.setTransaction(transaction, 100).then(); await this.transactionService.setTransaction(transaction, 100);
} }
@HostListener('window:cic_convert', ['$event']) @HostListener('window:cic_convert', ['$event'])
cicConvert(event: CustomEvent): void { async cicConvert(event: CustomEvent): Promise<void> {
const conversion = event.detail.tx; const conversion = event.detail.tx;
this.transactionService.setConversion(conversion, 100).then(); await this.transactionService.setConversion(conversion, 100);
} }
} }

View File

@ -22,35 +22,33 @@ export class AuthComponent implements OnInit {
private router: Router private router: Router
) { } ) { }
ngOnInit(): void { async ngOnInit(): Promise<void> {
this.keyForm = this.formBuilder.group({ this.keyForm = this.formBuilder.group({
key: ['', Validators.required], key: ['', Validators.required],
}); });
if (this.authService.privateKey !== undefined) { if (this.authService.privateKey !== undefined) {
this.authService.setKey(this.authService.privateKey).then(r => { const setKey = await this.authService.setKey(this.authService.privateKey);
if (this.authService.sessionToken !== undefined) { if (setKey && this.authService.sessionToken !== undefined) {
this.authService.setState( this.authService.setState(
'Click button to perform login ' + this.authService.sessionLoginCount + ' with token ' + this.authService.sessionToken); 'Click button to perform login ' + this.authService.sessionLoginCount + ' with token ' + this.authService.sessionToken);
} }
});
} }
} }
get keyFormStub(): any { return this.keyForm.controls; } get keyFormStub(): any { return this.keyForm.controls; }
onSubmit(): void { async onSubmit(): Promise<void> {
this.submitted = true; this.submitted = true;
if (this.keyForm.invalid) { return; } if (this.keyForm.invalid) { return; }
this.loading = true; this.loading = true;
this.authService.setKey(this.keyFormStub.key.value).then(); await this.authService.setKey(this.keyFormStub.key.value);
this.loading = false; this.loading = false;
} }
login(): void { login(): void {
const loginStatus = this.authService.login(); const loginStatus = this.authService.login();
console.log(loginStatus);
if (loginStatus) { if (loginStatus) {
this.router.navigate(['/home']); this.router.navigate(['/home']);
} }

View File

@ -1,6 +1,5 @@
import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core'; import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core';
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';
import {SelectionModel} from '@angular/cdk/collections';
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
import {BlockSyncService, LocationService, LoggingService, TokenService, TransactionService, UserService} from '@app/_services'; import {BlockSyncService, LocationService, LoggingService, TokenService, TransactionService, UserService} from '@app/_services';
@ -81,11 +80,11 @@ export class AccountDetailsComponent implements OnInit {
this.route.paramMap.subscribe(async (params: Params) => { this.route.paramMap.subscribe(async (params: Params) => {
this.accountAddress = params.get('id'); this.accountAddress = params.get('id');
this.bloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.accountAddress + '/transactions'; this.bloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.accountAddress + '/transactions';
this.userService.getAccountDetailsFromMeta(await User.toKey(this.accountAddress)).pipe(first()).subscribe(res => { this.userService.getAccountDetailsFromMeta(await User.toKey(this.accountAddress)).pipe(first()).subscribe(async res => {
this.metaAccount = Envelope.fromJSON(JSON.stringify(res.body)).unwrap(); this.metaAccount = Envelope.fromJSON(JSON.stringify(res.body)).unwrap();
this.account = this.metaAccount.m.data; this.account = this.metaAccount.m.data;
this.loggingService.sendInfoLevelMessage(this.account); this.loggingService.sendInfoLevelMessage(this.account);
this.tokenService.getTokenBalance(this.accountAddress).then(r => this.accountBalance = r); this.accountBalance = await this.tokenService.getTokenBalance(this.accountAddress);
this.account.vcard = vCard.parse(atob(this.account.vcard)); this.account.vcard = vCard.parse(atob(this.account.vcard));
this.accountInfoForm.patchValue({ this.accountInfoForm.patchValue({
name: this.account.vcard?.fn[0].value, name: this.account.vcard?.fn[0].value,
@ -159,10 +158,10 @@ export class AccountDetailsComponent implements OnInit {
get accountInfoFormStub(): any { return this.accountInfoForm.controls; } get accountInfoFormStub(): any { return this.accountInfoForm.controls; }
saveInfo(): void { async saveInfo(): Promise<void> {
this.submitted = true; this.submitted = true;
if (this.accountInfoForm.invalid) { return; } if (this.accountInfoForm.invalid) { return; }
this.userService.changeAccountInfo( const accountKey = await this.userService.changeAccountInfo(
this.account.address, this.account.address,
this.accountInfoFormStub.name.value, this.accountInfoFormStub.name.value,
this.accountInfoFormStub.phoneNumber.value, this.accountInfoFormStub.phoneNumber.value,
@ -175,7 +174,8 @@ export class AccountDetailsComponent implements OnInit {
this.accountInfoFormStub.location.value, this.accountInfoFormStub.location.value,
this.accountInfoFormStub.locationType.value, this.accountInfoFormStub.locationType.value,
this.metaAccount this.metaAccount
).then(res => this.loggingService.sendInfoLevelMessage(`Response: ${res}`)); );
this.loggingService.sendInfoLevelMessage(`Response: ${accountKey}`);
this.submitted = false; this.submitted = false;
} }

View File

@ -2,7 +2,7 @@ import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/co
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
import {UserService} from '@app/_services'; import {LoggingService, UserService} from '@app/_services';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
@Component({ @Component({
@ -24,9 +24,16 @@ export class AccountsComponent implements OnInit {
constructor( constructor(
private userService: UserService, private userService: UserService,
private loggingService: LoggingService,
private router: Router private router: Router
) { ) {
this.userService.loadAccounts(100).then(); (async () => {
try {
await this.userService.loadAccounts(100);
} catch (error) {
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, {error});
}
})();
} }
ngOnInit(): void { ngOnInit(): void {
@ -42,8 +49,8 @@ export class AccountsComponent implements OnInit {
this.dataSource.filter = value.trim().toLocaleLowerCase(); this.dataSource.filter = value.trim().toLocaleLowerCase();
} }
viewAccount(account): void { async viewAccount(account): Promise<void> {
this.router.navigateByUrl(`/accounts/${account.identities.evm['bloxberg:8996']}`).then(); await this.router.navigateByUrl(`/accounts/${account.identities.evm['bloxberg:8996']}`);
} }
filterAccounts(): void { filterAccounts(): void {

View File

@ -1,7 +1,6 @@
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core'; import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {LocationService, UserService} from '@app/_services'; import {LocationService} from '@app/_services';
import {CustomErrorStateMatcher} from '@app/_helpers'; import {CustomErrorStateMatcher} from '@app/_helpers';
@Component({ @Component({
@ -18,8 +17,6 @@ export class CreateAccountComponent implements OnInit {
constructor( constructor(
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private router: Router,
private userService: UserService,
private locationService: LocationService private locationService: LocationService
) { } ) { }
@ -47,21 +44,6 @@ export class CreateAccountComponent implements OnInit {
onSubmit(): void { onSubmit(): void {
this.submitted = true; this.submitted = true;
if (this.createForm.invalid) { return; } if (this.createForm.invalid) { return; }
// this.userService.createAccount(
// this.createFormStub.accountType.value,
// this.createFormStub.idNumber.value,
// this.createFormStub.phoneNumber.value,
// this.createFormStub.givenName.value,
// this.createFormStub.surname.value,
// this.createFormStub.directoryEntry.value,
// this.createFormStub.location.value,
// this.createFormStub.gender.value,
// this.createFormStub.referrer.value,
// this.createFormStub.businessCategory.value,
// ).pipe(first()).subscribe(res => {
// console.log(res);
// });
// this.router.navigateByUrl(`/accounts`);
this.submitted = false; this.submitted = false;
} }

View File

@ -2,7 +2,7 @@ import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/co
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
import {UserService} from '@app/_services'; import {LoggingService, UserService} from '@app/_services';
import {animate, state, style, transition, trigger} from '@angular/animations'; import {animate, state, style, transition, trigger} from '@angular/animations';
import {first} from 'rxjs/operators'; import {first} from 'rxjs/operators';
@ -28,7 +28,8 @@ export class AdminComponent implements OnInit {
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
constructor( constructor(
private userService: UserService private userService: UserService,
private loggingService: LoggingService
) { ) {
this.userService.getActions(); this.userService.getActions();
this.userService.actionsSubject.subscribe(actions => { this.userService.actionsSubject.subscribe(actions => {
@ -50,12 +51,12 @@ export class AdminComponent implements OnInit {
} }
approveAction(action: any): void { approveAction(action: any): void {
this.userService.approveAction(action.id).pipe(first()).subscribe(res => console.log(res.body)); this.userService.approveAction(action.id).pipe(first()).subscribe(res => this.loggingService.sendInfoLevelMessage(res.body));
this.userService.getActions(); this.userService.getActions();
} }
revertAction(action: any): void { revertAction(action: any): void {
this.userService.revokeAction(action.id).pipe(first()).subscribe(res => console.log(res.body)); this.userService.revokeAction(action.id).pipe(first()).subscribe(res => this.loggingService.sendInfoLevelMessage(res.body));
this.userService.getActions(); this.userService.getActions();
} }

View File

@ -1,7 +1,7 @@
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core'; import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
import {Color, Label} from 'ng2-charts'; import {Color, Label} from 'ng2-charts';
import {ChartDataSets, ChartOptions, ChartType} from 'chart.js'; import {ChartDataSets, ChartOptions, ChartType} from 'chart.js';
import {LocationService, UserService} from '@app/_services'; import {LocationService, LoggingService} from '@app/_services';
import {ArraySum} from '@app/_helpers'; import {ArraySum} from '@app/_helpers';
@Component({ @Component({
@ -149,8 +149,8 @@ export class PagesComponent implements OnInit {
]; ];
constructor( constructor(
private userService: UserService, private locationService: LocationService,
private locationService: LocationService private loggingService: LoggingService
) { ) {
this.locationService.getLocations(); this.locationService.getLocations();
this.locationService.locationsSubject.subscribe(locations => { this.locationService.locationsSubject.subscribe(locations => {
@ -177,11 +177,11 @@ export class PagesComponent implements OnInit {
} }
public chartClicked({ event, active}: { event: MouseEvent, active: {}[] }): void { public chartClicked({ event, active}: { event: MouseEvent, active: {}[] }): void {
console.log(event, active); this.loggingService.sendInfoLevelMessage(`Event: ${event}, ${active}`);
} }
public chartHovered({ event, active }: { event: MouseEvent, active: {}[] }): void { public chartHovered({ event, active }: { event: MouseEvent, active: {}[] }): void {
console.log(event, active); this.loggingService.sendInfoLevelMessage(`Event: ${event}, ${active}`);
} }
public trackByName(index, item): string { public trackByName(index, item): string {

View File

@ -58,8 +58,7 @@
<div class="card mb-3"> <div class="card mb-3">
<mat-card-title class="card-header"> <mat-card-title class="card-header">
<div class="row"> <div class="row">
USERS TRUSTED 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>
</div> </div>
</mat-card-title> </mat-card-title>
<div class="card-body"> <div class="card-body">
@ -70,46 +69,24 @@
</mat-form-field> </mat-form-field>
<mat-table class="mat-elevation-z10" [dataSource]="dataSource" matSort matSortActive="name" <mat-table class="mat-elevation-z10" [dataSource]="dataSource" matSort matSortActive="name"
matSortDirection="asc" matSortDisableClear> matSortDirection="asc" matSortDisableClear>
<ng-container matColumnDef="name"> <ng-container matColumnDef="name">
<mat-header-cell *matHeaderCellDef mat-sort-header> NAME </mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header> NAME </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.name}} </mat-cell> <mat-cell *matCellDef="let user"> {{user.name}} </mat-cell>
</ng-container> </ng-container>
<ng-container matColumnDef="accountType"> <ng-container matColumnDef="email">
<mat-header-cell *matHeaderCellDef mat-sort-header> ACCOUNT TYPE </mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header> EMAIL </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.accountType}} </mat-cell> <mat-cell *matCellDef="let user"> {{user.email}} </mat-cell>
</ng-container> </ng-container>
<ng-container matColumnDef="created"> <ng-container matColumnDef="userId">
<mat-header-cell *matHeaderCellDef mat-sort-header> CREATED </mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header> USER ID </mat-header-cell>
<mat-cell *matCellDef="let user"> {{user.created}} </mat-cell> <mat-cell *matCellDef="let user"> {{user.userid}} </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> </ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <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-table>
<mat-paginator [pageSize]="5" [pageSizeOptions]="[5, 10, 20, 50, 100]" showFirstLastButtons></mat-paginator> <mat-paginator [pageSize]="5" [pageSizeOptions]="[5, 10, 20, 50, 100]" showFirstLastButtons></mat-paginator>

View File

@ -2,8 +2,8 @@ import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/co
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
import {UserService} from '@app/_services'; import {AuthService} from '@app/_services';
import {first} from 'rxjs/operators'; import {Staff} from '@app/_models/staff';
@Component({ @Component({
selector: 'app-settings', selector: 'app-settings',
@ -14,43 +14,26 @@ import {first} from 'rxjs/operators';
export class SettingsComponent implements OnInit { export class SettingsComponent implements OnInit {
date: string; date: string;
dataSource: MatTableDataSource<any>; dataSource: MatTableDataSource<any>;
displayedColumns = ['name', 'accountType', 'created', 'status', 'options']; displayedColumns = ['name', 'email', 'userId'];
trustedUsers: Staff[];
@ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
constructor( constructor(
private userService: UserService private authService: AuthService
) { ) { }
this.userService.getStaff();
}
ngOnInit(): void { 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(); const d = new Date();
this.date = `${d.getDate()}/${d.getMonth()}/${d.getFullYear()}`; 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 { doFilter(value: string): void {
this.dataSource.filter = value.trim().toLocaleLowerCase(); 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();
}
} }

View File

@ -1,7 +1,7 @@
import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core'; import {ChangeDetectionStrategy, Component, OnInit, ViewChild} from '@angular/core';
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
import {TokenService} from '@app/_services'; import {LoggingService, TokenService} from '@app/_services';
import {MatTableDataSource} from '@angular/material/table'; import {MatTableDataSource} from '@angular/material/table';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
@ -16,15 +16,17 @@ export class TokensComponent implements OnInit {
columnsToDisplay = ['name', 'symbol', 'address', 'supply']; columnsToDisplay = ['name', 'symbol', 'address', 'supply'];
@ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
tokens: any;
constructor( constructor(
private tokenService: TokenService, private tokenService: TokenService,
private loggingService: LoggingService,
private router: Router private router: Router
) { ) { }
tokenService.getTokens();
}
ngOnInit(): void { async ngOnInit(): Promise<void> {
this.tokens = await this.tokenService.getTokens();
this.loggingService.sendInfoLevelMessage(this.tokens);
this.tokenService.tokensSubject.subscribe(tokens => { this.tokenService.tokensSubject.subscribe(tokens => {
this.dataSource = new MatTableDataSource(tokens); this.dataSource = new MatTableDataSource(tokens);
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
@ -36,7 +38,7 @@ export class TokensComponent implements OnInit {
this.dataSource.filter = value.trim().toLocaleLowerCase(); this.dataSource.filter = value.trim().toLocaleLowerCase();
} }
viewToken(token): void { async viewToken(token): Promise<void> {
this.router.navigateByUrl(`/tokens/${token.symbol}`).then(); await this.router.navigateByUrl(`/tokens/${token.symbol}`);
} }
} }

View File

@ -19,11 +19,11 @@ export class TransactionDetailsComponent implements OnInit {
this.recipientBloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.transaction?.to + '/transactions'; this.recipientBloxbergLink = 'https://blockexplorer.bloxberg.org/address/' + this.transaction?.to + '/transactions';
} }
viewSender(): void { async viewSender(): Promise<void> {
this.router.navigateByUrl(`/accounts/${this.transaction.from}`).then(); await this.router.navigateByUrl(`/accounts/${this.transaction.from}`);
} }
viewRecipient(): void { async viewRecipient(): Promise<void> {
this.router.navigateByUrl(`/accounts/${this.transaction.to}`).then(); await this.router.navigateByUrl(`/accounts/${this.transaction.to}`);
} }
} }