Save some work
This commit is contained in:
parent
12dbdd999d
commit
bcfea17dbc
3 changed files with 27 additions and 20 deletions
|
@ -24,7 +24,7 @@ export class NotifierService {
|
|||
}
|
||||
|
||||
playSound() {
|
||||
console.log('Play sound called...');
|
||||
// console.log('Play sound called...');
|
||||
let audio = new Audio();
|
||||
audio.src = '../assets/notifier.mp3';
|
||||
audio.load();
|
||||
|
|
|
@ -60,6 +60,7 @@ export class SettingsComponent implements OnInit {
|
|||
accCodeUpdate: Observable<string>;
|
||||
linked2Xero : boolean = false;
|
||||
pmtServiceURL : string = '';
|
||||
saveStat : boolean = false;
|
||||
|
||||
constructor(
|
||||
private notifierService : NotifierService,
|
||||
|
@ -180,25 +181,33 @@ export class SettingsComponent implements OnInit {
|
|||
}
|
||||
|
||||
saveAccCod() {
|
||||
|
||||
this.xeroAccCod = this.accCodForm.value.xAcc;
|
||||
console.log(">>> " + this.xeroAccCod);
|
||||
if ( this.xeroAccCod.length <= 10 ) {
|
||||
const savedAcc = this.xeroService
|
||||
.setXeroAccountCode(this.owner.address,
|
||||
this.xeroAccCod );
|
||||
console.log("savedAcc: " + JSON.stringify(savedAcc));
|
||||
if ( savedAcc ) {
|
||||
this.notifierService
|
||||
.showNotification("Account saved correctly!!","Close",'success');
|
||||
} else {
|
||||
this.notifierService
|
||||
.showNotification("Error while saving account code!!","Close",'error');
|
||||
}
|
||||
this.xeroService
|
||||
.setXeroAccountCode(this.owner.address,
|
||||
this.xeroAccCod);
|
||||
|
||||
} 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,7 @@ export class XeroService {
|
|||
tokenType: ''
|
||||
};
|
||||
xeroAcc: string = '';
|
||||
|
||||
private _clientIdUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientId);
|
||||
//private _clientSecretUpdated: BehaviorSubject<string> = new BehaviorSubject(this.clientSecret);
|
||||
private _tokenUpdated: BehaviorSubject<any> = new BehaviorSubject(this.xeroToken);
|
||||
|
@ -77,19 +78,16 @@ export class XeroService {
|
|||
|
||||
}
|
||||
|
||||
setXeroAccountCode(address: string, code: string) : boolean {
|
||||
let res : boolean = false;
|
||||
setXeroAccountCode(address: string, code: string) {
|
||||
|
||||
const params = new HttpParams().append('address', address).append('code', code);
|
||||
let obs = this.http.post(this.beUrl + 'api/xerotoken', {}, {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 => {
|
||||
if (responseData.status == 202) {
|
||||
console.log('Account saved');
|
||||
res = true;
|
||||
|
||||
}
|
||||
}, error => {
|
||||
console.log('Oops!! ',error.message);
|
||||
res = false;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue