Skip to content

Commit

Permalink
web-ui: Add infinite scroll to block screen
Browse files Browse the repository at this point in the history
  • Loading branch information
JonSalazar committed Jan 17, 2019
1 parent 870f2c7 commit 9100fc6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions web-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ <h2 class="col-xs-12">{{'label.block' | translate}} #{{blockDetails.block.height
</tr>
</thead>

<tbody>
<tbody
infiniteScroll
[infiniteScrollDistance]="1"
[infiniteScrollThrottle]="300"
(scrolled)="load()"
[scrollWindow]="true">
<tr *ngFor="let index = index; let item of transactions">
<td>{{index + 1}}</td>
<td>
Expand All @@ -285,13 +290,6 @@ <h2 class="col-xs-12">{{'label.block' | translate}} #{{blockDetails.block.height
</table>
</div>

<div class="row">
<div class="col-xs-11 col-xs-offset-1 col-sm-5 col-sm-offset-4">
<button (click)="load()">{{'label.more' | translate}}</button>
</div>
</div>
</div>

<!-- transaction list only -->
<div *ngIf="transactions != null && transactions.length == 0" class="col-xs-12 col-md-offset-2 col-md-8">
<div class="table-responsive">
Expand Down
15 changes: 12 additions & 3 deletions web-ui/src/app/components/block-details/block-details.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, HostListener } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { BlockDetails } from '../../models/block';
Expand All @@ -8,6 +8,8 @@ import { BlocksService } from '../../services/blocks.service';
import { ErrorService } from '../../services/error.service';
import { PaginatedResult } from '../../models/paginated-result';

import { getNumberOfRowsForScreen } from '../../utils';

@Component({
selector: 'app-block-details',
templateUrl: './block-details.component.html',
Expand All @@ -19,7 +21,7 @@ export class BlockDetailsComponent implements OnInit {
blockDetails: BlockDetails;

// pagination
limit = 10;
limit = 30;
transactions: Transaction[] = [];

constructor(
Expand All @@ -28,6 +30,8 @@ export class BlockDetailsComponent implements OnInit {
private errorService: ErrorService) { }

ngOnInit() {
const height = this.getScreenSize();
this.limit = getNumberOfRowsForScreen(height);
this.route.params.forEach(params => this.onQuery(params['query']));
}

Expand Down Expand Up @@ -59,10 +63,15 @@ export class BlockDetailsComponent implements OnInit {

this.blocksService
.getTransactionsV2(this.blockhash, this.limit, lastSeenTxid)
.do(response => this.transactions = this.transactions.concat(response.data))
.do(response => this.transactions.push(...response.data))
.subscribe();
}

@HostListener('window:resize', ['$event'])
private getScreenSize(_?): number {
return window.innerHeight;
}

private onError(response: any) {
this.errorService.renderServerErrors(null, response);
}
Expand Down

0 comments on commit 9100fc6

Please sign in to comment.