mempool/frontend/src/app/components/about/about.component.ts

59 lines
2.1 KiB
TypeScript
Raw Normal View History

import { ChangeDetectionStrategy, Component, Inject, LOCALE_ID, OnInit } from '@angular/core';
import { WebsocketService } from '../../services/websocket.service';
2020-03-24 00:52:08 +07:00
import { SeoService } from 'src/app/services/seo.service';
import { StateService } from 'src/app/services/state.service';
2021-05-18 13:23:39 +04:00
import { Observable } from 'rxjs';
import { ApiService } from 'src/app/services/api.service';
import { IBackendInfo } from 'src/app/interfaces/websocket.interface';
2021-05-18 13:23:39 +04:00
import { Router } from '@angular/router';
import { map } from 'rxjs/operators';
2019-07-21 17:59:47 +03:00
@Component({
selector: 'app-about',
templateUrl: './about.component.html',
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 {
backendInfo$: Observable<IBackendInfo>;
sponsors$: Observable<any>;
allContributors$: Observable<any>;
frontendGitCommitHash = this.stateService.env.GIT_COMMIT_HASH;
packetJsonVersion = this.stateService.env.PACKAGE_JSON_VERSION;
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
constructor(
private websocketService: WebsocketService,
2020-03-24 00:52:08 +07:00
private seoService: SeoService,
public stateService: StateService,
private apiService: ApiService,
2021-05-18 13:23:39 +04:00
private router: Router,
@Inject(LOCALE_ID) public locale: string,
) { }
2019-07-21 17:59:47 +03:00
ngOnInit() {
this.backendInfo$ = this.stateService.backendInfo$;
2020-12-03 18:34:19 +07:00
this.seoService.setTitle($localize`:@@004b222ff9ef9dd4771b777950ca1d0e4cd4348a:About`);
2020-02-17 20:39:20 +07:00
this.websocketService.want(['blocks']);
2021-05-18 13:23:39 +04:00
this.sponsors$ = this.apiService.getDonation$();
this.allContributors$ = this.apiService.getContributor$().pipe(
map((contributors) => {
return {
regular: contributors.filter((user) => !user.core_constributor),
core: contributors.filter((user) => user.core_constributor),
};
})
);
}
2021-05-18 13:23:39 +04:00
sponsor() {
if (this.officialMempoolSpace && this.stateService.env.BASE_MODULE === 'mempool') {
2021-05-18 13:23:39 +04:00
this.router.navigateByUrl('/sponsor');
} else {
this.showNavigateToSponsor = true;
}
}
2019-07-21 17:59:47 +03:00
}