2024-02-07 23:26:06 +00:00
import { AfterViewInit , ChangeDetectionStrategy , Component , HostListener , OnInit } from '@angular/core' ;
2022-09-21 17:23:45 +02:00
import { SeoService } from '../../services/seo.service' ;
import { WebsocketService } from '../../services/websocket.service' ;
2023-07-24 10:18:00 +09:00
import { StateService } from '../../services/state.service' ;
2023-07-25 15:03:39 +09:00
import { EventType , NavigationStart , Router } from '@angular/router' ;
2022-02-16 17:32:12 +09:00
@Component ( {
selector : 'app-mining-dashboard' ,
templateUrl : './mining-dashboard.component.html' ,
2022-02-17 17:10:20 +09:00
styleUrls : [ './mining-dashboard.component.scss' ] ,
changeDetection : ChangeDetectionStrategy.OnPush ,
2022-02-16 17:32:12 +09:00
} )
2023-07-25 15:03:39 +09:00
export class MiningDashboardComponent implements OnInit , AfterViewInit {
2024-02-07 23:26:06 +00:00
graphHeight = 300 ;
2022-03-19 23:32:01 +04:00
constructor (
private seoService : SeoService ,
private websocketService : WebsocketService ,
2023-07-25 15:03:39 +09:00
private stateService : StateService ,
private router : Router
2022-03-07 11:22:54 +01:00
) {
2022-05-10 17:05:07 +04:00
this . seoService . setTitle ( $localize ` :@@a681a4e2011bb28157689dbaa387de0dd0aa0c11:Mining Dashboard ` ) ;
2023-08-30 20:26:07 +09:00
this . seoService . setDescription ( $localize ` :@@meta.description.mining.dashboard:Get real-time Bitcoin mining stats like hashrate, difficulty adjustment, block rewards, pool dominance, and more. ` ) ;
2022-02-24 20:20:18 +09:00
}
2022-02-16 17:32:12 +09:00
ngOnInit ( ) : void {
2024-02-07 23:26:06 +00:00
this . onResize ( ) ;
2022-06-13 11:13:00 +02:00
this . websocketService . want ( [ 'blocks' , 'mempool-blocks' , 'stats' ] ) ;
2022-03-07 11:22:54 +01:00
}
2023-07-24 10:18:00 +09:00
2023-07-25 15:03:39 +09:00
ngAfterViewInit ( ) : void {
2023-07-24 11:35:46 +09:00
this . stateService . focusSearchInputDesktop ( ) ;
2023-07-25 15:03:39 +09:00
this . router . events . subscribe ( ( e : NavigationStart ) = > {
if ( e . type === EventType . NavigationStart ) {
if ( e . url . indexOf ( 'graphs' ) === - 1 ) { // The mining dashboard and the graph component are part of the same module so we can't use ngAfterViewInit in graphs.component.ts to blur the input
2023-08-30 20:26:07 +09:00
this . stateService . focusSearchInputDesktop ( ) ;
2023-07-25 15:03:39 +09:00
}
}
} ) ;
2023-07-24 10:18:00 +09:00
}
2024-02-07 23:26:06 +00:00
@HostListener ( 'window:resize' , [ '$event' ] )
onResize ( ) : void {
if ( window . innerWidth >= 992 ) {
2024-02-08 02:47:46 +00:00
this . graphHeight = 340 ;
2024-02-07 23:26:06 +00:00
} else if ( window . innerWidth >= 768 ) {
this . graphHeight = 245 ;
} else {
this . graphHeight = 240 ;
}
}
2022-02-16 17:32:12 +09:00
}