From 1a37c8b11650462e5ab01182202c78672402c895 Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 19 Oct 2021 23:24:12 +0400 Subject: [PATCH] Add output ID to transaction info fixes #413 --- .../search-form/search-form.component.ts | 19 ++++++++++--------- .../transaction/transaction.component.html | 2 +- .../transaction/transaction.component.ts | 5 ++++- .../transactions-list.component.html | 8 ++++---- .../transactions-list.component.ts | 9 +++++++++ 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index 61807b674..e560076e7 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -25,7 +25,7 @@ export class SearchFormComponent implements OnInit { regexAddress = /^([a-km-zA-HJ-NP-Z1-9]{26,35}|[a-km-zA-HJ-NP-Z1-9]{80}|[a-z]{2,5}1[ac-hj-np-z02-9]{8,100}|[A-Z]{2,5}1[AC-HJ-NP-Z02-9]{8,100})$/; regexBlockhash = /^[0]{8}[a-fA-F0-9]{56}$/; - regexTransaction = /^[a-fA-F0-9]{64}$/; + regexTransaction = /^([a-fA-F0-9]{64}):?(\d+)?$/; regexBlockheight = /^[0-9]+$/; @ViewChild('instance', {static: true}) instance: NgbTypeahead; @@ -100,22 +100,23 @@ export class SearchFormComponent implements OnInit { } else if (this.regexBlockhash.test(searchText) || this.regexBlockheight.test(searchText)) { this.navigate('/block/', searchText); } else if (this.regexTransaction.test(searchText)) { + const matches = this.regexTransaction.exec(searchText); if (this.network === 'liquid') { - if (this.assets[searchText]) { - this.navigate('/asset/', searchText); + if (this.assets[matches[1]]) { + this.navigate('/asset/', matches[1]); } - this.electrsApiService.getAsset$(searchText) + this.electrsApiService.getAsset$(matches[1]) .subscribe( - () => { this.navigate('/asset/', searchText); }, + () => { this.navigate('/asset/', matches[1]); }, () => { - this.electrsApiService.getBlock$(searchText) + this.electrsApiService.getBlock$(matches[1]) .subscribe( - (block) => { this.navigate('/block/', searchText, { state: { data: { block } } }); }, - () => { this.navigate('/tx/', searchText); }); + (block) => { this.navigate('/block/', matches[1], { state: { data: { block } } }); }, + () => { this.navigate('/tx/', matches[0]); }); } ); } else { - this.navigate('/tx/', searchText); + this.navigate('/tx/', matches[0]); } } else { this.isSearching = false; diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 96e118eb5..72aabd6cd 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -198,7 +198,7 @@
- +

Details

diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index b9a4ebffa..8bb1c4782 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -44,6 +44,7 @@ export class TransactionComponent implements OnInit, OnDestroy { now = new Date().getTime(); timeAvg$: Observable; liquidUnblinding = new LiquidUnblinding(); + outputIndex: number; constructor( private route: ActivatedRoute, @@ -125,7 +126,9 @@ export class TransactionComponent implements OnInit, OnDestroy { this.subscription = this.route.paramMap .pipe( switchMap((params: ParamMap) => { - this.txId = params.get('id') || ''; + const urlMatch = (params.get('id') || '').split(':'); + this.txId = urlMatch[0]; + this.outputIndex = urlMatch[1] === undefined ? null : parseInt(urlMatch[1], 10); this.seoService.setTitle( $localize`:@@bisq.transaction.browser-title:Transaction: ${this.txId}:INTERPOLATION:` ); diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.html b/frontend/src/app/components/transactions-list/transactions-list.component.html index 6207531dc..657d88197 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.html +++ b/frontend/src/app/components/transactions-list/transactions-list.component.html @@ -33,7 +33,7 @@ - + @@ -121,8 +121,8 @@
- - + + - + diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.ts b/frontend/src/app/components/transactions-list/transactions-list.component.ts index 4425317c0..8cb62c104 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.ts +++ b/frontend/src/app/components/transactions-list/transactions-list.component.ts @@ -22,6 +22,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { @Input() showConfirmations = false; @Input() transactionPage = false; @Input() errorUnblinded = false; + @Input() outputIndex: number; @Output() loadMore = new EventEmitter(); @@ -51,6 +52,14 @@ export class TransactionsListComponent implements OnInit, OnChanges { if (!this.transactions || !this.transactions.length) { return; } + if (this.outputIndex) { + setTimeout(() => { + const assetBoxElements = document.getElementsByClassName('assetBox'); + if (assetBoxElements && assetBoxElements[0]) { + assetBoxElements[0].scrollIntoView(); + } + }, 10); + } const observableObject = {}; this.transactions.forEach((tx, i) => { tx['@voutLimit'] = true;
{{ vout.scriptpubkey_address | shortenString : 16 }} @@ -197,7 +197,7 @@