Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-ui: added color effect on newest blocks (fixes #20) #25

Merged
merged 4 commits into from
Jun 17, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.latest-block {
AlexITC marked this conversation as resolved.
Show resolved Hide resolved
animation: blinker 1s linear;
}

@keyframes blinker {
50% {
background-color: #D4FFD4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h4>{{'message.loadingLatestBlocks' | translate}}</h4>
</thead>

<tbody>
<tr *ngFor="let item of blocks">
<tr *ngFor="let item of blocks" [ngClass]="{ 'latest-block': isBlockRecent(item) }">
<td>
<a routerLink="/blocks/{{item.hash}}">{{item.height}}</a>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ErrorService } from '../../services/error.service';
export class LatestBlocksComponent implements OnInit, OnDestroy {

blocks: Block[];
private latestBlockHeight: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, initialize this to 0 or -1 to avoid undefined issues.

private subscription$: Subscription;

constructor(
Expand Down Expand Up @@ -70,6 +71,7 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
}

private onBlockRetrieved(response: Block[]) {
this.latestBlockHeight = this.blocks ? this.blocks[0].height : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please just get the maximum instead.

this.blocks = response;
}

Expand All @@ -92,4 +94,8 @@ export class LatestBlocksComponent implements OnInit, OnDestroy {
age(block: Block): string {
return '';
}

isBlockRecent(item: Block): boolean {
return item.height > this.latestBlockHeight;
}
}