@@ -17,7 +17,7 @@ import {
1717} from '@shared/types/nodes/dashboard/nodes-overview-ledger.type' ;
1818import { filter } from 'rxjs' ;
1919import { NodesOverviewNode } from '@shared/types/nodes/dashboard/nodes-overview-node.type' ;
20- import { ONE_BILLION , ONE_MILLION , ONE_THOUSAND , SecDurationConfig } from '@openmina/shared' ;
20+ import { ONE_MILLION , SecDurationConfig } from '@openmina/shared' ;
2121import { Overlay , OverlayRef } from '@angular/cdk/overlay' ;
2222import { TemplatePortal } from '@angular/cdk/portal' ;
2323import { DashboardRpcStats } from '@shared/types/dashboard/dashboard-rpc-stats.type' ;
@@ -67,8 +67,6 @@ const initialStaged: NodesOverviewRootStagedLedgerStep = {
6767} )
6868export class DashboardLedgerComponent extends StoreDispatcher implements OnInit , OnDestroy {
6969
70- protected readonly NodesOverviewLedgerStepState = NodesOverviewLedgerStepState ;
71-
7270 ledgers : NodesOverviewLedger = {
7371 stakingEpoch : initialSnarked ,
7472 nextEpoch : initialSnarked ,
@@ -102,38 +100,59 @@ export class DashboardLedgerComponent extends StoreDispatcher implements OnInit,
102100
103101 private listenToNodesChanges ( ) : void {
104102 this . select ( selectDashboardNodesAndRpcStats , ( [ nodes , rpcStats ] : [ NodesOverviewNode [ ] , DashboardRpcStats ] ) => {
105- this . ledgers = nodes [ 0 ] . ledgers ;
106-
107- const getConfig = ( state : NodesOverviewLedgerStepState ) : SecDurationConfig =>
108- state === NodesOverviewLedgerStepState . LOADING ? this . undefinedConfig : this . emptyConfig ;
109-
110- this . configMap = {
111- stakingEpoch : getConfig ( this . ledgers . stakingEpoch . state ) ,
112- nextEpoch : getConfig ( this . ledgers . nextEpoch . state ) ,
113- rootSnarked : getConfig ( this . ledgers . rootSnarked . state ) ,
114- rootStaged : getConfig ( this . ledgers . rootStaged . state ) ,
115- } ;
116- this . setProgressTime ( ) ;
117- this . stakingProgress = rpcStats . stakingLedger ?. fetched / rpcStats . stakingLedger ?. estimation * 100 || 0 ;
118- this . nextProgress = rpcStats . nextLedger ?. fetched / rpcStats . nextLedger ?. estimation * 100 || 0 ;
119- this . rootSnarkedProgress = rpcStats . rootLedger ?. fetched / rpcStats . rootLedger ?. estimation * 100 || 0 ;
120- this . rootStagedProgress = this . ledgers . rootStaged . staged . fetchPartsEnd ? 50 : 0 ;
121-
122- if ( this . ledgers . stakingEpoch . state === NodesOverviewLedgerStepState . SUCCESS ) {
123- this . stakingProgress = 100 ;
124- }
125- if ( this . ledgers . nextEpoch . state === NodesOverviewLedgerStepState . SUCCESS ) {
126- this . nextProgress = 100 ;
127- }
128- if ( this . ledgers . rootSnarked . state === NodesOverviewLedgerStepState . SUCCESS ) {
129- this . rootSnarkedProgress = 100 ;
103+ if ( nodes . length === 0 ) {
104+ this . ledgers = {
105+ stakingEpoch : initialSnarked ,
106+ nextEpoch : initialSnarked ,
107+ rootSnarked : initialSnarked ,
108+ rootStaged : initialStaged ,
109+ } ;
110+ this . configMap = {
111+ stakingEpoch : this . emptyConfig ,
112+ nextEpoch : this . emptyConfig ,
113+ rootSnarked : this . emptyConfig ,
114+ rootStaged : this . emptyConfig ,
115+ } ;
116+ this . progress = undefined ;
117+ this . stakingProgress = 0 ;
118+ this . nextProgress = 0 ;
119+ this . rootSnarkedProgress = 0 ;
120+ this . rootStagedProgress = 0 ;
121+ this . totalProgress = 0 ;
122+ } else {
123+ this . ledgers = nodes [ 0 ] . ledgers ;
124+
125+ const getConfig = ( state : NodesOverviewLedgerStepState ) : SecDurationConfig =>
126+ state === NodesOverviewLedgerStepState . LOADING ? this . undefinedConfig : this . emptyConfig ;
127+
128+ this . configMap = {
129+ stakingEpoch : getConfig ( this . ledgers . stakingEpoch . state ) ,
130+ nextEpoch : getConfig ( this . ledgers . nextEpoch . state ) ,
131+ rootSnarked : getConfig ( this . ledgers . rootSnarked . state ) ,
132+ rootStaged : getConfig ( this . ledgers . rootStaged . state ) ,
133+ } ;
134+ this . setProgressTime ( ) ;
135+ this . stakingProgress = rpcStats . stakingLedger ?. fetched / rpcStats . stakingLedger ?. estimation * 100 || 0 ;
136+ this . nextProgress = rpcStats . nextLedger ?. fetched / rpcStats . nextLedger ?. estimation * 100 || 0 ;
137+ this . rootSnarkedProgress = rpcStats . rootLedger ?. fetched / rpcStats . rootLedger ?. estimation * 100 || 0 ;
138+ this . rootStagedProgress = this . ledgers . rootStaged . staged . fetchPartsEnd ? 50 : 0 ;
139+
140+ if ( this . ledgers . stakingEpoch . state === NodesOverviewLedgerStepState . SUCCESS ) {
141+ this . stakingProgress = 100 ;
142+ }
143+ if ( this . ledgers . nextEpoch . state === NodesOverviewLedgerStepState . SUCCESS ) {
144+ this . nextProgress = 100 ;
145+ }
146+ if ( this . ledgers . rootSnarked . state === NodesOverviewLedgerStepState . SUCCESS ) {
147+ this . rootSnarkedProgress = 100 ;
148+ }
149+ if ( this . ledgers . rootStaged . state === NodesOverviewLedgerStepState . SUCCESS ) {
150+ this . rootStagedProgress = 100 ;
151+ }
152+ this . totalProgress = ( this . stakingProgress + this . nextProgress + this . rootSnarkedProgress + this . rootStagedProgress ) / 4 ;
130153 }
131- if ( this . ledgers . rootStaged . state === NodesOverviewLedgerStepState . SUCCESS ) {
132- this . rootStagedProgress = 100 ;
133- }
134- this . totalProgress = ( this . stakingProgress + this . nextProgress + this . rootSnarkedProgress + this . rootStagedProgress ) / 4 ;
135154 this . detect ( ) ;
136- } , filter ( n => n [ 0 ] . length > 0 ) ) ;
155+ } ) ;
137156 }
138157
139158 show ( event : MouseEvent , start : number , end : number ) : void {
0 commit comments