Compare commits
4 Commits
master
...
bvander/ac
Author | SHA1 | Date | |
---|---|---|---|
|
c83cc5240e | ||
5061dc0d32 | |||
6f26793359 | |||
e5fe424185 |
@ -35,7 +35,7 @@ http {
|
|||||||
location / {
|
location / {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
try_files $uri $uri/ /index.html =404;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,10 @@ export class RegistryService {
|
|||||||
this.registry.load();
|
this.registry.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async load(): Promise<any> {
|
||||||
|
this.registry.load();
|
||||||
|
}
|
||||||
|
|
||||||
getRegistry(): any {
|
getRegistry(): any {
|
||||||
return this.registry;
|
return this.registry;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Injectable} from '@angular/core';
|
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 {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||||
import {environment} from '@src/environments/environment';
|
import {environment} from '@src/environments/environment';
|
||||||
import {first} from 'rxjs/operators';
|
import {first} from 'rxjs/operators';
|
||||||
@ -38,14 +38,32 @@ export class UserService {
|
|||||||
private loggingService: LoggingService,
|
private loggingService: LoggingService,
|
||||||
private tokenService: TokenService,
|
private tokenService: TokenService,
|
||||||
private registryService: RegistryService,
|
private registryService: RegistryService,
|
||||||
private authService: AuthService,
|
private authService: AuthService
|
||||||
) {
|
) {
|
||||||
this.authService.init().then(() => {
|
//this.authService.init().then(() => {
|
||||||
this.keystore = authService.mutableKeyStore;
|
// 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.signer = new PGPSigner(this.keystore);
|
||||||
});
|
this.registry = this.registryService.getRegistry();
|
||||||
this.registry = registryService.getRegistry();
|
return of(0);
|
||||||
this.registry.load();
|
} catch (error) {
|
||||||
|
console.log('ERROR: Failed to initiialize User Service', error)
|
||||||
|
return throwError(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPin(phone: string): Observable<any> {
|
resetPin(phone: string): Observable<any> {
|
||||||
@ -148,10 +166,17 @@ 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();
|
this.resetAccountsList();
|
||||||
|
let accountAddresses: Array<string>;
|
||||||
|
try {
|
||||||
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
|
const accountIndexAddress: string = await this.registry.getContractAddressByName('AccountRegistry');
|
||||||
const accountIndexQuery = new AccountIndex(accountIndexAddress);
|
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);
|
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)) {
|
for (const accountAddress of accountAddresses.slice(offset, offset + limit)) {
|
||||||
await this.getAccountByAddress(accountAddress, limit);
|
await this.getAccountByAddress(accountAddress, limit);
|
||||||
}
|
}
|
||||||
@ -216,3 +241,5 @@ export class UserService {
|
|||||||
return this.httpClient.get(`${environment.cicMetaUrl}/genders`);
|
return this.httpClient.get(`${environment.cicMetaUrl}/genders`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import {strip0x} from '@src/assets/js/ethtx/dist/hex';
|
|||||||
import {first} from 'rxjs/operators';
|
import {first} from 'rxjs/operators';
|
||||||
import {environment} from '@src/environments/environment';
|
import {environment} from '@src/environments/environment';
|
||||||
import {AccountDetails} from '@app/_models';
|
import {AccountDetails} from '@app/_models';
|
||||||
|
import {Observable, of} from 'rxjs';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-accounts',
|
selector: 'app-accounts',
|
||||||
@ -30,22 +32,16 @@ export class AccountsComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private loggingService: LoggingService,
|
private router: Router,
|
||||||
private router: Router
|
private loggingService: LoggingService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(async () => {
|
this.userService = userService;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
of(this.userService.load())
|
||||||
|
this.userService.getAccountTypes().pipe(first()).subscribe(res => this.accountTypes = res);
|
||||||
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;
|
||||||
|
@ -7,10 +7,10 @@ export const environment = {
|
|||||||
serverLogLevel: NgxLoggerLevel.OFF,
|
serverLogLevel: NgxLoggerLevel.OFF,
|
||||||
loggingUrl: 'http://localhost:8000',
|
loggingUrl: 'http://localhost:8000',
|
||||||
cicMetaUrl: 'https://meta.dev.grassrootseconomics.net',
|
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',
|
cicCacheUrl: 'https://cache.dev.grassrootseconomics.net',
|
||||||
web3Provider: 'ws://localhost:63546',
|
web3Provider: 'wss://bloxberg-ws.dev.grassrootseconomics.net',
|
||||||
cicUssdUrl: 'https://ussd.dev.grassrootseconomics.net',
|
cicUssdUrl: 'https://ussd.dev.grassrootseconomics.net',
|
||||||
registryAddress: '0x6Ca3cB14aA6F761712E1C18646AfBA4d5Ae249E8',
|
registryAddress: '0xea6225212005e86a4490018ded4bf37f3e772161',
|
||||||
trustedDeclaratorAddress: '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'
|
trustedDeclaratorAddress: '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user