From e536a2e2b35c63d63b821e513c4f67f6660158f0 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Wed, 9 Oct 2024 01:28:45 +0200 Subject: [PATCH] Genral fixes --- .../services/daemon/daemon-data.service.ts | 2 +- .../core/services/daemon/daemon.service.ts | 11 +++++ src/app/pages/bans/bans.component.ts | 2 +- .../pages/blockchain/blockchain.component.ts | 6 +-- src/app/pages/detail/detail.component.ts | 2 +- .../hard-fork-info.component.html | 7 ++- .../hard-fork-info.component.ts | 30 ++++++------- src/app/pages/logs/logs.component.ts | 4 +- src/app/pages/mining/mining.component.ts | 2 +- src/app/pages/outputs/outputs.component.ts | 2 +- .../pages/settings/settings.component.html | 2 +- .../transactions/transactions.component.ts | 2 +- .../daemon-not-running.component.ts | 43 +++++++++---------- .../shared/components/navbar/navbar.model.ts | 2 +- 14 files changed, 66 insertions(+), 51 deletions(-) diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index 6215fa5..80171a7 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -77,7 +77,7 @@ export class DaemonDataService { else { this.stopLoop(); } - }) + }); } public get initializing(): boolean { diff --git a/src/app/core/services/daemon/daemon.service.ts b/src/app/core/services/daemon/daemon.service.ts index cad23c9..f55ad16 100644 --- a/src/app/core/services/daemon/daemon.service.ts +++ b/src/app/core/services/daemon/daemon.service.ts @@ -767,6 +767,17 @@ export class DaemonService { 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) { return; diff --git a/src/app/pages/bans/bans.component.ts b/src/app/pages/bans/bans.component.ts index 5fa073d..481ad2c 100644 --- a/src/app/pages/bans/bans.component.ts +++ b/src/app/pages/bans/bans.component.ts @@ -13,7 +13,7 @@ import { Ban } from '../../../common'; }) export class BansComponent implements AfterViewInit { 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) ]; diff --git a/src/app/pages/blockchain/blockchain.component.ts b/src/app/pages/blockchain/blockchain.component.ts index a271c8c..b5af78b 100644 --- a/src/app/pages/blockchain/blockchain.component.ts +++ b/src/app/pages/blockchain/blockchain.component.ts @@ -55,7 +55,7 @@ export class BlockchainComponent implements AfterViewInit { constructor(private daemonService: DaemonService, private daemonData: DaemonDataService, private navbarService: NavbarService, private ngZone: NgZone) { 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-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'), @@ -65,8 +65,8 @@ export class BlockchainComponent implements AfterViewInit { } ngAfterViewInit(): void { - this.navbarService - this.load(); + this.navbarService.setLinks(this.navbarLinks); + this.load(); } public async load(): Promise { diff --git a/src/app/pages/detail/detail.component.ts b/src/app/pages/detail/detail.component.ts index 9d306a2..a70f75d 100644 --- a/src/app/pages/detail/detail.component.ts +++ b/src/app/pages/detail/detail.component.ts @@ -114,7 +114,7 @@ export class DetailComponent implements AfterViewInit { private ngZone: NgZone) { 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-spans-tab', '#pills-spans', 'pills-spans', false, 'Spans', true) ]; diff --git a/src/app/pages/hard-fork-info/hard-fork-info.component.html b/src/app/pages/hard-fork-info/hard-fork-info.component.html index e9e316b..db36c89 100644 --- a/src/app/pages/hard-fork-info/hard-fork-info.component.html +++ b/src/app/pages/hard-fork-info/hard-fork-info.component.html @@ -2,11 +2,16 @@

Hard Fork Info

