dceejay / electron-node-red

Electron Node-RED template
Apache License 2.0
57 stars 32 forks source link

Feature request: Save .node-red on current folder and others suggesting #13

Closed feecat closed 3 years ago

feecat commented 3 years ago

Hi For currently if we use compiled electron-node-red package, then it will save installed node to $home$/.node-red. But i think save to local folder is good idea, cus we can easyly re-package and hand out it. add the settings follow this, node-red will install nodes to current folder:

//save all nodes for local folder
settings.userDir = './.node-red/';
settings.nodesDir = './.node-red/node_modules';

But it take a little problem, when you install a new node library in node-red, it will fail. just close program and open, it will success load. And please zip the ./dist/win-unpacked folder for windows, if we use electron then we want a full portable program just unzip-run.

Another problem is single instance lock. add the follow line:

//Only allow one instance
let isSingleInstance = app.requestSingleInstanceLock()
if (!isSingleInstance) {
    app.quit()
}

Also it take a little problem, the second instance will quit but not focus on last one instance.. idk how to fix it.

The last one is modify autoHideMenuBar : true in function createWindow() , for end user they dont want to see menubar at starting, just see node-red ui is enough. I'm work for industrial automation, use electron-node-red to communication plcs and create a easy-to-use HMI. You repositories is great for us. But maybe my suggest is wrong, please point me.

Thanks you

dceejay commented 3 years ago

All fine suggestions - The app is not intended to be used as-is - so you are free to customise it as you wish.

Not sure what you mean about the win-unpacked directory... if the yarn dist -w command complete correctly you should end up with a .msi file in the dist drectory... that is all you need I think.

dceejay commented 3 years ago

You can add a listener for a second instance - and use it to refocus

app.on('second-instance', (event, commandLine, workingDirectory) => {
    // Someone tried to run a second instance, we should focus our window.
    if (mainWindow) {
        if (mainWindow.isMinimized()) { mainWindow.restore(); }
        mainWindow.focus();
    }
})
feecat commented 3 years ago

Hi .msi file will install but we want unzip-run, not install-run. We have a lot of machine use this program, sometime we need modify flow file, Install program not good for re-pack it. So just compress win-unpack folder to .zip is good for us. You code is great running. Thanks.

I have a idea for industrial control like hslcommunication but i dont want people write a lot of code and compile it -- fall in loop of debug and compile. Node-RED is simple and suitable for small industrial automation project. but compile is complicated also, i had fall into bcrypt lib compile and take a long time to fix it. Maybe i need create a fork and do some test.

Great Thanks.

dceejay commented 3 years ago

Ah right - you can change how it packs by changing the package.json file to say "target": "zip", around line 98. Lots of options available in the docs - https://www.electron.build/configuration/win

feecat commented 3 years ago

Ah right - you can change how it packs by changing the package.json file to say "target": "zip", around line 98. Lots of options available in the docs - https://www.electron.build/configuration/win

It useful for me. thanks. I had create a fork at feecat/electron-node-red and add some idea. config.json can save some config like window size, add minimize button and so.
But I have a trouble with install nodes in node-red. I have use local folder to save nodes. But Some nodes like beckhoff ads will fail install. Some nodes like modbus will success install after restart program. I don't know why. Please tell me if you have ideas.

Thanks.

dceejay commented 3 years ago

For an electron app I would really not expect to give users full access to instal nodes etc - I would bundle up (and test) any nodes within the app first and then just use those.