Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for the UI #1398

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnDestroy, OnInit, NgZone, Injector } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs/internal/Subscription';
import { Observable, ReplaySubject, timer } from 'rxjs';
import { Observable, of, ReplaySubject, timer } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { delay } from 'rxjs/operators';

import { NodeService, BackendData } from '../../../services/node.service';
import { Node } from '../../../app.datatypes';
Expand Down Expand Up @@ -57,10 +58,15 @@ export class NodeComponent implements OnInit, OnDestroy {
* Keeps track of the browser URL.
*/
private lastUrl: string;
/**
* Allows to know if a route event already fired.
*/
private initialRouteEventFired = false;

private dataSubscription: Subscription;
private updateTimeSubscription: Subscription;
private navigationsSubscription: Subscription;
private initSubscription: Subscription;

// Vars for keeping track of the data updating.
secondsSinceLastUpdate = 0;
Expand Down Expand Up @@ -111,17 +117,9 @@ export class NodeComponent implements OnInit, OnDestroy {

this.navigationsSubscription = router.events.subscribe(event => {
if (event['urlAfterRedirects']) {
NodeComponent.currentNodeKey = this.route.snapshot.params['key'];
if (this.nodeActionsHelper) {
this.nodeActionsHelper.setCurrentNodeKey(NodeComponent.currentNodeKey);
}
this.lastUrl = event['urlAfterRedirects'] as string;
this.updateTabBar();
this.navigationsSubscription.unsubscribe();

// Load the data.
this.nodeService.startRequestingSpecificNode(NodeComponent.currentNodeKey);
this.startGettingData();
this.processRouteUpdate();
this.initialRouteEventFired = true;
}
});
}
Expand All @@ -134,6 +132,26 @@ export class NodeComponent implements OnInit, OnDestroy {
this.secondsSinceLastUpdate = Math.floor((Date.now() - this.lastUpdate) / 1000);
}));
});

this.initSubscription = of(0).pipe(delay(500)).subscribe(() => {
if (!this.initialRouteEventFired) {
this.lastUrl = window.location.href;
this.processRouteUpdate();
}
});
}

private processRouteUpdate() {
NodeComponent.currentNodeKey = this.route.snapshot.params['key'];
if (this.nodeActionsHelper) {
this.nodeActionsHelper.setCurrentNodeKey(NodeComponent.currentNodeKey);
}
this.updateTabBar();
this.navigationsSubscription.unsubscribe();

// Load the data.
this.nodeService.startRequestingSpecificNode(NodeComponent.currentNodeKey);
this.startGettingData();
}

private updateTabBar() {
Expand Down Expand Up @@ -311,6 +329,7 @@ export class NodeComponent implements OnInit, OnDestroy {
this.dataSubscription.unsubscribe();
this.updateTimeSubscription.unsubscribe();
this.navigationsSubscription.unsubscribe();
this.initSubscription.unsubscribe();

NodeComponent.currentInstanceInternal = undefined;
NodeComponent.currentNodeKey = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export class ProxyDiscoveryService {
// In case of error, retry.
retryWhen(errors => errors.pipe(delay(4000))),
map((result: any[]) => {
if (!result) {
result = [];
}

// Process the data.
result.forEach(proxy => {
const currentEntry = new ProxyDiscoveryEntry();
Expand Down