redo file import and save

master
Dave Conway-Jones 2020-10-05 00:00:45 +01:00
rodzic 54040e45ce
commit fbdb4afe01
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 88BA2B8A411BE9FF
4 zmienionych plików z 2236 dodań i 41 usunięć

Wyświetl plik

@ -33,7 +33,7 @@
</head> </head>
<body style="margin:0;" onload="scrollDown()" > <body style="margin:0;" onload="scrollDown()" >
<font style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif; font-size:9pt;"> <font style="font-family:'Helvetica Neue', Arial, Helvetica, sans-serif; font-size:9pt;">
<div id="header" style="background-color:#910000; position:fixed; height:16px; width:100%; padding:8px;"><input type="button" value="Clear Log" onclick="clearList()";/></div> <div id="header" style="background-color:#910000; position:fixed; height:16px; width:100%; padding:8px;"><input type="button" style="float:right; margin-right:15px" value="Clear Log" onclick="clearList()";/></div>
<div id="debug" style="padding:4px; padding-left:8px; padding-top:34px;"></div> <div id="debug" style="padding:4px; padding-left:8px; padding-top:34px;"></div>
</font> </font>
</body> </body>

File diff suppressed because one or more lines are too long

39
main.js
Wyświetl plik

@ -116,7 +116,12 @@ var settings = {
httpNodeRoot: "/", httpNodeRoot: "/",
userDir: userdir, userDir: userdir,
flowFile: flowfile, flowFile: flowfile,
editorTheme: { projects:{ enabled:false }, palette: { editable:addNodes } }, // enable projects feature flowFilePretty: true,
editorTheme: {
projects:{ enabled:false },
header: { title: options.productName },
palette: { editable:addNodes }
}, // enable projects feature
functionGlobalContext: { }, // enables global context - add extras ehre if you need them functionGlobalContext: { }, // enables global context - add extras ehre if you need them
logging: { logging: {
websock: { websock: {
@ -242,18 +247,21 @@ if (isDev) {
}) })
} }
let fileName = ""; let fileName = path.join(userdir,flowfile);
function saveFlow() { function saveFlow() {
dialog.showSaveDialog({ const file_path = dialog.showSaveDialogSync({
title:"Save Flow As",
filters:[{ name:'JSON', extensions:['json'] }], filters:[{ name:'JSON', extensions:['json'] }],
defaultPath: fileName properties: ["showHiddenFiles"],
}, function(file_path) { defaultPath: fileName,
buttonLabel: "Save Flow"
});
if (file_path) { if (file_path) {
var flo = JSON.stringify(RED.nodes.getFlows().flows); var flo = JSON.stringify(RED.nodes.getFlows().flows, null , 2);
fs.writeFile(file_path, flo, function(err) { fs.writeFile(file_path, flo, function(err) {
if (err) { dialog.showErrorBox('Error', err); } if (err) { dialog.showErrorBox('Error', err); }
else { else {
dialog.showMessageBox({ dialog.showMessageBoxSync({
icon: nrIcon, icon: nrIcon,
message:"Flow file saved as\n\n"+file_path, message:"Flow file saved as\n\n"+file_path,
buttons: ["OK"] buttons: ["OK"]
@ -261,19 +269,23 @@ function saveFlow() {
} }
}); });
} }
});
} }
function openFlow() { function openFlow() {
dialog.showOpenDialog({ filters:[{ name:'JSON', extensions:['json']} ]}, const fileNames = dialog.showOpenDialogSync({
function (fileNames) { title:"Load Flow File",
filters:[{ name:'JSON', extensions:['json'] }],
properties: ["openFile","showHiddenFiles"],
defaultPath: fileName,
buttonLabel: "Load Flow"
});
if (fileNames && fileNames.length > 0) { if (fileNames && fileNames.length > 0) {
fs.readFile(fileNames[0], 'utf-8', function (err, data) { fs.readFile(fileNames[0], 'utf-8', function (err, data) {
try { try {
var flo = JSON.parse(data); var flo = JSON.parse(data);
if (Array.isArray(flo) && (flo.length > 0)) { if (Array.isArray(flo) && (flo.length > 0)) {
RED.nodes.setFlows(flo,"full");
fileName = fileNames[0]; fileName = fileNames[0];
RED.nodes.setFlows(flo,"full");
} }
else { else {
dialog.showErrorBox("Error", "Failed to parse flow file.\n\n "+fileNames[0]+".\n\nAre you sure it's a flow file ?"); dialog.showErrorBox("Error", "Failed to parse flow file.\n\n "+fileNames[0]+".\n\nAre you sure it's a flow file ?");
@ -284,8 +296,7 @@ function openFlow() {
} }
}); });
} }
}
)
} }
// Create the console log window // Create the console log window
@ -298,6 +309,7 @@ function createConsole() {
height: 600, height: 600,
icon: path.join(__dirname, nrIcon), icon: path.join(__dirname, nrIcon),
autoHideMenuBar: true, autoHideMenuBar: true,
titleBarStyle: "hidden",
webPreferences: { webPreferences: {
nodeIntegration: true nodeIntegration: true
} }
@ -334,6 +346,7 @@ function createWindow() {
icon: path.join(__dirname, nrIcon), icon: path.join(__dirname, nrIcon),
fullscreenable: true, fullscreenable: true,
autoHideMenuBar: false, autoHideMenuBar: false,
titleBarStyle: "hidden",
kiosk: kioskMode, kiosk: kioskMode,
webPreferences: { webPreferences: {
nodeIntegration: false nodeIntegration: false

Wyświetl plik

@ -4,7 +4,7 @@
"description": "Electron Node-RED application starter kit for development", "description": "Electron Node-RED application starter kit for development",
"main": "main.js", "main": "main.js",
"NRelectron": { "NRelectron": {
"productName": "Node-RED Electron", "productName": "Node-RED Electron App",
"editable": true, "editable": true,
"allowLoadSave": false, "allowLoadSave": false,
"showMap": false, "showMap": false,