2023-05-31 14:39:19 +07:00
import { ChangeDetectionStrategy , Component , ElementRef , Inject , LOCALE_ID , OnInit , ViewChild } from '@angular/core' ;
2020-02-16 22:15:07 +07:00
import { WebsocketService } from '../../services/websocket.service' ;
2022-09-21 17:23:45 +02:00
import { SeoService } from '../../services/seo.service' ;
import { StateService } from '../../services/state.service' ;
2021-05-18 13:23:39 +04:00
import { Observable } from 'rxjs' ;
2022-09-21 17:23:45 +02:00
import { ApiService } from '../../services/api.service' ;
import { IBackendInfo } from '../../interfaces/websocket.interface' ;
2023-02-24 02:24:51 -05:00
import { Router , ActivatedRoute } from '@angular/router' ;
2023-02-17 18:54:48 +09:00
import { map , share , tap } from 'rxjs/operators' ;
2022-09-21 17:23:45 +02:00
import { ITranslators } from '../../interfaces/node-api.interface' ;
2023-03-02 21:50:09 +09:00
import { DOCUMENT } from '@angular/common' ;
2019-07-21 17:59:47 +03:00
@Component ( {
selector : 'app-about' ,
templateUrl : './about.component.html' ,
2020-08-10 14:59:29 +07:00
styleUrls : [ './about.component.scss' ] ,
2021-05-18 13:23:39 +04:00
changeDetection : ChangeDetectionStrategy.OnPush ,
2019-07-21 17:59:47 +03:00
} )
2021-05-18 13:23:39 +04:00
export class AboutComponent implements OnInit {
2023-05-31 14:39:19 +07:00
@ViewChild ( 'promoVideo' ) promoVideo : ElementRef ;
2021-04-12 22:17:13 +04:00
backendInfo$ : Observable < IBackendInfo > ;
2021-06-16 11:47:05 -07:00
frontendGitCommitHash = this . stateService . env . GIT_COMMIT_HASH ;
2021-04-12 22:17:13 +04:00
packetJsonVersion = this . stateService . env . PACKAGE_JSON_VERSION ;
2021-04-13 11:51:55 +04:00
officialMempoolSpace = this . stateService . env . OFFICIAL_MEMPOOL_SPACE ;
2021-05-18 13:23:39 +04:00
showNavigateToSponsor = false ;
2019-07-21 17:59:47 +03:00
2023-02-17 18:54:48 +09:00
profiles$ : Observable < any > ;
translators$ : Observable < ITranslators > ;
allContributors$ : Observable < any > ;
ogs$ : Observable < any > ;
2019-07-26 12:48:32 +03:00
constructor (
2020-02-16 22:15:07 +07:00
private websocketService : WebsocketService ,
2020-03-24 00:52:08 +07:00
private seoService : SeoService ,
2021-08-14 01:37:28 +03:00
public stateService : StateService ,
2020-10-07 20:15:42 +07:00
private apiService : ApiService ,
2021-05-18 13:23:39 +04:00
private router : Router ,
2023-02-24 02:24:51 -05:00
private route : ActivatedRoute ,
2021-07-13 12:00:05 +03:00
@Inject ( LOCALE_ID ) public locale : string ,
2023-03-02 21:50:09 +09:00
@Inject ( DOCUMENT ) private document : Document ,
2019-07-26 12:48:32 +03:00
) { }
2019-07-21 17:59:47 +03:00
ngOnInit() {
2021-04-12 22:17:13 +04:00
this . backendInfo $ = this . stateService . backendInfo $ ;
2020-12-03 18:34:19 +07:00
this . seoService . setTitle ( $localize ` :@@004b222ff9ef9dd4771b777950ca1d0e4cd4348a:About ` ) ;
2023-08-30 20:26:07 +09:00
this . seoService . setDescription ( $localize ` :@@meta.description.about:Learn more about The Mempool Open Source Project™ \ : enterprise sponsors, individual sponsors, integrations, who contributes, FOSS licensing, and more. ` ) ;
2020-02-17 20:39:20 +07:00
this . websocketService . want ( [ 'blocks' ] ) ;
2020-10-07 20:15:42 +07:00
2023-02-17 18:54:48 +09:00
this . profiles $ = this . apiService . getAboutPageProfiles $ ( ) . pipe (
tap ( ( ) = > {
this . goToAnchor ( )
} ) ,
share ( ) ,
)
2022-01-13 03:58:12 +04:00
this . translators $ = this . apiService . getTranslators $ ( )
. pipe (
map ( ( translators ) = > {
for ( const t in translators ) {
if ( translators [ t ] === '' ) {
2023-03-02 21:50:09 +09:00
delete translators [ t ] ;
2022-01-13 03:58:12 +04:00
}
}
return translators ;
2023-03-02 21:50:09 +09:00
} ) ,
tap ( ( ) = > this . goToAnchor ( ) )
2022-01-13 03:58:12 +04:00
) ;
2023-02-17 18:54:48 +09:00
this . ogs $ = this . apiService . getOgs $ ( ) ;
2021-12-07 18:00:49 +04:00
this . allContributors $ = this . apiService . getContributor $ ( ) . pipe (
map ( ( contributors ) = > {
return {
regular : contributors.filter ( ( user ) = > ! user . core_constributor ) ,
core : contributors.filter ( ( user ) = > user . core_constributor ) ,
} ;
2023-03-02 21:50:09 +09:00
} ) ,
tap ( ( ) = > this . goToAnchor ( ) )
2021-12-07 18:00:49 +04:00
) ;
2020-10-07 20:15:42 +07:00
}
2023-03-15 06:08:57 -04:00
2023-03-02 21:50:09 +09:00
ngAfterViewInit() {
this . goToAnchor ( ) ;
}
goToAnchor() {
setTimeout ( ( ) = > {
if ( this . route . snapshot . fragment ) {
if ( this . document . getElementById ( this . route . snapshot . fragment ) ) {
this . document . getElementById ( this . route . snapshot . fragment ) . scrollIntoView ( { behavior : 'smooth' } ) ;
2023-02-24 02:24:51 -05:00
}
2023-03-02 21:50:09 +09:00
}
} , 1 ) ;
}
2020-10-07 20:15:42 +07:00
2022-08-12 03:44:58 +04:00
sponsor ( ) : void {
2021-08-15 20:05:49 +03:00
if ( this . officialMempoolSpace && this . stateService . env . BASE_MODULE === 'mempool' ) {
2022-08-12 03:44:58 +04:00
this . router . navigateByUrl ( '/enterprise' ) ;
2021-05-18 13:23:39 +04:00
} else {
this . showNavigateToSponsor = true ;
2020-10-07 20:15:42 +07:00
}
2020-10-16 16:29:54 +07:00
}
2023-03-15 06:08:57 -04:00
2023-05-31 14:39:19 +07:00
showSubtitles ( language ) : boolean {
2023-03-16 02:29:33 -04:00
return ( this . locale . startsWith ( language ) && ! this . locale . startsWith ( 'en' ) ) ;
2023-03-15 06:08:57 -04:00
}
2023-05-27 12:38:20 -04:00
2023-05-31 14:39:19 +07:00
unmutePromoVideo ( ) : void {
this . promoVideo . nativeElement . muted = false ;
2023-05-27 12:38:20 -04:00
}
2019-07-21 17:59:47 +03:00
}