mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add "Unknown node" type to core.
Relates to Issue #5 not the best/complete solution - but a start.
This commit is contained in:
parent
3984b6b702
commit
ac884bfdf3
49
nodes/core/core/98-unknown.html
Normal file
49
nodes/core/core/98-unknown.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<!--
|
||||||
|
Copyright 2013 IBM Corp.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<script type="text/x-red" data-template-name="unknown">
|
||||||
|
<div class="form-tips">This node is currently unknown to Node-RED. <i>DO NOT Deploy while in this state or the flow file may well be trashed...</i>. Usually this can be resolved by installing the npm module that this node relies on. To do this - stop Node-RED and restart. Look at the errors shown for one that matches this missing node. Stop Node-RED again and type <b>npm install {missing module name}</b>. Restart Node-RED, and hopefully this will have resolved it.</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="unknown">
|
||||||
|
<p>This node is currently unknown to Node-RED.</p>
|
||||||
|
<p><i>DO NOT Deploy while in this state or the flow file may well be trashed...</i></p>
|
||||||
|
<p>Usually this can be resolved by installing the npm module that this node relies on. To do this, stop Node-RED and restart.</p>
|
||||||
|
<p>Look at the errors shown in the console for one that matches the name of this missing node.</p>
|
||||||
|
<p>Stop Node-RED again and type <b>npm install {missing module name}</b>. Restart Node-RED, and hopefully this will have resolved it.</p>
|
||||||
|
<p>If not then you will need to obtain that Node-RED module from somewhere... ask the author of the flow where they got it from.</p>
|
||||||
|
<p>(hopefully soon we will have a central repository where all nodes can be registered. work in progress.)</p>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('unknown',{
|
||||||
|
category: 'unknown',
|
||||||
|
color:"#C00000",
|
||||||
|
defaults: {
|
||||||
|
name: {value:""},
|
||||||
|
foo: {value:"",required:true}
|
||||||
|
},
|
||||||
|
inputs:1,
|
||||||
|
outputs:1,
|
||||||
|
icon: "",
|
||||||
|
label: function() {
|
||||||
|
return this.name||"unknown";
|
||||||
|
},
|
||||||
|
labelStyle: function() {
|
||||||
|
return "node_label_white";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
22
nodes/core/core/98-unknown.js
Normal file
22
nodes/core/core/98-unknown.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2013 IBM Corp.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
var RED = require(process.env.NODE_RED_HOME+"/red/red");
|
||||||
|
|
||||||
|
function UnknownNode(n) {
|
||||||
|
RED.nodes.createNode(this,n);
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("unknown",UnknownNode);
|
@ -16,15 +16,12 @@
|
|||||||
RED.nodes = function() {
|
RED.nodes = function() {
|
||||||
|
|
||||||
var node_defs = {};
|
var node_defs = {};
|
||||||
|
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
var configNodes = {};
|
var configNodes = {};
|
||||||
var links = [];
|
var links = [];
|
||||||
|
|
||||||
var defaultWorkspace;
|
var defaultWorkspace;
|
||||||
var workspaces = {};
|
var workspaces = {};
|
||||||
|
|
||||||
|
|
||||||
function registerType(nt,def) {
|
function registerType(nt,def) {
|
||||||
node_defs[nt] = def;
|
node_defs[nt] = def;
|
||||||
// TODO: too tightly coupled into palette UI
|
// TODO: too tightly coupled into palette UI
|
||||||
@ -230,8 +227,10 @@ RED.nodes = function() {
|
|||||||
// TODO: remove workspace in next release+1
|
// TODO: remove workspace in next release+1
|
||||||
if (n.type != "workspace" && n.type != "tab" && !getType(n.type)) {
|
if (n.type != "workspace" && n.type != "tab" && !getType(n.type)) {
|
||||||
// TODO: get this UI thing out of here! (see below as well)
|
// TODO: get this UI thing out of here! (see below as well)
|
||||||
RED.notify("<strong>Failed to import nodes</strong>: unrecognised type '"+n.type+"'","error");
|
RED.notify("<strong>Failed to import node</strong>: unrecognised type '"+n.type+"'<br/>DO NOT DEPLOY while in this state.<br/>Either, add missing types to Node-RED, restart and then reload page,<br/>or delete unknown ( "+n.type+" ), rewire as required, and then deploy.","error","true");
|
||||||
return null;
|
//return null; //
|
||||||
|
n.name = "( "+n.type+" )"; // DCJ - mod to make it load, but will lose all "self knowledge".
|
||||||
|
n.type = "unknown"; //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i in newNodes) {
|
for (var i in newNodes) {
|
||||||
@ -373,5 +372,4 @@ RED.nodes = function() {
|
|||||||
nodes: nodes, // TODO: exposed for d3 vis
|
nodes: nodes, // TODO: exposed for d3 vis
|
||||||
links: links // TODO: exposed for d3 vis
|
links: links // TODO: exposed for d3 vis
|
||||||
};
|
};
|
||||||
|
|
||||||
}();
|
}();
|
||||||
|
Loading…
Reference in New Issue
Block a user