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:
Joohansson (Json) 2023-08-18 16:02:16 +02:00 committed by GitHub
commit 7f28852483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View file

@ -188,26 +188,24 @@
</div>
</div>
<div class="uk-form-controls">
<!-- <div class="uk-form-controls">
<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-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 *ngIf="showRecommendedReps">
<!-- <div *ngIf="showRecommendedReps">
<hr>
<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>
<!--<h4>Or, Select a recommended representative</h4>-->
<ul class="uk-list uk-list-striped" style="margin-bottom: 0;">
<li class="uk-list-header">
<div uk-grid>
<div class="uk-width-expand">Representative</div>
<div class="uk-width-1-2">Weight / Uptime / Accounts</div>
<!--<div class="uk-width-1-5">Uptime / Delegators</div>-->
</div>
</li>
</ul>
@ -242,7 +240,7 @@
</ul>
</div>
</div>
</div> -->
</div>

View file

@ -6,8 +6,9 @@ import { UtilService } from './util.service';
@Injectable()
export class NinjaService {
// URL to Ninja API
ninjaUrl = 'https://mynano.ninja/api/';
// URL to MyNanoNinja-compatible representative health check API
// set to empty string to disable
ninjaUrl = '';
// null - loading, false - offline, true - online
status = null;
@ -15,6 +16,10 @@ export class NinjaService {
constructor(private http: HttpClient, private notifications: NotificationService, private util: UtilService) { }
private async request(action): Promise<any> {
if (this.ninjaUrl === '') {
return Promise.resolve(null);
}
return await this.http.get(this.ninjaUrl + action).toPromise()
.then(res => {
return res;
@ -67,8 +72,14 @@ export class NinjaService {
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> {
if (this.ninjaUrl === '') {
return Promise.resolve(null);
}
const REQUEST_TIMEOUT_MS = 10000;
const successPromise =