Update settings component and xeroService

This commit is contained in:
Rene V. Vergara A. 2022-09-07 22:00:43 -05:00
parent 8679dc1b67
commit e9eda2d30c
5 changed files with 32 additions and 23 deletions

View file

@ -11,7 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added new service for Xero integration - Added new service for Xero integration
### Changed ### Changed
- settings component updated to use observable when saving Account Code
- xeroService's saveAccountCode function optimized to export observable
- Field for Xero's AccountCode added to Settings component's integration tab - Field for Xero's AccountCode added to Settings component's integration tab
- Listorders component updated to show date in ANSI international format. - Listorders component updated to show date in ANSI international format.
- Settings component updated to use owner's invoices field to control - Settings component updated to use owner's invoices field to control

View file

@ -26,7 +26,7 @@ export class NotifierService {
playSound() { playSound() {
// console.log('Play sound called...'); // console.log('Play sound called...');
let audio = new Audio(); let audio = new Audio();
audio.src = '../assets/notifier.mp3'; audio.src = '../assets/notifier_1.mp3';
audio.load(); audio.load();
audio.play(); audio.play();
} }

View file

@ -60,7 +60,6 @@ export class SettingsComponent implements OnInit {
accCodeUpdate: Observable<string>; accCodeUpdate: Observable<string>;
linked2Xero : boolean = false; linked2Xero : boolean = false;
pmtServiceURL : string = ''; pmtServiceURL : string = '';
saveStat : boolean = false;
constructor( constructor(
private notifierService : NotifierService, private notifierService : NotifierService,
@ -185,29 +184,28 @@ export class SettingsComponent implements OnInit {
this.xeroAccCod = this.accCodForm.value.xAcc; this.xeroAccCod = this.accCodForm.value.xAcc;
console.log(">>> " + this.xeroAccCod); console.log(">>> " + this.xeroAccCod);
if ( this.xeroAccCod.length <= 10 ) { if ( this.xeroAccCod.length <= 10 ) {
this.xeroService const obs = this.xeroService
.setXeroAccountCode(this.owner.address, .setXeroAccountCode(this.owner.address,
this.xeroAccCod); this.xeroAccCod);
obs.subscribe(responseData => {
if (responseData.status == 202) {
console.log('Account saved');
this.notifierService
.showNotification("Account Code saved!!","Close",'success');
} else {
console.log('Account not saved -> status[' + responseData.status + ']');
this.notifierService
.showNotification("Account Code not saved","Close",'error');
}
}, error => {
console.log('Error saving Account Code -> ' + error.msg)
});
} else { } else {
this.notifierService this.notifierService
.showNotification("Invalid Account code (10 chars max.)","Close",'error'); .showNotification("Invalid Account code (10 chars max.)","Close",'error');
}; };
console.log("saveStat -> ",this.saveStat);
}
checkSave( arg: any ) {
console.log("CheckSave -> " + arg);
this.saveStat = arg;
/*
if ( arg ) {
this.notifierService
.showNotification("Account saved correctly.)","Close",'success');
} else {
this.notifierService
.showNotification("Account was not saved!!","Close",'error');
}
*/
} }
xeroAccCodChanged( arg: any ) { xeroAccCodChanged( arg: any ) {

View file

@ -21,6 +21,12 @@ export class XeroService {
tokenType: '' tokenType: ''
}; };
xeroAcc: string = ''; xeroAcc: string = '';
savedAcc : boolean = false;
public savedAccObs = new Observable((observer) => {
console.log("starting savedAccObs");
setTimeout(() => {observer.next(this.savedAcc)},1000);
})
private _clientIdUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientId); private _clientIdUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientId);
//private _clientSecretUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientSecret); //private _clientSecretUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientSecret);
@ -75,19 +81,23 @@ export class XeroService {
} }
}); });
return obs; return obs;
} }
setXeroAccountCode(address: string, code: string) { setXeroAccountCode(address: string, code: string) {
const params = new HttpParams().append('address', address).append('code', code); const params = new HttpParams().append('address', address).append('code', code);
let obs = this.http.post(this.beUrl + 'api/xeroaccount', {}, {headers: this.reqHeaders, params: params, observe: 'response'}); let obs = this.http.post(this.beUrl + 'api/xeroaccount', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
/*
obs.subscribe(responseData => { obs.subscribe(responseData => {
if (responseData.status == 202) { if (responseData.status == 202) {
console.log('Account saved'); console.log('Account saved');
this.savedAcc = true;
} }
}, error => { }, error => {
this.savedAcc = false;
console.log("error : " + error.msg)
}); });
*/
return obs;
} }
} }

BIN
src/assets/notifier_1.mp3 Normal file

Binary file not shown.