mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fixing settings usage in UI
This commit is contained in:
parent
12a06cacce
commit
6c093eef99
16
red/ui.js
16
red/ui.js
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
|
var util = require('util');
|
||||||
|
var crypto = require('crypto');
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var app = express();
|
var app = express();
|
||||||
var events = require("./events");
|
var events = require("./events");
|
||||||
@ -21,13 +23,16 @@ var path = require("path");
|
|||||||
|
|
||||||
var icon_paths = [path.resolve(__dirname + '/../public/icons')];
|
var icon_paths = [path.resolve(__dirname + '/../public/icons')];
|
||||||
|
|
||||||
|
var settings; // settings has to be global, otherwise variable not in scope for express
|
||||||
|
|
||||||
events.on("node-icon-dir",function(dir) {
|
events.on("node-icon-dir",function(dir) {
|
||||||
icon_paths.push(path.resolve(dir));
|
icon_paths.push(path.resolve(dir));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// TODO: nothing here uses settings... so does this need to be a function?
|
function setupUI(_settings) {
|
||||||
function setupUI(settings) {
|
|
||||||
|
settings = _settings; // TODO confirm if settings are needed
|
||||||
|
|
||||||
// Need to ensure the url ends with a '/' so the static serving works
|
// Need to ensure the url ends with a '/' so the static serving works
|
||||||
// with relative paths
|
// with relative paths
|
||||||
@ -45,7 +50,7 @@ function setupUI(settings) {
|
|||||||
|
|
||||||
app.get("/icons/:icon",function(req,res) {
|
app.get("/icons/:icon",function(req,res) {
|
||||||
if (iconCache[req.params.icon]) {
|
if (iconCache[req.params.icon]) {
|
||||||
res.sendfile(iconCache[req.params.icon]);
|
res.sendfile(iconCache[req.params.icon]); // if not found, express prints this to the console and serves 404
|
||||||
} else {
|
} else {
|
||||||
for (var p=0;p<icon_paths.length;p++) {
|
for (var p=0;p<icon_paths.length;p++) {
|
||||||
var iconPath = path.join(icon_paths[p],req.params.icon);
|
var iconPath = path.join(icon_paths[p],req.params.icon);
|
||||||
@ -72,9 +77,4 @@ function setupUI(settings) {
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = setupUI;
|
module.exports = setupUI;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user