Fix display of all acounts on account details page.
This commit is contained in:
parent
d74bebbbc3
commit
daeed45b25
@ -17,7 +17,6 @@ export class BlockSyncService {
|
|||||||
constructor(private transactionService: TransactionService) {}
|
constructor(private transactionService: TransactionService) {}
|
||||||
|
|
||||||
async blockSync(address: string = null, offset: number = 0, limit: number = 100): Promise<void> {
|
async blockSync(address: string = null, offset: number = 0, limit: number = 100): Promise<void> {
|
||||||
this.transactionService.resetTransactionsList();
|
|
||||||
const settings: Settings = new Settings(this.scan);
|
const settings: Settings = new Settings(this.scan);
|
||||||
const readyStateElements: { network: number } = { network: 2 };
|
const readyStateElements: { network: number } = { network: 2 };
|
||||||
settings.w3.provider = environment.web3Provider;
|
settings.w3.provider = environment.web3Provider;
|
||||||
|
@ -198,7 +198,6 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
|
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
|
||||||
this.resetAccountsList();
|
|
||||||
try {
|
try {
|
||||||
const accountRegistry = await RegistryService.getAccountRegistry();
|
const accountRegistry = await RegistryService.getAccountRegistry();
|
||||||
const accountAddresses: Array<string> = await accountRegistry.last(limit);
|
const accountAddresses: Array<string> = await accountRegistry.last(limit);
|
||||||
|
@ -9,6 +9,8 @@ import {
|
|||||||
UserService,
|
UserService,
|
||||||
} from '@app/_services';
|
} from '@app/_services';
|
||||||
import { SwUpdate } from '@angular/service-worker';
|
import { SwUpdate } from '@angular/service-worker';
|
||||||
|
import { NavigationEnd, Router } from '@angular/router';
|
||||||
|
import { filter } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -19,6 +21,8 @@ import { SwUpdate } from '@angular/service-worker';
|
|||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
title = 'CICADA';
|
title = 'CICADA';
|
||||||
mediaQuery: MediaQueryList = window.matchMedia('(max-width: 768px)');
|
mediaQuery: MediaQueryList = window.matchMedia('(max-width: 768px)');
|
||||||
|
url: string;
|
||||||
|
accountDetailsRegex = '/accounts/[a-z,A-Z,0-9]{40}';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
@ -28,7 +32,8 @@ export class AppComponent implements OnInit {
|
|||||||
private tokenService: TokenService,
|
private tokenService: TokenService,
|
||||||
private transactionService: TransactionService,
|
private transactionService: TransactionService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private swUpdate: SwUpdate
|
private swUpdate: SwUpdate,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
this.mediaQuery.addEventListener('change', this.onResize);
|
this.mediaQuery.addEventListener('change', this.onResize);
|
||||||
this.onResize(this.mediaQuery);
|
this.onResize(this.mediaQuery);
|
||||||
@ -39,7 +44,24 @@ export class AppComponent implements OnInit {
|
|||||||
await this.tokenService.init();
|
await this.tokenService.init();
|
||||||
await this.userService.init();
|
await this.userService.init();
|
||||||
await this.transactionService.init();
|
await this.transactionService.init();
|
||||||
await this.blockSyncService.blockSync();
|
await this.router.events
|
||||||
|
.pipe(filter((e) => e instanceof NavigationEnd))
|
||||||
|
.forEach(async (routeInfo) => {
|
||||||
|
if (routeInfo instanceof NavigationEnd) {
|
||||||
|
this.url = routeInfo.url;
|
||||||
|
if (!this.url.match(this.accountDetailsRegex) || !this.url.includes('tx')) {
|
||||||
|
await this.blockSyncService.blockSync();
|
||||||
|
}
|
||||||
|
if (!this.url.includes('accounts')) {
|
||||||
|
try {
|
||||||
|
// TODO it feels like this should be in the onInit handler
|
||||||
|
await this.userService.loadAccounts(100);
|
||||||
|
} catch (error) {
|
||||||
|
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const publicKeys = await this.authService.getPublicKeys();
|
const publicKeys = await this.authService.getPublicKeys();
|
||||||
await this.authService.mutableKeyStore.importPublicKey(publicKeys);
|
await this.authService.mutableKeyStore.importPublicKey(publicKeys);
|
||||||
@ -50,12 +72,6 @@ export class AppComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
// TODO do something to halt user progress...show a sad cicada page 🦗?
|
// TODO do something to halt user progress...show a sad cicada page 🦗?
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
// TODO it feels like this should be in the onInit handler
|
|
||||||
await this.userService.loadAccounts(100);
|
|
||||||
} catch (error) {
|
|
||||||
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
|
||||||
}
|
|
||||||
this.tokenService.load.subscribe(async (status: boolean) => {
|
this.tokenService.load.subscribe(async (status: boolean) => {
|
||||||
if (status) {
|
if (status) {
|
||||||
await this.tokenService.getTokens();
|
await this.tokenService.getTokens();
|
||||||
|
@ -104,6 +104,7 @@ export class AccountDetailsComponent implements OnInit, AfterViewInit {
|
|||||||
location: ['', Validators.required],
|
location: ['', Validators.required],
|
||||||
locationType: ['', Validators.required],
|
locationType: ['', Validators.required],
|
||||||
});
|
});
|
||||||
|
this.transactionService.resetTransactionsList();
|
||||||
await this.blockSyncService.blockSync(this.accountAddress);
|
await this.blockSyncService.blockSync(this.accountAddress);
|
||||||
this.userService.resetAccountsList();
|
this.userService.resetAccountsList();
|
||||||
(await this.userService.getAccountByAddress(this.accountAddress, 100)).subscribe(
|
(await this.userService.getAccountByAddress(this.accountAddress, 100)).subscribe(
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
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 { TokenService, UserService } from '@app/_services';
|
import { LoggingService, TokenService, UserService } from '@app/_services';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { exportCsv } from '@app/_helpers';
|
import { exportCsv } from '@app/_helpers';
|
||||||
import { strip0x } from '@src/assets/js/ethtx/dist/hex';
|
import { strip0x } from '@src/assets/js/ethtx/dist/hex';
|
||||||
@ -36,18 +36,25 @@ export class AccountsComponent implements OnInit, AfterViewInit {
|
|||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private loggingService: LoggingService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private tokenService: TokenService
|
private tokenService: TokenService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
async ngOnInit(): Promise<void> {
|
||||||
this.userService.accountsSubject.subscribe((accounts) => {
|
this.userService.accountsSubject.subscribe((accounts) => {
|
||||||
this.dataSource = new MatTableDataSource<any>(accounts);
|
this.dataSource = new MatTableDataSource<any>(accounts);
|
||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource.sort = this.sort;
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
});
|
});
|
||||||
|
try {
|
||||||
|
// TODO it feels like this should be in the onInit handler
|
||||||
|
await this.userService.loadAccounts(100);
|
||||||
|
} catch (error) {
|
||||||
|
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
||||||
|
}
|
||||||
this.userService
|
this.userService
|
||||||
.getAccountTypes()
|
.getAccountTypes()
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
@ -60,8 +67,10 @@ export class AccountsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.dataSource.paginator = this.paginator;
|
if (this.dataSource) {
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doFilter(value: string): void {
|
doFilter(value: string): void {
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { TokenService, TransactionService, UserService } from '@app/_services';
|
import { BlockSyncService, TokenService, TransactionService, UserService } from '@app/_services';
|
||||||
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';
|
||||||
@ -34,12 +34,14 @@ export class TransactionsComponent implements OnInit, AfterViewInit {
|
|||||||
@ViewChild(MatSort) sort: MatSort;
|
@ViewChild(MatSort) sort: MatSort;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private blockSyncService: BlockSyncService,
|
||||||
private transactionService: TransactionService,
|
private transactionService: TransactionService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private tokenService: TokenService
|
private tokenService: TokenService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
async ngOnInit(): Promise<void> {
|
||||||
|
await this.blockSyncService.blockSync();
|
||||||
this.transactionService.transactionsSubject.subscribe((transactions) => {
|
this.transactionService.transactionsSubject.subscribe((transactions) => {
|
||||||
this.transactionDataSource = new MatTableDataSource<any>(transactions);
|
this.transactionDataSource = new MatTableDataSource<any>(transactions);
|
||||||
this.transactionDataSource.paginator = this.paginator;
|
this.transactionDataSource.paginator = this.paginator;
|
||||||
@ -79,8 +81,10 @@ export class TransactionsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.transactionDataSource.paginator = this.paginator;
|
if (this.transactionDataSource) {
|
||||||
this.transactionDataSource.sort = this.sort;
|
this.transactionDataSource.paginator = this.paginator;
|
||||||
|
this.transactionDataSource.sort = this.sort;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadCsv(): void {
|
downloadCsv(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user