Use mining pool slug in urls
This commit is contained in:
@@ -85,7 +85,7 @@ let routes: Routes = [
|
||||
path: 'pool',
|
||||
children: [
|
||||
{
|
||||
path: ':poolId',
|
||||
path: ':slug',
|
||||
component: PoolComponent,
|
||||
},
|
||||
]
|
||||
@@ -227,7 +227,7 @@ let routes: Routes = [
|
||||
path: 'pool',
|
||||
children: [
|
||||
{
|
||||
path: ':poolId',
|
||||
path: ':slug',
|
||||
component: PoolComponent,
|
||||
},
|
||||
]
|
||||
@@ -363,7 +363,7 @@ let routes: Routes = [
|
||||
path: 'pool',
|
||||
children: [
|
||||
{
|
||||
path: ':poolId',
|
||||
path: ':slug',
|
||||
component: PoolComponent,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="time-difference"><app-time-since [time]="block.timestamp" [fastRender]="true"></app-time-since></div>
|
||||
</div>
|
||||
<div class="animated" [class]="showMiningInfo ? 'show' : 'hide'" *ngIf="block.extras?.pool != undefined">
|
||||
<a class="badge badge-primary" [routerLink]="[('/mining/pool/' + block.extras.pool.id) | relativeUrl]">
|
||||
<a class="badge badge-primary" [routerLink]="[('/mining/pool/' + block.extras.pool.slug) | relativeUrl]">
|
||||
{{ block.extras.pool.name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</td>
|
||||
<td class="pool text-left" [class]="widget ? 'widget' : ''">
|
||||
<div class="tooltip-custom">
|
||||
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.id) | relativeUrl]">
|
||||
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.slug) | relativeUrl]">
|
||||
<img width="25" height="25" src="{{ block.extras.pool['logo'] }}"
|
||||
onError="this.src = './resources/mining-pools/default.svg'">
|
||||
<span class="pool-name">{{ block.extras.pool.name }}</span>
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
<td class="d-none d-md-block">{{ pool.rank }}</td>
|
||||
<td class="text-right"><img width="25" height="25" src="{{ pool.logo }}"
|
||||
onError="this.src = './resources/mining-pools/default.svg'"></td>
|
||||
<td class=""><a [routerLink]="[('/mining/pool/' + pool.poolId) | relativeUrl]">{{ pool.name }}</a></td>
|
||||
<td class=""><a [routerLink]="[('/mining/pool/' + pool.slug) | relativeUrl]">{{ pool.name }}</a></td>
|
||||
<td class="" *ngIf="this.poolsWindowPreference === '24h' && !isLoading">{{ pool.lastEstimatedHashrate }} {{
|
||||
miningStats.miningUnits.hashrateUnit }}</td>
|
||||
<td class="">{{ pool['blockText'] }}</td>
|
||||
|
||||
@@ -159,7 +159,7 @@ export class PoolRankingComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
},
|
||||
data: pool.poolId,
|
||||
data: pool.slug,
|
||||
} as PieSeriesOption);
|
||||
});
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ export class PoolComponent implements OnInit {
|
||||
};
|
||||
|
||||
blocks: BlockExtended[] = [];
|
||||
poolId: number = undefined;
|
||||
slug: string = undefined;
|
||||
|
||||
loadMoreSubject: BehaviorSubject<number> = new BehaviorSubject(this.poolId);
|
||||
loadMoreSubject: BehaviorSubject<string> = new BehaviorSubject(this.slug);
|
||||
|
||||
constructor(
|
||||
@Inject(LOCALE_ID) public locale: string,
|
||||
@@ -45,23 +45,23 @@ export class PoolComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.poolStats$ = this.route.params.pipe(map((params) => params.poolId))
|
||||
this.poolStats$ = this.route.params.pipe(map((params) => params.slug))
|
||||
.pipe(
|
||||
switchMap((poolId: any) => {
|
||||
switchMap((slug: any) => {
|
||||
this.isLoading = true;
|
||||
this.poolId = poolId;
|
||||
this.loadMoreSubject.next(this.poolId);
|
||||
return this.apiService.getPoolHashrate$(this.poolId)
|
||||
this.slug = slug;
|
||||
this.loadMoreSubject.next(this.slug);
|
||||
return this.apiService.getPoolHashrate$(this.slug)
|
||||
.pipe(
|
||||
switchMap((data) => {
|
||||
this.isLoading = false;
|
||||
this.prepareChartOptions(data.hashrates.map(val => [val.timestamp * 1000, val.avgHashrate]));
|
||||
return poolId;
|
||||
return slug;
|
||||
}),
|
||||
);
|
||||
}),
|
||||
switchMap(() => {
|
||||
return this.apiService.getPoolStats$(this.poolId);
|
||||
return this.apiService.getPoolStats$(this.slug);
|
||||
}),
|
||||
map((poolStats) => {
|
||||
let regexes = '"';
|
||||
@@ -80,10 +80,10 @@ export class PoolComponent implements OnInit {
|
||||
this.blocks$ = this.loadMoreSubject
|
||||
.pipe(
|
||||
switchMap((flag) => {
|
||||
if (this.poolId === undefined) {
|
||||
if (this.slug === undefined) {
|
||||
return [];
|
||||
}
|
||||
return this.apiService.getPoolBlocks$(this.poolId, this.blocks[this.blocks.length - 1]?.height);
|
||||
return this.apiService.getPoolBlocks$(this.slug, this.blocks[this.blocks.length - 1]?.height);
|
||||
}),
|
||||
tap((newBlocks) => {
|
||||
this.blocks = this.blocks.concat(newBlocks);
|
||||
@@ -182,7 +182,7 @@ export class PoolComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadMore() {
|
||||
this.loadMoreSubject.next(this.poolId);
|
||||
this.loadMoreSubject.next(this.slug);
|
||||
}
|
||||
|
||||
trackByBlock(index: number, block: BlockExtended) {
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
<td class="table-cell-height" ><a [routerLink]="['/block' | relativeUrl, block.id]" [state]="{ data: { block: block } }">{{ block.height }}</a></td>
|
||||
<td *ngIf="!stateService.env.MINING_DASHBOARD" class="table-cell-mined" ><app-time-since [time]="block.timestamp" [fastRender]="true"></app-time-since></td>
|
||||
<td *ngIf="stateService.env.MINING_DASHBOARD" class="table-cell-mined pl-lg-4">
|
||||
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.id) | relativeUrl]">
|
||||
<a class="clear-link" [routerLink]="[('/mining/pool/' + block.extras.pool.slug) | relativeUrl]">
|
||||
<img width="20" height="20" src="{{ block.extras.pool['logo'] }}"
|
||||
onError="this.src = './resources/mining-pools/default.svg'">
|
||||
<span class="pool-name">{{ block.extras.pool.name }}</span>
|
||||
|
||||
@@ -71,6 +71,7 @@ export interface SinglePoolStats {
|
||||
lastEstimatedHashrate: string;
|
||||
emptyBlockRatio: string;
|
||||
logo: string;
|
||||
slug: string;
|
||||
}
|
||||
export interface PoolsStats {
|
||||
blockCount: number;
|
||||
@@ -107,6 +108,7 @@ export interface BlockExtension {
|
||||
pool?: {
|
||||
id: number;
|
||||
name: string;
|
||||
slug: string;
|
||||
}
|
||||
|
||||
stage?: number; // Frontend only
|
||||
|
||||
@@ -132,17 +132,17 @@ export class ApiService {
|
||||
);
|
||||
}
|
||||
|
||||
getPoolStats$(poolId: number): Observable<PoolStat> {
|
||||
return this.httpClient.get<PoolStat>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${poolId}`);
|
||||
getPoolStats$(slug: string): Observable<PoolStat> {
|
||||
return this.httpClient.get<PoolStat>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}`);
|
||||
}
|
||||
|
||||
getPoolHashrate$(poolId: number): Observable<any> {
|
||||
return this.httpClient.get<any>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${poolId}/hashrate`);
|
||||
getPoolHashrate$(slug: string): Observable<any> {
|
||||
return this.httpClient.get<any>(this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}/hashrate`);
|
||||
}
|
||||
|
||||
getPoolBlocks$(poolId: number, fromHeight: number): Observable<BlockExtended[]> {
|
||||
getPoolBlocks$(slug: string, fromHeight: number): Observable<BlockExtended[]> {
|
||||
return this.httpClient.get<BlockExtended[]>(
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${poolId}/blocks` +
|
||||
this.apiBaseUrl + this.apiBasePath + `/api/v1/mining/pool/${slug}/blocks` +
|
||||
(fromHeight !== undefined ? `/${fromHeight}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user