Compare commits

..

No commits in common. "1f39c6f8f9c13c2ca1a43d55312dea3eccff0b13" and "04ae91b9b7a2526eea0d1868d214c83a33fa3018" have entirely different histories.

6 changed files with 92 additions and 278 deletions

View file

@ -39,8 +39,8 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "5mb",
"maximumError": "10mb"
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",

View file

@ -45,15 +45,4 @@
color: dodgerblue;
}
.small {
font-size: 12px;
background: #dddddd;
}
.heading {
padding-top: 10px;
}
.toolbar {
padding: 12px;
}

View file

@ -77,147 +77,98 @@
<mat-tab *ngIf="proVersion"
label="Integrations"
style="align-items: center;">
<mat-tab-group mat-tab-align-tabs="start">
<mat-tab label="Xero">
<div class="container" style="margin-bottom: 20px;">
<mat-dialog-content [formGroup]="accCodForm">
<div style="height: 10px;
margin-top: 10px;">
</div>
<div class="container"
style="height: 300;">
<p style="text-align:center">
<a mat-raised-button
color="primary"
href="{{this.xeroLink}}">
{{ linkMsg }}
</a>
</p>
<table *ngIf="linked2Xero"
[style.width.%]="100"
style="margin-top: 10px;">
<thead style="width: 100%;">
<tr>
<th class="urlLabel"
style="text-align: left;"
width="94%">Payment Service URL:
</th>
<th></th>
</tr>
</thead>
<tbody>
<td class="urlDetail"
style="text-align: left;"
width="94%">
<div>
<textarea disabled
style="font-size: 10px !important;
border: none;
outline: none;
min-height: 150px;
width: 95%;"
cdkTextareaAutosize
cdkAutosizeMinRows="6"
cdkAutosizeMaxRows="10">{{ pmtServiceURL }}
</textarea>
</div>
</td>
<td class="urlCopyBtn">
<a (click)='copyUrl()' >
<fa-icon [icon]="faCopy"
class="copy-button">
</fa-icon>
</a>
</td>
</tbody>
</table>
<div style="height: 10px;
margin-top: 10px;">
</div>
<mat-form-field *ngIf="linked2Xero"
class="settings-field"
[style.width.%]="100">
<mat-label>Account Code</mat-label>
<input matInput
width="100%"
placeholder="9999999999"
formControlName="xAcc"
(keyup)="checkStatus($event)">
</mat-form-field>
</div>
</mat-dialog-content>
</div>
<div class="container"
style="display: flex;
justify-content: space-between;
align-items: center;">
<button mat-raised-button
(click)="closeIntegration()">
Close
</button>
<button *ngIf="saveAccOk"
mat-raised-button
color="primary"
(click)="saveAccCod()">
Save Code
</button>
</div>
<div style="height: 20px;
<div class="container" style="margin-bottom: 20px;">
<mat-dialog-content [formGroup]="accCodForm">
<div style="height: 10px;
margin-top: 10px;">
</div>
</mat-tab>
<mat-tab label="WooCommerce">
<div *ngIf="wooOwner == ''">
<button mat-raised-button color="primary" (click)="generateWooToken()">
Generate Token
</button>
</div>
<table *ngIf="wooOwner != ''">
<tr>
<td class="heading">Owner:</td>
</tr>
<tr>
<td class="small">{{wooOwner}}</td>
<td class="urlCopyBtn">
<a (click)='copyWooOwner()' >
<fa-icon [icon]="faCopy"
class="copy-button">
</fa-icon>
</a>
</td>
</tr>
<tr>
<td class="heading">Token:</td>
</tr>
<tr>
<td class="small">{{wooToken}}</td>
<td class="urlCopyBtn">
<a (click)='copyWooToken()' >
<fa-icon [icon]="faCopy"
class="copy-button">
</fa-icon>
</a>
</td>
</tr>
<tr>
<td class="heading">URL:</td>
</tr>
<tr>
<td class="small">{{wooUrl}}</td>
</tr>
</table>
<div class="toolbar" align="center">
<button mat-raised-button
(click)="close()">
Close
</button>
</div>
<div class="container"
style="height: 300;">
<p style="text-align:center">
<a mat-raised-button
color="primary"
href="{{this.xeroLink}}">
{{ linkMsg }}
</a>
</p>
</mat-tab>
</mat-tab-group>
<table *ngIf="linked2Xero"
[style.width.%]="100"
style="margin-top: 10px;">
<thead style="width: 100%;">
<tr>
<th class="urlLabel"
style="text-align: left;"
width="94%">Payment Service URL:
</th>
<th></th>
</tr>
</thead>
<tbody>
<td class="urlDetail"
style="text-align: left;"
width="94%">
<div>
<textarea disabled
style="font-size: 10px !important;
border: none;
outline: none;
min-height: 150px;
width: 95%;"
cdkTextareaAutosize
cdkAutosizeMinRows="6"
cdkAutosizeMaxRows="10">{{ pmtServiceURL }}
</textarea>
</div>
</td>
<td class="urlCopyBtn">
<a (click)='copyUrl()' >
<fa-icon [icon]="faCopy"
class="copy-button">
</fa-icon>
</a>
</td>
</tbody>
</table>
<div style="height: 10px;
margin-top: 10px;">
</div>
<mat-form-field *ngIf="linked2Xero"
class="settings-field"
[style.width.%]="100">
<mat-label>Account Code</mat-label>
<input matInput
width="100%"
placeholder="9999999999"
formControlName="xAcc"
(keyup)="checkStatus($event)">
<!--
(change)="xeroAccCodChanged($event)">
-->
</mat-form-field>
</div>
</mat-dialog-content>
</div>
<div class="container"
style="display: flex;
justify-content: space-between;
align-items: center;">
<button mat-raised-button
(click)="closeIntegration()">
Close
</button>
<button *ngIf="saveAccOk"
mat-raised-button
color="primary"
(click)="saveAccCod()">
Save Code
</button>
</div>
<div style="height: 20px;
margin-top: 10px;">
</div>
</mat-tab>
</mat-tab-group>
</div>

