Merge pull request #602 from keerifox/disable-requests-to-ninja-api
Disable requests to defunct MyNanoNinja API, hide recommended representatives section
This commit is contained in:
commit
7f28852483
2 changed files with 18 additions and 9 deletions
|
|
@ -188,26 +188,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="uk-form-controls">
|
<!-- <div class="uk-form-controls">
|
||||||
<div class="uk-inline uk-width-1-1 uk-margin-top">
|
<div class="uk-inline uk-width-1-1 uk-margin-top">
|
||||||
<button class="uk-button uk-button-default uk-button-small" *ngIf="showRecommendedReps" (click)="showRecommendedReps = !showRecommendedReps"><span uk-icon="icon: minus; ratio: 0.8" style="margin-right: 5px;"></span> Hide Recommended Representatives</button>
|
<button class="uk-button uk-button-default uk-button-small" *ngIf="showRecommendedReps" (click)="showRecommendedReps = !showRecommendedReps"><span uk-icon="icon: minus; ratio: 0.8" style="margin-right: 5px;"></span> Hide Recommended Representatives</button>
|
||||||
<button class="uk-button uk-button-primary uk-button-small" *ngIf="!showRecommendedReps" (click)="showRecommendedReps = !showRecommendedReps"><span uk-icon="icon: plus; ratio: 0.8" style="margin-right: 5px;"></span> View Recommended Representatives</button>
|
<button class="uk-button uk-button-primary uk-button-small" *ngIf="!showRecommendedReps" (click)="showRecommendedReps = !showRecommendedReps"><span uk-icon="icon: plus; ratio: 0.8" style="margin-right: 5px;"></span> View Recommended Representatives</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div *ngIf="showRecommendedReps">
|
<!-- <div *ngIf="showRecommendedReps">
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="uk-margin">
|
<div class="uk-margin">
|
||||||
<p class="uk-text-lead uk-text-center">Select a representative recommended by <a href="https://mynano.ninja" target="_blank" rel="noopener noreferrer" class="uk-link-text">MyNanoNinja</a></p>
|
<p class="uk-text-lead uk-text-center">Select a representative recommended by <a href="https://mynano.ninja" target="_blank" rel="noopener noreferrer" class="uk-link-text">MyNanoNinja</a></p>
|
||||||
<!--<h4>Or, Select a recommended representative</h4>-->
|
|
||||||
<ul class="uk-list uk-list-striped" style="margin-bottom: 0;">
|
<ul class="uk-list uk-list-striped" style="margin-bottom: 0;">
|
||||||
<li class="uk-list-header">
|
<li class="uk-list-header">
|
||||||
<div uk-grid>
|
<div uk-grid>
|
||||||
<div class="uk-width-expand">Representative</div>
|
<div class="uk-width-expand">Representative</div>
|
||||||
<div class="uk-width-1-2">Weight / Uptime / Accounts</div>
|
<div class="uk-width-1-2">Weight / Uptime / Accounts</div>
|
||||||
<!--<div class="uk-width-1-5">Uptime / Delegators</div>-->
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -242,7 +240,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@ import { UtilService } from './util.service';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NinjaService {
|
export class NinjaService {
|
||||||
|
|
||||||
// URL to Ninja API
|
// URL to MyNanoNinja-compatible representative health check API
|
||||||
ninjaUrl = 'https://mynano.ninja/api/';
|
// set to empty string to disable
|
||||||
|
ninjaUrl = '';
|
||||||
|
|
||||||
// null - loading, false - offline, true - online
|
// null - loading, false - offline, true - online
|
||||||
status = null;
|
status = null;
|
||||||
|
|
@ -15,6 +16,10 @@ export class NinjaService {
|
||||||
constructor(private http: HttpClient, private notifications: NotificationService, private util: UtilService) { }
|
constructor(private http: HttpClient, private notifications: NotificationService, private util: UtilService) { }
|
||||||
|
|
||||||
private async request(action): Promise<any> {
|
private async request(action): Promise<any> {
|
||||||
|
if (this.ninjaUrl === '') {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
return await this.http.get(this.ninjaUrl + action).toPromise()
|
return await this.http.get(this.ninjaUrl + action).toPromise()
|
||||||
.then(res => {
|
.then(res => {
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -67,8 +72,14 @@ export class NinjaService {
|
||||||
return replist[0];
|
return replist[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// false - does not exist, null - any other error
|
// Expected to return:
|
||||||
|
// false, if the representative never voted as part of nano consensus
|
||||||
|
// null, if the representative state is unknown (any other error)
|
||||||
async getAccount(account: string): Promise<any> {
|
async getAccount(account: string): Promise<any> {
|
||||||
|
if (this.ninjaUrl === '') {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
const REQUEST_TIMEOUT_MS = 10000;
|
const REQUEST_TIMEOUT_MS = 10000;
|
||||||
|
|
||||||
const successPromise =
|
const successPromise =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue