mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2025-01-03 09:29:36 +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'),
|
||||
nodeIntegration: false,
|
||||
allowRunningInsecureContent: (serve),
|
||||
contextIsolation: true
|
||||
contextIsolation: true,
|
||||
devTools: true
|
||||
},
|
||||
autoHideMenuBar: true,
|
||||
icon: wdwIcon
|
||||
});
|
||||
|
||||
win.webContents.openDevTools();
|
||||
|
||||
if (serve) {
|
||||
const debug = require('electron-debug');
|
||||
|
|
|
@ -9,6 +9,13 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||
onMonerodStarted: (callback) => {
|
||||
ipcRenderer.on('monerod-started', callback);
|
||||
},
|
||||
unsubscribeOnMonerodStarted: () => {
|
||||
const listeners = ipcRenderer.listeners('monerod-started');
|
||||
|
||||
listeners.forEach((listener) => {
|
||||
ipcRenderer.removeListener('monerod-started', listener);
|
||||
});
|
||||
},
|
||||
onMoneroStdout: (callback) => {
|
||||
ipcRenderer.on('monero-stdout', callback);
|
||||
},
|
||||
|
|
|
@ -396,7 +396,15 @@ export class DaemonService {
|
|||
});
|
||||
|
||||
window.electronAPI.startMonerod(this.settings.toCommandOptions());
|
||||
await startPromise;
|
||||
|
||||
try {
|
||||
await startPromise;
|
||||
}
|
||||
catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
window.electronAPI.unsubscribeOnMonerodStarted();
|
||||
}
|
||||
|
||||
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 class="terminal-output" id="terminalOutput">
|
||||
<ng-container *ngFor="let line of lines; trackBy: trackByFn">
|
||||
<div>{{ line }}</div>
|
||||
</ng-container>
|
||||
@for(line of lines; track line) {
|
||||
<ng-container>
|
||||
<div>{{ line }}</div>
|
||||
</ng-container>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -8,6 +8,7 @@ import { LogCategories } from '../../../common';
|
|||
export class LogsService {
|
||||
public readonly onLog: EventEmitter<string> = new EventEmitter<string>();
|
||||
public readonly lines: string[] = [];
|
||||
public readonly maxLines: number = 250;
|
||||
public readonly categories: LogCategories = new LogCategories();
|
||||
|
||||
constructor(private electronService: ElectronService, private ngZone: NgZone) {
|
||||
|
@ -31,7 +32,13 @@ export class LogsService {
|
|||
|
||||
public log(message: string): void {
|
||||
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));
|
||||
});
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ declare global {
|
|||
electronAPI: {
|
||||
startMonerod: (options: string[]) => void;
|
||||
onMonerodStarted: (callback: (event: any, started: boolean) => void) => void;
|
||||
unsubscribeOnMonerodStarted: () => void;
|
||||
onMoneroClose: (callback: (event: any, code: number) => void) => void;
|
||||
isWifiConnected: () => void;
|
||||
onIsWifiConnectedResponse: (callback: (event: any, connected: boolean) => void) => void;
|
||||
|
|
Loading…
Reference in a new issue