View file

@ -5,7 +5,6 @@ import { UntypedFormBuilder, Validators, UntypedFormGroup, FormControl } from '@
import { Observable } from 'rxjs';
import { Owner } from '../owner.model';
import { XeroService } from '../xero.service';
import { WoocommerceService } from '../woocommerce.service';
import { NotifierService } from '../notifier.service';
import { faCopy } from '@fortawesome/free-solid-svg-icons';
@ -57,13 +56,6 @@ export class SettingsComponent implements OnInit {
xeroLink: string = '';
localToken: string = '';
clientId: string = '';
wooOwner: string = '';
wooToken: string = '';
wooUrl: string = '';
wooOwnerUpdate: Observable<string>;
wooTokenUpdate: Observable<string>;
wooUrlUpdate: Observable<string>;
clientIdUpdate: Observable<string>;
accCodeUpdate: Observable<string>;
linked2Xero : boolean = false;
@ -73,7 +65,6 @@ export class SettingsComponent implements OnInit {
private notifierService : NotifierService,
private fb: UntypedFormBuilder,
public xeroService: XeroService,
public wooService: WoocommerceService,
private dialogRef: MatDialogRef<SettingsComponent>,
@Inject(MAT_DIALOG_DATA) public data: Owner) {
this.useZats = data.zats;
@ -111,19 +102,6 @@ export class SettingsComponent implements OnInit {
console.log("xeroAccCod -> [" + this.xeroAccCod + "]");
this.accCodForm.get('xAcc')!.setValue(this.xeroAccCod);
});
this.wooOwnerUpdate = wooService.ownerUpdate;
this.wooTokenUpdate = wooService.tokenUpdate;
this.wooUrlUpdate = wooService.siteurlUpdate;
wooService.getWooToken(this.owner._id!);
this.wooOwnerUpdate.subscribe(owData => {
this.wooOwner = owData;
});
this.wooTokenUpdate.subscribe(tkData => {
this.wooToken = tkData;
});
this.wooUrlUpdate.subscribe(uData => {
this.wooUrl = uData;
});
}
ngOnInit() {
@ -150,7 +128,7 @@ export class SettingsComponent implements OnInit {
closeIntegration() {
if ( (this.xeroAccCod == '') && (this.linked2Xero) )
this.notifierService
.showNotification("Xero Payment confirmation disabled!!","Close",'warning');
.showNotification("Payment confirmation disabled!!","Close",'warning');
this.dialogRef.close();
}
@ -201,29 +179,6 @@ export class SettingsComponent implements OnInit {
}
}
copyWooOwner(){
try {
navigator.clipboard.writeText(this.wooOwner);
this.notifierService.showNotification("Owner ID copied to clipboard", "Close", "success");
} catch (err) {
this.notifierService.showNotification("Copying not available in your browser", "Close", "error");
}
}
copyWooToken(){
try {
navigator.clipboard.writeText(this.wooToken);
this.notifierService.showNotification("WooCommerce Token copied to clipboard", "Close", "success");
} catch (err) {
this.notifierService.showNotification("Copying not available in your browser", "Close", "error");
}
}
generateWooToken(){
this.wooService.createWooToken(this.owner._id!);
this.wooService.getWooToken(this.owner._id!);
}
saveAccCod() {
this.xeroAccCod = this.accCodForm.value.xAcc;

View file

@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { WoocommerceService } from './woocommerce.service';
describe('WoocommerceService', () => {
let service: WoocommerceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(WoocommerceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -1,65 +0,0 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { ConfigData } from './configdata';
var Buffer = require('buffer/').Buffer;
@Injectable({
providedIn: 'root'
})
export class WoocommerceService {
beUrl = ConfigData.Be_URL;
private reqHeaders: HttpHeaders;
private ownerId: string = '';
private token: string = '';
private siteurl: 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);
public readonly ownerUpdate: Observable<string> = this._ownerIdUpdated.asObservable();
public readonly tokenUpdate: Observable<string> = this._tokenUpdated.asObservable();
public readonly siteurlUpdate: Observable<string> = this._siteurlUpdated.asObservable();
constructor(
private http: HttpClient
) {
var auth = 'Basic ' + Buffer.from(ConfigData.UsrPwd).toString('base64');
this.reqHeaders = new HttpHeaders().set('Authorization', auth);
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);
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) {
this.ownerId = tokenResponse.body!.ownerid;
this.token = tokenResponse.body!.token;
this.siteurl = tokenResponse.body!.siteurl;
this._ownerIdUpdated.next(Object.assign({}, this).ownerId);
this._tokenUpdated.next(Object.assign({}, this).token);
this._siteurlUpdated.next(Object.assign({}, this).siteurl);
} else {
console.log('No WooCommerce token found');
}
});
return obs;
}
createWooToken(ownerId: string) {
const params = new HttpParams().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) {
console.log('WooToken created.');
} else {
console.log('WooToken creation failed.');
}
});
}
}