Fix header
This commit is contained in:
parent
7e6cd11962
commit
62658f7be9
5 changed files with 25 additions and 14 deletions
|
@ -16,3 +16,8 @@ ul{
|
||||||
.spacer{
|
.spacer{
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mini {
|
||||||
|
font-size: 9px;
|
||||||
|
line-height: 0.8;
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<mat-toolbar color="primary">
|
<mat-toolbar color="primary">
|
||||||
<span>
|
<span>
|
||||||
<a routerLink = "/">
|
<a routerLink = "/">
|
||||||
ZEC Block Height: {{heightUpdate | async}}
|
Zgo!
|
||||||
</a>
|
</a>
|
||||||
|
<p class="mini">Last block seen: {{heightUpdate | async}}</p>
|
||||||
</span>
|
</span>
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
<span>
|
<span align="center">
|
||||||
{{shortenZaddr()}}
|
<div>{{(ownerUpdate | async)!.name}}</div>
|
||||||
|
<div class="mini">{{ shortenZaddr((ownerUpdate | async)!.address) }}</div>
|
||||||
</span>
|
</span>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
|
|
|
@ -18,28 +18,26 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||||
private session: string | null = '';
|
private session: string | null = '';
|
||||||
public heightUpdate: Observable<number>;
|
public heightUpdate: Observable<number>;
|
||||||
public ownerUpdate: Observable<Owner>;
|
public ownerUpdate: Observable<Owner>;
|
||||||
|
public uZaddrUpdate: Observable<string>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public fullnodeService: FullnodeService,
|
public fullnodeService: FullnodeService,
|
||||||
public userService: UserService
|
public userService: UserService
|
||||||
){
|
){
|
||||||
this.heightUpdate = fullnodeService.heightUpdate;
|
this.heightUpdate = fullnodeService.heightUpdate;
|
||||||
|
this.uZaddrUpdate = userService.uZaddrUpdate;
|
||||||
this.ownerUpdate = userService.ownerUpdate;
|
this.ownerUpdate = userService.ownerUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ngOnInit(){
|
ngOnInit(){
|
||||||
this.ownerUpdate.subscribe((owner) => {
|
|
||||||
this.owner = owner;
|
|
||||||
});
|
|
||||||
console.log('Header owner', this.owner);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(){
|
ngOnDestroy(){
|
||||||
}
|
}
|
||||||
|
|
||||||
shortenZaddr() {
|
shortenZaddr(address:string) {
|
||||||
var addr = this.owner.address;
|
var addr = address;
|
||||||
var end = addr.length;
|
var end = addr.length;
|
||||||
var last = end - 5;
|
var last = end - 5;
|
||||||
return addr.substring(0,5).concat('...').concat(addr.substring(last, end));
|
return addr.substring(0,5).concat('...').concat(addr.substring(last, end));
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class UserService{
|
||||||
this.dataStore.user = UserDataResponse.body!.user[0];
|
this.dataStore.user = UserDataResponse.body!.user[0];
|
||||||
console.log(`US: Found user, returning it`);
|
console.log(`US: Found user, returning it`);
|
||||||
this._uZaddrUpdated.next(Object.assign({},this.dataStore).user.address);
|
this._uZaddrUpdated.next(Object.assign({},this.dataStore).user.address);
|
||||||
|
this.getOwner(Object.assign({},this.dataStore.user).address);
|
||||||
} else {
|
} else {
|
||||||
console.log('US: Did not find user');
|
console.log('US: Did not find user');
|
||||||
}
|
}
|
||||||
|
@ -87,15 +88,18 @@ export class UserService{
|
||||||
|
|
||||||
|
|
||||||
getOwner(address: string) {
|
getOwner(address: string) {
|
||||||
|
console.log('getOwner', address);
|
||||||
const ownParams = new HttpParams().append('address', 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'});
|
let obs = this.http.get<{message:string, owner: any}>('http://localhost:3000/api/getowner', {params: ownParams, observe: 'response'});
|
||||||
|
|
||||||
obs.subscribe((OwnerDataResponse) => {
|
obs.subscribe((OwnerDataResponse) => {
|
||||||
|
console.log('api/getowner', OwnerDataResponse.status);
|
||||||
if (OwnerDataResponse.status == 200) {
|
if (OwnerDataResponse.status == 200) {
|
||||||
this.dataStore.owner = OwnerDataResponse.body!.owner[0];
|
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 {
|
} else {
|
||||||
console.log("No owner found");
|
console.log("No owner found, adding");
|
||||||
this.addOwner(address);
|
this.addOwner(address);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,9 +21,8 @@ import {Owner} from '../owner.model';
|
||||||
|
|
||||||
export class ViewerComponent implements OnInit {
|
export class ViewerComponent implements OnInit {
|
||||||
public message: string = "Welcome to the inside!";
|
public message: string = "Welcome to the inside!";
|
||||||
private UserSub: Subscription = new Subscription();
|
|
||||||
private OwnerSub: Subscription = new Subscription();
|
|
||||||
public addrUpdate: Observable<string>;
|
public addrUpdate: Observable<string>;
|
||||||
|
public ownerUpdate: Observable<Owner>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public fullnodeService: FullnodeService,
|
public fullnodeService: FullnodeService,
|
||||||
|
@ -32,10 +31,13 @@ export class ViewerComponent implements OnInit {
|
||||||
private dialog: MatDialog
|
private dialog: MatDialog
|
||||||
){
|
){
|
||||||
this.addrUpdate = fullnodeService.addrUpdate;
|
this.addrUpdate = fullnodeService.addrUpdate;
|
||||||
|
this.ownerUpdate = userService.ownerUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(){
|
ngOnInit(){
|
||||||
|
this.ownerUpdate.subscribe((owner) => {
|
||||||
|
this.message = owner.name;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(){
|
ngOnDestroy(){
|
||||||
|
|
Loading…
Reference in a new issue