diff --git a/src/app/header/header.component.css b/src/app/header/header.component.css index 41057db..9d41a83 100644 --- a/src/app/header/header.component.css +++ b/src/app/header/header.component.css @@ -16,3 +16,8 @@ ul{ .spacer{ flex: 1 1 auto; } + +.mini { + font-size: 9px; + line-height: 0.8; +} diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index fe758ab..e2ebb4d 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -1,11 +1,13 @@ - ZEC Block Height: {{heightUpdate | async}} + Zgo! +

Last block seen: {{heightUpdate | async}}

- - {{shortenZaddr()}} + +
{{(ownerUpdate | async)!.name}}
+
{{ shortenZaddr((ownerUpdate | async)!.address) }}
diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index c9920f3..f5ca8ef 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -18,28 +18,26 @@ export class HeaderComponent implements OnInit, OnDestroy { private session: string | null = ''; public heightUpdate: Observable; public ownerUpdate: Observable; + public uZaddrUpdate: Observable; constructor( public fullnodeService: FullnodeService, public userService: UserService ){ this.heightUpdate = fullnodeService.heightUpdate; + this.uZaddrUpdate = userService.uZaddrUpdate; this.ownerUpdate = userService.ownerUpdate; } ngOnInit(){ - this.ownerUpdate.subscribe((owner) => { - this.owner = owner; - }); - console.log('Header owner', this.owner); } ngOnDestroy(){ } - shortenZaddr() { - var addr = this.owner.address; + shortenZaddr(address:string) { + var addr = address; var end = addr.length; var last = end - 5; return addr.substring(0,5).concat('...').concat(addr.substring(last, end)); diff --git a/src/app/user.service.ts b/src/app/user.service.ts index b5e4a62..bfb8414 100644 --- a/src/app/user.service.ts +++ b/src/app/user.service.ts @@ -45,6 +45,7 @@ export class UserService{ this.dataStore.user = UserDataResponse.body!.user[0]; console.log(`US: Found user, returning it`); this._uZaddrUpdated.next(Object.assign({},this.dataStore).user.address); + this.getOwner(Object.assign({},this.dataStore.user).address); } else { console.log('US: Did not find user'); } @@ -87,15 +88,18 @@ export class UserService{ getOwner(address: string) { + console.log('getOwner', address); const ownParams = new HttpParams().append('address', address); let obs = this.http.get<{message:string, owner: any}>('http://localhost:3000/api/getowner', {params: ownParams, observe: 'response'}); obs.subscribe((OwnerDataResponse) => { + console.log('api/getowner', OwnerDataResponse.status); if (OwnerDataResponse.status == 200) { this.dataStore.owner = OwnerDataResponse.body!.owner[0]; - this._ownerUpdated.next(this.dataStore.owner); + //console.log('getOwner object', this.dataStore.owner); + this._ownerUpdated.next(Object.assign({},this.dataStore).owner); } else { - console.log("No owner found"); + console.log("No owner found, adding"); this.addOwner(address); } }); diff --git a/src/app/viewer/viewer.component.ts b/src/app/viewer/viewer.component.ts index f70c1df..eff7420 100644 --- a/src/app/viewer/viewer.component.ts +++ b/src/app/viewer/viewer.component.ts @@ -21,9 +21,8 @@ import {Owner} from '../owner.model'; export class ViewerComponent implements OnInit { public message: string = "Welcome to the inside!"; - private UserSub: Subscription = new Subscription(); - private OwnerSub: Subscription = new Subscription(); public addrUpdate: Observable; + public ownerUpdate: Observable; constructor( public fullnodeService: FullnodeService, @@ -32,10 +31,13 @@ export class ViewerComponent implements OnInit { private dialog: MatDialog ){ this.addrUpdate = fullnodeService.addrUpdate; + this.ownerUpdate = userService.ownerUpdate; } ngOnInit(){ - + this.ownerUpdate.subscribe((owner) => { + this.message = owner.name; + }); } ngOnDestroy(){