Display input/output asset transfers

fixes #85
This commit is contained in:
softsimon 2020-06-12 16:17:52 +07:00
parent 56c6612e2e
commit 6eca311147
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
4 changed files with 27 additions and 13 deletions

View File

@ -59,6 +59,7 @@ export interface Prevout {
scriptpubkey_type: string;
scriptpubkey_address: string;
value: number;
asset?: string;
}
export interface Vin {

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { AssetsService } from '../services/assets.service';
import { environment } from 'src/environments/environment';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { filter, distinctUntilChanged } from 'rxjs/operators';
import { distinctUntilChanged } from 'rxjs/operators';
@Component({
selector: 'app-assets',
@ -32,13 +32,11 @@ export class AssetsComponent implements OnInit {
ngOnInit() {
this.itemsPerPage = Math.max(Math.round(this.contentSpace / this.fiveItemsPxSize) * 5, 10);
setTimeout(() => this.getAssets());
this.searchForm = this.formBuilder.group({
searchText: ['', Validators.required],
searchText: [{ value: '', disabled: true }, Validators.required]
});
this.searchForm.controls.searchText.valueChanges
this.searchForm.get('searchText').valueChanges
.pipe(
distinctUntilChanged(),
)
@ -54,6 +52,8 @@ export class AssetsComponent implements OnInit {
this.filteredAssets = this.assets.slice(0, this.itemsPerPage);
}
});
this.getAssets();
}
getAssets() {
@ -67,6 +67,7 @@ export class AssetsComponent implements OnInit {
});
this.assets = this.assets.sort((a: any, b: any) => a.name.localeCompare(b.name));
this.assetsCache = this.assets;
this.searchForm.controls['searchText'].enable();
this.filteredAssets = this.assets.slice(0, this.itemsPerPage);
this.isLoading = false;
},

View File

@ -51,7 +51,14 @@
</div>
</td>
<td class="text-right nowrap">
<app-amount *ngIf="vin.prevout" [satoshis]="vin.prevout.value"></app-amount>
<ng-template [ngIf]="vin.prevout && vin.prevout.asset && vin.prevout.asset !== nativeAssetId" [ngIfElse]="defaultOutput">
<div *ngIf="assetsMinimal && assetsMinimal[vin.prevout.asset]">
<ng-container *ngTemplateOutlet="assetBox; context:{ $implicit: vin.prevout }"></ng-container>
</div>
</ng-template>
<ng-template #defaultOutput>
<app-amount *ngIf="vin.prevout" [satoshis]="vin.prevout.value"></app-amount>
</ng-template>
</td>
</tr>
<tr *ngIf="tx.vin.length > tx['@vinLength']">
@ -85,14 +92,9 @@
</ng-template>
</td>
<td class="text-right nowrap">
<ng-template [ngIf]="vout.asset && vout.scriptpubkey_type === 'op_return' && vout.asset !== nativeAssetId" [ngIfElse]="defaultOutput">
<ng-template [ngIf]="vout.asset && vout.asset !== nativeAssetId" [ngIfElse]="defaultOutput">
<div *ngIf="assetsMinimal && assetsMinimal[vout.asset]">
{{ vout.value / 100000000 | number: '1.0-' + assetsMinimal[vout.asset][3] }} {{ assetsMinimal[vout.asset][1] }}
<br>
{{ assetsMinimal[vout.asset][0] }}
<br>
<a [routerLink]="['/asset/' | relativeUrl, vout.asset]">{{ vout.asset | shortenString : 13 }}</a>
<br><br>
<ng-container *ngTemplateOutlet="assetBox; context:{ $implicit: vout }"></ng-container>
</div>
</ng-template>
<ng-template #defaultOutput>
@ -147,3 +149,12 @@
<br>
</ng-container>
<ng-template #assetBox let-item>
{{ item.value / 100000000 | number: '1.0-' + assetsMinimal[item.asset][3] }} {{ assetsMinimal[item.asset][1] }}
<br>
{{ assetsMinimal[item.asset][0] }}
<br>
<a [routerLink]="['/asset/' | relativeUrl, item.asset]">{{ item.asset | shortenString : 13 }}</a>
<br><br>
</ng-template>

View File

@ -24,6 +24,7 @@ export interface Prevout {
scriptpubkey_type: string;
scriptpubkey_address: string;
value: number;
asset?: string;
}
export interface Vin {