Merge branch '0.19' into runtime-api

This commit is contained in:
Nick O'Leary
2018-06-06 21:59:46 +01:00
35 changed files with 1277 additions and 464 deletions

View File

@@ -150,7 +150,9 @@
"disabled": "Projects disabled : editorTheme.projects.enabled=false",
"disabledNoFlag": "Projects disabled : set editorTheme.projects.enabled=true to enable",
"git-not-found": "Projects disabled : git command not found",
"git-version-old": "Projects disabled : git __version__ not supported. Requires 2.x"
"git-version-old": "Projects disabled : git __version__ not supported. Requires 2.x",
"summary": "A Node-RED Project",
"readme": "### About\n\nThis is your project's README.md file. It helps users understand what your\nproject does, how to use it and anything else they may need to know."
}
}
}

View File

@@ -0,0 +1,10 @@
{
"storage": {
"localfilesystem": {
"projects": {
"summary": "Node-REDプロジェクト",
"readme": "### 説明\nこれはプロジェクトのREADME.mdファイルです。このファイルには、\nプロジェクトの説明、利用方法、その他の情報を記載します。"
}
}
}
}

View File

@@ -480,11 +480,19 @@ function addFlow(flow) {
}
flow.id = redUtil.generateId();
var nodes = [{
var tabNode = {
type:'tab',
label:flow.label,
id:flow.id
}];
}
if (flow.hasOwnProperty('info')) {
tabNode.info = flow.info;
}
if (flow.hasOwnProperty('disabled')) {
tabNode.disabled = flow.disabled;
}
var nodes = [tabNode];
for (i=0;i<flow.nodes.length;i++) {
node = flow.nodes[i];
@@ -537,6 +545,12 @@ function getFlow(id) {
if (flow.label) {
result.label = flow.label;
}
if (flow.disabled) {
result.disabled = flow.disabled;
}
if (flow.hasOwnProperty('info')) {
result.info = flow.info;
}
if (id !== 'global') {
result.nodes = [];
}
@@ -626,6 +640,13 @@ function updateFlow(id,newFlow) {
label:newFlow.label,
id:id
}
if (newFlow.hasOwnProperty('info')) {
tabNode.info = newFlow.info;
}
if (newFlow.hasOwnProperty('disabled')) {
tabNode.disabled = newFlow.disabled;
}
nodes = [tabNode].concat(newFlow.nodes||[]).concat(newFlow.configs||[]);
nodes.forEach(function(n) {
n.z = id;

View File

@@ -25,6 +25,8 @@ var storageModule;
var settingsAvailable;
var sessionsAvailable;
var libraryFlowsCachedResult = null;
function moduleSelector(aSettings) {
var toReturn;
if (aSettings.storageModule) {
@@ -156,7 +158,14 @@ var storageModuleInterface = {
if (storageModule.hasOwnProperty("getAllFlows")) {
return storageModule.getAllFlows();
} else {
return listFlows("/");
if (libraryFlowsCachedResult) {
return Promise.resolve(libraryFlowsCachedResult);
} else {
return listFlows("/").then(function(result) {
libraryFlowsCachedResult = result;
return result;
});
}
}
},
getFlow: function(fn) {
@@ -178,6 +187,7 @@ var storageModuleInterface = {
err.code = "forbidden";
return when.reject(err);
}
libraryFlowsCachedResult = null;
if (storageModule.hasOwnProperty("saveFlow")) {
return storageModule.saveFlow(fn, data);
} else {

View File

@@ -162,7 +162,7 @@ Project.prototype.initialise = function(user,data) {
if (defaultFileSet.hasOwnProperty(file)) {
var path = fspath.join(project.path,file);
if (!fs.existsSync(path)) {
promises.push(util.writeFile(path,defaultFileSet[file](project)));
promises.push(util.writeFile(path,defaultFileSet[file](project, runtime)));
}
}
@@ -850,7 +850,7 @@ function createDefaultProject(user, project) {
}
for (var file in defaultFileSet) {
if (defaultFileSet.hasOwnProperty(file)) {
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project)));
promises.push(util.writeFile(fspath.join(projectPath,file),defaultFileSet[file](project, runtime)));
}
}

View File

@@ -15,10 +15,11 @@
**/
module.exports = {
"package.json": function(project) {
"package.json": function(project, runtime) {
var i18n = runtime.i18n;
var package = {
"name": project.name,
"description": project.summary||"A Node-RED Project",
"description": project.summary||i18n._("storage.localfilesystem.projects.summary"),
"version": "0.0.1",
"dependencies": {},
"node-red": {
@@ -34,13 +35,13 @@ module.exports = {
}
return JSON.stringify(package,"",4);
},
"README.md": function(project) {
"README.md": function(project, runtime) {
var i18n = runtime.i18n;
var content = project.name+"\n"+("=".repeat(project.name.length))+"\n\n";
if (project.summary) {
content += project.summary+"\n\n";
}
content += "### About\n\nThis is your project's README.md file. It helps users understand what your\nproject does, how to use it and anything else they may need to know.";
content += i18n._("storage.localfilesystem.projects.readme");
return content;
},
".gitignore": function() { return "*.backup" ;}