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

Allow palette categories to be predefined

This commit is contained in:
Nick O'Leary 2015-02-06 13:16:19 +00:00
parent 010abbd3d5
commit 86c8a5de81
3 changed files with 26 additions and 6 deletions

View File

@ -21,8 +21,8 @@ RED.palette = (function() {
function createCategoryContainer(category){ function createCategoryContainer(category){
var escapedCategory = category.replace(" ","_"); var escapedCategory = category.replace(" ","_");
$("#palette-container").append('<div class="palette-category">'+ var catDiv = $("#palette-container").append('<div id="palette-container-'+category+'" class="palette-category hide">'+
'<div id="header-'+category+'" class="palette-header"><i class="expanded fa fa-caret-down"></i><span>'+category.replace("_"," ")+'</span></div>'+ '<div id="palette-header-'+category+'" class="palette-header"><i class="expanded fa fa-caret-down"></i><span>'+category.replace("_"," ")+'</span></div>'+
'<div class="palette-content" id="palette-base-category-'+category+'">'+ '<div class="palette-content" id="palette-base-category-'+category+'">'+
'<div id="palette-'+category+'-input"></div>'+ '<div id="palette-'+category+'-input"></div>'+
'<div id="palette-'+category+'-output"></div>'+ '<div id="palette-'+category+'-output"></div>'+
@ -30,7 +30,7 @@ RED.palette = (function() {
'</div>'+ '</div>'+
'</div>'); '</div>');
$("#header-"+category).on('click', function(e) { $("#palette-header-"+category).on('click', function(e) {
$(this).next().slideToggle(); $(this).next().slideToggle();
$(this).children("i").toggleClass("expanded"); $(this).children("i").toggleClass("expanded");
}); });
@ -151,6 +151,7 @@ RED.palette = (function() {
if ($("#palette-base-category-"+rootCategory).length === 0) { if ($("#palette-base-category-"+rootCategory).length === 0) {
createCategoryContainer(rootCategory); createCategoryContainer(rootCategory);
} }
$("#palette-container-"+rootCategory).show();
if ($("#palette-"+category).length === 0) { if ($("#palette-"+category).length === 0) {
$("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>'); $("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>');
@ -241,7 +242,12 @@ RED.palette = (function() {
function init() { function init() {
$(".palette-spinner").show(); $(".palette-spinner").show();
core.forEach(createCategoryContainer); if (RED.settings.paletteCategories) {
RED.settings.paletteCategories.forEach(createCategoryContainer);
} else {
core.forEach(createCategoryContainer);
}
$("#palette-search-input").focus(function(e) { $("#palette-search-input").focus(function(e) {
RED.keyboard.disable(); RED.keyboard.disable();
}); });

View File

@ -1,5 +1,5 @@
/** /**
* Copyright 2014 IBM Corp. * Copyright 2014, 2015 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,6 +15,8 @@
**/ **/
var settings = require('../settings'); var settings = require('../settings');
var util = require('util');
module.exports = { module.exports = {
settings: function(req,res) { settings: function(req,res) {
var safeSettings = { var safeSettings = {
@ -22,6 +24,11 @@ module.exports = {
version: settings.version, version: settings.version,
user: req.user user: req.user
}; };
if (util.isArray(settings.paletteCategories)) {
safeSettings.paletteCategories = settings.paletteCategories;
}
res.json(safeSettings); res.json(safeSettings);
} }
} }

View File

@ -1,5 +1,5 @@
/** /**
* Copyright 2013 IBM Corp. * Copyright 2013, 2015 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -134,6 +134,13 @@ module.exports = {
// arduino:require('duino') // arduino:require('duino')
}, },
// The following property can be used to order the categories in the editor
// palette. If a node's category is not in the list, the category will get
// added to the end of the palette.
// If not set, the following default order is used:
//paletteCategories: ['input', 'output', 'function', 'subflows', 'social', 'storage', 'analysis', 'advanced'],
// Configure the logging output // Configure the logging output
logging: { logging: {
// Only console logging is currently supported // Only console logging is currently supported