2020-05-02 12:36:35 +07:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
2020-05-09 20:37:50 +07:00
|
|
|
import { Observable } from 'rxjs';
|
2020-05-05 15:26:23 +07:00
|
|
|
import { shareReplay } from 'rxjs/operators';
|
2020-11-23 18:22:21 +07:00
|
|
|
import { StateService } from './state.service';
|
2020-05-02 12:36:35 +07:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class AssetsService {
|
2020-05-05 15:26:23 +07:00
|
|
|
getAssetsJson$: Observable<any>;
|
|
|
|
getAssetsMinimalJson$: Observable<any>;
|
2020-05-10 00:35:21 +07:00
|
|
|
getMiningPools$: Observable<any>;
|
2020-05-02 12:36:35 +07:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private httpClient: HttpClient,
|
2020-11-23 18:22:21 +07:00
|
|
|
private stateService: StateService,
|
2020-05-02 12:36:35 +07:00
|
|
|
) {
|
2020-11-27 23:01:47 +09:00
|
|
|
let apiBaseUrl = '';
|
2020-11-23 18:22:21 +07:00
|
|
|
if (!this.stateService.isBrowser) {
|
2020-11-27 23:01:47 +09:00
|
|
|
apiBaseUrl = this.stateService.env.NGINX_PROTOCOL + '://' + this.stateService.env.NGINX_HOSTNAME + ':' + this.stateService.env.NGINX_PORT;
|
2020-11-23 18:22:21 +07:00
|
|
|
}
|
|
|
|
|
2020-11-27 23:01:47 +09:00
|
|
|
this.getAssetsJson$ = this.httpClient.get(apiBaseUrl + '/resources/assets.json').pipe(shareReplay());
|
|
|
|
this.getAssetsMinimalJson$ = this.httpClient.get(apiBaseUrl + '/resources/assets.minimal.json').pipe(shareReplay());
|
|
|
|
this.getMiningPools$ = this.httpClient.get(apiBaseUrl + '/resources/pools.json').pipe(shareReplay());
|
2020-05-02 16:29:34 +07:00
|
|
|
}
|
2020-05-02 12:36:35 +07:00
|
|
|
}
|