Merge branch 'hotfix-a1'

This commit is contained in:
Rene Vergara 2023-05-15 09:56:27 -05:00
commit 3535e1b43f
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
33 changed files with 4027 additions and 12076 deletions

View File

@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.2.0]
## Added
- New API calls for requesting language data for login page
### Changed
- Owner model modified to remove unnecessary fields
- Fullnode service uses `session` for API calls.
- User service uses `session` for API calls.
- Auth-guard service uses new `checkUser` function to confirm session exists and is validated.
### Fixed
- Business sign-up stepper skipping is corrected
## [2.1.0] - 2023-05-02
### Added

View File

@ -1,5 +1,7 @@
# ZGo - The Zcash Register
[![Please don't upload to GitHub](https://nogithub.codeberg.page/badge.svg)](https://nogithub.codeberg.page)
A Point-of-Sale application for accepting payments in [Zcash](https://z.cash/)
Visit our [ZGo Homepage](https://zgo.cash/) for more details.

14857
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "zgo",
"version": "2.1.0",
"version": "2.2.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
@ -10,23 +10,22 @@
},
"private": true,
"dependencies": {
"@angular-material-components/datetime-picker": "^9.0.0",
"@angular/animations": "^15.1.2",
"@angular/cdk": "^15.1.2",
"@angular/common": "^15.1.2",
"@angular/compiler": "^15.1.2",
"@angular/core": "^15.1.2",
"@angular/forms": "^15.1.2",
"@angular/material": "^15.1.2",
"@angular/platform-browser": "^15.1.2",
"@angular/platform-browser-dynamic": "^15.1.2",
"@angular/router": "^15.1.2",
"@fortawesome/angular-fontawesome": "^0.12.1",
"@fortawesome/fontawesome-free": "^6.2.1",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.2.1",
"@fortawesome/free-regular-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@angular/animations": "^16.0.0",
"@angular/cdk": "^16.0.0",
"@angular/common": "^16.0.0",
"@angular/compiler": "^16.0.0",
"@angular/core": "^16.0.0",
"@angular/forms": "^16.0.0",
"@angular/material": "^16.0.0",
"@angular/platform-browser": "^16.0.0",
"@angular/platform-browser-dynamic": "^16.0.0",
"@angular/router": "^16.0.0",
"@fortawesome/angular-fontawesome": "^0.13.0",
"@fortawesome/fontawesome-free": "^6.4.0",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@supercharge/request-ip": "^1.2.0",
"angular-local-storage": "^0.7.1",
"angular-material-datepicker": "^1.0.2",
@ -39,23 +38,23 @@
"tslib": "^2.5.0",
"urlsafe-base64": "^1.0.0",
"uuid": "^9.0.0",
"zone.js": "~0.12.0"
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.1.3",
"@angular/cli": "^15.1.3",
"@angular/compiler-cli": "^15.1.2",
"@angular-devkit/build-angular": "^16.0.0",
"@angular/cli": "^16.0.0",
"@angular/compiler-cli": "^16.0.0",
"@types/jasmine": "~4.3.1",
"@types/node": "^18.11.18",
"@types/node": "^18.16.6",
"@types/request": "^2.48.8",
"@types/urlsafe-base64": "^1.0.28",
"@types/uuid": "^9.0.0",
"@types/uuid": "^9.0.1",
"jasmine-core": "~4.5.0",
"karma": "~6.4.1",
"karma": "~6.4.2",
"karma-chrome-launcher": "~3.1.1",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.9.4"
"typescript": "~4.9.5"
}
}

View File

@ -45,7 +45,7 @@
style="margin-top: 10px;
margin-bottom: 20px;">
<div >&copy; 2023 Vergara Technologies LLC</div>
<div class="tiny">Version 2.1.0</div>
<div class="tiny">Version 2.2.0</div>
<div class="tiny">{{ vE.mainPriceData }}</div>
</div>
<div></div>

View File

@ -1,8 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { LanguageService } from './language.service';
import { LanguageData } from './language.model';
//import { Post} from './posts/post.model';
@Component({
selector: 'app-root',
@ -24,21 +22,21 @@ export class AppComponent {
}
ngOnInit(){
console.log('chgUILanguage() called on ngOnInit ');
//console.log('chgUILanguage() called on ngOnInit ');
this.chgUILanguage();
}
chgUILanguage() {
console.log('MAIN.chgUILanguage Called ');
this.languageService.getViewElements('main').subscribe(
response => {
console.log('response >> ', response );
console.log('main_price_data -> ',response.data.main_price_data);
//console.log('MAIN.chgUILanguage Called ');
this.languageService.getViewElements('main').subscribe({
next: response => {
//console.log('response >> ', response );
//console.log('main_price_data -> ',response.data.main_price_data);
this.vE.mainPriceData = response.data.main_price_data;
this.zgoLanguage = response.language;
},
error => { console.log('Error --> ',error); }
);
error: error => { console.log('Error --> ',error); }
});
}
usFlagClicked() {

View File

@ -1,57 +1,51 @@
import { Injectable } from '@angular/core';
import { CanActivate, Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import {HttpClient, HttpParams} from '@angular/common/http';
import { UserService } from './user.service';
import { Subscription, Observable } from 'rxjs';
import { Owner } from './owner.model';
import { Observable } from 'rxjs';
@Injectable()
export class AuthGuardService implements CanActivate {
private UserSub: Subscription = new Subscription();
export class AuthGuardService {
private addr = '';
private paid = false;
private paidUpdate: Observable<boolean>;
constructor(
private router: Router,
private http: HttpClient,
public userService: UserService
){
this.userService.findUser();
this.paidUpdate = this.userService.paidUpdate;
this.paidUpdate.subscribe((indicator) => {
this.paid = indicator;
});
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const token = localStorage.getItem('s4z_token');
var path = route.url[0].path;
if(token != null){
this.userService.uZaddrUpdate.
subscribe((addr) => {
if (addr != null) {
console.log(addr);
this.addr = addr;
} else {
console.log("No record for that token");
}
});
if (path === 'biz') {
if (this.addr.length > 0) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
this.userService.checkUser()?.subscribe( response => {
if (response.status == 200 && response.body?.validated) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
});
} else {
if (this.addr != null && this.paid) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
this.userService.checkUser()?.subscribe( response => {
if (response.status == 200 && response.body?.validated && this.paid) {
return true;
} else {
this.router.navigate(['/login']);
return false;
}
});
}
} else {
console.log("Not logged in");

View File

@ -13,6 +13,11 @@ mat-card.centercard{
font-family: 'Spartan', sans-serif;
font-size: 11px;
}
::ng-deep .mat-vertical-stepper-header{
pointer-events: none;
}
a.link{
text-decoration: underline;
}

View File

@ -2,7 +2,7 @@
<div align="center">
<mat-card class="centercard">
<h3>{{ vE.businessSignupTitle }}</h3>
<mat-vertical-stepper #stepper linear>
<mat-vertical-stepper #stepper [linear]="true">
<mat-step label="{{ vE.businessBizInfo }}" editable="false">
<p>{{ vE.businessAddrsNobiz }}</p>
<mat-card [formGroup]="bizForm">

View File

@ -15,7 +15,6 @@ import { ScanComponent } from '../scan/scan.component';
import { TermsComponent } from '../terms/terms.component';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-business',
@ -51,29 +50,19 @@ export class BusinessComponent implements OnInit {
countries: Country[] = [];
owner: Owner = {
address: '',
name: '',
currency: 'usd',
tax: false,
taxValue: 0,
vat: false,
vatValue: 0,
phone: '',
paid: false,
first: '',
last: '',
name: '',
street: '',
city: '',
state: '',
postal: '',
country: '',
email: '',
website: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
}
public countriesUpdate: Observable<Country[]>;
public ownerUpdate: Observable<Owner>;
@ -83,45 +72,59 @@ export class BusinessComponent implements OnInit {
sessionId = '';
ownerKnown = false;
termsChecked = false;
ownerdata = {
first: '',
last: '',
phone: '',
name: '',
street: '',
city: '',
state: '',
postal: '',
country: '',
email: '',
website: '',
payconf: false
};
// -------------------------------------
//
// Language Support
//
vE = {
businessSignupTitle : '',
businessBizInfo : '',
businessAddrsNobiz : '',
businessBizNamelbl : '',
businessBizNameholder : '',
businessContactFnamelbl : '',
businessContactFnholder : '',
businessContactLnamelbl : '',
businessContactLnholder : '',
businessBizAddresslbl : '',
businessBizAddressholder : '',
businessBizCitylbl : '',
businessBizCityholder : '',
businessBizStatelbl : '',
businessBizStateholder : '',
businessBizPcodelbl : '',
businessBizPcodeholder : '',
businessBizCountrylbl : '',
businessBizCountryholder : '',
businessBizMaillbl : '',
businessBizMailholder : '',
businessBizWebsitelbl : '',
businessBizWebsiteholder : '',
businessAcceptTerms : '',
businessTermsOfuse : '',
businessSaveBtn : '',
businessSessionLengthlbl : '',
businessSelectSession : '',
businessSessionLabel : '',
businessSessionPaylbl : '',
businessZGoConfirmlbl : ''
vE = {
businessSignupTitle : '',
businessBizInfo : '',
businessAddrsNobiz : '',
businessBizNamelbl : '',
businessBizNameholder : '',
businessContactFnamelbl : '',
businessContactFnholder : '',
businessContactLnamelbl : '',
businessContactLnholder : '',
businessBizAddresslbl : '',
businessBizAddressholder : '',
businessBizCitylbl : '',
businessBizCityholder : '',
businessBizStatelbl : '',
businessBizStateholder : '',
businessBizPcodelbl : '',
businessBizPcodeholder : '',
businessBizCountrylbl : '',
businessBizCountryholder : '',
businessBizMaillbl : '',
businessBizMailholder : '',
businessBizWebsitelbl : '',
businessBizWebsiteholder : '',
businessAcceptTerms : '',
businessTermsOfuse : '',
businessSaveBtn : '',
businessSessionLengthlbl : '',
businessSelectSession : '',
businessSessionLabel : '',
businessSessionPaylbl : '',
businessZGoConfirmlbl : ''
};
//
};
//
//
constructor(
private languageService : LanguageService,
@ -187,7 +190,7 @@ export class BusinessComponent implements OnInit {
}
onChange(ob: MatSlideToggleChange){
console.log(ob.checked);
//console.log(ob.checked);
this.termsChecked = ob.checked;
}
@ -196,25 +199,17 @@ export class BusinessComponent implements OnInit {
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
const dialogRef = this.dialog.open(TermsComponent, dialogConfig);
dialogRef.afterClosed().subscribe(val => {
console.log('Terms read');
});
this.dialog.open(TermsComponent, dialogConfig);
//dialogRef.afterClosed().subscribe(val => {
//console.log('Terms read');
//});
}
save() {
this.owner = {
_id: '',
address: '',
currency: 'usd',
tax: false,
taxValue: 0,
vat: false,
vatValue: 0,
this.ownerdata = {
first: this.bizForm.get('first')!.value,
last: this.bizForm.get('last')!.value,
phone: '',
paid: false,
name: this.bizForm.get('name')!.value,
street: this.bizForm.get('street')!.value,
city: this.bizForm.get('city')!.value,
@ -223,14 +218,9 @@ export class BusinessComponent implements OnInit {
country: this.bizForm.get('country')!.value,
email: this.bizForm.get('email')!.value,
website: this.bizForm.get('website')!.value,
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
payconf: false
};
this.userService.addOwner(this.owner);
this.userService.addOwner(this.ownerdata);
this.stepper!.next();
}
@ -248,7 +238,7 @@ export class BusinessComponent implements OnInit {
const dialogRef = this.dialog.open(ScanComponent, dialogConfig);
dialogRef.afterClosed().subscribe(val => {
console.log('Awaiting payment');
//console.log('Awaiting payment');
if(val){
this.stepper!.next();
}
@ -266,46 +256,46 @@ export class BusinessComponent implements OnInit {
}
chgUILanguage(){
console.log('BUSINESS.chgUILanguage Called ');
this.languageService.getViewElements('business').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('BUSINESS.chgUILanguage Called ');
this.languageService.getViewElements('business').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.businessSignupTitle = response.data.business_signup_title;
this.vE.businessBizInfo = response.data.business_biz_info;
this.vE.businessAddrsNobiz = response.data.business_addrs_nobiz;
this.vE.businessBizNamelbl = response.data.business_biz_namelbl;
this.vE.businessBizNameholder = response.data.business_biz_nameholder;
this.vE.businessContactFnamelbl = response.data.business_contact_fnamelbl;
this.vE.businessContactFnholder = response.data.business_contact_fnholder;
this.vE.businessContactLnamelbl = response.data.business_contact_lnamelbl;
this.vE.businessBizAddresslbl = response.data.business_biz_addresslbl;
this.vE.businessBizAddressholder = response.data.business_biz_addressholder;
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
this.vE.businessBizStatelbl = response.data.business_biz_statelbl;
this.vE.businessBizStateholder = response.data.business_biz_stateholder;
this.vE.businessBizPcodelbl = response.data.business_biz_pcodelbl;
this.vE.businessBizPcodeholder = response.data.business_biz_pcodeholder;
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
this.vE.businessBizCountrylbl = response.data.business_biz_countrylbl;
this.vE.businessBizCountryholder = response.data.business_biz_countryholder;
this.vE.businessBizMaillbl = response.data.business_biz_maillbl;
this.vE.businessBizMailholder = response.data.business_biz_mailholder;
this.vE.businessBizWebsitelbl = response.data.business_biz_websitelbl;
this.vE.businessBizWebsiteholder = response.data.business_biz_websiteholder;
this.vE.businessAcceptTerms = response.data.business_accept_terms;
this.vE.businessTermsOfuse = response.data.business_terms_ofuse;
this.vE.businessSaveBtn = response.data.business_save_btn;
this.vE.businessSessionLengthlbl = response.data.business_session_lengthlbl;
this.vE.businessSelectSession = response.data.business_select_session;
this.vE.businessSessionLabel = response.data.business_session_label;
this.vE.businessSessionPaylbl = response.data.business_session_paylbl;
this.vE.businessZGoConfirmlbl = response.data.business_zgo_confirmlbl;
this.vE.businessSignupTitle = response.data.business_signup_title;
this.vE.businessBizInfo = response.data.business_biz_info;
this.vE.businessAddrsNobiz = response.data.business_addrs_nobiz;
this.vE.businessBizNamelbl = response.data.business_biz_namelbl;
this.vE.businessBizNameholder = response.data.business_biz_nameholder;
this.vE.businessContactFnamelbl = response.data.business_contact_fnamelbl;
this.vE.businessContactFnholder = response.data.business_contact_fnholder;
this.vE.businessContactLnamelbl = response.data.business_contact_lnamelbl;
this.vE.businessBizAddresslbl = response.data.business_biz_addresslbl;
this.vE.businessBizAddressholder = response.data.business_biz_addressholder;
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
this.vE.businessBizStatelbl = response.data.business_biz_statelbl;
this.vE.businessBizStateholder = response.data.business_biz_stateholder;
this.vE.businessBizPcodelbl = response.data.business_biz_pcodelbl;
this.vE.businessBizPcodeholder = response.data.business_biz_pcodeholder;
this.vE.businessBizCitylbl = response.data.business_biz_citylbl;
this.vE.businessBizCityholder = response.data.business_biz_cityholder;
this.vE.businessBizCountrylbl = response.data.business_biz_countrylbl;
this.vE.businessBizCountryholder = response.data.business_biz_countryholder;
this.vE.businessBizMaillbl = response.data.business_biz_maillbl;
this.vE.businessBizMailholder = response.data.business_biz_mailholder;
this.vE.businessBizWebsitelbl = response.data.business_biz_websitelbl;
this.vE.businessBizWebsiteholder = response.data.business_biz_websiteholder;
this.vE.businessAcceptTerms = response.data.business_accept_terms;
this.vE.businessTermsOfuse = response.data.business_terms_ofuse;
this.vE.businessSaveBtn = response.data.business_save_btn;
this.vE.businessSessionLengthlbl = response.data.business_session_lengthlbl;
this.vE.businessSelectSession = response.data.business_select_session;
this.vE.businessSessionLabel = response.data.business_session_label;
this.vE.businessSessionPaylbl = response.data.business_session_paylbl;
this.vE.businessZGoConfirmlbl = response.data.business_zgo_confirmlbl;
},
error => { console.log('Error >> ',error); }

View File

@ -33,23 +33,13 @@ export class DbExportComponent implements OnInit {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
_ordersOk = false;

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {Subject, Subscription, BehaviorSubject, Observable} from 'rxjs';
import {BehaviorSubject, Observable} from 'rxjs';
import {HttpClient, HttpParams, HttpHeaders} from '@angular/common/http';
import {UserService} from './user.service';
import { Owner } from './owner.model';
@ -12,6 +12,7 @@ var Buffer = require('buffer/').Buffer;
@Injectable({providedIn: 'root'})
export class FullnodeService{
beUrl = ConfigData.Be_URL;
private session: null|string = '';
private dataStore: { height: number, memoList: string[], addr: string, price: number } = { height: 0, memoList: [], addr: '', price:0 };
private _heightUpdated: BehaviorSubject<number> = new BehaviorSubject(this.dataStore.height);
private _memoUpdated: BehaviorSubject<string[]> = new BehaviorSubject(this.dataStore.memoList);
@ -22,8 +23,8 @@ export class FullnodeService{
public readonly memoUpdate: Observable<string[]> = this._memoUpdated.asObservable();
public readonly priceUpdate: Observable<number> = this._priceUpdated.asObservable();
public readonly ownerUpdate: Observable<Owner>;
private UserSub: Subscription = new Subscription();
private reqHeaders: HttpHeaders;
private params : HttpParams;
private owner: Owner = {
_id: '',
name: '',
@ -33,26 +34,18 @@ export class FullnodeService{
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
constructor(private http: HttpClient, public userService: UserService){
this.session = localStorage.getItem('s4z_token');
this.params = new HttpParams().append('session', this.session!);
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.ownerUpdate = userService.ownerUpdate;
@ -65,7 +58,7 @@ export class FullnodeService{
}
getHeight(){
let obs = this.http.get<{message: string, height: number}>(this.beUrl+'api/blockheight', { headers: this.reqHeaders });
let obs = this.http.get<{message: string, height: number}>(this.beUrl+'blockheight', { headers: this.reqHeaders, params: this.params });
obs.subscribe((BlockData) => {
this.dataStore.height = BlockData.height;
this._heightUpdated.next(Object.assign({}, this.dataStore).height);
@ -76,8 +69,8 @@ export class FullnodeService{
getPrice(currency: string){
//var currency = 'usd';
const params = new HttpParams().append('currency', currency);
let obs = this.http.get<{message: string, price: any}>(this.beUrl+'api/price', { headers:this.reqHeaders, params: params, observe: 'response'});
const params = this.params.append('currency', currency);
let obs = this.http.get<{message: string, price: any}>(this.beUrl+'price', { headers:this.reqHeaders, params: params, observe: 'response'});
obs.subscribe((PriceData) => {
if (PriceData.status == 200) {
this.dataStore.price = PriceData.body!.price.price;
@ -92,7 +85,7 @@ export class FullnodeService{
}
getAddr() {
let obs = this.http.get<{message: string, addr: string}>(this.beUrl+'api/getaddr', { headers: this.reqHeaders });
let obs = this.http.get<{message: string, addr: string}>(this.beUrl+'getaddr', { headers: this.reqHeaders, params: this.params });
obs.subscribe((AddrData) => {
this.dataStore.addr = AddrData.addr;

View File

@ -4,12 +4,11 @@ import { FullnodeService } from '../fullnode.service';
import { Router } from '@angular/router';
import { UserService } from '../user.service';
import { CancelComponent } from '../cancel/cancel.component';
import { Subscription, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import {Owner} from '../owner.model';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-header',
@ -29,25 +28,14 @@ export class HeaderComponent implements OnInit, OnDestroy {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
private session: string | null = '';
public heightUpdate: Observable<number>;
public ownerUpdate: Observable<Owner>;
public uZaddrUpdate: Observable<string>;
@ -99,14 +87,14 @@ export class HeaderComponent implements OnInit, OnDestroy {
msg1: this.vE.headerLogoutMsg1,
msg2: this.vE.headerLogoutMsg2 };
console.log(dialogConfig.data);
//console.log(dialogConfig.data);
const dialogRef = this.dialog.open(CancelComponent, dialogConfig);
dialogRef.afterClosed().subscribe(val => {
if(val){
// console.log('Logout!');
this.userService.deleteUser().subscribe(UserResponse => {
console.log('Rerouting');
//console.log('Rerouting');
this.userService.findUser();
this.router.navigate(['/login']);
});
@ -115,13 +103,13 @@ export class HeaderComponent implements OnInit, OnDestroy {
}
chgUILanguage(){
console.log('HEADER.chgUILanguage Called ');
this.languageService.getViewElements('header').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('HEADER.chgUILanguage Called ');
this.languageService.getViewElements('header').subscribe({
next: 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.headerLastBlock = response.data.header_last_block;
this.vE.headerGetCurrency = response.data.header_get_currency;
@ -130,8 +118,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.vE.headerLogoutMsg2 = response.data.header_logout_msg2;
},
error => { console.log('Error >> ',error); }
);
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -1,4 +1,4 @@
import { Input, Inject, Component, OnInit } from '@angular/core';
import { Input, Component, OnInit } from '@angular/core';
import { MatDialog, MatDialogConfig} from '@angular/material/dialog';
import { faCartShopping } from '@fortawesome/free-solid-svg-icons';
@ -17,7 +17,6 @@ import { ItemAddComponent } from '../item-add/item-add.component';
import { NotifierService } from '../../notifier.service';
import { LanguageService } from '../../language.service';
import { LanguageData } from '../../language.model';
@Component({
selector: 'app-item-list',
@ -42,23 +41,13 @@ export class ItemListComponent implements OnInit{
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
public ownerUpdate: Observable<Owner>;
@ -119,7 +108,7 @@ export class ItemListComponent implements OnInit{
if(val != null) {
var item:Item = {_id: '', name: val.name, description: val.description, cost: val.cost, owner: this.owner.address};
this.itemService.addItem(item);
console.log('creando item y llamando a notifier >>>');
//console.log('creando item y llamando a notifier >>>');
this.notifierService
.showNotification(this.vE.itemlistItemAdded ,
this.vE.itemlistNotifClose,
@ -142,7 +131,7 @@ export class ItemListComponent implements OnInit{
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
dialogConfig.data = item;
console.log('Entrando a dialogo de edicion')
//console.log('Entrando a dialogo de edicion')
const dialogRef = this.dialog.open(ItemEditComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {
if (val != null) {
@ -153,8 +142,8 @@ export class ItemListComponent implements OnInit{
cost: val.cost,
owner: this.owner.address
};
console.log('Edit:', editItem);
console.log('itemlistItemUpdated = ' + this.vE.itemlistItemUpdated);
//console.log('Edit:', editItem);
//console.log('itemlistItemUpdated = ' + this.vE.itemlistItemUpdated);
this.itemService.addItem(editItem).subscribe((response) => {
this.itemService.getItems(this.owner.address);
});
@ -213,7 +202,7 @@ export class ItemListComponent implements OnInit{
const dialogRef = this.dialog.open(ItemAddComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {
if (val != null) {
console.log('Adding to order', val);
//console.log('Adding to order', val);
this.orderService.addToOrder(val);
}
this.itemService.getItems(this.owner.address);
@ -225,13 +214,13 @@ export class ItemListComponent implements OnInit{
}
chgUILanguage(){
console.log('ITEMLIST.chgUILanguage Called ');
this.languageService.getViewElements('itemlist').subscribe(
//console.log('ITEMLIST.chgUILanguage Called ');
this.languageService.getViewElements('itemlist').subscribe({next:
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('Received >> ', response );
//console.log('Language Code : ', response.language);
//console.log('Component Name : ',response.component);
//console.log('Language data : ',response.data);
this.vE.itemlistListEmpty = response.data.itemlist_list_empty;
this.vE.itemlistAvailItems = response.data.itemlist_avail_items;
@ -241,8 +230,9 @@ export class ItemListComponent implements OnInit{
this.vE.itemlistNotifClose = response.data.itemlist_notif_close;
this.vE.itemlistNotifSuccess = response.data.itemlist_notif_success;
},
error:
error => { console.log('Error >> ',error); }
);
});
}
}

View File

@ -1,6 +1,6 @@
import { Item } from './item.model';
import { Injectable } from '@angular/core';
import { Subject, BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { ConfigData } from '../configdata';
@ -10,27 +10,29 @@ var Buffer = require('buffer/').Buffer;
@Injectable({providedIn: 'root'})
export class ItemService{
// beUrl = 'https://test.zgo.cash/';
beUrl = ConfigData.Be_URL;
// console.log(ConfigData.Be_URL);
private dataStore: { items: Item[] } = { items: [] } ;
private _itemsUpdated: BehaviorSubject<Item[]> = new BehaviorSubject(this.dataStore.items);
public readonly itemsUpdated: Observable<Item[]> = this._itemsUpdated.asObservable();
private address:string = '';
private reqHeaders: HttpHeaders;
private session: null|string;
private params: HttpParams;
constructor(private http: HttpClient){
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.session = localStorage.getItem('s4z_token');
this.params = new HttpParams().append('session', this.session!);
}
getItems(addr: string){
this.address = addr;
const params = new HttpParams().append('address', addr);
let obs = this.http.get<{message: string, items: any}>(this.beUrl+'api/items', { headers:this.reqHeaders, params: params, observe: 'response'});
const newParams = this.params.append('address', addr);
let obs = this.http.get<{message: string, items: any}>(this.beUrl+'api/items', { headers:this.reqHeaders, params: newParams, observe: 'response'});
obs.subscribe((ItemDataResponse) => {
if (ItemDataResponse.status == 200 ) {
@ -39,7 +41,6 @@ export class ItemService{
} else {
this.dataStore.items = [];
this._itemsUpdated.next(Object.assign({},this.dataStore).items);
// console.log('No items found');
}
});
@ -47,11 +48,9 @@ export class ItemService{
}
addItem(item: Item) {
//const params = new HttpParams().append('item', JSON.stringify(item));
let obs = this.http.post<{message: string}>(this.beUrl+'api/item', { payload: item }, { headers: this.reqHeaders });
let obs = this.http.post<{message: string}>(this.beUrl+'api/item', { payload: item }, { headers: this.reqHeaders, params: this.params });
obs.subscribe((ItemResponse) => {
// console.log('Item added');
obs.subscribe(() => {
this.getItems(this.address);
});
@ -59,10 +58,9 @@ export class ItemService{
}
deleteItem(id: string) {
let obs = this.http.delete<{message: string}>(this.beUrl+'api/item/'+id, { headers: this.reqHeaders });
let obs = this.http.delete<{message: string}>(this.beUrl+'api/item/'+id, { headers: this.reqHeaders, params: this.params });
obs.subscribe((ItemResponse) => {
// console.log('Item deleted');
obs.subscribe(() => {
this.getItems(this.address);
});

View File

@ -19,10 +19,16 @@ export class LanguageService {
//
// URL for access MongoDB database from remote server
private baseURL = ConfigData.Be_URL + 'api/getlang';
private loginURL = ConfigData.Be_URL + 'getloginlang';
private mainURL = ConfigData.Be_URL + 'getmainlang';
private scanURL = ConfigData.Be_URL + 'getscanlang';
public zgoLanguage: string = '';
private session: string|null = '';
constructor(private http:HttpClient) {
this.session = localStorage.getItem('s4z_token');
}
getViewElements ( viewName:string ) {
@ -45,10 +51,21 @@ export class LanguageService {
//
// Get component's text data from language database
//
return this.http.get<LanguageData>(this.baseURL +
'/?lang=' + this.zgoLanguage +
'&component=' + viewName
,{ headers : reqHeaders }
);
const params = new HttpParams().append('session', this.session!);
if (viewName === 'login') {
return this.http.get<LanguageData>(this.loginURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else if (viewName === 'main') {
return this.http.get<LanguageData>(this.mainURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else if (viewName === 'scan') {
return this.http.get<LanguageData>(this.scanURL + '/?lang=' + this.zgoLanguage, {headers: reqHeaders, params: params});
} else {
return this.http.get<LanguageData>(this.baseURL +
'/?lang=' + this.zgoLanguage +
'&component=' + viewName
,{ headers : reqHeaders
, params: params
}
);
}
}
}

View File

@ -20,7 +20,6 @@ import { faHourglass } from '@fortawesome/free-solid-svg-icons';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
import {SessionpayComponent} from '../sessionpay/sessionpay.component';
@Component({
@ -55,23 +54,13 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
zecPrice: number = 1;
nodeAddress: string = '';
@ -140,7 +129,7 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
var today = new Date();
this.orders = orders;
console.log(this.ownerUpdate);
//console.log(this.ownerUpdate);
for (let i=0; i < this.orders.length; i++){
this.total += this.orders[i].totalZec;
//
@ -217,7 +206,7 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
openDbExport(){
const dialogConfig = new MatDialogConfig();
console.log('openDbExport ---');
//console.log('openDbExport ---');
dialogConfig.disableClose = false;
dialogConfig.autoFocus = true;
@ -230,33 +219,33 @@ export class ListOrdersComponent implements OnInit, OnDestroy{
}
chgUILanguage(){
console.log('LISTORDERS.chgUILanguage Called ');
this.languageService.getViewElements('listorders').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
chgUILanguage(){
//console.log('LISTORDERS.chgUILanguage Called ');
this.languageService.getViewElements('listorders').subscribe({
next: 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.listordersBacktoshopBtn = response.data.listorders_backtoshop_btn;
this.vE.listordersExportOrders = response.data.listorders_export_orders;
this.vE.listordersTodaysTotal = response.data.listorders_todays_total;
this.vE.listordersOverallTotal = response.data.listorders_overall_total;
this.vE.listordersOrderId = response.data.listorders_order_id;
this.vE.listordersOrderTotal = response.data.listorders_order_total;
this.vE.listordersItemLbl = response.data.listorders_item_lbl;
this.vE.listordersQtyLbl = response.data.listorders_qty_lbl;
this.vE.listordersTotalLbl = response.data.listorders_total_lbl;
this.vE.listordersInvoiceBtn = response.data.listorders_invoice_btn;
this.vE.listordersReceiptBtn = response.data.listorders_receipt_btn;
this.vE.listordersNoOrders = response.data.listorders_no_orders;
this.vE.listordersEndDate = response.data.listorders_end_date;
this.vE.listordersBacktoshopBtn = response.data.listorders_backtoshop_btn;
this.vE.listordersExportOrders = response.data.listorders_export_orders;
this.vE.listordersTodaysTotal = response.data.listorders_todays_total;
this.vE.listordersOverallTotal = response.data.listorders_overall_total;
this.vE.listordersOrderId = response.data.listorders_order_id;
this.vE.listordersOrderTotal = response.data.listorders_order_total;
this.vE.listordersItemLbl = response.data.listorders_item_lbl;
this.vE.listordersQtyLbl = response.data.listorders_qty_lbl;
this.vE.listordersTotalLbl = response.data.listorders_total_lbl;
this.vE.listordersInvoiceBtn = response.data.listorders_invoice_btn;
this.vE.listordersReceiptBtn = response.data.listorders_receipt_btn;
this.vE.listordersNoOrders = response.data.listorders_no_orders;
this.vE.listordersEndDate = response.data.listorders_end_date;
},
error => { console.log('Error >> ',error); }
);
}
},
error: error => { console.log('Error >> ',error); }
});
}
paySession() {
const dialogConfig = new MatDialogConfig();

View File

@ -2,7 +2,7 @@
<mat-card class="coolcard">
<mat-card-content>
<img mat-card-image src="/assets/logo-new-white_01.png" height="120px" />
<p class="text">{{ vE.loginLastBlock }}<span class="numbers">{{ heightUpdate | async }}</span></p>
<p class="text">{{ vE.loginLastBlock }}<span class="numbers"> {{ heightUpdate | async }}</span></p>
</mat-card-content>
</mat-card>
</div>

View File

@ -1,7 +1,7 @@
import { Component, OnInit, OnDestroy, Injectable, ChangeDetectorRef, ViewChild, AfterViewInit } from '@angular/core';
import { CanActivate, Router, RouterStateSnapshot, ActivatedRouteSnapshot, ActivatedRoute } from '@angular/router';
import { Component, OnInit, ChangeDetectorRef, ViewChild, AfterViewInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { MatDialog, MatDialogConfig} from '@angular/material/dialog';
import { UntypedFormBuilder, Validators, UntypedFormGroup, FormControl } from '@angular/forms';
import { UntypedFormBuilder, Validators, UntypedFormGroup } from '@angular/forms';
import { ProgressBarMode } from '@angular/material/progress-bar';
import { MatStepper } from '@angular/material/stepper';
import { UserService } from '../user.service';
@ -11,15 +11,9 @@ import { Tx } from '../tx.model';
import { User } from '../user.model';
import { Owner } from '../owner.model';
import { Subscription, Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { v4 as uuidv4 } from 'uuid';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
var QRCode = require('easyqrcodejs');
var URLSafeBase64 = require('urlsafe-base64');
var Buffer = require('buffer/').Buffer;
@Component({
selector: 'app-login',
@ -49,23 +43,13 @@ export class LoginComponent implements OnInit, AfterViewInit {
taxValue:0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
private FullnodeSub: Subscription = new Subscription();
private UserSub: Subscription = new Subscription();
@ -73,7 +57,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
public uZaddrUpdate: Observable<string>;
public userUpdate: Observable<User>;
public ownerUpdate: Observable<Owner>;
public txsUpdate: Observable<Tx[]>;
//public txsUpdate: Observable<Tx[]>;
prompt: boolean = false;
confirmedMemo: boolean = false;
targetBlock: number = 0;
@ -82,7 +66,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
barMessage = 'Scanning blockchain for login memo, please wait.';
@ViewChild('stepper') private myStepper?: MatStepper;
entryForm: UntypedFormGroup;
pinForm: UntypedFormGroup;
//
@ -112,9 +95,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
){
//this.fullnodeService.getAddr();
this.entryForm = fb.group({
selectedSession: [0.001, Validators.required]
});
this.pinForm = fb.group({
pinValue: [null, Validators.required]
});
@ -128,10 +108,10 @@ export class LoginComponent implements OnInit, AfterViewInit {
this.ownerUpdate.subscribe((owner) => {
this.owner = owner;
});
this.txsUpdate = userService.txUpdate;
this.txsUpdate.subscribe((txs) => {
this.txs = txs;
});
//this.txsUpdate = userService.txUpdate;
//this.txsUpdate.subscribe((txs) => {
//this.txs = txs;
//});
}
ngAfterViewInit(){
@ -158,34 +138,35 @@ export class LoginComponent implements OnInit, AfterViewInit {
this.chgUILanguage();
this.intervalHolder = setInterval(() => {
this.fullnodeService.getHeight();
//this.userService.findUser();
this.loginCheck();
this._changeDetectorRef.markForCheck();
}, 1000 * 60);
}
loginCheck(){
this.userService.findUser();
this.userUpdate.subscribe((user) => {
if (user.blocktime > 0) {
if(this.myStepper!.selectedIndex === 0) {
this.myStepper!.next();
this.myStepper!.next();
} else {
if(this.myStepper!.selectedIndex === 1){
this.userService.checkUser()!.subscribe({
next: (checkResponse) => {
if (checkResponse.status == 200) {
console.log('checkUser true');
if(this.myStepper!.selectedIndex === 0) {
this.myStepper!.next();
this.myStepper!.next();
}
}
//console.log('Log in found in blockchain!');
if (user.validated) {
clearInterval(this.intervalHolder);
if (this.owner.paid) {
this.router.navigate(['/shop']);
} else {
if(this.myStepper!.selectedIndex === 1){
this.myStepper!.next();
}
}
if(checkResponse.body!.validated) {
console.log('redirecting to biz');
this.userService.getOwner();
this.router.navigate(['/biz']);
clearInterval(this.intervalHolder);
} else {
console.log('validated failed');
}
}
}
},
error: (error) => {console.log(error);}
});
}
@ -229,13 +210,13 @@ export class LoginComponent implements OnInit, AfterViewInit {
}
chgUILanguage(){
console.log('LOGIN.chgUILanguage Called ');
//console.log('LOGIN.chgUILanguage Called ');
this.languageService.getViewElements('login').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('Received >> ', response );
//console.log('Language Code : ', response.language);
//console.log('Component Name : ',response.component);
//console.log('Language data : ',response.data);
this.vE.loginLastBlock = response.data.login_last_block;
this.vE.loginConnectToZGo = response.data.login_connect_to_zgo;

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
@ -9,13 +9,13 @@ import { FullnodeService} from './fullnode.service';
providedIn: 'root'
})
export class NodeResolverService implements Resolve<any> {
export class NodeResolverService {
constructor(private fullnode: FullnodeService) {}
resolve(route: ActivatedRouteSnapshot): Observable<any> {
console.log('Called getAddr in resolver...', route);
//console.log('Called getAddr in resolver...', route);
return this.fullnode.getAddr().pipe(
catchError(error => {
catchError(() => {
return of('No data');
})
);

View File

@ -106,7 +106,7 @@ export class OrderComponent implements OnInit{
this.orderUpdate.subscribe((order) => {
this.order = order;
console.log('this.order > ' + JSON.stringify(this.order));
//console.log('this.order > ' + JSON.stringify(this.order));
// ------------------------------------------------
this.oLines = [];
this.myLines = this.order.lines;
@ -150,7 +150,7 @@ export class OrderComponent implements OnInit{
const dialogRef = this.dialog.open(CancelComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {
if (val) {
console.log('Canceling');
//console.log('Canceling');
this.orderService.cancelOrder(this.order._id!).subscribe((response) => {
this.orderService.getOrder();
this.notifierService
@ -159,9 +159,10 @@ export class OrderComponent implements OnInit{
'success',
this.vE.orderNotservSuccess);
});
} else {
console.log('Returning to page');
}
//else {
//console.log('Returning to page');
//}
this.orderService.getOrder();
this.oLines = [];
});
@ -215,7 +216,7 @@ export class OrderComponent implements OnInit{
orderId: this.order._id
};
console.log ('order_id : ' + this.order._id);
//console.log ('order_id : ' + this.order._id);
const dialogRef = this.dialog.open(PromptInvoiceComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {
@ -276,13 +277,13 @@ export class OrderComponent implements OnInit{
}
chgUILanguage(){
console.log('ORDER.chgUILanguage Called ');
this.languageService.getViewElements('order').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('ORDER.chgUILanguage Called ');
this.languageService.getViewElements('order').subscribe({
next: 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.orderNoOpenorder = response.data.order_no_openorder;
this.vE.orderCancelOrder = response.data.order_cancel_order;
@ -302,8 +303,8 @@ export class OrderComponent implements OnInit{
this.vE.orderCheckoutBtn = response.data.order_checkout_btn;
},
error => { console.log('Error >> ',error); }
);
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Subject, BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Order } from './order.model';
import { UserService } from '../user.service';
@ -35,23 +35,13 @@ export class OrderService {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
},
order: {
address: '',
@ -83,6 +73,8 @@ export class OrderService {
public userUpdate: Observable<User>;
public ownerUpdate: Observable<Owner>;
private reqHeaders: HttpHeaders;
private reqParams: HttpParams;
private session: null|string;
constructor(
private http: HttpClient,
@ -90,12 +82,13 @@ export class OrderService {
public userService: UserService
) {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.session = localStorage.getItem('s4z_token');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.reqParams = new HttpParams().append('session', this.session!);
this.userUpdate = userService.userUpdate;
this.ownerUpdate = userService.ownerUpdate;
this.userUpdate.subscribe((user) => {
this.dataStore.user = user;
//console.log('OS: const', user);
this.getOrder();
});
this.ownerUpdate.subscribe((owner) => {
@ -104,9 +97,7 @@ export class OrderService {
}
getOrder() {
var session = this.dataStore.user.session;
const params = new HttpParams().append('session', session);
let obs = this.http.get<{message: string, order: any}>(this.beUrl+'api/order', { headers:this.reqHeaders, params:params, observe: 'response'});
let obs = this.http.get<{message: string, order: any}>(this.beUrl+'api/order', { headers:this.reqHeaders, params: this.reqParams, observe: 'response'});
obs.subscribe((OrderDataResponse) => {
if (OrderDataResponse.status == 200) {
@ -127,7 +118,7 @@ export class OrderService {
getAllOrders(){
var address = this.dataStore.user.address;
const params = new HttpParams().append('address', address);
const params = this.reqParams.append('address', address);
let obs = this.http.get<{message: string, orders: any}>(this.beUrl+'api/allorders', { headers:this.reqHeaders, params:params, observe: 'response'});
obs.subscribe((OrdersData) => {
if (OrdersData.status == 200 ){
@ -145,7 +136,7 @@ export class OrderService {
addToOrder(lineItem: LineItem) {
if(this.dataStore.order._id != null) {
this.dataStore.order.lines.push(lineItem);
let obs = this.http.post(this.beUrl+'api/order', { payload: this.dataStore.order }, { headers: this.reqHeaders });
let obs = this.http.post(this.beUrl+'api/order', { payload: this.dataStore.order }, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((orderData) => {
this.getOrder();
});
@ -170,7 +161,7 @@ export class OrderService {
shortCode: '',
lines: [lineItem]
};
let obs = this.http.post<{message: string, order: Order}>(this.beUrl+'api/order', {payload: order}, { headers: this.reqHeaders });
let obs = this.http.post<{message: string, order: Order}>(this.beUrl+'api/order', {payload: order}, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((orderData) => {
console.log('Created order');
this.getOrder()
@ -180,7 +171,7 @@ export class OrderService {
}
cancelOrder(id: string) {
let obs = this.http.delete<{message: string}>(this.beUrl+'api/order/'+id, { headers: this.reqHeaders });
let obs = this.http.delete<{message: string}>(this.beUrl+'api/order/'+id, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((OrderResponse) => {
console.log('Order deleted');
@ -217,7 +208,7 @@ export class OrderService {
});
this.dataStore.order.closed = true;
this.dataStore.order.paid = paid;
let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders });
let obs = this.http.post(this.beUrl+'api/order', {payload: this.dataStore.order}, { headers: this.reqHeaders, params: this.reqParams });
obs.subscribe((orderData) => {
console.log('Closed order', orderData);
this.dataStore.order = {

View File

@ -7,21 +7,11 @@ export interface Owner {
taxValue: number;
vat: boolean;
vatValue: number;
first: string;
last: string;
email: string;
street: string;
city: string;
state: string;
postal: string;
phone: string;
paid: boolean;
website: string;
country: string;
zats: boolean;
invoices: boolean;
expiration: string;
payconf: boolean;
viewkey: string;
crmToken: string;
viewkey: string;
}

View File

@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from "@angular/router";
import { ActivatedRoute} from "@angular/router";
import { HttpClient, HttpParams, HttpHeaders } from "@angular/common/http";
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { PmtData } from "./pmtservice.model";
@ -17,7 +17,6 @@ var URLSafeBase64 = require('urlsafe-base64');
var Buffer = require('buffer/').Buffer;
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-pmtservice',
@ -64,23 +63,13 @@ export class PmtserviceComponent implements OnInit {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
public order: Order = {

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Subject, BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Order } from './order/order.model';
import { Owner } from './owner.model';
@ -24,23 +24,13 @@ export class ReceiptService {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
},
order: {
address: '',
@ -69,25 +59,28 @@ export class ReceiptService {
public readonly nameUpdate: Observable<string>= this._nameUpdated.asObservable();
public readonly ownerUpdate;
private reqHeaders: HttpHeaders;
private session: null|string;
private params: HttpParams;
constructor(
constructor(
private http: HttpClient,
public userService: UserService
) {
) {
this.session = localStorage.getItem('s4z_token');
this.params = new HttpParams().append('session', this.session!);
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.ownerUpdate = userService.ownerUpdate;
}
}
getOrderById(id:string) {
//const params = new HttpParams().append('id', id);
let obs = this.http.get<{message: string, order: any}>(this.beUrl+'api/order/'+id, { headers:this.reqHeaders, observe: 'response'});
let obs = this.http.get<{message: string, order: any}>(this.beUrl+'api/order/'+id, { headers:this.reqHeaders, params: this.params, observe: 'response'});
obs.subscribe((OrderDataResponse) => {
if (OrderDataResponse.status == 200) {
this.dataStore.order = OrderDataResponse.body!.order;
this._orderUpdated.next(Object.assign({}, this.dataStore).order);
this.userService.getOwner(this.dataStore.order.address);
this.userService.getOwner();
this.ownerUpdate.subscribe((owner) => {
this.dataStore.owner = owner;
this._nameUpdated.next(Object.assign({}, this.dataStore).owner.name);

View File

@ -5,7 +5,6 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { NotifierService } from '../notifier.service';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
var QRCode = require('easyqrcodejs');
var URLSafeBase64 = require('urlsafe-base64');
@ -148,13 +147,14 @@ export class ScanComponent implements OnInit{
}
chgUILanguage(){
console.log('SCAN.chgUILanguage Called ');
this.languageService.getViewElements('scan').subscribe(
//console.log('SCAN.chgUILanguage Called ');
this.languageService.getViewElements('scan').subscribe({
next:
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('Received >> ', response );
//console.log('Language Code : ', response.language);
//console.log('Component Name : ',response.component);
//console.log('Language data : ',response.data);
this.vE.scanScanqrCode = response.data.scan_scanqr_code;
this.vE.scanTextInfo = response.data.scan_text_info;
@ -172,8 +172,8 @@ export class ScanComponent implements OnInit{
this.vE.scanOrButton = response.data.scan_or_button;
},
error => { console.log('Error >> ',error); }
);
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -34,6 +34,7 @@ export class SettingsComponent implements OnInit {
linkMsg: string = '';
xeroAccCod: string = '';
saveAccOk: boolean = false;
private viewkey: string = '';
coins = [
{
@ -126,25 +127,26 @@ export class SettingsComponent implements OnInit {
public xeroService: XeroService,
public wooService: WoocommerceService,
private dialogRef: MatDialogRef<SettingsComponent>,
@Inject(MAT_DIALOG_DATA) public data: Owner) {
this.useZats = data.zats;
this.useVKey = data.payconf;
@Inject(MAT_DIALOG_DATA) public data: {o: Owner}) {
this.useZats = data.o.zats;
this.useVKey = data.o.payconf;
this.settingsForm = fb.group({
name: [data.name, Validators.required],
currency: [data.currency, Validators.required],
useZats: [data.zats, Validators.required],
useVKey: [data.payconf, Validators.required],
name: [data.o.name, Validators.required],
currency: [data.o.currency, Validators.required],
useZats: [data.o.zats, Validators.required],
useVKey: [data.o.payconf, Validators.required],
// proVersion: [data.invoices, Validators.required],
vKey: [data.viewkey]
vKey: [data.o.viewkey]
});
this.accCodForm = fb.group ({
xAcc: [this.xeroAccCod]
});
if (data.payconf) {
if (data.o.payconf) {
this.settingsForm.get('vKey')!.enable();
}
this.owner = data;
this.owner = data.o;
this.viewkey = data.o.viewkey;
this.proVersion = this.owner.invoices;
if ( this.owner.crmToken !== '' ) {
this.linked2Xero = true;
@ -159,7 +161,7 @@ export class SettingsComponent implements OnInit {
xeroService.getXeroAccountCode(this.owner.address);
this.accCodeUpdate.subscribe(accData => {
this.xeroAccCod = accData;
console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
//console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod);
});
this.wooOwnerUpdate = wooService.ownerUpdate;
@ -183,7 +185,7 @@ export class SettingsComponent implements OnInit {
this.settingsForm.get('vKey')!.disable();
//
this.chgUILanguage();
console.log('SETTINGS: Return from chgUILanguage()');
//console.log('SETTINGS: Return from chgUILanguage()');
//
this.languageRdy.subscribe (
data => {
@ -222,7 +224,7 @@ export class SettingsComponent implements OnInit {
this.owner.currency = this.settingsForm.value.currency;
this.owner.zats = this.settingsForm.value.useZats;
this.owner.payconf = this.settingsForm.value.useVKey;
this.owner.viewkey = this.settingsForm.value.vKey;
this.viewkey = this.settingsForm.value.vKey;
//this.owner.invoices = this.settingsForm.value.proVersion
this.dialogRef.close(this.owner);
}
@ -332,32 +334,33 @@ export class SettingsComponent implements OnInit {
saveAccCod() {
this.xeroAccCod = this.accCodForm.value.xAcc;
console.log(">>> " + this.xeroAccCod);
//console.log(">>> " + this.xeroAccCod);
if ( this.xeroAccCod.length <= 10 ) {
const obs = this.xeroService
.setXeroAccountCode(this.owner.address,
this.xeroAccCod);
obs.subscribe(responseData => {
if (responseData.status == 202) {
console.log('Account saved');
this.notifierService
.showNotification(this.vE.settingsAcodeSaved,
this.vE.settingsNotservClose,
"success",
this.vE.settingsNotservSuccess);
} else {
console.log('Account not saved -> status[' + responseData.status + ']');
this.notifierService
.showNotification(
this.vE.settingsAcodeNotsaved,
this.vE.settingsNotservClose,
"error",
this.vE.settingsNotservError);
}
obs.subscribe({ next: responseData => {
if (responseData.status == 202) {
//console.log('Account saved');
this.notifierService
.showNotification(this.vE.settingsAcodeSaved,
this.vE.settingsNotservClose,
"success",
this.vE.settingsNotservSuccess);
} else {
//console.log('Account not saved -> status[' + responseData.status + ']');
this.notifierService
.showNotification(
this.vE.settingsAcodeNotsaved,
this.vE.settingsNotservClose,
"error",
this.vE.settingsNotservError);
}
}, error => {
console.log('Error saving Account Code -> ' + error.msg)
});
},
error: error => {
//console.log('Error saving Account Code -> ' + error.msg)
}});
} else {
this.notifierService
@ -376,63 +379,63 @@ export class SettingsComponent implements OnInit {
}
*/
checkStatus( arg : any ) {
console.log('onChange - checkStatus');
console.log(arg.target.value);
//console.log('onChange - checkStatus');
//console.log(arg.target.value);
this.saveAccOk = (arg.target.value != this.xeroAccCod );
}
chgUILanguage(){
console.log('SETTINGS.chgUILanguage Called ');
this.languageService.getViewElements('settings').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('SETTINGS.chgUILanguage Called ');
this.languageService.getViewElements('settings').subscribe({
next: 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.settingsViewTitle = response.data.settings_view_title;
this.vE.settingsTabMainlbl = response.data.settings_tab_mainlbl;
this.vE.settingsNameLbl = response.data.settings_name_lbl;
this.vE.settingsCurrencyLbl = response.data.settings_currency_lbl;
this.vE.settingsNamePlaceholder = response.data.settings_name_placeholder;
this.vE.settingsUseSatoshi = response.data.settings_use_satoshi;
this.vE.settingsVkeyLbl = response.data.settings_vkey_lbl;
this.vE.settingsVkeyPlaceholder = response.data.settings_vkey_placeholder;
this.vE.settingsConfirmPayments = response.data.settings_confirm_payments;
this.vE.settingsCloseBtn = response.data.settings_close_btn;
this.vE.settingsSaveBtn = response.data.settings_save_btn;
this.vE.settingsTabIntegrations = response.data.settings_tab_integrations;
this.vE.settingsXeroLbl = response.data.settings_xero_lbl;
this.vE.settingsLink2Xero = response.data.settings_link_2xero;
this.vE.settingsRelink2Xero = response.data.settings_relink_2xero;
this.vE.settingsXeropmtConfirmdis = response.data.settings_xeropmt_confirmdis;
this.vE.settingsNotservClose = response.data.settings_notserv_close;
this.vE.settingsNotservWarning = response.data.settings_notserv_warning;
this.vE.settingsPmtservURL = response.data.settings_pmtserv_url;
this.vE.settingsAcodeLbl = response.data.settings_acode_lbl;
this.vE.settingsXeroClosebtn = response.data.settings_xero_closebtn;
this.vE.settingsXeroSavebtn = response.data.settings_xero_savebtn;
this.vE.settingsWCLbl = response.data.settings_wc_lbl;
this.vE.settingsWCGentoken = response.data.settings_wc_gentoken;
this.vE.settingsWCOwnerlbl = response.data.settings_wc_ownerlbl;
this.vE.settingsWCClosebtn = response.data.settings_wc_closebtn;
this.vE.settingsURLCopied = response.data.settings_url_copied;
this.vE.settingsNotservSuccess = response.data.settings_notserv_success;
this.vE.settingsNotservError = response.data.settings_notserv_error;
this.vE.settingsCopyNotavail = response.data.settings_copy_notavail;
this.vE.settingsOwneridCopied = response.data.settings_ownerid_copied;
this.vE.settingsOwneridNotcopied = response.data.settings_ownerid_notcopied;
this.vE.settingsWCTokenCopied = response.data.settings_wctoken_copied;
this.vE.settingsWCTokenNotcopied = response.data.settings_wctoken_notcopied;
this.vE.settingsWCTokenGenerated = response.data.settings_wctoken_generated;
this.vE.settingsWCTokenGenfail = response.data.settings_wctoken_genfail;
this.vE.settingsAcodeSaved = response.data.settings_acode_saved;
this.vE.settingsAcodeNotsaved = response.data.settings_acode_notsaved;
this.vE.settingsAcodeInvalid = response.data.settings_acode_invalid;
//
this.languageRdy.next(true);
},
error => { console.log('Error >> ',error); }
);
this.vE.settingsViewTitle = response.data.settings_view_title;
this.vE.settingsTabMainlbl = response.data.settings_tab_mainlbl;
this.vE.settingsNameLbl = response.data.settings_name_lbl;
this.vE.settingsCurrencyLbl = response.data.settings_currency_lbl;
this.vE.settingsNamePlaceholder = response.data.settings_name_placeholder;
this.vE.settingsUseSatoshi = response.data.settings_use_satoshi;
this.vE.settingsVkeyLbl = response.data.settings_vkey_lbl;
this.vE.settingsVkeyPlaceholder = response.data.settings_vkey_placeholder;
this.vE.settingsConfirmPayments = response.data.settings_confirm_payments;
this.vE.settingsCloseBtn = response.data.settings_close_btn;
this.vE.settingsSaveBtn = response.data.settings_save_btn;
this.vE.settingsTabIntegrations = response.data.settings_tab_integrations;
this.vE.settingsXeroLbl = response.data.settings_xero_lbl;
this.vE.settingsLink2Xero = response.data.settings_link_2xero;
this.vE.settingsRelink2Xero = response.data.settings_relink_2xero;
this.vE.settingsXeropmtConfirmdis = response.data.settings_xeropmt_confirmdis;
this.vE.settingsNotservClose = response.data.settings_notserv_close;
this.vE.settingsNotservWarning = response.data.settings_notserv_warning;
this.vE.settingsPmtservURL = response.data.settings_pmtserv_url;
this.vE.settingsAcodeLbl = response.data.settings_acode_lbl;
this.vE.settingsXeroClosebtn = response.data.settings_xero_closebtn;
this.vE.settingsXeroSavebtn = response.data.settings_xero_savebtn;
this.vE.settingsWCLbl = response.data.settings_wc_lbl;
this.vE.settingsWCGentoken = response.data.settings_wc_gentoken;
this.vE.settingsWCOwnerlbl = response.data.settings_wc_ownerlbl;
this.vE.settingsWCClosebtn = response.data.settings_wc_closebtn;
this.vE.settingsURLCopied = response.data.settings_url_copied;
this.vE.settingsNotservSuccess = response.data.settings_notserv_success;
this.vE.settingsNotservError = response.data.settings_notserv_error;
this.vE.settingsCopyNotavail = response.data.settings_copy_notavail;
this.vE.settingsOwneridCopied = response.data.settings_ownerid_copied;
this.vE.settingsOwneridNotcopied = response.data.settings_ownerid_notcopied;
this.vE.settingsWCTokenCopied = response.data.settings_wctoken_copied;
this.vE.settingsWCTokenNotcopied = response.data.settings_wctoken_notcopied;
this.vE.settingsWCTokenGenerated = response.data.settings_wctoken_generated;
this.vE.settingsWCTokenGenfail = response.data.settings_wctoken_genfail;
this.vE.settingsAcodeSaved = response.data.settings_acode_saved;
this.vE.settingsAcodeNotsaved = response.data.settings_acode_notsaved;
this.vE.settingsAcodeInvalid = response.data.settings_acode_invalid;
//
this.languageRdy.next(true);
},
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Subject, BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
@ -8,7 +8,6 @@ import { NotifierService } from './notifier.service';
import { User } from './user.model';
import { Owner } from './owner.model';
import { Country } from './country.model';
import { Tx } from './tx.model';
import { ConfigData } from './configdata';
@ -18,7 +17,7 @@ var Buffer = require('buffer/').Buffer;
export class UserService{
beUrl = ConfigData.Be_URL;
private dataStore: { user: User, owner: Owner, txs: Tx[], countries: Country[]} = {
private dataStore: { user: User, owner: Owner, countries: Country[]} = {
user: {
address: '',
session: '',
@ -34,45 +33,30 @@ export class UserService{
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
},
txs : [],
countries: []
};
private uZaddr = '';
private oZaddr = '';
private uName = '';
private session: string | null = '';
private _uZaddrUpdated: BehaviorSubject<string> = new BehaviorSubject(this.uZaddr);
private _userUpdated: BehaviorSubject<User> = new BehaviorSubject(this.dataStore.user);
private uNameUpdated = new Subject<string>();
private _ownerUpdated: BehaviorSubject<Owner> = new BehaviorSubject(this.dataStore.owner);
private _txsUpdated: BehaviorSubject<Tx[]> = new BehaviorSubject(this.dataStore.txs);
private _paidUpdated: BehaviorSubject<boolean> = new BehaviorSubject(this.dataStore.owner.paid);
private _countriesUpdated: BehaviorSubject<Country[]> = new BehaviorSubject(this.dataStore.countries);
public readonly uZaddrUpdate: Observable<string> = this._uZaddrUpdated.asObservable();
public readonly ownerUpdate: Observable<Owner> = this._ownerUpdated.asObservable();
public readonly userUpdate: Observable<User> = this._userUpdated.asObservable();
public readonly txUpdate: Observable<Tx[]> = this._txsUpdated.asObservable();
public readonly paidUpdate: Observable<boolean> = this._paidUpdated.asObservable();
public readonly countriesUpdate: Observable<Country[]> = this._countriesUpdated.asObservable();
private reqHeaders: HttpHeaders;
private reqParams: HttpParams;
constructor(private http: HttpClient,
private notifierService : NotifierService ){
@ -80,13 +64,14 @@ export class UserService{
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
//console.log('US:', this.reqHeaders);
this.session = localStorage.getItem('s4z_token');
if (this.session != null) {
this.findUser();
}
this.reqParams = new HttpParams().append('session', this.session!);
//if (this.session != null) {
//this.findUser();
//}
}
getCountries() {
let obs = this.http.get<{message: string, countries: any}>(this.beUrl+'api/countries', { headers: this.reqHeaders, observe: 'response'});
let obs = this.http.get<{message: string, countries: any}>(this.beUrl+'api/countries', { headers: this.reqHeaders, params: this.reqParams, observe: 'response'});
obs.subscribe((CountryResponse) => {
if (CountryResponse.status == 200) {
@ -96,20 +81,29 @@ export class UserService{
});
}
findUser() {
this.session = localStorage.getItem('s4z_token');
checkUser() {
if (this.session != null) {
const params = new HttpParams().append('session', this.session!);
let obs = this.http.get<{message: string, user: any}>(this.beUrl+'api/user', { headers: this.reqHeaders, params: params, observe: 'response'});
console.log('calling checkUser');
let obs = this.http.get<{validated: boolean}>(this.beUrl + 'checkuser', {headers: this.reqHeaders, params: this.reqParams, observe: 'response'});
return obs;
} else {
return null;
}
}
findUser() {
if (this.session != null) {
let obs = this.http.get<{message: string, user: any}>(this.beUrl+'api/user', { headers: this.reqHeaders, params: this.reqParams, observe: 'response'});
obs.subscribe((UserDataResponse) => {
console.log(UserDataResponse.status);
//console.log(UserDataResponse.status);
if (UserDataResponse.status == 200){
this.dataStore.user = UserDataResponse.body!.user;
console.log(`US: Found user, returning it`);
//console.log(`US: Found user, returning it`);
this._uZaddrUpdated.next(Object.assign({},this.dataStore).user.address);
this._userUpdated.next(Object.assign({}, this.dataStore).user);
this.getOwner(Object.assign({},this.dataStore.user).address);
this.getOwner();
} else {
this.dataStore.user = {
address: '',
@ -120,7 +114,7 @@ export class UserService{
};
this._uZaddrUpdated.next(Object.assign({},this.dataStore).user.address);
this._userUpdated.next(Object.assign({}, this.dataStore).user);
console.log('US: Did not find user');
//console.log('US: Did not find user');
}
});
@ -132,8 +126,8 @@ export class UserService{
}
validateUser(pinString:string){
const params = new HttpParams().append('session', this.dataStore.user.session).append('pin', pinString);
let obs = this.http.post(this.beUrl+'api/validateuser', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
const params = this.reqParams.append('pin', pinString);
let obs = this.http.post(this.beUrl+'validateuser', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe((responseData) => {
if (responseData.status == 202) {
console.log('Pin validated!');
@ -147,29 +141,44 @@ export class UserService{
return obs;
}
addOwner(owner: Owner) {
addOwner(oData: {first: string, last: string, phone: string, name: string, street: string, city: string, state: string, postal: string, country: string, email: string, website: string}) {
owner.address = this.dataStore.user.address;
let obs = this.http.post(this.beUrl+'api/owner', {payload: owner}, {headers: this.reqHeaders});
let obs = this.http.post(this.beUrl+'api/owner', {payload: oData}, {headers: this.reqHeaders, params: this.reqParams});
obs.subscribe((responseData) => {
//console.log("Entra a console log");
this.getOwner(this.dataStore.user.address);
}, (error) => {
//console.log("Status is : [" + error.status + "]");
if ( error.status = 500 ) {
this.notifierService
.showNotification("Invalid Viewing Key, changes not saved!!","Close",'error');
};
obs.subscribe({
next: () => {
//console.log("Entra a console log");
this.getOwner();
},
error: (error) => {
//console.log("Status is : [" + error.status + "]");
if ( error.status = 500 ) {
this.notifierService.showNotification("Invalid Viewing Key, changes not saved!!","Close",'error');
};
}
});
return obs;
}
getOwner(address: string) {
console.log('getOwner', address);
const ownParams = new HttpParams().append('address', address);
let obs = this.http.get<{message:string, owner: any}>(this.beUrl+'api/owner', { headers: this.reqHeaders, params: ownParams, observe: 'response'});
saveOwnerSettings(o: Owner) {
let obs = this.http.post(this.beUrl + 'api/ownersettings', {payload: o}, {headers: this.reqHeaders, params: this.reqParams});
obs.subscribe({
next: () => {
this.getOwner();
},
error: (error) => {
if ( error.status == 500 ){
this.notifierService.showNotification("Saving settings failed", "Close", "error")
}
}
})
}
getOwner() {
//console.log('getOwner', address);
//const ownParams = this.reqParams.append('address', address)
let obs = this.http.get<{message:string, owner: any}>(this.beUrl+'api/owner', { headers: this.reqHeaders, params: this.reqParams, observe: 'response'});
obs.subscribe((OwnerDataResponse) => {
//console.log('api/getowner', OwnerDataResponse.status);
@ -187,16 +196,19 @@ export class UserService{
}
deleteUser() {
let obs = this.http.delete<{message: string}>(this.beUrl+'api/user/'+this.dataStore.user._id, {headers: this.reqHeaders });
let obs = this.http.delete<{message: string}>(this.beUrl+'api/user/'+this.dataStore.user._id, {headers: this.reqHeaders, params: this.reqParams });
obs.subscribe(UserResponse => {
obs.subscribe({next: () => {
//console.log('User delete request sent.');
this.findUser();
});
}});
return obs;
}
saveSettings(o: Owner) {
}
currentOwner() : Owner {
return this.dataStore.owner;
}

View File

@ -1,17 +1,15 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { CanActivate, Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { UserService } from '../user.service';
import { FullnodeService } from '../fullnode.service';
import { ItemService } from '../items/items.service';
import { Subscription, Observable } from 'rxjs';
import { Observable } from 'rxjs';
import { SettingsComponent } from '../settings/settings.component';
import {Owner} from '../owner.model';
import {User} from '../user.model';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
@Component({
selector: 'app-viewer',
@ -38,23 +36,13 @@ export class ViewerComponent implements OnInit {
taxValue: 0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
public price: number = 1;
public addrUpdate: Observable<string>;
@ -127,13 +115,13 @@ export class ViewerComponent implements OnInit {
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
dialogConfig.data = this.owner;
dialogConfig.data = {o: this.owner};
const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
dialogRef.afterClosed().subscribe((val) => {
if (val != null) {
//console.log('Saving settings', val);
this.userService.addOwner(val);
this.userService.saveOwnerSettings(val);
this.fullnodeService.getPrice(val.currency);
this.loginCheck();
}
@ -148,7 +136,7 @@ export class ViewerComponent implements OnInit {
this.user = user;
//console.log('Viewer loginCheck', this.user);
if (!this.owner.paid || !this.user.validated) {
console.log('Log in expired!');
//console.log('Log in expired!');
this.router.navigate(['/login']);
}
});
@ -156,18 +144,18 @@ export class ViewerComponent implements OnInit {
}
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);
//console.log('VIEWER.chgUILanguage Called ');
this.languageService.getViewElements('viewer').subscribe({
next: 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); }
);
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -12,9 +12,11 @@ var Buffer = require('buffer/').Buffer;
export class WoocommerceService {
beUrl = ConfigData.Be_URL;
private reqHeaders: HttpHeaders;
private reqParams: HttpParams;
private ownerId: string = '';
private token: string = '';
private siteurl: string = '';
private session: null | string;
private _ownerIdUpdated: BehaviorSubject<string> = new BehaviorSubject(this.ownerId);
private _tokenUpdated: BehaviorSubject<string> = new BehaviorSubject(this.token);
private _siteurlUpdated: BehaviorSubject<string> = new BehaviorSubject(this.siteurl);
@ -27,13 +29,15 @@ export class WoocommerceService {
) {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.session = localStorage.getItem('s4z_token');
this.reqParams = new HttpParams().append('session', this.session!);
this._ownerIdUpdated.next(Object.assign({}, this).ownerId);
this._tokenUpdated.next(Object.assign({}, this).token);
this._siteurlUpdated.next(Object.assign({}, this).siteurl);
}
getWooToken(ownerId: string) {
const params = new HttpParams().append('ownerid', ownerId);
const params = this.reqParams.append('ownerid', ownerId);
let obs = this.http.get<{ownerid: string, token: string, siteurl: string}>(this.beUrl + 'api/wootoken', {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe(tokenResponse => {
if (tokenResponse.status == 200) {
@ -51,7 +55,7 @@ export class WoocommerceService {
}
createWooToken(ownerId: string) {
const params = new HttpParams().append('ownerid', ownerId);
const params = this.reqParams.append('ownerid', ownerId);
let obs = this.http.post(this.beUrl+'api/wootoken', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe(responseData => {
if (responseData.status == 202) {

View File

@ -37,24 +37,26 @@ export class XeroService {
public readonly tokenUpdate: Observable<any> = this._tokenUpdated.asObservable();
public readonly accCodeUpdate: Observable<string> = this._accCodeUpdated.asObservable();
private reqHeaders: HttpHeaders;
private reqParams: HttpParams;
private session: null | string;
constructor(
private http: HttpClient
) {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
this.session = localStorage.getItem('s4z_token');
this.reqParams = new HttpParams().append('session', this.session!);
this.getXeroConfig();
}
getXeroConfig(){
let obs = this.http.get<{message: string, xeroConfig: any}>(this.beUrl+'api/xero', { headers:this.reqHeaders, observe: 'response'});
let obs = this.http.get<{message: string, xeroConfig: any}>(this.beUrl+'api/xero', { headers:this.reqHeaders, observe: 'response', params: this.reqParams});
obs.subscribe(xeroDataResponse => {
if (xeroDataResponse.status == 200) {
this.clientId = xeroDataResponse.body!.xeroConfig.clientId;
//this.clientSecret = xeroDataResponse.body!.xeroConfig.clientSecret;
this._clientIdUpdated.next(Object.assign({}, this).clientId);
//this._clientSecretUpdated.next(Object.assign({}, this).clientSecret);
} else {
console.log('No config in DB!');
}
@ -64,13 +66,13 @@ export class XeroService {
}
getXeroAccessToken(code: string, address: string){
const params = new HttpParams().append('code', code).append('address', address);
const params = this.reqParams.append('code', code).append('address', address);
let obs = this.http.get(this.beUrl + 'api/xerotoken' , {headers: this.reqHeaders, params: params, observe: 'response'});
return obs;
}
getXeroAccountCode(address: string){
const params = new HttpParams().append('address', address);
const params = this.reqParams.append('address', address);
let obs = this.http.get<{message: string, code: string}>(this.beUrl + 'api/xeroaccount', {headers: this.reqHeaders, params: params, observe: 'response'});
obs.subscribe(accountResponse => {
if (accountResponse.status == 200) {
@ -85,7 +87,7 @@ export class XeroService {
setXeroAccountCode(address: string, code: string) {
const params = new HttpParams().append('address', address).append('code', code);
const params = this.reqParams.append('address', address).append('code', code);
let obs = this.http.post(this.beUrl + 'api/xeroaccount', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
/*
obs.subscribe(responseData => {

View File

@ -6,7 +6,6 @@ import { Owner } from '../owner.model';
import { Observable } from 'rxjs';
import { LanguageService } from '../language.service';
import { LanguageData } from '../language.model';
var Buffer = require('buffer/').Buffer;
@ -27,6 +26,7 @@ async function redirect(r: Router) {
export class XeroRegComponent implements OnInit {
public owner:Owner = {
_id: '',
address: '',
name: '',
currency: '',
@ -34,23 +34,13 @@ export class XeroRegComponent implements OnInit {
taxValue:0,
vat: false,
vatValue: 0,
first: '',
last: '',
email: '',
street: '',
city: '',
state: '',
postal: '',
phone: '',
paid: false,
website: '',
country: '',
zats: false,
invoices: false,
expiration: new Date(Date.now()).toISOString(),
payconf: false,
viewkey: '',
crmToken: ''
crmToken: '',
viewkey: ''
};
public ownerUpdate:Observable<Owner>;
public flag: boolean = false;
@ -85,15 +75,15 @@ export class XeroRegComponent implements OnInit {
this.ownerUpdate.subscribe((owner) => {
this.owner = owner;
this.activatedRoute.queryParams.subscribe((params) => {
console.log(params);
//console.log(params);
if (params.state === this.owner.address.substring(0,6)) {
this.xeroService.getXeroAccessToken(params.code, this.owner.address).subscribe(tokenData => {
if (tokenData.status == 200) {
console.log(tokenData.body!);
//console.log(tokenData.body!);
this.flag = true;
redirect(this.router);
} else {
console.log('Error: '+tokenData.status);
//console.log('Error: '+tokenData.status);
this.flag = false;
}
});
@ -106,20 +96,20 @@ export class XeroRegComponent implements OnInit {
}
chgUILanguage(){
console.log('XERO.chgUILanguage Called ');
this.languageService.getViewElements('xero').subscribe(
response => {
console.log('Received >> ', response );
console.log('Language Code : ', response.language);
console.log('Component Name : ',response.component);
console.log('Language data : ',response.data);
//console.log('XERO.chgUILanguage Called ');
this.languageService.getViewElements('xero').subscribe({
next: 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.xeroConnecting2xero = response.data.xero_connecting_2xero;
this.vE.xeroConnected2xero = response.data.xero_connected_2xero;
},
error => { console.log('Error >> ',error); }
);
},
error: error => { console.log('Error >> ',error); }
});
}
}

View File

@ -6,7 +6,7 @@
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,