1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Another pass of categorisation

This commit is contained in:
Nick O'Leary 2019-07-09 20:26:26 +01:00
parent 00a3e25714
commit 2b66723d42
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
19 changed files with 40 additions and 35 deletions

View File

@ -19,15 +19,15 @@ RED.palette = (function() {
var exclusion = ['config','unknown','deprecated']; var exclusion = ['config','unknown','deprecated'];
var coreCategories = [ var coreCategories = [
'subflows', 'subflows',
'flow', 'common',
'input',
'output',
'function', 'function',
'input/output',
'sequence',
'parser', 'parser',
'social',
'mobile',
'storage', 'storage',
'analysis', 'analysis',
'social',
'mobile',
'advanced' 'advanced'
]; ];
@ -35,6 +35,7 @@ RED.palette = (function() {
var sidebarControls; var sidebarControls;
function createCategory(originalCategory,rootCategory,category,ns) { function createCategory(originalCategory,rootCategory,category,ns) {
console.log("createCategory",originalCategory,rootCategory,category,ns);
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) { if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory); createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
} }
@ -44,6 +45,7 @@ RED.palette = (function() {
} }
} }
function createCategoryContainer(originalCategory,category, labelId) { function createCategoryContainer(originalCategory,category, labelId) {
console.log("createCategoryContainer",originalCategory,category,labelId);
var label = RED._(labelId, {defaultValue:category}); var label = RED._(labelId, {defaultValue:category});
label = (label || category).replace(/_/g, " "); label = (label || category).replace(/_/g, " ");
var catDiv = $('<div id="red-ui-palette-container-'+category+'" class="red-ui-palette-category hide">'+ var catDiv = $('<div id="red-ui-palette-container-'+category+'" class="red-ui-palette-category hide">'+
@ -165,6 +167,9 @@ RED.palette = (function() {
return $(".red-ui-palette-node[data-palette-type='"+type+"']"); return $(".red-ui-palette-node[data-palette-type='"+type+"']");
} }
function escapeCategory(category) {
return category.replace(/[ /.]/g,"_");
}
function addNodeType(nt,def) { function addNodeType(nt,def) {
if (getPaletteNode(nt).length) { if (getPaletteNode(nt).length) {
return; return;
@ -172,7 +177,7 @@ RED.palette = (function() {
if (exclusion.indexOf(def.category)===-1) { if (exclusion.indexOf(def.category)===-1) {
var originalCategory = def.category; var originalCategory = def.category;
var category = def.category.replace(/ /g,"_"); var category = escapeCategory(def.category);
var rootCategory = category.split("-")[0]; var rootCategory = category.split("-")[0];
var d = $('<div>',{class:"red-ui-palette-node"}).attr("data-palette-type",nt).data('category',rootCategory); var d = $('<div>',{class:"red-ui-palette-node"}).attr("data-palette-type",nt).data('category',rootCategory);
@ -423,7 +428,7 @@ RED.palette = (function() {
var currentCategory = paletteNode.data('category'); var currentCategory = paletteNode.data('category');
var newCategory = (sf.category||"subflows"); var newCategory = (sf.category||"subflows");
if (currentCategory !== newCategory) { if (currentCategory !== newCategory) {
var category = newCategory.replace(/ /g,"_"); var category = escapeCategory(newCategory);
createCategory(newCategory,category,category,"node-red"); createCategory(newCategory,category,category,"node-red");
var currentCategoryNode = paletteNode.closest(".red-ui-palette-category"); var currentCategoryNode = paletteNode.closest(".red-ui-palette-category");
@ -556,7 +561,7 @@ RED.palette = (function() {
categoryList = coreCategories categoryList = coreCategories
} }
categoryList.forEach(function(category){ categoryList.forEach(function(category){
createCategoryContainer(category, category, "palette.label."+category); createCategoryContainer(category, escapeCategory(category), "palette.label."+escapeCategory(category));
}); });

View File

@ -156,7 +156,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('inject',{ RED.nodes.registerType('inject',{
category: 'flow', category: 'common',
color:"#a6bbcf", color:"#a6bbcf",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -37,7 +37,7 @@
(function() { (function() {
var subWindow = null; var subWindow = null;
RED.nodes.registerType('debug',{ RED.nodes.registerType('debug',{
category: 'flow', category: 'common',
defaults: { defaults: {
name: {value:""}, name: {value:""},
active: {value:true}, active: {value:true},

View File

@ -25,7 +25,7 @@
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('catch',{ RED.nodes.registerType('catch',{
category: 'flow', category: 'common',
color:"#e49191", color:"#e49191",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -21,7 +21,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('status',{ RED.nodes.registerType('status',{
category: 'flow', category: 'common',
color:"#d9f4fd", color:"#d9f4fd",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -162,7 +162,7 @@
} }
RED.nodes.registerType('link in',{ RED.nodes.registerType('link in',{
category: 'flow', category: 'common',
color:"#ddd",//"#87D8CF", color:"#ddd",//"#87D8CF",
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -191,7 +191,7 @@
}); });
RED.nodes.registerType('link out',{ RED.nodes.registerType('link out',{
category: 'flow', category: 'common',
color:"#ddd",//"#87D8CF", color:"#ddd",//"#87D8CF",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -53,7 +53,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('exec',{ RED.nodes.registerType('exec',{
category: 'advanced-function', category: 'function',
color:"darksalmon", color:"darksalmon",
defaults: { defaults: {
command: {value:""}, command: {value:""},

View File

@ -12,7 +12,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('comment',{ RED.nodes.registerType('comment',{
category: 'flow', category: 'common',
color:"#ffffff", color:"#ffffff",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -46,7 +46,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('mqtt in',{ RED.nodes.registerType('mqtt in',{
category: 'input', category: 'input/output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)}, topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
@ -107,7 +107,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('mqtt out',{ RED.nodes.registerType('mqtt out',{
category: 'output', category: 'input/output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
topic: {value:""}, topic: {value:""},

View File

@ -66,7 +66,7 @@
<script type="text/javascript"> <script type="text/javascript">
(function() { (function() {
RED.nodes.registerType('http in',{ RED.nodes.registerType('http in',{
category: 'input', category: 'input/output',
color:"rgb(231, 231, 174)", color:"rgb(231, 231, 174)",
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -142,7 +142,7 @@
]; ];
RED.nodes.registerType('http response',{ RED.nodes.registerType('http response',{
category: 'output', category: 'input/output',
color:"rgb(231, 231, 174)", color:"rgb(231, 231, 174)",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -98,7 +98,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('http request',{ RED.nodes.registerType('http request',{
category: 'function', category: 'input/output',
color:"rgb(231, 231, 174)", color:"rgb(231, 231, 174)",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -97,7 +97,7 @@
} }
RED.nodes.registerType('websocket in',{ RED.nodes.registerType('websocket in',{
category: 'input', category: 'input/output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
server: {type:"websocket-listener", validate: ws_validateserver}, server: {type:"websocket-listener", validate: ws_validateserver},
@ -116,7 +116,7 @@
}); });
RED.nodes.registerType('websocket out',{ RED.nodes.registerType('websocket out',{
category: 'output', category: 'input/output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
server: {type:"websocket-listener", validate: ws_validateserver}, server: {type:"websocket-listener", validate: ws_validateserver},

View File

@ -33,7 +33,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('watch',{ RED.nodes.registerType('watch',{
category: 'advanced-input', category: 'storage',
defaults: { defaults: {
name: {value:""}, name: {value:""},
files: {value:"",required:true}, files: {value:"",required:true},

View File

@ -57,7 +57,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('tcp in',{ RED.nodes.registerType('tcp in',{
category: 'input', category: 'input/output',
color:"Silver", color:"Silver",
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -143,7 +143,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('tcp out',{ RED.nodes.registerType('tcp out',{
category: 'output', category: 'input/output',
color:"Silver", color:"Silver",
defaults: { defaults: {
host: {value:"",validate:function(v) { return (this.beserver != "client")||v.length > 0;} }, host: {value:"",validate:function(v) { return (this.beserver != "client")||v.length > 0;} },
@ -215,7 +215,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('tcp request',{ RED.nodes.registerType('tcp request',{
category: 'function', category: 'input/output',
color:"Silver", color:"Silver",
defaults: { defaults: {
server: {value:""}, server: {value:""},

View File

@ -57,7 +57,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('udp in',{ RED.nodes.registerType('udp in',{
category: 'input', category: 'input/output',
color:"Silver", color:"Silver",
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -159,7 +159,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('udp out',{ RED.nodes.registerType('udp out',{
category: 'output', category: 'input/output',
color:"Silver", color:"Silver",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -48,7 +48,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('split',{ RED.nodes.registerType('split',{
category: 'function', category: 'sequence',
color:"#E2D96E", color:"#E2D96E",
defaults: { defaults: {
name: {value:""}, name: {value:""},
@ -196,7 +196,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('join',{ RED.nodes.registerType('join',{
category: 'function', category: 'sequence',
color:"#E2D96E", color:"#E2D96E",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -60,7 +60,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('sort',{ RED.nodes.registerType('sort',{
category: 'function', category: 'sequence',
color:"#E2D96E", color:"#E2D96E",
defaults: { defaults: {
name: { value:"" }, name: { value:"" },

View File

@ -68,7 +68,7 @@
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType("batch",{ RED.nodes.registerType("batch",{
category: "function", category: "sequence",
color:"#E2D96E", color:"#E2D96E",
defaults: { defaults: {
name: {value:""}, name: {value:""},

View File

@ -193,7 +193,7 @@
]; ];
RED.nodes.registerType('file',{ RED.nodes.registerType('file',{
category: 'storage-output', category: 'storage',
defaults: { defaults: {
name: {value:""}, name: {value:""},
filename: {value:""}, filename: {value:""},
@ -258,7 +258,7 @@
}); });
RED.nodes.registerType('file in',{ RED.nodes.registerType('file in',{
category: 'storage-input', category: 'storage',
defaults: { defaults: {
name: {value:""}, name: {value:""},
filename: {value:""}, filename: {value:""},