Compare commits

...

4 Commits

Author SHA1 Message Date
Spencer Ofwiti
c83cc5240e Merge remote-tracking branch 'origin/bvander/accounts-search-review' into bvander/accounts-search-review
# Conflicts:
#	src/app/_services/user.service.ts
#	src/app/pages/accounts/accounts.component.ts
2021-05-09 20:08:39 +03:00
5061dc0d32 still kinda broken 2021-05-09 10:07:49 -07:00
6f26793359 more changes 2021-05-09 09:05:36 -07:00
e5fe424185 refactor based on review 2021-05-08 12:12:33 -07:00
5 changed files with 54 additions and 27 deletions

View File

@ -35,7 +35,7 @@ http {
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
try_files $uri $uri/ /index.html;
}
}
}

View File

@ -18,6 +18,10 @@ export class RegistryService {
this.registry.load();
}
async load(): Promise<any> {
this.registry.load();
}
getRegistry(): any {
return this.registry;
}

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {BehaviorSubject, Observable, Subject} from 'rxjs';
import {BehaviorSubject, Observable, Subject, throwError, of} from 'rxjs';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {environment} from '@src/environments/environment';
import {first} from 'rxjs/operators';
@ -38,14 +38,32 @@ export class UserService {
private loggingService: LoggingService,
private tokenService: TokenService,
private registryService: RegistryService,
private authService: AuthService,
private authService: AuthService
) {
this.authService.init().then(() => {
this.keystore = authService.mutableKeyStore;
//this.authService.init().then(() => {
// this.keystore = authService.mutableKeyStore;
// this.signer = new PGPSigner(this.keystore);
//});
//this.registry = registryService.getRegistry();
//this.registry.load();
}
async load(): Promise<any> {
try {
// TODO this method is called by ngOnInit so we need to
// emit an observalbe or conver ngonInit to promise
// TODO alig the load/init methods naming
await this.authService.init();
// await this.registryService.load();
// TODO key store is defined
this.keystore = this.authService.mutableKeyStore;
this.signer = new PGPSigner(this.keystore);
});
this.registry = registryService.getRegistry();
this.registry.load();
this.registry = this.registryService.getRegistry();
return of(0);
} catch (error) {
console.log('ERROR: Failed to initiialize User Service', error)
return throwError(error);
}
}
resetPin(phone: string): Observable<any> {
@ -148,10 +166,17 @@ export class UserService {
async loadAccounts(limit: number = 100, offset: number = 0): Promise<void> {
this.resetAccountsList();
let accountAddresses: Array<string>;
try {
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
const accountIndexQuery = new AccountIndex(accountIndexAddress);
const accountAddresses: Array<string> = await accountIndexQuery.last(await accountIndexQuery.totalAccounts());
const totalAccounts = await accountIndexQuery.totalAccounts()
const accountAddresses = await accountIndexQuery.last(totalAccounts);
this.loggingService.sendInfoLevelMessage(accountAddresses);
} catch (error){
// TODO real logging:
console.log("ERROR: failed to load accounts \n", error)
}
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
await this.getAccountByAddress(accountAddress, limit);
}
@ -216,3 +241,5 @@ export class UserService {
return this.httpClient.get(`${environment.cicMetaUrl}/genders`);
}
}

View File

@ -9,6 +9,8 @@ import {strip0x} from '@src/assets/js/ethtx/dist/hex';
import {first} from 'rxjs/operators';
import {environment} from '@src/environments/environment';
import {AccountDetails} from '@app/_models';
import {Observable, of} from 'rxjs';
@Component({
selector: 'app-accounts',
@ -30,22 +32,16 @@ export class AccountsComponent implements OnInit {
constructor(
private userService: UserService,
private loggingService: LoggingService,
private router: Router
private router: Router,
private loggingService: LoggingService
)
{
(async () => {
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.getAccountTypes().pipe(first()).subscribe(res => this.accountTypes = res);
this.userService = userService;
}
ngOnInit(): void {
of(this.userService.load())
this.userService.getAccountTypes().pipe(first()).subscribe(res => this.accountTypes = res);
this.userService.accountsSubject.subscribe(accounts => {
this.dataSource = new MatTableDataSource<any>(accounts);
this.dataSource.paginator = this.paginator;

View File

@ -7,10 +7,10 @@ export const environment = {
serverLogLevel: NgxLoggerLevel.OFF,
loggingUrl: 'http://localhost:8000',
cicMetaUrl: 'https://meta.dev.grassrootseconomics.net',
publicKeysUrl: 'http://localhost:8000/keys.asc',
publicKeysUrl: 'https://dev.grassrootseconomics.net/.well-known/publickeys/',
cicCacheUrl: 'https://cache.dev.grassrootseconomics.net',
web3Provider: 'ws://localhost:63546',
web3Provider: 'wss://bloxberg-ws.dev.grassrootseconomics.net',
cicUssdUrl: 'https://ussd.dev.grassrootseconomics.net',
registryAddress: '0x6Ca3cB14aA6F761712E1C18646AfBA4d5Ae249E8',
registryAddress: '0xea6225212005e86a4490018ded4bf37f3e772161',
trustedDeclaratorAddress: '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'
};