Change collapsing dashboard into 3 levels.
This commit is contained in:
		
							parent
							
								
									e61574c630
								
							
						
					
					
						commit
						396ff6a375
					
				@ -39,7 +39,7 @@ class DiskCache {
 | 
			
		||||
        mempool: memPool.getMempool(),
 | 
			
		||||
        blocks: blocks.getBlocks(),
 | 
			
		||||
      }));
 | 
			
		||||
      logger.info('Mempool and blocks data saved to disk cache');
 | 
			
		||||
      logger.debug('Mempool and blocks data saved to disk cache');
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.warn('Error writing to cache file asynchronously');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,7 @@ import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 | 
			
		||||
import { FeesBoxComponent } from './components/fees-box/fees-box.component';
 | 
			
		||||
import { DashboardComponent } from './dashboard/dashboard.component';
 | 
			
		||||
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
 | 
			
		||||
import { faBolt, faChartArea, faCogs, faCubes, faDatabase, faInfoCircle,
 | 
			
		||||
import { faAngleDoubleDown, faAngleDoubleUp, faAngleDown, faAngleUp, faBolt, faChartArea, faCogs, faCubes, faDatabase, faInfoCircle,
 | 
			
		||||
  faLink, faList, faSearch, faTachometerAlt, faThList, faTint, faTv } from '@fortawesome/free-solid-svg-icons';
 | 
			
		||||
import { ApiDocsComponent } from './components/api-docs/api-docs.component';
 | 
			
		||||
import { TermsOfServiceComponent } from './components/terms-of-service/terms-of-service.component';
 | 
			
		||||
@ -119,5 +119,7 @@ export class AppModule {
 | 
			
		||||
    library.addIcons(faLink);
 | 
			
		||||
    library.addIcons(faBolt);
 | 
			
		||||
    library.addIcons(faTint);
 | 
			
		||||
    library.addIcons(faAngleDown);
 | 
			
		||||
    library.addIcons(faAngleUp);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
<div class="container-xl mt-2">
 | 
			
		||||
 | 
			
		||||
  <div class="row row-cols-1 row-cols-md-2" *ngIf="{ value: (mempoolInfoData$ | async) } as mempoolInfoData">
 | 
			
		||||
    <ng-template [ngIf]="collapsed" [ngIfElse]="expanded">
 | 
			
		||||
    <ng-template [ngIf]="collapseLevel === 'three'" [ngIfElse]="expanded">
 | 
			
		||||
      <div class="col mb-4">
 | 
			
		||||
        <div class="card text-center">
 | 
			
		||||
          <div class="card-body">
 | 
			
		||||
@ -68,6 +68,7 @@
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
      <ng-template [ngIf]="collapseLevel === 'one'">
 | 
			
		||||
      <div class="col mb-4">
 | 
			
		||||
        <div class="card text-center">
 | 
			
		||||
          <div class="card-body">
 | 
			
		||||
@ -122,9 +123,15 @@
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </ng-template>
 | 
			
		||||
    </ng-template>
 | 
			
		||||
  </div>
 | 
			
		||||
 | 
			
		||||
  <button type="button" class="btn btn-secondary btn-sm d-block mx-auto" (click)="toggleCollapsed()">{{ collapsed ? 'Expand' : 'Collapse' }}</button>
 | 
			
		||||
  <button type="button" class="btn btn-secondary btn-sm d-block mx-auto" (click)="toggleCollapsed()">
 | 
			
		||||
    <div [ngSwitch]="collapseLevel">
 | 
			
		||||
      <fa-icon *ngSwitchCase="'three'" [icon]="['fas', 'angle-down']" [fixedWidth]="true" title="Collapse"></fa-icon>
 | 
			
		||||
      <fa-icon *ngSwitchDefault [icon]="['fas', 'angle-up']" [fixedWidth]="true" title="Expand"></fa-icon>
 | 
			
		||||
    </div>
 | 
			
		||||
  </button>
 | 
			
		||||
 | 
			
		||||
  <br>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,7 @@ interface MempoolStatsData {
 | 
			
		||||
  changeDetection: ChangeDetectionStrategy.OnPush
 | 
			
		||||
})
 | 
			
		||||
export class DashboardComponent implements OnInit {
 | 
			
		||||
  collapsed = true;
 | 
			
		||||
  collapseLevel: string;
 | 
			
		||||
  network$: Observable<string>;
 | 
			
		||||
  mempoolBlocksData$: Observable<MempoolBlocksData>;
 | 
			
		||||
  mempoolInfoData$: Observable<MempoolInfoData>;
 | 
			
		||||
@ -69,7 +69,7 @@ export class DashboardComponent implements OnInit {
 | 
			
		||||
    this.seoService.resetTitle();
 | 
			
		||||
    this.websocketService.want(['blocks', 'stats', 'mempool-blocks', 'live-2h-chart']);
 | 
			
		||||
    this.network$ = merge(of(''), this.stateService.networkChanged$);
 | 
			
		||||
    this.collapsed = this.storageService.getValue('dashboard-collapsed') === 'true' || false;
 | 
			
		||||
    this.collapseLevel = this.storageService.getValue('dashboard-collapsed') || 'one';
 | 
			
		||||
 | 
			
		||||
    this.mempoolInfoData$ = combineLatest([
 | 
			
		||||
      this.stateService.mempoolInfo$,
 | 
			
		||||
@ -223,7 +223,13 @@ export class DashboardComponent implements OnInit {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  toggleCollapsed() {
 | 
			
		||||
    this.collapsed = !this.collapsed;
 | 
			
		||||
    this.storageService.setValue('dashboard-collapsed', this.collapsed);
 | 
			
		||||
    if (this.collapseLevel === 'one') {
 | 
			
		||||
      this.collapseLevel = 'two';
 | 
			
		||||
    } else if (this.collapseLevel === 'two') {
 | 
			
		||||
      this.collapseLevel = 'three';
 | 
			
		||||
    } else {
 | 
			
		||||
      this.collapseLevel = 'one';
 | 
			
		||||
    }
 | 
			
		||||
    this.storageService.setValue('dashboard-collapsed', this.collapseLevel);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user