Progress bar not showing up
Hi, I saw the issue #9 , and did update the progress bar to version 1.2.0, however, I have the same issue, well not exactly the same. When I create a new progress bar on App Ready, it shows the progress bar and it's ok. However, when I start it later, as shown in the following code, I just get a blank window.
Node: 10.15.0 Electron: 4.0.4 electron-progressbar: 1.2.0
Output:
In Addition to the previous, it shows up when the Task is completed.

Code:
const { app, BrowserWindow, Menu , ipcMain } = require('electron'),
url = require('url'),
path = require('path'),
parser = require('./main/Parser'),
ProgressBar = require('electron-progressbar');
// process.env.NODE_ENV = 'production';
process.env.NODE_ENV = 'development';
let mainWindow, progressBar;
app.on('ready', () => {
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, 'assets/js/preload.js')
}
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'html/mainWindow.html'),
protocol: 'file',
slashes: true
}));
mainWindow.on('closed', () => {
app.quit();
})
// Build menut from template
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
//Insert Menu
Menu.setApplicationMenu(mainMenu);
})
ipcMain.on('parse:logFiles', (e, item) => {
parser.setLogFiles(item);
})
ipcMain.on('parse:options', async (e, item) => {
showProgressbar();
try {
parser.setOptions(item);
const {result, parsedFilePath} = await parser.startParse();
console.log(`App: ${result}, Directory: ${parsedFilePath}`);
mainWindow.webContents.send('parse:done', parsedFilePath);
setProgressbarCompleted();
} catch (error) {
console.log(error);
}
})
function showProgressbar () {
if (progressBar) {
return;
}
progressBar = new ProgressBar({
title: 'Parsing',
text: 'Parsing files...',
detail: 'Wait...',
options: {
closeOnComplete: false
},
browserWindow: {
parent: mainWindow
}
});
progressBar
.on('completed', function() {
progressBar.detail = 'Task completed. Exiting...';
progressBar = null;
});
}
function setProgressbarCompleted () {
if (progressBar) {
progressBar.setCompleted();
}
}
// Create menut template
const mainMenuTemplate = [
{
label: 'File',
submenu: [
{
label: 'Quit',
accelerator: process.platform === 'darwin' ? 'Command+Q' : 'Ctrl+Q',
click() {
app.quit();
}
}
]
}
];
// If mac, add empty object to menu
if (process.platform === 'darwin') {
mainMenuTemplate.unshift({});
}
// Add developer tools item if not in production
if (process.env.NODE_ENV !== 'production') {
mainMenuTemplate.push({
label: 'Developer Tools',
submenu: [
{
label: 'Toggle DevTools',
accelerator: process.platform === 'darwin' ? 'Command+I' : 'Ctrl+I',
click(item, focusedWindow) {
focusedWindow.toggleDevTools();
}
},
{
role: 'reload'
}
]
});
}
Also, even though I have set `` closeOnComplete: false, it still closes the dialog box.
Hello brother, I solved this by including following code in the source code of electron progress bar, this code need to be included in the browser window code of
webPreferences: { nodeIntegration: true } So the chaged source code looks like this
browserWindow: { parent: null, modal: true, resizable: false, closable: false, minimizable: false, maximizable: false, width: 500, height: 170, webPreferences: { nodeIntegration: true } }
@impraveensingh this fixed it for me 2, you should create a PR for it ;) gj
You can just pass the node option along when creating the progress bar like so:
new ProgressBar({
text: 'Preparing data...',
detail: 'Wait...',
browserWindow: {
webPreferences: {
nodeIntegration: true
}
}
})
Correct format is:
new ProgressBar({
text: 'Preparing data...',
detail: 'Wait...',
browserWindow: {
webPreferences: {
nodeIntegration: true
}
}
})
Hello guys,
Thank you all for figuring this out and for the contribution!
I'm updating electron-progressbar and making nodeIntegration enabled by default (I just merged #14 ) as I can see it's a common issue :)
electron-progressbar v2.0.0 has just been released and includes the above mentioned changes (enable nodeIntegration by default). See changelog here