Update settings component and xeroService
This commit is contained in:
parent
8679dc1b67
commit
e9eda2d30c
5 changed files with 32 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ export class SettingsComponent implements OnInit {
|
|||
accCodeUpdate: Observable<string>;
|
||||
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
|
||||
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 ) {
|
||||
|
|
|
@ -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<string> = new BehaviorSubject(this.clientId);
|
||||
//private _clientSecretUpdated: BehaviorSubject<string> = 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;
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/assets/notifier_1.mp3
Normal file
BIN
src/assets/notifier_1.mp3
Normal file
Binary file not shown.
Loading…
Reference in a new issue