2021-10-20 20:51:14 +00:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2021-10-15 19:14:49 +00:00
|
|
|
import { CanActivate, Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
|
2021-10-20 20:51:14 +00:00
|
|
|
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
|
2021-10-15 19:14:49 +00:00
|
|
|
import { UserService } from '../user.service';
|
|
|
|
import { FullnodeService } from '../fullnode.service';
|
2021-10-21 21:23:33 +00:00
|
|
|
import { ItemService } from '../items/items.service';
|
2021-10-21 15:23:58 +00:00
|
|
|
import { Subscription, Observable } from 'rxjs';
|
2021-11-11 15:18:38 +00:00
|
|
|
import { SettingsComponent } from '../settings/settings.component';
|
2021-10-20 20:51:14 +00:00
|
|
|
|
|
|
|
import {Owner} from '../owner.model';
|
2021-11-11 15:18:38 +00:00
|
|
|
import {User} from '../user.model';
|
2021-10-15 19:14:49 +00:00
|
|
|
|
2023-02-01 03:36:53 +00:00
|
|
|
import { LanguageService } from '../language.service';
|
|
|
|
import { LanguageData } from '../language.model';
|
2021-10-15 19:14:49 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-viewer',
|
|
|
|
templateUrl: './viewer.component.html',
|
|
|
|
styleUrls: ['./viewer.component.css']
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ViewerComponent implements OnInit {
|
2022-07-26 16:26:42 +00:00
|
|
|
//intervalHolder: any;
|
2021-10-20 20:51:14 +00:00
|
|
|
public message: string = "Welcome to the inside!";
|
2021-11-11 15:18:38 +00:00
|
|
|
public user: User = {
|
|
|
|
address: '',
|
|
|
|
session: '',
|
|
|
|
blocktime: 0,
|
|
|
|
pin: '',
|
|
|
|
validated: false
|
|
|
|
};
|
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
|
|
|
};
|
2022-07-14 19:04:04 +00:00
|
|
|
public price: number = 1;
|
2021-10-21 15:23:58 +00:00
|
|
|
public addrUpdate: Observable<string>;
|
2021-10-21 19:29:04 +00:00
|
|
|
public ownerUpdate: Observable<Owner>;
|
2021-11-11 15:18:38 +00:00
|
|
|
public userUpdate: Observable<User>;
|
2022-07-14 19:04:04 +00:00
|
|
|
public priceUpdate: Observable<number>;
|
2021-11-18 15:57:22 +00:00
|
|
|
orientation: boolean = false;
|
2023-02-01 03:36:53 +00:00
|
|
|
//
|
|
|
|
// Language Support
|
|
|
|
//
|
|
|
|
vE = {
|
|
|
|
viewerViewOrders : ''
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// ------------------------------------------------------------
|
2021-10-15 19:14:49 +00:00
|
|
|
constructor(
|
|
|
|
public fullnodeService: FullnodeService,
|
|
|
|
private router: Router,
|
2021-10-20 20:51:14 +00:00
|
|
|
public userService: UserService,
|
2023-02-01 03:36:53 +00:00
|
|
|
private dialog: MatDialog,
|
|
|
|
private languageService: LanguageService
|
2021-10-15 19:14:49 +00:00
|
|
|
){
|
2021-10-21 15:23:58 +00:00
|
|
|
this.addrUpdate = fullnodeService.addrUpdate;
|
2021-10-21 19:29:04 +00:00
|
|
|
this.ownerUpdate = userService.ownerUpdate;
|
2022-07-14 19:04:04 +00:00
|
|
|
this.priceUpdate = fullnodeService.priceUpdate;
|
2021-11-11 15:18:38 +00:00
|
|
|
this.ownerUpdate.subscribe((owner) => {
|
|
|
|
this.owner = owner;
|
|
|
|
});
|
2022-08-17 02:27:18 +00:00
|
|
|
|
|
|
|
// console.log(this.owner._id);
|
|
|
|
|
2021-11-11 15:18:38 +00:00
|
|
|
this.userUpdate = userService.userUpdate;
|
|
|
|
this.userUpdate.subscribe((user) => {
|
|
|
|
this.user = user;
|
|
|
|
});
|
2022-07-14 19:04:04 +00:00
|
|
|
this.priceUpdate.subscribe((price) => {
|
|
|
|
this.price = price;
|
|
|
|
});
|
2021-10-15 19:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit(){
|
2023-02-01 03:36:53 +00:00
|
|
|
this.chgUILanguage();
|
2021-11-18 15:57:22 +00:00
|
|
|
this.orientation = (window.innerWidth <= 500);
|
2021-10-21 19:29:04 +00:00
|
|
|
this.ownerUpdate.subscribe((owner) => {
|
|
|
|
this.message = owner.name;
|
|
|
|
});
|
2021-11-11 15:18:38 +00:00
|
|
|
this.loginCheck();
|
2022-07-14 18:12:26 +00:00
|
|
|
//this.intervalHolder = setInterval(() => {
|
|
|
|
//this.loginCheck();
|
|
|
|
//}, 60000);
|
2021-10-15 19:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(){
|
|
|
|
}
|
2021-10-20 20:51:14 +00:00
|
|
|
|
2021-11-18 15:57:22 +00:00
|
|
|
onResize(event: any){
|
|
|
|
this.orientation = (event.target.innerWidth <= 500);
|
|
|
|
}
|
|
|
|
|
2021-11-11 15:18:38 +00:00
|
|
|
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));
|
|
|
|
}
|
2021-11-18 15:57:22 +00:00
|
|
|
|
2021-11-11 15:18:38 +00:00
|
|
|
openSettings() {
|
|
|
|
|
|
|
|
const dialogConfig = new MatDialogConfig();
|
|
|
|
|
|
|
|
dialogConfig.disableClose = true;
|
|
|
|
dialogConfig.autoFocus = true;
|
|
|
|
dialogConfig.data = this.owner;
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
|
|
|
|
dialogRef.afterClosed().subscribe((val) => {
|
|
|
|
if (val != null) {
|
2021-11-22 20:37:45 +00:00
|
|
|
//console.log('Saving settings', val);
|
2022-05-18 21:07:26 +00:00
|
|
|
this.userService.addOwner(val);
|
2021-11-22 20:37:45 +00:00
|
|
|
this.fullnodeService.getPrice(val.currency);
|
2022-03-07 20:53:10 +00:00
|
|
|
this.loginCheck();
|
2021-11-11 15:18:38 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
loginCheck(){
|
2022-02-01 18:04:16 +00:00
|
|
|
this.userService.findUser();
|
|
|
|
this.ownerUpdate.subscribe((owner) => {
|
|
|
|
this.owner = owner;
|
|
|
|
this.userUpdate.subscribe((user) => {
|
|
|
|
this.user = user;
|
2022-07-26 16:26:42 +00:00
|
|
|
//console.log('Viewer loginCheck', this.user);
|
2022-05-18 20:51:39 +00:00
|
|
|
if (!this.owner.paid || !this.user.validated) {
|
2022-02-01 18:04:16 +00:00
|
|
|
console.log('Log in expired!');
|
|
|
|
this.router.navigate(['/login']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2021-11-11 15:18:38 +00:00
|
|
|
}
|
2023-02-01 03:36:53 +00:00
|
|
|
|
|
|
|
chgUILanguage(){
|
|
|
|
console.log('VIEWER.chgUILanguage Called ');
|
|
|
|
this.languageService.getViewElements('viewer').subscribe(
|
|
|
|
response => {
|
|
|
|
console.log('Received >> ', response );
|
|
|
|
console.log('Language Code : ', response.language);
|
|
|
|
console.log('Component Name : ',response.component);
|
|
|
|
console.log('Language data : ',response.data);
|
|
|
|
|
|
|
|
this.vE.viewerViewOrders = response.data.viewer_view_orders;
|
|
|
|
},
|
|
|
|
error => { console.log('Error >> ',error); }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-10-15 19:14:49 +00:00
|
|
|
}
|