Skip to content

Commit b152745

Browse files
authored
Frontend - Leaderboard improvements and changes #1064
Frontend - Leaderboard improvements and changes
2 parents 982f020 + 1116084 commit b152745

File tree

54 files changed

+616
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+616
-165
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frontend",
3-
"version": "1.0.103",
3+
"version": "1.0.121",
44
"scripts": {
55
"install:deps": "npm install",
66
"start": "npm install && ng serve --configuration local --open",

frontend/src/app/app.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
class="overflow-hidden"
2929
[class.no-toolbar]="hideToolbar"
3030
[class.no-submenus]="subMenusLength < 2"
31-
[class.mobile]="menu.isMobile">
31+
[class.mobile]="menu.isMobile"
32+
[class.uptime]="showUptime">
3233
<router-outlet></router-outlet>
3334
</div>
3435
@if (!isDesktop) {

frontend/src/app/app.component.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ mat-sidenav-content {
7676
margin-bottom: 4px;
7777
border-top-right-radius: 6px;
7878

79-
&.no-toolbar {
80-
height: calc(100% - #{$subMenus} - #{$tabs});
79+
80+
&.uptime {
81+
$toolbar: 130px;
82+
height: calc(100% - #{$toolbar} - #{$subMenus} - #{$tabs});
8183
}
8284

8385
&.no-submenus {
@@ -86,6 +88,14 @@ mat-sidenav-content {
8688
&.no-toolbar {
8789
height: 100%;
8890
}
91+
92+
&.uptime {
93+
height: calc(100% - #{$toolbar} - #{$subMenus});
94+
}
95+
}
96+
97+
&.no-toolbar {
98+
height: calc(100% - #{$subMenus} - #{$tabs});
8999
}
90100
}
91101
}

frontend/src/app/app.component.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class AppComponent extends StoreDispatcher implements OnInit {
2828
readonly showLeaderboardPage$: Observable<boolean> = this.select$(getMergedRoute).pipe(filter(Boolean), map((route: MergedRoute) => route.url.startsWith(`/${Routes.LEADERBOARD}`)));
2929
subMenusLength: number = 0;
3030
hideToolbar: boolean = CONFIG.hideToolbar;
31+
showUptime: boolean = CONFIG.showLeaderboard;
3132
loaded: boolean;
3233
isDesktop: boolean = isDesktop();
3334

@@ -54,31 +55,30 @@ export class AppComponent extends StoreDispatcher implements OnInit {
5455
localStorage.setItem('webnodeArgs', args);
5556
}
5657
}
58+
this.select(getMergedRoute, () => {
59+
this.loaded = true;
60+
this.detect();
61+
}, filter(Boolean), take(1));
5762

58-
this.select(
59-
getMergedRoute,
60-
() => this.initAppFunctionalities(),
61-
filter(Boolean),
62-
take(1),
63-
filter((route: MergedRoute) => route.url !== '/' && !route.url.startsWith('/?') && !route.url.startsWith('/leaderboard')),
64-
);
65-
this.select(
66-
getMergedRoute,
67-
() => {
68-
this.loaded = true;
69-
this.detect();
70-
},
71-
filter(Boolean),
72-
take(1),
73-
);
63+
if (CONFIG.showLeaderboard && CONFIG.showWebNodeLandingPage) {
64+
/* frontend with some landing page */
65+
this.select(getMergedRoute, () => {
66+
this.initAppFunctionalities();
67+
}, filter((route: MergedRoute) => route?.url.startsWith('/loading-web-node')), take(1));
68+
69+
} else if (!CONFIG.showLeaderboard && !CONFIG.showWebNodeLandingPage) {
70+
/* normal frontend (no landing pages) */
71+
this.initAppFunctionalities();
72+
}
7473
}
7574

7675
goToWebNode(): void {
77-
this.router.navigate([Routes.LOADING_WEB_NODE], { queryParamsHandling: 'merge' });
76+
// this.router.navigate([Routes.LOADING_WEB_NODE], { queryParamsHandling: 'merge' });
7877
this.initAppFunctionalities();
7978
}
8079

8180
private initAppFunctionalities(): void {
81+
console.log('initAppFunctionalities');
8282
if (this.webNodeService.hasWebNodeConfig() && !this.webNodeService.isWebNodeLoaded()) {
8383
if (!getWindow()?.location.href.includes(`/${Routes.LOADING_WEB_NODE}`)) {
8484
this.router.navigate([Routes.LOADING_WEB_NODE], { queryParamsHandling: 'preserve' });

frontend/src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { BlockProductionPillComponent } from '@app/layout/block-production-pill/
4343
import { MenuTabsComponent } from '@app/layout/menu-tabs/menu-tabs.component';
4444
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
4545
import { LeaderboardModule } from '@leaderboard/leaderboard.module';
46+
import { UptimePillComponent } from '@app/layout/uptime-pill/uptime-pill.component';
4647

4748
registerLocaleData(localeFr, 'fr');
4849
registerLocaleData(localeEn, 'en');
@@ -166,6 +167,7 @@ export class AppGlobalErrorhandler implements ErrorHandler {
166167
BlockProductionPillComponent,
167168
MenuTabsComponent,
168169
LeaderboardModule,
170+
UptimePillComponent,
169171
],
170172
providers: [
171173
THEME_PROVIDER,

frontend/src/app/app.routing.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import { NgModule } from '@angular/core';
22
import { NoPreloading, RouterModule, Routes } from '@angular/router';
33
import { CONFIG, getFirstFeature } from '@shared/constants/config';
44
import { WebNodeLandingPageComponent } from '@app/layout/web-node-landing-page/web-node-landing-page.component';
5+
import { getMergedRoute, MergedRoute } from '@openmina/shared';
6+
import { filter, take } from 'rxjs';
7+
import { landingPageGuard } from '@shared/guards/landing-page.guard';
58

69
const APP_TITLE: string = 'Open Mina';
710

@@ -24,6 +27,7 @@ function generateRoutes(): Routes {
2427
path: 'dashboard',
2528
loadChildren: () => import('@dashboard/dashboard.module').then(m => m.DashboardModule),
2629
title: DASHBOARD_TITLE,
30+
canActivate: [landingPageGuard],
2731
},
2832
{
2933
path: 'nodes',
@@ -45,6 +49,7 @@ function generateRoutes(): Routes {
4549
path: 'state',
4650
loadChildren: () => import('@state/state.module').then(m => m.StateModule),
4751
title: STATE_TITLE,
52+
canActivate: [landingPageGuard],
4853
},
4954
{
5055
path: 'snarks',
@@ -55,16 +60,19 @@ function generateRoutes(): Routes {
5560
path: 'block-production',
5661
loadChildren: () => import('@block-production/block-production.module').then(m => m.BlockProductionModule),
5762
title: BLOCK_PRODUCTION_TITLE,
63+
canActivate: [landingPageGuard],
5864
},
5965
{
6066
path: 'mempool',
6167
loadChildren: () => import('@mempool/mempool.module').then(m => m.MempoolModule),
6268
title: MEMPOOL_TITLE,
69+
canActivate: [landingPageGuard],
6370
},
6471
{
6572
path: 'benchmarks',
6673
loadChildren: () => import('@benchmarks/benchmarks.module').then(m => m.BenchmarksModule),
6774
title: BENCHMARKS_TITLE,
75+
canActivate: [landingPageGuard],
6876
},
6977
{
7078
path: 'fuzzing',
@@ -75,12 +83,19 @@ function generateRoutes(): Routes {
7583
path: 'loading-web-node',
7684
loadChildren: () => import('@web-node/web-node.module').then(m => m.WebNodeModule),
7785
title: WEBNODE_TITLE,
86+
canActivate: [landingPageGuard],
7887
},
79-
{
88+
// {
89+
// path: '',
90+
// loadChildren: () => import('@leaderboard/leaderboard.module').then(m => m.LeaderboardModule),
91+
// },
92+
];
93+
if (CONFIG.showLeaderboard) {
94+
routes.push({
8095
path: '',
8196
loadChildren: () => import('@leaderboard/leaderboard.module').then(m => m.LeaderboardModule),
82-
},
83-
];
97+
});
98+
}
8499
if (CONFIG.showWebNodeLandingPage) {
85100
routes.push({
86101
path: '',

frontend/src/app/core/helpers/file-progress.helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BehaviorSubject } from 'rxjs';
22
import { safelyExecuteInBrowser } from '@openmina/shared';
33

4-
const WASM_FILE_SIZE = 31705944;
4+
const WASM_FILE_SIZE = 31556926;
55

66
class AssetMonitor {
77
readonly downloads: Map<string, any> = new Map();

frontend/src/app/core/services/firestore.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
DocumentData,
1212
} from '@angular/fire/firestore';
1313
import { HttpClient } from '@angular/common/http';
14-
import { Observable } from 'rxjs';
14+
import { catchError, EMPTY, Observable } from 'rxjs';
1515

1616
@Injectable({
1717
providedIn: 'root',
@@ -27,7 +27,12 @@ export class FirestoreService {
2727

2828
addHeartbeat(data: any): Observable<any> {
2929
console.log('Posting to cloud function:', data);
30-
return this.http.post(this.cloudFunctionUrl, { data });
30+
return this.http.post(this.cloudFunctionUrl, { data }).pipe(
31+
catchError(error => {
32+
console.error('Error while posting to cloud function:', error);
33+
return error;
34+
}),
35+
);
3136
}
3237

3338
updateHeartbeat(id: string, data: any): Promise<void> {

frontend/src/app/core/services/rust.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class RustService {
1515
private webNodeService: WebNodeService) {}
1616

1717
changeRustNode(node: MinaNode): void {
18+
console.log('Changing Rust node to:', node);
1819
this.node = node;
1920
}
2021

frontend/src/app/core/services/web-node.service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class WebNodeService {
6060
}
6161

6262
loadWasm$(): Observable<void> {
63+
console.log('Loading wasm');
6364
this.webNodeStartTime = Date.now();
6465

6566
if (isBrowser()) {
@@ -142,9 +143,14 @@ export class WebNodeService {
142143
return throwError(() => new Error(error.message));
143144
}),
144145
switchMap(() => this.webnode$.asObservable()),
146+
// filter(() => CONFIG.globalConfig.heartbeats),
145147
switchMap(() => timer(0, 60000)),
146148
switchMap(() => this.heartBeat$),
147149
switchMap(heartBeat => this.firestore.addHeartbeat(heartBeat)),
150+
catchError(error => {
151+
console.log('Error from heartbeat api:', error);
152+
return of(null);
153+
}),
148154
);
149155
}
150156
return EMPTY;

0 commit comments

Comments
 (0)