Skip to content

Commit d8684bf

Browse files
committed
Frontend - Improve web node loading
1 parent 3f18c5e commit d8684bf

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

.idea/vcs.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"install:deps": "npm install",
66
"start": "npm install && ng serve --configuration local --open",
77
"start:dev": "ng serve --configuration development",
8+
"start:dev:mobile": "ng serve --configuration development --host 0.0.0.0",
89
"build": "ng build",
910
"build:prod": "ng build --configuration production",
1011
"tests": "npx cypress open --config baseUrl=http://localhost:4200",

frontend/src/app/features/webnode/web-node-demo-dashboard/web-node-demo-dashboard.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div class="logo-header w-100 border-bottom fx-row-full-cent">
22
<img ngSrc="assets/images/logo/logo-text.svg" height="40" width="136"/>
33
</div>
4-
<div class="data-wrapper fx-col-full-cent">
5-
<div class="header flex-column align-center mb-16 pb-12 pl-10 pr-10 text-center">
4+
<div class="data-wrapper flex-column flex-around align-center">
5+
<div class="header flex-column align-center pl-10 pr-10 text-center mb-16">
66
<div class="loading-webnode f-500">
77
Produce blocks,
8-
<span>&nbsp;right in your browser</span>
8+
<span>right in your browser</span>
99
</div>
1010

1111
<div class="font-16 tertiary mt-16 font-16 f-300">
@@ -21,7 +21,7 @@
2121
</div>
2222
</div>
2323

24-
<div #progress class="progress w-100"></div>
24+
<div #progress class="progress w-100 fx-row-full-cent"></div>
2525

2626
<div class="mt-16 flex-column w-100 pl-10 pr-10">
2727
@for (item of loading; track $index) {

frontend/src/app/features/webnode/web-node-demo-dashboard/web-node-demo-dashboard.component.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ $white: #000000;
1717
.data-wrapper {
1818
height: calc(100% - 56px - 72px);
1919
max-width: 568px;
20+
padding: 10vw 0;
2021

2122
.header {
22-
margin-bottom: 56px;
23-
2423
.loading-webnode {
2524
font-size: 24px;
2625
line-height: 32px;
@@ -40,8 +39,10 @@ $white: #000000;
4039
}
4140

4241
.progress {
43-
height: 380px;
44-
margin: 64px 0;
42+
min-height: 380px;
43+
@media (max-width: 768px) {
44+
min-height: 36vh;
45+
}
4546
}
4647
}
4748

@@ -80,9 +81,9 @@ $white: #000000;
8081
}
8182
}
8283

83-
@media (max-width: 768px) {
84+
@media (max-width: 568px) {
8485
.font-16 {
85-
font-size: 15px;
86+
font-size: 14px;
8687
}
8788
.loading-webnode span {
8889
display: block;

frontend/src/app/features/webnode/web-node-demo-dashboard/web-node-demo-dashboard.component.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { ChangeDetectionStrategy, Component, ElementRef, NgZone, OnInit, ViewChild } from '@angular/core';
1+
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
22
import { untilDestroyed } from '@ngneat/until-destroy';
33
import { StoreDispatcher } from '@shared/base-classes/store-dispatcher.class';
44
import { WebNodeService } from '@core/services/web-node.service';
55
import { GlobalErrorHandlerService } from '@openmina/shared';
66
import { NgClass, NgForOf, NgIf, NgOptimizedImage } from '@angular/common';
77
import { Router } from '@angular/router';
88
import { getFirstFeature } from '@shared/constants/config';
9-
import { trigger, state, style, transition, animate } from '@angular/animations';
9+
import { animate, state, style, transition, trigger } from '@angular/animations';
1010
import { filter, switchMap, timer } from 'rxjs';
1111
import { LoadingSpinnerComponent } from '@shared/loading-spinner/loading-spinner.component';
1212
import { FileProgressHelper } from '@core/helpers/file-progress.helper';
@@ -53,7 +53,7 @@ export interface WebNodeLoadingStep {
5353
]),
5454
],
5555
})
56-
export class WebNodeDemoDashboardComponent extends StoreDispatcher implements OnInit {
56+
export class WebNodeDemoDashboardComponent extends StoreDispatcher implements OnInit, AfterViewInit {
5757

5858
protected readonly WebNodeStepStatus = WebNodeStepStatus;
5959
readonly loading: WebNodeLoadingStep[] = [
@@ -87,6 +87,9 @@ export class WebNodeDemoDashboardComponent extends StoreDispatcher implements On
8787
this.listenToErrorIssuing();
8888
this.checkWebNodeProgress();
8989
this.fetchPeersInformation();
90+
}
91+
92+
ngAfterViewInit(): void {
9093
this.buildProgressBar();
9194
}
9295

@@ -196,10 +199,10 @@ export class WebNodeDemoDashboardComponent extends StoreDispatcher implements On
196199
downloaded: (progress.downloaded / 1e6).toFixed(1),
197200
total: (progress.totalSize / 1e6).toFixed(1),
198201
};
199-
// this step is only 1 out of 3. But it counts as 80% of the 100% progress.
200-
// So we need to calculate the total progress based on the current step.
201-
const totalProgress = (progress.progress * this.stepsPercentages[0]) / 100;
202-
this.updateProgressBar(totalProgress);
202+
if (this.svg) {
203+
const totalProgress = (progress.progress * this.stepsPercentages[0]) / 100;
204+
this.updateProgressBar(totalProgress);
205+
}
203206
this.detect();
204207
});
205208
}
@@ -259,7 +262,8 @@ export class WebNodeDemoDashboardComponent extends StoreDispatcher implements On
259262

260263
this.progressBar.append('text')
261264
.attr('text-anchor', 'middle')
262-
.attr('dominant-baseline', 'middle')
265+
.attr('alignment-baseline', 'central')
266+
.attr('dominant-baseline', 'central')
263267
.attr('font-size', '40px')
264268
.attr('fill', 'var(--base-primary)')
265269
.attr('opacity', 0.8)

0 commit comments

Comments
 (0)