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

97 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-10-20 20:51:14 +00:00
import {Component, OnInit, OnDestroy} from '@angular/core';
2021-10-28 20:34:48 +00:00
import { MatDialog, MatDialogConfig} from '@angular/material/dialog';
2021-10-15 19:14:49 +00:00
import {FullnodeService} from '../fullnode.service';
2022-02-01 18:04:16 +00:00
import { Router } from '@angular/router';
2021-10-20 20:51:14 +00:00
import { UserService } from '../user.service';
2022-02-01 18:56:02 +00:00
import { CancelComponent } from '../cancel/cancel.component';
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;
2021-11-22 20:37:45 +00:00
private owner: Owner= {
_id:'',
address: 'none',
name:'',
currency: 'usd',
tax: false,
taxValue: 0,
vat: false,
2022-01-17 20:49:08 +00:00
vatValue: 0,
2022-01-28 20:03:35 +00:00
first: '',
last: '',
2022-01-17 20:49:08 +00:00
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
2022-01-18 22:40:20 +00:00
paid: false,
2022-01-19 16:26:25 +00:00
website: '',
2022-03-07 17:14:29 +00:00
country: '',
2022-05-18 20:51:39 +00:00
zats: false,
invoices: false,
2022-07-14 16:11:04 +00:00
expiration: new Date(Date.now()).toISOString(),
2022-07-18 20:29:27 +00:00
payconf: false,
2022-08-31 13:56:06 +00:00
viewkey: '',
crmToken: ''
2021-11-22 20:37:45 +00:00
};
2021-10-20 20:51:14 +00:00
private session: string | null = '';
2021-10-21 16:22:48 +00:00
public heightUpdate: Observable<number>;
public ownerUpdate: Observable<Owner>;
2021-10-21 19:29:04 +00:00
public uZaddrUpdate: Observable<string>;
2021-10-21 16:22:48 +00:00
2021-10-20 20:51:14 +00:00
constructor(
public fullnodeService: FullnodeService,
2021-10-28 20:34:48 +00:00
public userService: UserService,
2022-02-01 18:04:16 +00:00
private dialog: MatDialog,
private router: Router
2021-10-20 20:51:14 +00:00
){
2021-10-21 16:22:48 +00:00
this.heightUpdate = fullnodeService.heightUpdate;
2021-10-21 19:29:04 +00:00
this.uZaddrUpdate = userService.uZaddrUpdate;
2021-10-21 16:22:48 +00:00
this.ownerUpdate = userService.ownerUpdate;
2021-10-28 20:34:48 +00:00
this.ownerUpdate.subscribe((owner) => {
this.owner = owner;
});
2021-10-15 19:14:49 +00:00
}
ngOnInit(){
2021-10-20 20:51:14 +00:00
}
ngOnDestroy(){
}
2021-11-22 20:37:45 +00:00
getCurrency(){
return this.owner.currency.toUpperCase();
}
2022-02-01 18:04:16 +00:00
logout(){
const dialogConfig = new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
2022-02-01 18:56:02 +00:00
dialogConfig.data = {title: 'Logout?', msg: 'Are you sure you want to disconnect from ZGo? You will have to re-link your wallet via shielded memo.'};
2022-02-01 18:04:16 +00:00
2022-02-01 18:56:02 +00:00
const dialogRef = this.dialog.open(CancelComponent, dialogConfig);
2022-02-01 18:04:16 +00:00
dialogRef.afterClosed().subscribe(val => {
if(val){
// console.log('Logout!');
2022-02-01 18:04:16 +00:00
this.userService.deleteUser().subscribe(UserResponse => {
console.log('Rerouting');
this.userService.findUser();
this.router.navigate(['/login']);
});
}
});
}
2021-10-15 19:14:49 +00:00
}