cic-staff-client/src/app/pages/transactions/transactions.component.ts

59 lines
3.9 KiB
TypeScript
Raw Normal View History

import {Component, OnDestroy, OnInit} from '@angular/core';
import {TransactionService} from '../../_services/transaction.service';
import {Transaction} from '../../_models';
import {Subject} from 'rxjs';
import {first} from 'rxjs/operators';
@Component({
selector: 'app-transactions',
templateUrl: './transactions.component.html',
styleUrls: ['./transactions.component.scss']
})
export class TransactionsComponent implements OnInit, OnDestroy {
public data: Transaction[] = [
{from: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', to: '0xc14958CD9A605AB0d9A36850362AaD2b9D42DF97', token: {address: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', name: 'RSV', symbol: 'Reserve Token'}, value: 100000, tx: {block: 20, txIndex: 0, txHash: '0x88a498042610113f1348fdaab03eabd6d67e1d182fb23cb2b580a3db342a5aa5', timestamp: 1603360297, success: true}},
{from: '0xc14958CD9A605AB0d9A36850362AaD2b9D42DF97', to: '0xbF0b5cD8Ae50b3bfA304D1f989916038E6d2Fa2e', token: {address: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', name: 'RSV', symbol: 'Reserve Token'}, value: 100000, tx: {block: 26, txIndex: 0, txHash: '0x165b4a37ccf7f8bf1fac057d509939d890ada47d040d1f8e180aed538c72af6c', timestamp: 1603360298, success: true}},
{from: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', to: '0xe3C4db5947409Aff0FF8D643047EA41515cA4B8e', token: {address: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', name: 'RSV', symbol: 'Reserve Token'}, value: 50000, tx: {block: 21, txIndex: 0, txHash: '0x552948b95f0bf2768e0ed2251627295d9c60d9d3509f397aa1c585be496dea39', timestamp: 1603360298, success: true}},
{from: '0xe3C4db5947409Aff0FF8D643047EA41515cA4B8e', to: '0xee617C30f026536d420358CF00fE60b993975A6f', token: {address: '0x36Bd1f197E2b3D2b8213d4A1Dc20a6d949B8C273', name: 'RSV', symbol: 'Reserve Token'}, value: 50000, tx: {block: 29, txIndex: 0, txHash: '0x2aa5cfb84eb1d36fe9f9554c4633914eb8e5813a47ef07d02b621b96c9d86ffa', timestamp: 1603360298, success: true}},
{from: '0x0000000000000000000000000000000000000000', to: '0xc14958CD9A605AB0d9A36850362AaD2b9D42DF97', token: {address: '0x528c3E8B3e6dC646530440D88F83da0e45DaC25b', name: 'BRT', symbol: 'Bert Token'}, value: 400000, tx: {block: 26, txIndex: 0, txHash: '0x165b4a37ccf7f8bf1fac057d509939d890ada47d040d1f8e180aed538c72af6c', timestamp: 1603360298, success: true}},
{from: '0x0000000000000000000000000000000000000000', to: '0xe3C4db5947409Aff0FF8D643047EA41515cA4B8e', token: {address: '0x720B26ebd87476b39a47DE50020376d099d7e1A0', name: 'RNI', symbol: 'Ernie Token'}, value: 200000, tx: {block: 29, txIndex: 0, txHash: '0x2aa5cfb84eb1d36fe9f9554c4633914eb8e5813a47ef07d02b621b96c9d86ffa', timestamp: 1603360298, success: true}},
{from: '0xc14958CD9A605AB0d9A36850362AaD2b9D42DF97', to: '0x528c3E8B3e6dC646530440D88F83da0e45DaC25b', token: {address: '0x528c3E8B3e6dC646530440D88F83da0e45DaC25b', name: 'BRT', symbol: 'Bert Token'}, value: 100, tx: {block: 33, txIndex: 0, txHash: '0xfbe21fcf7677a760b8792e5499e4cf7d5b9d16b0e343e81502882962467bba3b', timestamp: 1603645828, success: true}},
];
dtOptions: DataTables.Settings = {};
dtTrigger: Subject<any> = new Subject();
defaultLimit = 100;
defaultOffset = 0;
transactions: any[] = [];
transaction: Transaction;
error: any;
constructor(private transactionService: TransactionService) { }
ngOnInit(): void {
this.dtOptions = {
pagingType: 'full_numbers',
pageLength: 5,
lengthMenu: [5, 10, 25, 50, 100],
processing: true
};
this.transactionService.getAllTransactions(this.defaultOffset, this.defaultLimit)
.pipe(first()).subscribe(response => {
this.transactions = response;
this.dtTrigger.next();
console.log(response);
}, error => {
this.error = error;
console.log(error);
});
}
ngOnDestroy(): void {
this.dtTrigger.unsubscribe();
}
viewTransaction(transaction): void {
this.transaction = transaction;
}
}