diff --git a/CHANGELOG.md b/CHANGELOG.md index bc15eaa..7287b72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### 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 - Listorders component updated to show date in ANSI international format. - Settings component updated to use owner's invoices field to control diff --git a/src/app/notifier.service.ts b/src/app/notifier.service.ts index 4e6b524..e917c6e 100644 --- a/src/app/notifier.service.ts +++ b/src/app/notifier.service.ts @@ -26,7 +26,7 @@ export class NotifierService { playSound() { // console.log('Play sound called...'); let audio = new Audio(); - audio.src = '../assets/notifier.mp3'; + audio.src = '../assets/notifier_1.mp3'; audio.load(); audio.play(); } diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 7681150..08bf988 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -60,7 +60,6 @@ export class SettingsComponent implements OnInit { accCodeUpdate: Observable; linked2Xero : boolean = false; pmtServiceURL : string = ''; - saveStat : boolean = false; constructor( private notifierService : NotifierService, @@ -185,29 +184,28 @@ export class SettingsComponent implements OnInit { this.xeroAccCod = this.accCodForm.value.xAcc; console.log(">>> " + this.xeroAccCod); if ( this.xeroAccCod.length <= 10 ) { - this.xeroService - .setXeroAccountCode(this.owner.address, - this.xeroAccCod); + const obs = this.xeroService + .setXeroAccountCode(this.owner.address, + 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 { this.notifierService .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 ) { diff --git a/src/app/xero.service.ts b/src/app/xero.service.ts index 465da7e..1edeb0f 100644 --- a/src/app/xero.service.ts +++ b/src/app/xero.service.ts @@ -21,6 +21,12 @@ export class XeroService { tokenType: '' }; xeroAcc: string = ''; + savedAcc : boolean = false; + + public savedAccObs = new Observable((observer) => { + console.log("starting savedAccObs"); + setTimeout(() => {observer.next(this.savedAcc)},1000); + }) private _clientIdUpdated: BehaviorSubject = new BehaviorSubject(this.clientId); //private _clientSecretUpdated: BehaviorSubject = new BehaviorSubject(this.clientSecret); @@ -75,19 +81,23 @@ export class XeroService { } }); return obs; - } setXeroAccountCode(address: string, code: string) { 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'}); +/* obs.subscribe(responseData => { if (responseData.status == 202) { console.log('Account saved'); - + this.savedAcc = true; } }, error => { + this.savedAcc = false; + console.log("error : " + error.msg) }); +*/ + return obs; } } diff --git a/src/assets/notifier_1.mp3 b/src/assets/notifier_1.mp3 new file mode 100644 index 0000000..5325142 Binary files /dev/null and b/src/assets/notifier_1.mp3 differ