mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2025-01-05 10:29:27 +00:00
Fix DaemonService.startDaemon(), fix logs size
This commit is contained in:
parent
126891dfdc
commit
4fb5627ac1
6 changed files with 34 additions and 6 deletions
|
@ -68,12 +68,14 @@ function createWindow(): BrowserWindow {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
nodeIntegration: false,
|
nodeIntegration: false,
|
||||||
allowRunningInsecureContent: (serve),
|
allowRunningInsecureContent: (serve),
|
||||||
contextIsolation: true
|
contextIsolation: true,
|
||||||
|
devTools: true
|
||||||
},
|
},
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
icon: wdwIcon
|
icon: wdwIcon
|
||||||
});
|
});
|
||||||
|
|
||||||
|
win.webContents.openDevTools();
|
||||||
|
|
||||||
if (serve) {
|
if (serve) {
|
||||||
const debug = require('electron-debug');
|
const debug = require('electron-debug');
|
||||||
|
|
|
@ -9,6 +9,13 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||||
onMonerodStarted: (callback) => {
|
onMonerodStarted: (callback) => {
|
||||||
ipcRenderer.on('monerod-started', callback);
|
ipcRenderer.on('monerod-started', callback);
|
||||||
},
|
},
|
||||||
|
unsubscribeOnMonerodStarted: () => {
|
||||||
|
const listeners = ipcRenderer.listeners('monerod-started');
|
||||||
|
|
||||||
|
listeners.forEach((listener) => {
|
||||||
|
ipcRenderer.removeListener('monerod-started', listener);
|
||||||
|
});
|
||||||
|
},
|
||||||
onMoneroStdout: (callback) => {
|
onMoneroStdout: (callback) => {
|
||||||
ipcRenderer.on('monero-stdout', callback);
|
ipcRenderer.on('monero-stdout', callback);
|
||||||
},
|
},
|
||||||
|
|
|
@ -396,7 +396,15 @@ export class DaemonService {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
||||||
await startPromise;
|
|
||||||
|
try {
|
||||||
|
await startPromise;
|
||||||
|
}
|
||||||
|
catch(error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.electronAPI.unsubscribeOnMonerodStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async restartDaemon(): Promise<void> {
|
public async restartDaemon(): Promise<void> {
|
||||||
|
|
|
@ -20,9 +20,12 @@
|
||||||
|
|
||||||
<div *ngIf="lines.length > 0" class="terminal bg-dark text-light p-3 m-4" #logTerminal>
|
<div *ngIf="lines.length > 0" class="terminal bg-dark text-light p-3 m-4" #logTerminal>
|
||||||
<div class="terminal-output" id="terminalOutput">
|
<div class="terminal-output" id="terminalOutput">
|
||||||
<ng-container *ngFor="let line of lines; trackBy: trackByFn">
|
@for(line of lines; track line) {
|
||||||
<div>{{ line }}</div>
|
<ng-container>
|
||||||
</ng-container>
|
<div>{{ line }}</div>
|
||||||
|
</ng-container>
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { LogCategories } from '../../../common';
|
||||||
export class LogsService {
|
export class LogsService {
|
||||||
public readonly onLog: EventEmitter<string> = new EventEmitter<string>();
|
public readonly onLog: EventEmitter<string> = new EventEmitter<string>();
|
||||||
public readonly lines: string[] = [];
|
public readonly lines: string[] = [];
|
||||||
|
public readonly maxLines: number = 250;
|
||||||
public readonly categories: LogCategories = new LogCategories();
|
public readonly categories: LogCategories = new LogCategories();
|
||||||
|
|
||||||
constructor(private electronService: ElectronService, private ngZone: NgZone) {
|
constructor(private electronService: ElectronService, private ngZone: NgZone) {
|
||||||
|
@ -31,7 +32,13 @@ export class LogsService {
|
||||||
|
|
||||||
public log(message: string): void {
|
public log(message: string): void {
|
||||||
this.ngZone.run(() => {
|
this.ngZone.run(() => {
|
||||||
this.lines.push(this.cleanLog(message));
|
if (this.lines.length <= this.maxLines) {
|
||||||
|
this.lines.push(this.cleanLog(message));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.lines.shift();
|
||||||
|
this.lines.push(this.cleanLog(message));
|
||||||
|
}
|
||||||
this.onLog.emit(this.cleanLog(message));
|
this.onLog.emit(this.cleanLog(message));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ declare global {
|
||||||
electronAPI: {
|
electronAPI: {
|
||||||
startMonerod: (options: string[]) => void;
|
startMonerod: (options: string[]) => void;
|
||||||
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
|
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
|
||||||
|
unsubscribeOnMonerodStarted: () => void;
|
||||||
onMoneroClose: (callback: (event: any, code: number) => void) => void;
|
onMoneroClose: (callback: (event: any, code: number) => void) => void;
|
||||||
isWifiConnected: () => void;
|
isWifiConnected: () => void;
|
||||||
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
|
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
|
||||||
|
|
Loading…
Reference in a new issue