mirror of
https://github.com/mempool/mempool.git
synced 2025-03-03 17:47:01 +01:00
UI/UX - Add skeleton for blocks preload. (#615)
* Add skeleton for blocks preload. * Add e2e testing for skeleton blocks preloader. * Fix reduce mempool blocks to fit the screen. * Fix variable naming.
This commit is contained in:
parent
652f88770e
commit
71cf41362f
7 changed files with 99 additions and 18 deletions
|
@ -16,6 +16,17 @@ describe('Mainnet', () => {
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('loads the dashboard with the skeleton blocks', () => {
|
||||||
|
cy.visit('/');
|
||||||
|
cy.get('#mempool-block-0').should('be.visible');
|
||||||
|
cy.get('#mempool-block-1').should('be.visible');
|
||||||
|
cy.get('#mempool-block-2').should('be.visible');
|
||||||
|
cy.get(':nth-child(1) > #bitcoin-block-0').should('be.visible');
|
||||||
|
cy.get(':nth-child(2) > #bitcoin-block-0').should('be.visible');
|
||||||
|
cy.get(':nth-child(3) > #bitcoin-block-0').should('be.visible');
|
||||||
|
cy.wait(1000);
|
||||||
|
});
|
||||||
|
|
||||||
it('loads the blocks screen', () => {
|
it('loads the blocks screen', () => {
|
||||||
cy.visit('/');
|
cy.visit('/');
|
||||||
cy.get('li:nth-of-type(2) > a').click().then(() => {
|
cy.get('li:nth-of-type(2) > a').click().then(() => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="blocks-container" *ngIf="blocks.length">
|
<div class="blocks-container" *ngIf="(isLoading$ | async) === false">
|
||||||
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
||||||
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]">
|
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]">
|
||||||
<a [routerLink]="['/block/' | relativeUrl, block.id]" [state]="{ data: { block: block } }" class="blockLink"> </a>
|
<a [routerLink]="['/block/' | relativeUrl, block.id]" [state]="{ data: { block: block } }" class="blockLink"> </a>
|
||||||
|
@ -24,3 +24,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div [hidden]="!arrowVisible" id="arrow-up" [style.transition]="transition" [ngStyle]="{'left': arrowLeftPx + 'px' }"></div>
|
<div [hidden]="!arrowVisible" id="arrow-up" [style.transition]="transition" [ngStyle]="{'left': arrowLeftPx + 'px' }"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="blocks-container" *ngIf="(isLoading$ | async) === true">
|
||||||
|
<div class="flashing">
|
||||||
|
<div *ngFor="let block of blocks; let i = index; trackBy: trackByBlocksFn" >
|
||||||
|
<div class="text-center bitcoin-block mined-block" id="bitcoin-block-{{ block.height }}" [ngStyle]="blockStyles[i]"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -108,3 +108,15 @@
|
||||||
border-right: 35px solid transparent;
|
border-right: 35px solid transparent;
|
||||||
border-bottom: 35px solid #FFF;
|
border-bottom: 35px solid #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flashing {
|
||||||
|
animation: opacityPulse 2s ease-out;
|
||||||
|
animation-iteration-count: infinite;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes opacityPulse {
|
||||||
|
0% {opacity: 0.7;}
|
||||||
|
50% {opacity: 1.0;}
|
||||||
|
100% {opacity: 0.7;}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Input } from '@angular/core';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription, Observable } from 'rxjs';
|
||||||
import { Block } from 'src/app/interfaces/electrs.interface';
|
import { Block } from 'src/app/interfaces/electrs.interface';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
@ -11,8 +11,10 @@ import { Router } from '@angular/router';
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||||
|
@Input() isLoading$: Observable<boolean>;
|
||||||
|
|
||||||
network = '';
|
network = '';
|
||||||
blocks: Block[] = [];
|
blocks: Block[] = this.mountEmptyBlocks();
|
||||||
markHeight: number;
|
markHeight: number;
|
||||||
blocksSubscription: Subscription;
|
blocksSubscription: Subscription;
|
||||||
networkSubscriotion: Subscription;
|
networkSubscriotion: Subscription;
|
||||||
|
@ -42,6 +44,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.blocks.forEach((b) => this.blockStyles.push(this.getStyleForBlock(b)));
|
||||||
this.networkSubscriotion = this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
this.networkSubscriotion = this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
||||||
this.tabHiddenSubscription = this.stateService.isTabHidden$.subscribe((tabHidden) => this.tabHidden = tabHidden);
|
this.tabHiddenSubscription = this.stateService.isTabHidden$.subscribe((tabHidden) => this.tabHidden = tabHidden);
|
||||||
|
|
||||||
|
@ -178,5 +181,26 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
|
||||||
)`,
|
)`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
mountEmptyBlocks() {
|
||||||
|
const emptyBlocks = [];
|
||||||
|
for (let i = 0; i < 9; i++) {
|
||||||
|
emptyBlocks.push({
|
||||||
|
id: '',
|
||||||
|
height: 0,
|
||||||
|
version: 0,
|
||||||
|
timestamp: 0,
|
||||||
|
bits: 0,
|
||||||
|
nonce: 0,
|
||||||
|
difficulty: 0,
|
||||||
|
merkle_root: '',
|
||||||
|
tx_count: 0,
|
||||||
|
size: 0,
|
||||||
|
weight: 0,
|
||||||
|
previousblockhash: '',
|
||||||
|
matchRate: 0,
|
||||||
|
stage: 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return emptyBlocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
<div class="text-center" class="blockchain-wrapper">
|
<div class="text-center" class="blockchain-wrapper">
|
||||||
<div class="position-container" [hidden]="(isLoading$ | async) === true">
|
<div class="position-container">
|
||||||
<span>
|
<span>
|
||||||
<app-mempool-blocks></app-mempool-blocks>
|
<app-mempool-blocks [isLoading$]="isLoading$"></app-mempool-blocks>
|
||||||
<app-blockchain-blocks></app-blockchain-blocks>
|
<app-blockchain-blocks [isLoading$]="isLoading$"></app-blockchain-blocks>
|
||||||
<div id="divider"></div>
|
<div id="divider"></div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="(isLoading$ | async) === true" class="position-container loading">
|
|
||||||
<div class="loading-block">
|
|
||||||
<h3 i18n="blockchain.waiting-for-blocks|Loading text">Waiting for blocks...</h3>
|
|
||||||
<div class="spinner-border text-light mt-2"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="mempool-blocks-container">
|
<div class="mempool-blocks-container" *ngIf="(isLoading$ | async) === false">
|
||||||
<div class="flashing">
|
<div class="flashing">
|
||||||
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks$ | async" let-i="index" [ngForTrackBy]="trackByFn">
|
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks$ | async" let-i="index" [ngForTrackBy]="trackByFn">
|
||||||
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]">
|
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]">
|
||||||
|
@ -41,3 +41,11 @@
|
||||||
<ng-template let-i #nextBlockEtaPlural i18n="mempool-blocks.eta-of-next-block-plural|Block Frequency (plural)">In ~{{ i }} minutes</ng-template>
|
<ng-template let-i #nextBlockEtaPlural i18n="mempool-blocks.eta-of-next-block-plural|Block Frequency (plural)">In ~{{ i }} minutes</ng-template>
|
||||||
|
|
||||||
<ng-template let-i #nextBlockEta i18n="mempool-blocks.eta-of-next-block|Block Frequency">In ~{{ i }} minute</ng-template>
|
<ng-template let-i #nextBlockEta i18n="mempool-blocks.eta-of-next-block|Block Frequency">In ~{{ i }} minute</ng-template>
|
||||||
|
|
||||||
|
<div class="mempool-blocks-container" *ngIf="(isLoading$ | async) === true">
|
||||||
|
<div class="flashing">
|
||||||
|
<ng-template ngFor let-projectedBlock [ngForOf]="mempoolBlocks" let-i="index" [ngForTrackBy]="trackByFn">
|
||||||
|
<div class="bitcoin-block text-center mempool-block" id="mempool-block-{{ i }}" [ngStyle]="mempoolBlockStyles[i]"></div>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
|
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Input } from '@angular/core';
|
||||||
import { Subscription, Observable, fromEvent, merge, of } from 'rxjs';
|
import { Subscription, Observable, fromEvent, merge, of } from 'rxjs';
|
||||||
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
import { MempoolBlock } from 'src/app/interfaces/websocket.interface';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
|
@ -13,10 +13,12 @@ import { feeLevels, mempoolFeeColors } from 'src/app/app.constants';
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
||||||
mempoolBlocks: MempoolBlock[];
|
@Input() isLoading$: Observable<boolean>;
|
||||||
|
|
||||||
|
mempoolBlocks: MempoolBlock[] = this.mountEmptyBlocks();
|
||||||
mempoolBlocks$: Observable<MempoolBlock[]>;
|
mempoolBlocks$: Observable<MempoolBlock[]>;
|
||||||
|
|
||||||
mempoolBlocksFull: MempoolBlock[];
|
mempoolBlocksFull: MempoolBlock[] = this.mountEmptyBlocks();
|
||||||
mempoolBlockStyles = [];
|
mempoolBlockStyles = [];
|
||||||
markBlocksSubscription: Subscription;
|
markBlocksSubscription: Subscription;
|
||||||
blockSubscription: Subscription;
|
blockSubscription: Subscription;
|
||||||
|
@ -45,6 +47,11 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.mempoolBlocks.map(() => {
|
||||||
|
this.updateMempoolBlockStyles();
|
||||||
|
this.calculateTransactionPosition();
|
||||||
|
});
|
||||||
|
this.reduceMempoolBlocksToFitScreen(this.mempoolBlocks);
|
||||||
this.stateService.isTabHidden$.subscribe((tabHidden) => this.tabHidden = tabHidden);
|
this.stateService.isTabHidden$.subscribe((tabHidden) => this.tabHidden = tabHidden);
|
||||||
|
|
||||||
this.mempoolBlocks$ = merge(
|
this.mempoolBlocks$ = merge(
|
||||||
|
@ -235,4 +242,20 @@ export class MempoolBlocksComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mountEmptyBlocks() {
|
||||||
|
const emptyBlocks = [];
|
||||||
|
const numberOfBlocks = 8;
|
||||||
|
for (let i = 0; i <= numberOfBlocks; i++) {
|
||||||
|
emptyBlocks.push({
|
||||||
|
blockSize: 0,
|
||||||
|
blockVSize: 0,
|
||||||
|
feeRange: [],
|
||||||
|
index: 0,
|
||||||
|
medianFee: 0,
|
||||||
|
nTx: 0,
|
||||||
|
totalFees: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return emptyBlocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue