Added toast to display feedback from transaction submission
This commit is contained in:
parent
055a76e7ba
commit
d74ca064d2
@ -1,15 +1,10 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
import { IonicPage } from 'ionic-angular';
|
||||||
|
import { ToastController } from 'ionic-angular';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { Http } from '@angular/http';
|
import { Http } from '@angular/http';
|
||||||
import { ApiProvider } from '../../providers/api/api';
|
import { ApiProvider } from '../../providers/api/api';
|
||||||
|
|
||||||
/**
|
|
||||||
* Generated class for the BroadcastTxPage page.
|
|
||||||
*
|
|
||||||
* See http://ionicframework.com/docs/components/#navigation for more info
|
|
||||||
* on Ionic pages and navigation.
|
|
||||||
*/
|
|
||||||
@IonicPage()
|
@IonicPage()
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-broadcast-tx',
|
selector: 'page-broadcast-tx',
|
||||||
@ -18,46 +13,45 @@ import { ApiProvider } from '../../providers/api/api';
|
|||||||
export class BroadcastTxPage {
|
export class BroadcastTxPage {
|
||||||
|
|
||||||
public title: string;
|
public title: string;
|
||||||
private nav: NavController;
|
|
||||||
public transaction: string;
|
public transaction: string;
|
||||||
public txForm: FormGroup;
|
public txForm: FormGroup;
|
||||||
private status: string;
|
private status: string;
|
||||||
// private txid: any;
|
|
||||||
|
|
||||||
constructor(public navCtrl: NavController, public navParams: NavParams, public formBuilder: FormBuilder, private http: Http, private api: ApiProvider) {
|
constructor(
|
||||||
this.nav = navCtrl;
|
private toastCtrl: ToastController,
|
||||||
|
public formBuilder: FormBuilder,
|
||||||
|
private http: Http,
|
||||||
|
private api: ApiProvider,
|
||||||
|
) {
|
||||||
this.title = 'Broadcast Transaction';
|
this.title = 'Broadcast Transaction';
|
||||||
this.txForm = formBuilder.group({
|
this.txForm = formBuilder.group({
|
||||||
rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)]
|
rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ionViewDidLoad(): void {
|
|
||||||
console.log('ionViewDidLoad BroadcastTxPage');
|
|
||||||
}
|
|
||||||
|
|
||||||
public send(): void {
|
public send(): void {
|
||||||
let postData: any = {
|
let postData: any = {
|
||||||
rawtx: this.transaction
|
rawtx: this.transaction
|
||||||
};
|
};
|
||||||
this.status = 'loading';
|
this.status = 'loading';
|
||||||
|
|
||||||
console.log('the postData is', postData);
|
|
||||||
|
|
||||||
this.http.post(this.api.apiPrefix + 'tx/send', postData)
|
this.http.post(this.api.apiPrefix + 'tx/send', postData)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
response => console.log('response', response),
|
response => {
|
||||||
|
this.presentToast(response);
|
||||||
|
},
|
||||||
err => console.log('err', err)
|
err => console.log('err', err)
|
||||||
);
|
);
|
||||||
/*
|
}
|
||||||
.error(function(data, status, headers, config) {
|
|
||||||
$scope.status = 'error';
|
private presentToast(response: any): void {
|
||||||
if(data) {
|
let body: any = JSON.parse(response._body);
|
||||||
$scope.error = data;
|
let toast: any = this.toastCtrl.create({
|
||||||
} else {
|
message: 'Transaction successfully broadcast. Trasaction id: ' + body.txid,
|
||||||
$scope.error = "No error message given (connection error?)"
|
position: 'middle',
|
||||||
}
|
showCloseButton: true,
|
||||||
});
|
dismissOnPageChange: true
|
||||||
*/
|
});
|
||||||
|
toast.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user