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() {
|
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.mp3';
|
||||||
audio.load();
|
audio.load();
|
||||||
|
|
|
@ -60,6 +60,7 @@ 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,
|
||||||
|
@ -180,25 +181,33 @@ export class SettingsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAccCod() {
|
saveAccCod() {
|
||||||
|
|
||||||
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 ) {
|
||||||
const savedAcc = this.xeroService
|
this.xeroService
|
||||||
.setXeroAccountCode(this.owner.address,
|
.setXeroAccountCode(this.owner.address,
|
||||||
this.xeroAccCod);
|
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
} 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 ) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ export class XeroService {
|
||||||
tokenType: ''
|
tokenType: ''
|
||||||
};
|
};
|
||||||
xeroAcc: string = '';
|
xeroAcc: string = '';
|
||||||
|
|
||||||
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);
|
||||||
private _tokenUpdated: BehaviorSubject<any> = new BehaviorSubject(this.xeroToken);
|
private _tokenUpdated: BehaviorSubject<any> = new BehaviorSubject(this.xeroToken);
|
||||||
|
@ -77,19 +78,16 @@ export class XeroService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setXeroAccountCode(address: string, code: string) : boolean {
|
setXeroAccountCode(address: string, code: string) {
|
||||||
let res : boolean = false;
|
|
||||||
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/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 => {
|
obs.subscribe(responseData => {
|
||||||
if (responseData.status == 202) {
|
if (responseData.status == 202) {
|
||||||
console.log('Account saved');
|
console.log('Account saved');
|
||||||
res = true;
|
|
||||||
}
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log('Oops!! ',error.message);
|
|
||||||
res = false;
|
|
||||||
});
|
});
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue