Genral fixes

This commit is contained in:
everoddandeven 2024-10-09 01:28:45 +02:00
parent 0d7346f3e8
commit e536a2e2b3
14 changed files with 66 additions and 51 deletions

View file

@ -77,7 +77,7 @@ export class DaemonDataService {
else { else {
this.stopLoop(); this.stopLoop();
} }
}) });
} }
public get initializing(): boolean { public get initializing(): boolean {

View file

@ -767,6 +767,17 @@ export class DaemonService {
throw new Error(`Could not stop daemon: ${response.status}`); throw new Error(`Could not stop daemon: ${response.status}`);
} }
const maxChecks: number = 100;
for(let i = 0; i < maxChecks; i++) {
if (!await this.isRunning(true)) {
return;
}
await this.delay(5000);
}
throw new Error('Could not stop daemon');
/* /*
if (this.electronService.isElectron) { if (this.electronService.isElectron) {
return; return;

View file

@ -13,7 +13,7 @@ import { Ban } from '../../../common';
}) })
export class BansComponent implements AfterViewInit { export class BansComponent implements AfterViewInit {
public readonly navbarLinks: NavbarLink[] = [ public readonly navbarLinks: NavbarLink[] = [
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', true, 'Overview', true), new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', false, 'Overview', true),
new NavbarLink('pills-set-bans-tab', '#pills-set-bans', 'pills-set-bans', false, 'Set Bans', true) new NavbarLink('pills-set-bans-tab', '#pills-set-bans', 'pills-set-bans', false, 'Set Bans', true)
]; ];

View file

@ -55,7 +55,7 @@ export class BlockchainComponent implements AfterViewInit {
constructor(private daemonService: DaemonService, private daemonData: DaemonDataService, private navbarService: NavbarService, private ngZone: NgZone) { constructor(private daemonService: DaemonService, private daemonData: DaemonDataService, private navbarService: NavbarService, private ngZone: NgZone) {
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-last-block-header-tab', '#pills-last-block-header', 'pills-last-block-header', true, 'Last Block Header'), new NavbarLink('pills-last-block-header-tab', '#pills-last-block-header', 'pills-last-block-header', false, 'Last Block Header'),
new NavbarLink('pills-get-block-tab', '#pills-get-block', 'pills-get-block', false, 'Get Block'), new NavbarLink('pills-get-block-tab', '#pills-get-block', 'pills-get-block', false, 'Get Block'),
new NavbarLink('pills-get-block-header-tab', '#pills-get-block-header', 'pills-get-block-header', false, 'Get Block Header'), new NavbarLink('pills-get-block-header-tab', '#pills-get-block-header', 'pills-get-block-header', false, 'Get Block Header'),
new NavbarLink('pills-pop-blocks-tab', '#pills-pop-blocks', 'pills-pop-blocks', false, 'Pop Blocks'), new NavbarLink('pills-pop-blocks-tab', '#pills-pop-blocks', 'pills-pop-blocks', false, 'Pop Blocks'),
@ -65,8 +65,8 @@ export class BlockchainComponent implements AfterViewInit {
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.navbarService this.navbarService.setLinks(this.navbarLinks);
this.load(); this.load();
} }
public async load(): Promise<void> { public async load(): Promise<void> {

View file

@ -114,7 +114,7 @@ export class DetailComponent implements AfterViewInit {
private ngZone: NgZone) { private ngZone: NgZone) {
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-home-tab', '#pills-home', 'pills-home', true, 'Overview', true), new NavbarLink('pills-home-tab', '#pills-home', 'pills-home', false, 'Overview', true),
new NavbarLink('pills-profile-tab', '#pills-profile', 'pills-profile', false, 'Peers', true), new NavbarLink('pills-profile-tab', '#pills-profile', 'pills-profile', false, 'Peers', true),
new NavbarLink('pills-spans-tab', '#pills-spans', 'pills-spans', false, 'Spans', true) new NavbarLink('pills-spans-tab', '#pills-spans', 'pills-spans', false, 'Spans', true)
]; ];

View file

@ -2,11 +2,16 @@
<h1 class="h2">Hard Fork Info</h1> <h1 class="h2">Hard Fork Info</h1>
<div class="btn-toolbar mb-2 mb-md-0"> <div class="btn-toolbar mb-2 mb-md-0">
<ul class="nav nav-pills m-3" id="pills-tab" role="tablist"> <ul class="nav nav-pills m-3" id="pills-tab" role="tablist">
@for(navbarLink of navbarLinks; track navbarLink.name) {
<li class="nav-item mr-2" role="presentation">
<button [class]="navbarLink.selected ? 'nav-link active btn-sm' : 'nav-link btn-sm'" [id]="navbarLink.id" data-bs-toggle="pill" [attr.data-bs-target]="navbarLink.target" type="button" role="tab" [attr.aria-controls]="navbarLink.controls" [attr.aria-selected]="navbarLink.selected" [disabled]="navbarLink.disabled">{{navbarLink.name}}</button>
</li>
}
</ul> </ul>
</div> </div>
</div> </div>
<div *ngIf="daemonRunning" class="row d-flex justify-content-center"> <div *ngIf="daemonRunning && !daemonStopping" class="row d-flex justify-content-center">
@if(!loading) { @if(!loading) {
@for(card of cards; track card.header) { @for(card of cards; track card.header) {
<div class="card text-bg-dark m-3 text-center" style="max-width: 18rem;"> <div class="card text-bg-dark m-3 text-center" style="max-width: 18rem;">

View file

@ -3,6 +3,8 @@ import { DaemonService } from '../../core/services/daemon/daemon.service';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { NavbarService } from '../../shared/components/navbar/navbar.service'; import { NavbarService } from '../../shared/components/navbar/navbar.service';
import { SimpleBootstrapCard } from '../../shared/utils'; import { SimpleBootstrapCard } from '../../shared/utils';
import { DaemonDataService } from '../../core/services';
import { NavbarLink } from '../../shared/components/navbar/navbar.model';
@Component({ @Component({
selector: 'app-hard-fork-info', selector: 'app-hard-fork-info',
@ -19,11 +21,21 @@ export class HardForkInfoComponent implements AfterViewInit {
private voting: number; private voting: number;
private window: number; private window: number;
public daemonRunning: boolean; public get daemonRunning(): boolean {
return this.daemonData.running;
}
public get daemonStopping(): boolean {
return this.daemonService.stopping;
}
public loading: boolean = false; public loading: boolean = false;
constructor(private router: Router, private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) { public readonly navbarLinks: NavbarLink[] = [
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', false, 'Overview'),
];
constructor(private router: Router, private daemonData: DaemonDataService, private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) {
this.cards = []; this.cards = [];
this.enabled = false; this.enabled = false;
this.earliestHeight = 0; this.earliestHeight = 0;
@ -32,7 +44,6 @@ export class HardForkInfoComponent implements AfterViewInit {
this.votes = 0; this.votes = 0;
this.voting = 0; this.voting = 0;
this.window = 0; this.window = 0;
this.daemonRunning = false;
this.router.events.subscribe((event) => { this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
@ -40,21 +51,10 @@ export class HardForkInfoComponent implements AfterViewInit {
this.onNavigationEnd(); this.onNavigationEnd();
} }
}); });
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
this.daemonRunning = running;
});
this.daemonService.isRunning().then((running: boolean) => {
this.ngZone.run(() => {
this.daemonRunning = running;
});
});
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
this.navbarService.removeLinks(); this.navbarService.setLinks(this.navbarLinks);
} }
private onNavigationEnd(): void { private onNavigationEnd(): void {

View file

@ -37,7 +37,7 @@ export class LogsComponent implements AfterViewInit {
constructor(private navbarService: NavbarService, private logsService: LogsService, private daemonService: DaemonService, private ngZone: NgZone) { constructor(private navbarService: NavbarService, private logsService: LogsService, private daemonService: DaemonService, private ngZone: NgZone) {
this.logsService.onLog.subscribe((message: string) => this.onLog()); this.logsService.onLog.subscribe((message: string) => this.onLog());
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', true, 'Overview'), new NavbarLink('pills-overview-tab', '#pills-overview', 'pills-overview', false, 'Overview'),
new NavbarLink('pills-set-log-level-tab', '#pills-set-log-level', 'pills-set-log-level', false, 'Set Log Level'), new NavbarLink('pills-set-log-level-tab', '#pills-set-log-level', 'pills-set-log-level', false, 'Set Log Level'),
new NavbarLink('pills-set-log-categories-tab', '#pills-set-log-categories', 'pills-set-log-categories', false, 'Set Log Categories'), new NavbarLink('pills-set-log-categories-tab', '#pills-set-log-categories', 'pills-set-log-categories', false, 'Set Log Categories'),
new NavbarLink('pills-set-log-hash-rate-tab', '#pills-set-log-hash-rate', 'pills-set-log-hash-rate', false, 'Set Log Hash Rate') new NavbarLink('pills-set-log-hash-rate-tab', '#pills-set-log-hash-rate', 'pills-set-log-hash-rate', false, 'Set Log Hash Rate')
@ -73,7 +73,7 @@ export class LogsComponent implements AfterViewInit {
} }
public ngAfterViewInit(): void { public ngAfterViewInit(): void {
this.navbarService.removeLinks(); this.navbarService.setLinks(this.navbarLinks);
setTimeout(() => { setTimeout(() => {
this.scrollToBottom(); this.scrollToBottom();

View file

@ -141,7 +141,7 @@ export class MiningComponent implements AfterViewInit {
this.cards = []; this.cards = [];
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-mining-status-tab', '#pills-mining-status', 'mining-status', true, 'Status'), new NavbarLink('pills-mining-status-tab', '#pills-mining-status', 'mining-status', false, 'Status'),
new NavbarLink('pills-miner-data-tab', '#pills-miner-data', 'miner-data', false, 'Miner Data'), new NavbarLink('pills-miner-data-tab', '#pills-miner-data', 'miner-data', false, 'Miner Data'),
new NavbarLink('pills-hashrate-tab', '#pills-hashrate', 'hashrate', false, 'Hashrate'), new NavbarLink('pills-hashrate-tab', '#pills-hashrate', 'hashrate', false, 'Hashrate'),
new NavbarLink('pills-alternate-chains-tab', '#pills-alternate-chains', 'alternate-chains', false, 'Alternate Chains'), new NavbarLink('pills-alternate-chains-tab', '#pills-alternate-chains', 'alternate-chains', false, 'Alternate Chains'),

View file

@ -76,7 +76,7 @@ export class OutputsComponent implements AfterViewInit {
constructor(private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) { constructor(private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) {
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-outputs-overview-tab', '#pills-outputs-overview', 'outputs-overview', true, 'Overview'), new NavbarLink('pills-outputs-overview-tab', '#pills-outputs-overview', 'outputs-overview', false, 'Overview'),
new NavbarLink('pills-outputs-histogram-tab', '#pills-outputs-histogram', 'outputs-histogram', false, 'Histogram'), new NavbarLink('pills-outputs-histogram-tab', '#pills-outputs-histogram', 'outputs-histogram', false, 'Histogram'),
new NavbarLink('pills-outputs-distribution-tab', '#pills-outputs-distribution', 'outputs-distribution', false, 'Distribution'), new NavbarLink('pills-outputs-distribution-tab', '#pills-outputs-distribution', 'outputs-distribution', false, 'Distribution'),
new NavbarLink('pills-is-key-image-spent-tab', '#pills-is-key-image-spent', 'is-key-image-spent', false, 'Is Key Image Spent') new NavbarLink('pills-is-key-image-spent-tab', '#pills-is-key-image-spent', 'is-key-image-spent', false, 'Is Key Image Spent')

View file

@ -28,7 +28,7 @@
<input id="general-monerod-path-control" type="text" class="form-control form-control-sm" placeholder="" aria-label="Monerod path" aria-describedby="basic-addon2" [value]="currentSettings.monerodPath" readonly> <input id="general-monerod-path-control" type="text" class="form-control form-control-sm" placeholder="" aria-label="Monerod path" aria-describedby="basic-addon2" [value]="currentSettings.monerodPath" readonly>
<span class="input-group-text" id="basic-addon2"><button type="button" class="btn btn-secondary btn-sm" (click)="chooseMonerodFile()">Choose file</button></span> <span class="input-group-text" id="basic-addon2"><button type="button" class="btn btn-secondary btn-sm" (click)="chooseMonerodFile()">Choose file</button></span>
</div> </div>
<input type="file" class="form-control d-none" id="general-monerod-path" [(ngModel)]="currentSettings.monerodPath" [ngModelOptions]="{standalone: true}" (change)="onMonerodPathChange()" placeholder="AAA"> <input type="file" class="form-control d-none" id="general-monerod-path" (change)="onMonerodPathChange()">
<small class="text-body-secondary">Path to monerod executable</small> <small class="text-body-secondary">Path to monerod executable</small>
</div> </div>

View file

@ -76,7 +76,7 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
constructor(private daemonData: DaemonDataService, private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) { constructor(private daemonData: DaemonDataService, private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) {
this.navbarLinks = [ this.navbarLinks = [
new NavbarLink('pills-tx-pool-tab', '#pills-tx-pool', 'pills-tx-pool', true, 'Pool'), new NavbarLink('pills-tx-pool-tab', '#pills-tx-pool', 'pills-tx-pool', false, 'Pool'),
new NavbarLink('pills-relay-tx-tab', '#pills-relay-tx', 'pills-relay-tx', false, 'Relay Tx'), new NavbarLink('pills-relay-tx-tab', '#pills-relay-tx', 'pills-relay-tx', false, 'Relay Tx'),
new NavbarLink('pills-send-raw-tx-tab', '#pills-send-raw-tx', 'pills-send-raw-tx', false, 'Send Raw Tx'), new NavbarLink('pills-send-raw-tx-tab', '#pills-send-raw-tx', 'pills-send-raw-tx', false, 'Send Raw Tx'),
new NavbarLink('pills-get-fee-estimate-tab', '#pills-get-fee-estimate', 'pills-get-fee-estimate', false, 'Get Fee Estimate'), new NavbarLink('pills-get-fee-estimate-tab', '#pills-get-fee-estimate', 'pills-get-fee-estimate', false, 'Get Fee Estimate'),

View file

@ -1,5 +1,6 @@
import { Component, Input, NgZone } from '@angular/core'; import { Component, Input, NgZone } from '@angular/core';
import { DaemonService } from '../../../core/services/daemon/daemon.service'; import { DaemonService } from '../../../core/services/daemon/daemon.service';
import { DaemonDataService } from '../../../core/services';
@Component({ @Component({
selector: 'app-daemon-not-running', selector: 'app-daemon-not-running',
@ -8,24 +9,21 @@ import { DaemonService } from '../../../core/services/daemon/daemon.service';
}) })
export class DaemonNotRunningComponent { export class DaemonNotRunningComponent {
public daemonRunning: boolean = false; public get daemonRunning(): boolean {
public daemonConfigured: boolean = false; return this.daemonData.running;
}
public daemonConfigured: boolean = true;
public get startingDaemon(): boolean { public get startingDaemon(): boolean {
return this.daemonService.starting; return this.daemonService.starting;
} }
private stoppingDaemon: boolean = false; private get stoppingDaemon(): boolean{
return this.daemonData.stopping;
}
constructor(private daemonData: DaemonDataService, private daemonService: DaemonService, private ngZone: NgZone) {
constructor(private daemonService: DaemonService, private ngZone: NgZone) {
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
this.ngZone.run(() => this.daemonRunning = running);
this.daemonRunning = running;
});
this.daemonService.isRunning().then((running: boolean) => {
this.ngZone.run(() => this.daemonRunning = running);
});
this.daemonService.getSettings().then((settings) => { this.daemonService.getSettings().then((settings) => {
this.daemonConfigured = settings.monerodPath != ''; this.daemonConfigured = settings.monerodPath != '';
}) })
@ -41,16 +39,17 @@ export class DaemonNotRunningComponent {
return; return;
} }
setTimeout(async () => { await new Promise<void>((resolve, reject) => {
try { setTimeout(async () => {
await this.daemonService.startDaemon(); try {
this.daemonRunning = await this.daemonService.isRunning(); await this.daemonService.startDaemon();
} resolve();
catch(error) { }
console.error(error); catch(error) {
this.daemonRunning = false; console.error(error);
} reject(error);
}, 500); }
}, 500)});
} }
} }

View file

@ -8,7 +8,7 @@ export class NavbarLink {
public name: string; public name: string;
public disabled: boolean; public disabled: boolean;
constructor(id: string, target: string, controls: string, selected: boolean, name: string, disabled: boolean = false) { constructor(id: string, target: string, controls: string, selected: boolean, name: string, disabled: boolean = true) {
this.id = id; this.id = id;
this.target = target; this.target = target;
this.controls = controls; this.controls = controls;