mempool/frontend/src/app/explorer/transaction/transaction.component.ts

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-11-06 15:35:02 +08:00
import { Component, OnInit } from '@angular/core';
2019-11-10 16:44:00 +08:00
import { ApiService } from 'src/app/services/api.service';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { switchMap } from 'rxjs/operators';
import { MemPoolService } from 'src/app/services/mem-pool.service';
2019-11-06 15:35:02 +08:00
@Component({
selector: 'app-transaction',
templateUrl: './transaction.component.html',
styleUrls: ['./transaction.component.scss']
})
export class TransactionComponent implements OnInit {
2019-11-10 16:44:00 +08:00
tx: any;
isLoadingTx = true;
conversions: any;
2019-11-13 14:51:44 +08:00
error: any;
2019-11-10 16:44:00 +08:00
constructor(
private route: ActivatedRoute,
private apiService: ApiService,
private memPoolService: MemPoolService,
) { }
2019-11-06 15:35:02 +08:00
ngOnInit() {
2019-11-10 16:44:00 +08:00
this.route.paramMap.pipe(
switchMap((params: ParamMap) => {
2019-11-13 14:51:44 +08:00
this.error = undefined;
2019-11-10 16:44:00 +08:00
const txId: string = params.get('id') || '';
return this.apiService.getTransaction$(txId);
})
)
.subscribe((tx) => {
this.tx = tx;
this.isLoadingTx = false;
2019-11-13 14:51:44 +08:00
},
(error) => {
this.error = error;
this.isLoadingTx = false;
2019-11-10 16:44:00 +08:00
});
2019-11-06 15:35:02 +08:00
2019-11-10 16:44:00 +08:00
this.memPoolService.conversions$
.subscribe((conversions) => {
this.conversions = conversions;
});
}
2019-11-06 15:35:02 +08:00
}