-
+
@if(!loading) { @for(card of cards; track card.header) {
diff --git a/src/app/pages/hard-fork-info/hard-fork-info.component.ts b/src/app/pages/hard-fork-info/hard-fork-info.component.ts index e3833ea..d6ec3c4 100644 --- a/src/app/pages/hard-fork-info/hard-fork-info.component.ts +++ b/src/app/pages/hard-fork-info/hard-fork-info.component.ts @@ -3,6 +3,8 @@ import { DaemonService } from '../../core/services/daemon/daemon.service'; import { NavigationEnd, Router } from '@angular/router'; import { NavbarService } from '../../shared/components/navbar/navbar.service'; import { SimpleBootstrapCard } from '../../shared/utils'; +import { DaemonDataService } from '../../core/services'; +import { NavbarLink } from '../../shared/components/navbar/navbar.model'; @Component({ selector: 'app-hard-fork-info', @@ -19,11 +21,21 @@ export class HardForkInfoComponent implements AfterViewInit { private voting: 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; - 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.enabled = false; this.earliestHeight = 0; @@ -32,7 +44,6 @@ export class HardForkInfoComponent implements AfterViewInit { this.votes = 0; this.voting = 0; this.window = 0; - this.daemonRunning = false; this.router.events.subscribe((event) => { if (event instanceof NavigationEnd) { @@ -40,21 +51,10 @@ export class HardForkInfoComponent implements AfterViewInit { 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 { - this.navbarService.removeLinks(); + this.navbarService.setLinks(this.navbarLinks); } private onNavigationEnd(): void { diff --git a/src/app/pages/logs/logs.component.ts b/src/app/pages/logs/logs.component.ts index a81b4e3..66c4a31 100644 --- a/src/app/pages/logs/logs.component.ts +++ b/src/app/pages/logs/logs.component.ts @@ -37,7 +37,7 @@ export class LogsComponent implements AfterViewInit { constructor(private navbarService: NavbarService, private logsService: LogsService, private daemonService: DaemonService, private ngZone: NgZone) { this.logsService.onLog.subscribe((message: string) => this.onLog()); 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-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') @@ -73,7 +73,7 @@ export class LogsComponent implements AfterViewInit { } public ngAfterViewInit(): void { - this.navbarService.removeLinks(); + this.navbarService.setLinks(this.navbarLinks); setTimeout(() => { this.scrollToBottom(); diff --git a/src/app/pages/mining/mining.component.ts b/src/app/pages/mining/mining.component.ts index 694a271..7730fd3 100644 --- a/src/app/pages/mining/mining.component.ts +++ b/src/app/pages/mining/mining.component.ts @@ -141,7 +141,7 @@ export class MiningComponent implements AfterViewInit { this.cards = []; 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-hashrate-tab', '#pills-hashrate', 'hashrate', false, 'Hashrate'), new NavbarLink('pills-alternate-chains-tab', '#pills-alternate-chains', 'alternate-chains', false, 'Alternate Chains'), diff --git a/src/app/pages/outputs/outputs.component.ts b/src/app/pages/outputs/outputs.component.ts index de6bf39..073f48e 100644 --- a/src/app/pages/outputs/outputs.component.ts +++ b/src/app/pages/outputs/outputs.component.ts @@ -76,7 +76,7 @@ export class OutputsComponent implements AfterViewInit { constructor(private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) { 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-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') diff --git a/src/app/pages/settings/settings.component.html b/src/app/pages/settings/settings.component.html index 1701162..913d611 100644 --- a/src/app/pages/settings/settings.component.html +++ b/src/app/pages/settings/settings.component.html @@ -28,7 +28,7 @@
- + Path to monerod executable
diff --git a/src/app/pages/transactions/transactions.component.ts b/src/app/pages/transactions/transactions.component.ts index c0e5065..6ecba2b 100644 --- a/src/app/pages/transactions/transactions.component.ts +++ b/src/app/pages/transactions/transactions.component.ts @@ -76,7 +76,7 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy { constructor(private daemonData: DaemonDataService, private daemonService: DaemonService, private navbarService: NavbarService, private ngZone: NgZone) { 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-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'), diff --git a/src/app/shared/components/daemon-not-running/daemon-not-running.component.ts b/src/app/shared/components/daemon-not-running/daemon-not-running.component.ts index a376f34..d410ec3 100644 --- a/src/app/shared/components/daemon-not-running/daemon-not-running.component.ts +++ b/src/app/shared/components/daemon-not-running/daemon-not-running.component.ts @@ -1,5 +1,6 @@ import { Component, Input, NgZone } from '@angular/core'; import { DaemonService } from '../../../core/services/daemon/daemon.service'; +import { DaemonDataService } from '../../../core/services'; @Component({ selector: 'app-daemon-not-running', @@ -8,24 +9,21 @@ import { DaemonService } from '../../../core/services/daemon/daemon.service'; }) export class DaemonNotRunningComponent { - public daemonRunning: boolean = false; - public daemonConfigured: boolean = false; + public get daemonRunning(): boolean { + return this.daemonData.running; + } + + public daemonConfigured: boolean = true; public get startingDaemon(): boolean { return this.daemonService.starting; } - private stoppingDaemon: boolean = false; + private get stoppingDaemon(): boolean{ + return this.daemonData.stopping; + } - - 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); - }); + constructor(private daemonData: DaemonDataService, private daemonService: DaemonService, private ngZone: NgZone) { this.daemonService.getSettings().then((settings) => { this.daemonConfigured = settings.monerodPath != ''; }) @@ -41,16 +39,17 @@ export class DaemonNotRunningComponent { return; } - setTimeout(async () => { - try { - await this.daemonService.startDaemon(); - this.daemonRunning = await this.daemonService.isRunning(); - } - catch(error) { - console.error(error); - this.daemonRunning = false; - } - }, 500); + await new Promise((resolve, reject) => { + setTimeout(async () => { + try { + await this.daemonService.startDaemon(); + resolve(); + } + catch(error) { + console.error(error); + reject(error); + } + }, 500)}); } } diff --git a/src/app/shared/components/navbar/navbar.model.ts b/src/app/shared/components/navbar/navbar.model.ts index dff4b9f..5487650 100644 --- a/src/app/shared/components/navbar/navbar.model.ts +++ b/src/app/shared/components/navbar/navbar.model.ts @@ -8,7 +8,7 @@ export class NavbarLink { public name: string; 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.target = target; this.controls = controls;