mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
allow a node's icon to be set dynamically (#1490)
* create a proto type * Fixed some problems after reviewing
This commit is contained in:
committed by
Nick O'Leary
parent
cc88ebd2b9
commit
6d2389945b
@@ -579,6 +579,25 @@ var defaultIcon = path.resolve(__dirname + '/../../../../public/icons/arrow-in.p
|
||||
function nodeIconDir(dir) {
|
||||
icon_paths[dir.name] = icon_paths[dir.name] || [];
|
||||
icon_paths[dir.name].push(path.resolve(dir.path));
|
||||
|
||||
if (dir.icons) {
|
||||
if (!moduleConfigs[dir.name]) {
|
||||
moduleConfigs[dir.name] = {
|
||||
name: dir.name,
|
||||
nodes: {},
|
||||
icons: []
|
||||
};
|
||||
}
|
||||
var module = moduleConfigs[dir.name];
|
||||
if (module.icons === undefined) {
|
||||
module.icons = [];
|
||||
}
|
||||
dir.icons.forEach(function(icon) {
|
||||
if (module.icons.indexOf(icon) === -1) {
|
||||
module.icons.push(icon);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getNodeIconPath(module,icon) {
|
||||
@@ -607,6 +626,20 @@ function getNodeIconPath(module,icon) {
|
||||
}
|
||||
}
|
||||
|
||||
function getNodeIcons() {
|
||||
var iconList = {};
|
||||
|
||||
for (var module in moduleConfigs) {
|
||||
if (moduleConfigs.hasOwnProperty(module)) {
|
||||
if (moduleConfigs[module].icons) {
|
||||
iconList[module] = moduleConfigs[module].icons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iconList;
|
||||
}
|
||||
|
||||
var registry = module.exports = {
|
||||
init: init,
|
||||
load: load,
|
||||
@@ -629,6 +662,7 @@ var registry = module.exports = {
|
||||
getModuleInfo: getModuleInfo,
|
||||
|
||||
getNodeIconPath: getNodeIconPath,
|
||||
getNodeIcons: getNodeIcons,
|
||||
/**
|
||||
* Gets all of the node template configs
|
||||
* @return all of the node templates in a single string
|
||||
|
||||
Reference in New Issue
Block a user