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>
<body style="margin:0;" onload="scrollDown()" >
<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>
</font>
</body>

File diff suppressed because one or more lines are too long

89
main.js
Wyświetl plik

@ -116,7 +116,12 @@ var settings = {
httpNodeRoot: "/",
userDir: userdir,
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
logging: {
websock: {
@ -242,50 +247,56 @@ if (isDev) {
})
}
let fileName = "";
let fileName = path.join(userdir,flowfile);
function saveFlow() {
dialog.showSaveDialog({
const file_path = dialog.showSaveDialogSync({
title:"Save Flow As",
filters:[{ name:'JSON', extensions:['json'] }],
defaultPath: fileName
}, function(file_path) {
if (file_path) {
var flo = JSON.stringify(RED.nodes.getFlows().flows);
fs.writeFile(file_path, flo, function(err) {
if (err) { dialog.showErrorBox('Error', err); }
else {
dialog.showMessageBox({
icon: nrIcon,
message:"Flow file saved as\n\n"+file_path,
buttons: ["OK"]
});
}
});
}
properties: ["showHiddenFiles"],
defaultPath: fileName,
buttonLabel: "Save Flow"
});
if (file_path) {
var flo = JSON.stringify(RED.nodes.getFlows().flows, null , 2);
fs.writeFile(file_path, flo, function(err) {
if (err) { dialog.showErrorBox('Error', err); }
else {
dialog.showMessageBoxSync({
icon: nrIcon,
message:"Flow file saved as\n\n"+file_path,
buttons: ["OK"]
});
}
});
}
}
function openFlow() {
dialog.showOpenDialog({ filters:[{ name:'JSON', extensions:['json']} ]},
function (fileNames) {
if (fileNames && fileNames.length > 0) {
fs.readFile(fileNames[0], 'utf-8', function (err, data) {
try {
var flo = JSON.parse(data);
if (Array.isArray(flo) && (flo.length > 0)) {
RED.nodes.setFlows(flo,"full");
fileName = fileNames[0];
}
else {
dialog.showErrorBox("Error", "Failed to parse flow file.\n\n "+fileNames[0]+".\n\nAre you sure it's a flow file ?");
}
}
catch(e) {
dialog.showErrorBox("Error", "Failed to load flow file.\n\n "+fileNames[0]);
}
});
const fileNames = dialog.showOpenDialogSync({
title:"Load Flow File",
filters:[{ name:'JSON', extensions:['json'] }],
properties: ["openFile","showHiddenFiles"],
defaultPath: fileName,
buttonLabel: "Load Flow"
});
if (fileNames && fileNames.length > 0) {
fs.readFile(fileNames[0], 'utf-8', function (err, data) {
try {
var flo = JSON.parse(data);
if (Array.isArray(flo) && (flo.length > 0)) {
fileName = fileNames[0];
RED.nodes.setFlows(flo,"full");
}
else {
dialog.showErrorBox("Error", "Failed to parse flow file.\n\n "+fileNames[0]+".\n\nAre you sure it's a flow file ?");
}
}
}
)
catch(e) {
dialog.showErrorBox("Error", "Failed to load flow file.\n\n "+fileNames[0]);
}
});
}
}
// Create the console log window
@ -298,6 +309,7 @@ function createConsole() {
height: 600,
icon: path.join(__dirname, nrIcon),
autoHideMenuBar: true,
titleBarStyle: "hidden",
webPreferences: {
nodeIntegration: true
}
@ -334,6 +346,7 @@ function createWindow() {
icon: path.join(__dirname, nrIcon),
fullscreenable: true,
autoHideMenuBar: false,
titleBarStyle: "hidden",
kiosk: kioskMode,
webPreferences: {
nodeIntegration: false

Wyświetl plik

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