Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions js/configurator_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ $(function() {
import('./../tabs/cli').then(() => TABS.cli.initialize(content_ready));
break;
case 'search':
require('./../tabs/search');
TABS.search.initialize(content_ready);
import('./../tabs/search').then(() => TABS.search.initialize(content_ready));
break;
default:
console.log('Tab not found:' + tab);
Expand Down
14 changes: 12 additions & 2 deletions js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Store from "electron-store";
import path from 'path';
import { fileURLToPath } from 'node:url';
import started from 'electron-squirrel-startup';
import { writeFile, readFile } from 'node:fs/promises';
import { writeFile, readFile, appendFile } from 'node:fs/promises';

import tcp from './tcp';
import udp from './udp';
Expand Down Expand Up @@ -312,10 +312,20 @@ app.whenReady().then(() => {
resolve(false)
} catch (err) {
resolve(err);
}
}
});
});

ipcMain.handle('appendFile', async (_event, filename, data) => {
try {
await appendFile(filename, data);
return false;
} catch (err) {
// Re-throwing the error will cause the promise on the renderer side to be rejected.
throw err;
}
});

ipcMain.handle('readFile', (_event, filename, encoding) => {
return new Promise(async resolve => {
try {
Expand Down
1 change: 1 addition & 0 deletions js/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
onUdpError: (callback) => ipcRenderer.on('udpError', (_event, error) => callback(error)),
onUdpMessage: (callback) => ipcRenderer.on('udpMessage', (_event, data) => callback(data)),
writeFile: (filename, data) => ipcRenderer.invoke('writeFile', filename, data),
appendFile: (filename, data) => ipcRenderer.invoke('appendFile', filename, data),
readFile: (filename, encoding = 'utf8') => ipcRenderer.invoke('readFile', filename, encoding),
rm: (path) => ipcRenderer.invoke('rm', path),
chmod: (path, mode) => ipcRenderer.invoke('chmod', path, mode),
Expand Down
8 changes: 2 additions & 6 deletions tabs/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import interval from './../js/intervals';
import i18n from './../js/localization';
import { zeroPad } from './../js/helpers';
import dialog from '../js/dialog';
import store from './../js/store';


TABS.logging = {};
Expand Down Expand Up @@ -81,13 +82,8 @@ TABS.logging.initialize = function (callback) {
interval.add('log_data_poll', log_data_poll, parseInt($('select.speed').val()), true); // refresh rate goes here
interval.add('write_data', function write_data() {
if (log_buffer.length && readyToWrite) { // only execute when there is actual data to write

fs.writeFileSync(loggingFileName, log_buffer.join('\n') + '\n', {
"flag": "a"
})

window.electronAPI.appendFile(loggingFileName, log_buffer.join('\n') + '\n');
$('.samples').text(samples += log_buffer.length);

log_buffer = [];
}
}, 1000);
Expand Down
9 changes: 4 additions & 5 deletions tabs/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { GUI, TABS } = require('./../js/gui');
const path = require('path');
const i18n = require('./../js/localization');
import { GUI, TABS } from './../js/gui.js';
import i18n from './../js/localization.js';
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Normalize ESM import paths

Suggested change
import { GUI, TABS } from './../js/gui.js';
import i18n from './../js/localization.js';
import { GUI, TABS } from './../js/gui';
import i18n from './../js/localization';




Expand Down Expand Up @@ -185,12 +184,12 @@ TABS.search.initialize = function (callback) {
TABS.search.searchMessages(document.getElementById('search-keyword').value);
}
}
GUI.load(path.join(__dirname, "search.html"), function () {
import('./search.html?raw').then(({default: html}) => GUI.load(html, function () {
i18n.localize();
document.getElementById('search-label').addEventListener('click', searchKeyword, false);
document.getElementById('search-keyword').addEventListener('keyup', searchKeywordTyping, false);
GUI.content_ready(callback);
} );
}));
self.getMessages();
for (let tab of tabNames) {
self.indexTab(tab);
Expand Down