Expand mining dashboard widgets & improve responsiveness
This commit is contained in:
		
							parent
							
								
									ba0a3d004d
								
							
						
					
					
						commit
						ce7a007b62
					
				| @ -58,7 +58,6 @@ | |||||||
| .chart-widget { | .chart-widget { | ||||||
|   width: 100%; |   width: 100%; | ||||||
|   height: 100%; |   height: 100%; | ||||||
|   height: 240px; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .pool-distribution { | .pool-distribution { | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit, HostBinding } from '@angular/core'; | import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit, HostBinding } from '@angular/core'; | ||||||
| import { echarts, EChartsOption } from '../../graphs/echarts'; | import { echarts, EChartsOption } from '../../graphs/echarts'; | ||||||
| import { merge, Observable, of } from 'rxjs'; | import { combineLatest, fromEvent, merge, Observable, of } from 'rxjs'; | ||||||
| import { map, mergeMap, share, startWith, switchMap, tap } from 'rxjs/operators'; | import { map, mergeMap, share, startWith, switchMap, tap } from 'rxjs/operators'; | ||||||
| import { ApiService } from '../../services/api.service'; | import { ApiService } from '../../services/api.service'; | ||||||
| import { SeoService } from '../../services/seo.service'; | import { SeoService } from '../../services/seo.service'; | ||||||
| @ -31,6 +31,7 @@ import { seoDescriptionNetwork } from '../../shared/common.utils'; | |||||||
| export class HashrateChartComponent implements OnInit { | export class HashrateChartComponent implements OnInit { | ||||||
|   @Input() tableOnly = false; |   @Input() tableOnly = false; | ||||||
|   @Input() widget = false; |   @Input() widget = false; | ||||||
|  |   @Input() height: number = 300; | ||||||
|   @Input() right: number | string = 45; |   @Input() right: number | string = 45; | ||||||
|   @Input() left: number | string = 75; |   @Input() left: number | string = 75; | ||||||
| 
 | 
 | ||||||
| @ -86,7 +87,8 @@ export class HashrateChartComponent implements OnInit { | |||||||
|         } |         } | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|     this.hashrateObservable$ = merge( |     this.hashrateObservable$ = combineLatest( | ||||||
|  |         merge( | ||||||
|         this.radioGroupForm.get('dateSpan').valueChanges |         this.radioGroupForm.get('dateSpan').valueChanges | ||||||
|           .pipe( |           .pipe( | ||||||
|             startWith(this.radioGroupForm.controls.dateSpan.value), |             startWith(this.radioGroupForm.controls.dateSpan.value), | ||||||
| @ -107,7 +109,10 @@ export class HashrateChartComponent implements OnInit { | |||||||
|                 return this.apiService.getHistoricalHashrate$(this.timespan); |                 return this.apiService.getHistoricalHashrate$(this.timespan); | ||||||
|               }) |               }) | ||||||
|             ) |             ) | ||||||
|  |         ), | ||||||
|  |         fromEvent(window, 'resize').pipe(startWith(null)), | ||||||
|       ).pipe( |       ).pipe( | ||||||
|  |         map(([response, _]) => response), | ||||||
|         tap((response: any) => { |         tap((response: any) => { | ||||||
|           const data = response.body; |           const data = response.body; | ||||||
| 
 | 
 | ||||||
| @ -221,6 +226,7 @@ export class HashrateChartComponent implements OnInit { | |||||||
|         ]), |         ]), | ||||||
|       ], |       ], | ||||||
|       grid: { |       grid: { | ||||||
|  |         height: (this.widget && this.height) ? this.height - 30 : undefined, | ||||||
|         top: this.widget ? 20 : 40, |         top: this.widget ? 20 : 40, | ||||||
|         bottom: this.widget ? 30 : 70, |         bottom: this.widget ? 30 : 70, | ||||||
|         right: this.right, |         right: this.right, | ||||||
|  | |||||||
| @ -26,9 +26,11 @@ | |||||||
| 
 | 
 | ||||||
|     <!-- pool distribution --> |     <!-- pool distribution --> | ||||||
|     <div class="col" style="margin-bottom: 1.47rem"> |     <div class="col" style="margin-bottom: 1.47rem"> | ||||||
|       <div class="card graph-card"> |       <div class="card"> | ||||||
|         <div class="card-body pl-2 pr-2"> |         <div class="card-body pl-2 pr-2"> | ||||||
|           <app-pool-ranking [attr.data-cy]="'pool-distribution'" [widget]=true></app-pool-ranking> |           <div class="mempool-graph"> | ||||||
|  |             <app-pool-ranking [height]="graphHeight" [attr.data-cy]="'pool-distribution'" [widget]=true></app-pool-ranking> | ||||||
|  |           </div> | ||||||
|           <div class="mt-1"><a [attr.data-cy]="'pool-distribution-view-more'" [routerLink]="['/graphs/mining/pools' | relativeUrl]" i18n="dashboard.view-more">View more »</a></div> |           <div class="mt-1"><a [attr.data-cy]="'pool-distribution-view-more'" [routerLink]="['/graphs/mining/pools' | relativeUrl]" i18n="dashboard.view-more">View more »</a></div> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
| @ -38,7 +40,9 @@ | |||||||
|     <div class="col" style="margin-bottom: 1.47rem"> |     <div class="col" style="margin-bottom: 1.47rem"> | ||||||
|       <div class="card"> |       <div class="card"> | ||||||
|         <div class="card-body pl-lg-3 pr-lg-3 pl-2 pr-2"> |         <div class="card-body pl-lg-3 pr-lg-3 pl-2 pr-2"> | ||||||
|           <app-hashrate-chart [attr.data-cy]="'hashrate-graph'" [widget]="true"></app-hashrate-chart> |           <div class="fixed-mempool-graph"> | ||||||
|  |             <app-hashrate-chart [height]="graphHeight" [attr.data-cy]="'hashrate-graph'" [widget]="true"></app-hashrate-chart> | ||||||
|  |           </div> | ||||||
|           <div class="mt-1"><a [routerLink]="['/graphs/mining/hashrate-difficulty' | relativeUrl]" fragment="1y" i18n="dashboard.view-more">View more »</a></div> |           <div class="mt-1"><a [routerLink]="['/graphs/mining/hashrate-difficulty' | relativeUrl]" fragment="1y" i18n="dashboard.view-more">View more »</a></div> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  | |||||||
| @ -17,6 +17,19 @@ | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .fixed-mempool-graph { | ||||||
|  |   height: 330px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .mempool-graph, .fixed-mempool-graph { | ||||||
|  |   @media (min-width: 768px) { | ||||||
|  |     height: 345px; | ||||||
|  |   } | ||||||
|  |   @media (min-width: 992px) { | ||||||
|  |     height: 432px; | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .card-title { | .card-title { | ||||||
|   font-size: 1rem; |   font-size: 1rem; | ||||||
|   color: #4a68b9; |   color: #4a68b9; | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { AfterViewInit, ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | import { AfterViewInit, ChangeDetectionStrategy, Component, HostListener, OnInit } from '@angular/core'; | ||||||
| import { SeoService } from '../../services/seo.service'; | import { SeoService } from '../../services/seo.service'; | ||||||
| import { WebsocketService } from '../../services/websocket.service'; | import { WebsocketService } from '../../services/websocket.service'; | ||||||
| import { StateService } from '../../services/state.service'; | import { StateService } from '../../services/state.service'; | ||||||
| @ -11,6 +11,8 @@ import { EventType, NavigationStart, Router } from '@angular/router'; | |||||||
|   changeDetection: ChangeDetectionStrategy.OnPush, |   changeDetection: ChangeDetectionStrategy.OnPush, | ||||||
| }) | }) | ||||||
| export class MiningDashboardComponent implements OnInit, AfterViewInit { | export class MiningDashboardComponent implements OnInit, AfterViewInit { | ||||||
|  |   graphHeight = 300; | ||||||
|  | 
 | ||||||
|   constructor( |   constructor( | ||||||
|     private seoService: SeoService, |     private seoService: SeoService, | ||||||
|     private websocketService: WebsocketService, |     private websocketService: WebsocketService, | ||||||
| @ -22,6 +24,7 @@ export class MiningDashboardComponent implements OnInit, AfterViewInit { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   ngOnInit(): void { |   ngOnInit(): void { | ||||||
|  |     this.onResize(); | ||||||
|     this.websocketService.want(['blocks', 'mempool-blocks', 'stats']); |     this.websocketService.want(['blocks', 'mempool-blocks', 'stats']); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -35,4 +38,15 @@ export class MiningDashboardComponent implements OnInit, AfterViewInit { | |||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   @HostListener('window:resize', ['$event']) | ||||||
|  |   onResize(): void { | ||||||
|  |     if (window.innerWidth >= 992) { | ||||||
|  |       this.graphHeight = 330; | ||||||
|  |     } else if (window.innerWidth >= 768) { | ||||||
|  |       this.graphHeight = 245; | ||||||
|  |     } else { | ||||||
|  |       this.graphHeight = 240; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -76,7 +76,7 @@ | |||||||
|   </div> |   </div> | ||||||
| 
 | 
 | ||||||
|   <div [class]="!widget ? '' : 'pb-0'" class="container pb-lg-0"> |   <div [class]="!widget ? '' : 'pb-0'" class="container pb-lg-0"> | ||||||
|     <div [class]="widget ? 'chart-widget' : 'chart'" echarts [initOpts]="chartInitOptions" [options]="chartOptions" |     <div [class]="widget ? 'chart-widget' : 'chart'" [style]="{ height: widget ? (height + 'px') : null}" echarts [initOpts]="chartInitOptions" [options]="chartOptions" | ||||||
|       (chartInit)="onChartInit($event)"> |       (chartInit)="onChartInit($event)"> | ||||||
|     </div> |     </div> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -28,7 +28,9 @@ | |||||||
| .chart-widget { | .chart-widget { | ||||||
|   width: 100%; |   width: 100%; | ||||||
|   height: 100%; |   height: 100%; | ||||||
|   height: 240px; |   @media (max-width: 767px) { | ||||||
|  |     max-height: 240px; | ||||||
|  |   } | ||||||
|   @media (max-width: 485px) { |   @media (max-width: 485px) { | ||||||
|     max-height: 200px; |     max-height: 200px; | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ import { isMobile } from '../../shared/common.utils'; | |||||||
|   changeDetection: ChangeDetectionStrategy.OnPush, |   changeDetection: ChangeDetectionStrategy.OnPush, | ||||||
| }) | }) | ||||||
| export class PoolRankingComponent implements OnInit { | export class PoolRankingComponent implements OnInit { | ||||||
|  |   @Input() height: number = 300; | ||||||
|   @Input() widget = false; |   @Input() widget = false; | ||||||
| 
 | 
 | ||||||
|   miningWindowPreference: string; |   miningWindowPreference: string; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user