zgo/src/app/header/header.component.ts

49 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-10-20 20:51:14 +00:00
import {Component, OnInit, OnDestroy} from '@angular/core';
2021-10-15 19:14:49 +00:00
import {FullnodeService} from '../fullnode.service';
2021-10-20 20:51:14 +00:00
import { UserService } from '../user.service';
2021-10-21 16:22:48 +00:00
import {Subscription, Observable} from 'rxjs';
2021-10-15 19:14:49 +00:00
2021-10-20 20:51:14 +00:00
import {Owner} from '../owner.model';
2021-10-15 19:14:49 +00:00
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
2021-10-20 20:51:14 +00:00
export class HeaderComponent implements OnInit, OnDestroy {
2021-10-15 19:14:49 +00:00
2021-10-20 20:51:14 +00:00
public height = 0;
private owner: Owner= {_id:'', address: 'none', name:''};
private session: string | null = '';
2021-10-21 16:22:48 +00:00
public heightUpdate: Observable<number>;
public ownerUpdate: Observable<Owner>;
2021-10-20 20:51:14 +00:00
constructor(
public fullnodeService: FullnodeService,
public userService: UserService
){
2021-10-21 16:22:48 +00:00
this.heightUpdate = fullnodeService.heightUpdate;
this.ownerUpdate = userService.ownerUpdate;
2021-10-15 19:14:49 +00:00
}
ngOnInit(){
2021-10-21 16:22:48 +00:00
this.ownerUpdate.subscribe((owner) => {
this.owner = owner;
});
console.log('Header owner', this.owner);
2021-10-20 20:51:14 +00:00
}
ngOnDestroy(){
}
shortenZaddr() {
var addr = this.owner.address;
var end = addr.length;
var last = end - 5;
return addr.substring(0,5).concat('...').concat(addr.substring(last, end));
2021-10-15 19:14:49 +00:00
}
}