Skip to content

Commit 24d793a

Browse files
authored
Frontend - Estimations in the UI Sync Dashboard #947
Frontend - Estimations in the UI Sync Dashboard
2 parents 2a6b0a1 + e769814 commit 24d793a

File tree

56 files changed

+801
-276
lines changed

Some content is hidden

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

56 files changed

+801
-276
lines changed

frontend/cypress/e2e/dashboard/ledgers.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('DASHBOARD LEDGERS', () => {
8888
cy.get('mina-dashboard-ledger > div:first-child > div.h-minus-xl > .group:nth-child(3) div.primary')
8989
.then((el: any) => {
9090
let progress;
91-
progress = state.rpcStats.rootLedger?.fetched / state.rpcStats.rootLedger?.estimation * 100 || 0;
91+
progress = state.rpcStats.snarkedRootLedger?.fetched / state.rpcStats.snarkedRootLedger?.estimation * 100 || 0;
9292
progress = Math.round(progress);
9393

9494
if (state.nodes[0].ledgers.rootSnarked.state === 'success') {

frontend/package-lock.json

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

frontend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frontend",
3-
"version": "1.0.21",
3+
"version": "1.0.44",
44
"scripts": {
55
"install:deps": "npm install",
66
"start": "npm install && ng serve --configuration local --open",
@@ -42,7 +42,7 @@
4242
"@ngrx/router-store": "^17.2.0",
4343
"@ngrx/store": "^17.2.0",
4444
"@nguniversal/express-engine": "^7.0.2",
45-
"@openmina/shared": "^0.116.0",
45+
"@openmina/shared": "^0.117.0",
4646
"@sentry/angular": "^8.35.0",
4747
"@sentry/cli": "^2.38.2",
4848
"@sentry/tracing": "^7.114.0",
@@ -86,4 +86,4 @@
8686
"webpack": "^5.88.2",
8787
"webpack-bundle-analyzer": "^4.9.0"
8888
}
89-
}
89+
}

frontend/src/app/app.actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { MinaNode } from '@shared/types/core/environment/mina-env.type';
22
import { createType } from '@shared/constants/store-functions';
33
import { createAction, props } from '@ngrx/store';
44
import { AppNodeDetails } from '@shared/types/app/app-node-details.type';
5+
import { AppEnvBuild } from '@shared/types/app/app-env-build.type';
56

67
export const APP_KEY = 'app';
78
export const APP_PREFIX = 'App';
@@ -14,6 +15,8 @@ const initSuccess = createAction(type('Init Success'), props<{ activeNode: MinaN
1415
const changeActiveNode = createAction(type('Change Active Node'), props<{ node: MinaNode }>());
1516
const getNodeDetails = createAction(type('Get Node Details'));
1617
const getNodeDetailsSuccess = createAction(type('Get Node Details Success'), props<{ details: AppNodeDetails }>());
18+
const getNodeEnvBuild = createAction(type('Get Node Env Build'));
19+
const getNodeEnvBuildSuccess = createAction(type('Get Node Env Build Success'), props<{ envBuild: AppEnvBuild }>());
1720
const deleteNode = createAction(type('Delete Node'), props<{ node: MinaNode }>());
1821
const addNode = createAction(type('Add Node'), props<{ node: MinaNode }>());
1922

@@ -28,6 +31,8 @@ export const AppActions = {
2831
changeActiveNode,
2932
getNodeDetails,
3033
getNodeDetailsSuccess,
34+
getNodeEnvBuild,
35+
getNodeEnvBuildSuccess,
3136
deleteNode,
3237
addNode,
3338
changeMenuCollapsing,

frontend/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@if (!hideToolbar) {
2222
<mina-toolbar></mina-toolbar>
2323
}
24-
<div class="mina-content"
24+
<div id="mina-content"
2525
[class.no-toolbar]="hideToolbar"
2626
[class.no-submenus]="subMenusLength < 2"
2727
[class.mobile]="menu.isMobile">

frontend/src/app/app.component.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@ mat-sidenav-content {
5353
mat-sidenav-container,
5454
mat-sidenav-content {
5555
color: inherit;
56-
background-color: $base-surface;
57-
58-
@media (max-width: 767px) {
59-
background-color: $base-background;
60-
}
56+
background-color: $base-background;
6157
}
6258

63-
.mina-content {
59+
#mina-content {
6460
$toolbar: 40px;
6561
height: calc(100% - #{$toolbar});
6662
border-top-left-radius: 6px;

frontend/src/app/app.effects.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Injectable } from '@angular/core';
22
import { MinaState, selectMinaState } from '@app/app.setup';
33
import { Actions, createEffect, ofType } from '@ngrx/effects';
44
import { Store } from '@ngrx/store';
5-
import { createNonDispatchableEffect, Effect, NonDispatchableEffect, removeParamsFromURL } from '@openmina/shared';
6-
import { filter, from, map, switchMap, tap } from 'rxjs';
5+
import { createNonDispatchableEffect, Effect, removeParamsFromURL } from '@openmina/shared';
6+
import { filter, map, mergeMap, of, switchMap, tap } from 'rxjs';
77
import { AppActions } from '@app/app.actions';
88
import { Router } from '@angular/router';
99
import { FeatureType, MinaNode } from '@shared/types/core/environment/mina-env.type';
@@ -22,9 +22,10 @@ import { AppNodeStatus } from '@shared/types/app/app-node-details.type';
2222
export class AppEffects extends BaseEffect {
2323

2424
readonly init$: Effect;
25-
readonly initSuccess$: NonDispatchableEffect;
25+
readonly initSuccess$: Effect;
2626
readonly onNodeChange$: Effect;
2727
readonly getNodeDetails$: Effect;
28+
readonly getNodeEnvBuild$: Effect;
2829

2930
private requestInProgress: boolean = false;
3031

@@ -46,7 +47,7 @@ export class AppEffects extends BaseEffect {
4647
map((payload: { activeNode: MinaNode, nodes: MinaNode[] }) => AppActions.initSuccess(payload)),
4748
));
4849

49-
this.initSuccess$ = createNonDispatchableEffect(() => this.actions$.pipe(
50+
this.initSuccess$ = createEffect(() => this.actions$.pipe(
5051
ofType(AppActions.initSuccess),
5152
this.latestActionState(),
5253
switchMap(({ state }) => {
@@ -55,8 +56,9 @@ export class AppEffects extends BaseEffect {
5556
switchMap(() => this.webNodeService.startWasm$()),
5657
);
5758
}
58-
return from([]);
59+
return of({});
5960
}),
61+
map(() => AppActions.getNodeEnvBuild()),
6062
));
6163

6264
this.onNodeChange$ = createNonDispatchableEffect(() => this.actions$.pipe(
@@ -79,9 +81,16 @@ export class AppEffects extends BaseEffect {
7981
switchMap(() => this.webNodeService.startWasm$()),
8082
);
8183
}
82-
return from([]);
84+
return of({});
8385
}),
84-
map(() => AppActions.getNodeDetails()),
86+
switchMap(() => [AppActions.getNodeDetails(), AppActions.getNodeEnvBuild()]),
87+
));
88+
89+
this.getNodeEnvBuild$ = createEffect(() => this.actions$.pipe(
90+
ofType(AppActions.getNodeEnvBuild),
91+
mergeMap(() => this.appService.getEnvBuild()),
92+
map(envBuild => AppActions.getNodeEnvBuildSuccess({ envBuild })),
93+
catchErrorAndRepeat2(MinaErrorType.RUST, AppActions.getNodeEnvBuildSuccess({ envBuild: undefined })),
8594
));
8695

8796
this.getNodeDetails$ = createEffect(() => this.actions$.pipe(
@@ -95,9 +104,9 @@ export class AppEffects extends BaseEffect {
95104
status: AppNodeStatus.OFFLINE,
96105
blockHeight: null,
97106
blockTime: null,
98-
peers: 0,
99-
download: 0,
100-
upload: 0,
107+
peersConnected: 0,
108+
peersDisconnected: 0,
109+
peersConnecting: 0,
101110
transactions: 0,
102111
snarks: 0,
103112
producingBlockAt: null,

frontend/src/app/app.reducer.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ const initialState: AppState = {
1717
status: AppNodeStatus.PENDING,
1818
blockHeight: null,
1919
blockTime: null,
20-
peers: 0,
21-
download: 0,
22-
upload: 0,
20+
peersConnected: 0,
21+
peersDisconnected: 0,
22+
peersConnecting: 0,
2323
transactions: 0,
2424
snarks: 0,
2525
producingBlockAt: null,
2626
producingBlockGlobalSlot: null,
2727
producingBlockStatus: null,
2828
},
29+
envBuild: undefined,
2930
};
3031

3132
export const appReducer = createReducer(
@@ -53,4 +54,5 @@ export const appReducer = createReducer(
5354
const nodes = state.nodes.filter(n => n.name !== node.name);
5455
return { ...state, nodes, activeNode: state.activeNode?.name === node.name ? nodes[0] : state.activeNode };
5556
}),
57+
on(AppActions.getNodeEnvBuildSuccess, (state, { envBuild }) => ({ ...state, envBuild })),
5658
);

frontend/src/app/app.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AppNodeDetails, AppNodeStatus } from '@shared/types/app/app-node-detail
77
import { getNetwork } from '@shared/helpers/mina.helper';
88
import { getLocalStorage, ONE_MILLION } from '@openmina/shared';
99
import { BlockProductionWonSlotsStatus } from '@shared/types/block-production/won-slots/block-production-won-slots-slot.type';
10+
import { AppEnvBuild } from '@shared/types/app/app-env-build.type';
1011

1112
@Injectable({
1213
providedIn: 'root',
@@ -29,16 +30,20 @@ export class AppService {
2930
]);
3031
}
3132

33+
getEnvBuild(): Observable<AppEnvBuild> {
34+
return this.rust.get<AppEnvBuild>('/build_env');
35+
}
36+
3237
getActiveNodeDetails(): Observable<AppNodeDetails> {
3338
return this.rust.get<NodeDetailsResponse>('/status')
3439
.pipe(
3540
map((data: NodeDetailsResponse): AppNodeDetails => ({
3641
status: this.getStatus(data),
3742
blockHeight: data.transition_frontier.best_tip?.height,
3843
blockTime: data.transition_frontier.sync.time,
39-
peers: data.peers.filter(p => p.connection_status === 'Connected').length,
40-
download: 0,
41-
upload: 0,
44+
peersConnected: data.peers.filter(p => p.connection_status === 'Connected').length,
45+
peersDisconnected: data.peers.filter(p => p.connection_status === 'Disconnected').length,
46+
peersConnecting: data.peers.filter(p => p.connection_status === 'Connecting').length,
4247
snarks: data.snark_pool.snarks,
4348
transactions: data.transaction_pool.transactions,
4449
chainId: data.chain_id,

frontend/src/app/app.state.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { AppMenu } from '@shared/types/app/app-menu.type';
33
import { createSelector, MemoizedSelector } from '@ngrx/store';
44
import { MinaNode } from '@shared/types/core/environment/mina-env.type';
55
import { AppNodeDetails } from '@shared/types/app/app-node-details.type';
6+
import { AppEnvBuild } from '@shared/types/app/app-env-build.type';
67

78
export interface AppState {
89
menu: AppMenu;
910
nodes: MinaNode[];
1011
activeNode: MinaNode;
1112
activeNodeDetails: AppNodeDetails;
13+
envBuild: AppEnvBuild | undefined;
1214
}
1315

1416
const select = <T>(selector: (state: AppState) => T): MemoizedSelector<MinaState, T> => createSelector(
@@ -20,10 +22,12 @@ const menu = select(state => state.menu);
2022
const nodes = select(state => state.nodes);
2123
const activeNode = select(state => state.activeNode);
2224
const activeNodeDetails = select(state => state.activeNodeDetails);
25+
const envBuild = select(state => state.envBuild);
2326

2427
export const AppSelectors = {
2528
menu,
2629
nodes,
2730
activeNode,
2831
activeNodeDetails,
32+
envBuild,
2933
};

0 commit comments

Comments
 (0)