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 { IonicPage, NavController, NavParams } from 'ionic-angular';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { ToastController } from 'ionic-angular';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Http } from '@angular/http';
|
||||
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()
|
||||
@Component({
|
||||
selector: 'page-broadcast-tx',
|
||||
@ -18,46 +13,45 @@ import { ApiProvider } from '../../providers/api/api';
|
||||
export class BroadcastTxPage {
|
||||
|
||||
public title: string;
|
||||
private nav: NavController;
|
||||
public transaction: string;
|
||||
public txForm: FormGroup;
|
||||
private status: string;
|
||||
// private txid: any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams, public formBuilder: FormBuilder, private http: Http, private api: ApiProvider) {
|
||||
this.nav = navCtrl;
|
||||
constructor(
|
||||
private toastCtrl: ToastController,
|
||||
public formBuilder: FormBuilder,
|
||||
private http: Http,
|
||||
private api: ApiProvider,
|
||||
) {
|
||||
this.title = 'Broadcast Transaction';
|
||||
this.txForm = formBuilder.group({
|
||||
rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)]
|
||||
});
|
||||
}
|
||||
|
||||
public ionViewDidLoad(): void {
|
||||
console.log('ionViewDidLoad BroadcastTxPage');
|
||||
}
|
||||
|
||||
public send(): void {
|
||||
let postData: any = {
|
||||
rawtx: this.transaction
|
||||
};
|
||||
this.status = 'loading';
|
||||
|
||||
console.log('the postData is', postData);
|
||||
|
||||
this.http.post(this.api.apiPrefix + 'tx/send', postData)
|
||||
.subscribe(
|
||||
response => console.log('response', response),
|
||||
response => {
|
||||
this.presentToast(response);
|
||||
},
|
||||
err => console.log('err', err)
|
||||
);
|
||||
/*
|
||||
.error(function(data, status, headers, config) {
|
||||
$scope.status = 'error';
|
||||
if(data) {
|
||||
$scope.error = data;
|
||||
} else {
|
||||
$scope.error = "No error message given (connection error?)"
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
private presentToast(response: any): void {
|
||||
let body: any = JSON.parse(response._body);
|
||||
let toast: any = this.toastCtrl.create({
|
||||
message: 'Transaction successfully broadcast. Trasaction id: ' + body.txid,
|
||||
position: 'middle',
|
||||
showCloseButton: true,
|
||||
dismissOnPageChange: true
|
||||
});
|
||||
toast.present();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user