General fixes

This commit is contained in:
everoddandeven 2024-10-13 20:47:25 +02:00
parent 8ed6bb7036
commit bbcea66905
12 changed files with 108 additions and 69 deletions

View file

@ -69,7 +69,7 @@ function createWindow(): BrowserWindow {
icon: wdwIcon
});
win.webContents.openDevTools();
//win.webContents.openDevTools();
//win.setIcon()
if (serve) {
@ -365,6 +365,11 @@ try {
isQuitting = true;
});
ipcMain.handle('quit', (event) => {
isQuitting = true;
app.quit();
});
ipcMain.handle('start-monerod', (event, configFilePath: string[]) => {
startMoneroDaemon(configFilePath);
})

View file

@ -44,5 +44,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
},
gotOsType: (callback) => {
ipcRenderer.on('got-os-type', callback);
},
quit: () => {
ipcRenderer.invoke('quit');
}
});

View file

@ -1,6 +1,6 @@
import { EventEmitter, Injectable } from '@angular/core';
import { EventEmitter, Injectable, NgZone } from '@angular/core';
import { DaemonService } from './daemon.service';
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, PublicNode, SyncInfo, TxPool } from '../../../../common';
import { BlockCount, BlockHeader, Chain, Connection, CoreIsBusyError, DaemonInfo, MinerData, MiningStatus, NetStats, NetStatsHistory, PeerInfo, PublicNode, SyncInfo, TxBacklogEntry, TxPool } from '../../../../common';
@Injectable({
providedIn: 'root'
@ -57,6 +57,9 @@ export class DaemonDataService {
private _peerList: PeerInfo[] = [];
private _gettingPeerList: boolean = false;
private _txPoolBacklog: TxBacklogEntry[] = [];
private _gettingTxPoolBackLog: boolean = false;
public readonly syncStart: EventEmitter<void> = new EventEmitter<void>();
public readonly syncEnd: EventEmitter<void> = new EventEmitter<void>();
public readonly syncError: EventEmitter<Error> = new EventEmitter<Error>();
@ -67,16 +70,20 @@ export class DaemonDataService {
public readonly netStatsRefreshStart: EventEmitter<void> = new EventEmitter<void>();
public readonly netStatsRefreshEnd: EventEmitter<void> = new EventEmitter<void>();
constructor(private daemonService: DaemonService) {
constructor(private daemonService: DaemonService, private ngZone: NgZone) {
this.daemonService.onDaemonStatusChanged.subscribe((running: boolean) => {
this.ngZone.run(() => {
if (running) {
this._daemonRunning = true;
this.startLoop();
}
else {
this.stopLoop();
}
});
});
}
public get initializing(): boolean {
@ -215,6 +222,14 @@ export class DaemonDataService {
return this._gettingPeerList;
}
public get txPoolBacklog(): TxBacklogEntry[] {
return this._txPoolBacklog;
}
public get gettingTxPoolBacklog(): boolean {
return this._gettingTxPoolBackLog;
}
public setRefreshTimeout(ms: number = 5000): void {
this.refreshTimeoutMs = ms;
}
@ -313,6 +328,7 @@ export class DaemonDataService {
this._firstRefresh = false;
if (!this._daemonRunning) {
this.stopLoop();
this.syncEnd.emit();
return;
}

View file

@ -89,8 +89,15 @@ export class BansComponent implements AfterViewInit {
let _bans: Ban[] = [];
try {
const running = await this.daemonService.isRunning();
if (running) {
_bans = await this.daemonService.getBans();
}
else {
_bans = [];
}
}
catch (error) {
console.error(error);
_bans = [];

View file

@ -21,7 +21,10 @@ export class BlockchainComponent implements AfterViewInit {
return this.daemonData.stopping;
}
public lastBlockHeader?: BlockHeader;
public get lastBlockHeader(): BlockHeader | undefined {
return this.daemonData.lastBlockHeader;
}
public getLastBlockError: string = '';
public block?: Block;
public getBlockByHash: boolean = false;
@ -64,28 +67,8 @@ export class BlockchainComponent implements AfterViewInit {
];
}
ngAfterViewInit(): void {
public ngAfterViewInit(): void {
this.navbarService.setLinks(this.navbarLinks);
this.load().then().catch((error: any) => {
console.error(error);
});
}
public async load(): Promise<void> {
await this.getLastBlockHeader();
}
private async getLastBlockHeader(): Promise<void> {
this.gettingLastBlock = true;
try {
this.lastBlockHeader = await this.daemonService.getLastBlockHeader(true);
this.getLastBlockError = '';
}
catch(error: any) {
console.error(error);
this.getLastBlockError = `${error}`;
}
this.gettingLastBlock = false;
}
public async getBlock(): Promise<void> {

View file

@ -25,8 +25,8 @@ export class LogsService {
}
public cleanLog(message: string): string {
//return message.replace(/\u001b\[[0-9;]*m/g, '').replace(/[\r\n]+/g, '\n').trim();
return message.replace(/[\r\n]+/g, '\n').trim();
return message.replace(/\u001b\[[0-9;]*m/g, '').replace(/[\r\n]+/g, '\n').trim();
//return message.replace(/[\r\n]+/g, '\n').trim();
}
public log(message: string): void {

View file

@ -201,6 +201,27 @@
</div>
<div class="tab-pane fade" id="pills-tx-pool-backlog" role="tabpanel" aria-labelledby="pills-tx-pool-backlog-tab" tabindex="0">
<h4 class="mb-3">All transactions pool backlog</h4>
<br>
<table
id="txPoolBacklogTable"
data-toggle="txPoolBacklogTable"
data-toolbar="#toolbar"
data-paged="true"
data-height="460"
>
<thead>
<tr>
<th data-field="height">Blob Size</th>
<th data-field="key">Fee</th>
<th data-field="mask">Time In Pool</th>
</tr>
</thead>
</table>
</div>
<div class="tab-pane fade" id="pills-coinbase-tx-sum" role="tabpanel" aria-labelledby="pills-coinbase-tx-sum-tab" tabindex="0">
<div class="row g-5 p-2">
<div class="col-md-7 col-lg-12">

View file

@ -17,7 +17,11 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
public readonly navbarLinks: NavbarLink[];
public canRelay: boolean;
public txPoolBacklog: TxBacklogEntry[];
public get txPoolBacklog(): TxBacklogEntry[] {
return this.daemonData.txPoolBacklog;
}
public height: number;
public count: number;
@ -80,14 +84,13 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
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'),
new NavbarLink('pills-tx-backlog-tab', '#pills-tx-backlog', 'pills-tx-backlog', false, 'Tx Backlog'),
new NavbarLink('pills-tx-pool-backlog-tab', '#pills-tx-pool-backlog', 'pills-tx-pool-backlog', false, 'Tx Pool Backlog'),
new NavbarLink('pills-coinbase-tx-sum-tab', '#pills-coinbase-tx-sum', 'pills-coinbase-tx-sum', false, 'Coinbase Tx Sum'),
new NavbarLink('pills-flush-tx-pool-tab', '#pills-flush-tx-pool', 'pills-flush-tx-pool', false, 'Flush Tx Pool'),
new NavbarLink('pills-flush-cahe-tab', '#pills-flush-cache', 'pills-flush-cache', false, 'Flush Cache')
];
this.height = 0;
this.count = 0;
this.txPoolBacklog = [];
this.canRelay = false;
}
@ -100,13 +103,6 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
this.subscriptions.push(this.daemonData.syncEnd.subscribe(() => {
this.refreshTables();
}));
this.load().then(() => {
this.navbarService.enableLinks();
}).catch((error) => {
console.error(error);
this.navbarService.disableLinks();
});
});
}
@ -130,6 +126,7 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
private initTables(): void {
this.initTable('spentKeyImagesTable');
this.initTable('transactionsTable');
this.initTable('txPoolBacklogTable');
}
private loadTransactionsTable(): void {
@ -144,19 +141,16 @@ export class TransactionsComponent implements AfterViewInit, OnDestroy {
$table.bootstrapTable('load', this.spentKeyImages);
}
private loadTxPoolBacklogTable(): void {
const $table = $('#txPoolBacklogTable');
$table.bootstrapTable('load', this.txPoolBacklog)
}
private refreshTables(): void {
this.loadSpentKeyImagesTable();
this.loadTransactionsTable();
}
private async load(): Promise<void> {
try {
this.txPoolBacklog = await this.daemonService.getTxPoolBacklog();
console.log(this.txPoolBacklog)
}
catch (error) {
console.error(error);
}
this.loadTxPoolBacklogTable();
}
public validTxIds(): boolean {

View file

@ -47,7 +47,9 @@ export class DaemonNotRunningComponent {
}).catch((error: any) => {
console.error(error);
this.daemonConfigured = false;
})
});
this.daemonService.isRunning().then().catch((error: any) => console.error(error));
}
public async startDaemon(): Promise<void> {

View file

@ -72,6 +72,12 @@ export class NavbarComponent {
}
public async quit(): Promise<void> {
const running: boolean = await this.daemonService.isRunning();
if (running) {
await this.stopDaemon();
}
window.electronAPI.quit();
}
}

View file

@ -58,8 +58,10 @@ import 'bootstrap-table';
declare global {
interface Window {
electronAPI: {
startMonerod: (args: string[]) => void;
getOsType: () => void;
gotOsType: (callback: (event: any, osType: { platform: string, arch: string }) => void) => void;
quit: () => void;
};
}
}