mempool/frontend/src/app/tx-bubble/tx-bubble.component.ts

27 lines
825 B
TypeScript
Raw Normal View History

2019-07-21 17:59:47 +03:00
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { ITransaction } from '../blockchain/interfaces';
@Component({
selector: 'app-tx-bubble',
templateUrl: './tx-bubble.component.html',
styleUrls: ['./tx-bubble.component.scss']
})
export class TxBubbleComponent implements OnChanges {
@Input() tx: ITransaction | null = null;
@Input() txTrackingBlockHeight = 0;
@Input() latestBlockHeight = 0;
@Input() arrowPosition: 'top' | 'right' | 'bottom' | 'top-right' | 'top-left' = 'top';
txIdShort = '';
confirmations = 0;
constructor() { }
ngOnChanges() {
if (this.tx) {
this.txIdShort = this.tx.txid.substring(0, 6) + '...' + this.tx.txid.substring(this.tx.txid.length - 6);
}
this.confirmations = (this.latestBlockHeight - this.txTrackingBlockHeight) + 1;
}
}