mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
WIP - url rewriting to support debug
This commit is contained in:
parent
f82a779817
commit
e41d5c249f
@ -15,7 +15,8 @@
|
|||||||
**/
|
**/
|
||||||
var RED = (function() {
|
var RED = (function() {
|
||||||
|
|
||||||
function appendNodeConfig(nodeConfig) {
|
function appendNodeConfig(nodeConfig,done) {
|
||||||
|
done = done || function(){};
|
||||||
var m = /<!-- --- \[red-module:(\S+)\] --- -->/.exec(nodeConfig.trim());
|
var m = /<!-- --- \[red-module:(\S+)\] --- -->/.exec(nodeConfig.trim());
|
||||||
var moduleId;
|
var moduleId;
|
||||||
if (m) {
|
if (m) {
|
||||||
@ -24,13 +25,31 @@ var RED = (function() {
|
|||||||
moduleId = "unknown";
|
moduleId = "unknown";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$("body").append(nodeConfig);
|
var hasDeferred = false;
|
||||||
|
|
||||||
|
var nodeConfigEls = $("<div>"+nodeConfig+"</div>");
|
||||||
|
nodeConfigEls.find("script").each(function(i,el) {
|
||||||
|
var srcUrl = $(el).attr('src');
|
||||||
|
if (srcUrl && !/^\s*(https?:|\/|\.)/.test(srcUrl)) {
|
||||||
|
$(el).remove();
|
||||||
|
var newScript = document.createElement("script");
|
||||||
|
newScript.onload = function() { $("body").append(nodeConfigEls); done() }
|
||||||
|
$('body').append(newScript);
|
||||||
|
newScript.src = RED.settings.apiRootUrl+srcUrl;
|
||||||
|
hasDeferred = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!hasDeferred) {
|
||||||
|
$("body").append(nodeConfigEls);
|
||||||
|
done();
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
RED.notify(RED._("notification.errors.failedToAppendNode",{module:moduleId, error:err.toString()}),{
|
RED.notify(RED._("notification.errors.failedToAppendNode",{module:moduleId, error:err.toString()}),{
|
||||||
type: "error",
|
type: "error",
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
});
|
});
|
||||||
console.log("["+moduleId+"] "+err.toString());
|
console.log("["+moduleId+"] "+err.toString());
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,36 +94,40 @@ var RED = (function() {
|
|||||||
url: 'nodes',
|
url: 'nodes',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var configs = data.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/);
|
var configs = data.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/);
|
||||||
configs.forEach(function(data) {
|
var stepConfig = function() {
|
||||||
appendNodeConfig(data);
|
if (configs.length === 0) {
|
||||||
});
|
$("body").i18n();
|
||||||
|
$("#palette > .palette-spinner").hide();
|
||||||
$("body").i18n();
|
$(".palette-scroll").removeClass("hide");
|
||||||
$("#palette > .palette-spinner").hide();
|
$("#palette-search").removeClass("hide");
|
||||||
$(".palette-scroll").removeClass("hide");
|
loadFlows(function() {
|
||||||
$("#palette-search").removeClass("hide");
|
if (RED.settings.theme("projects.enabled",false)) {
|
||||||
loadFlows(function() {
|
RED.projects.refresh(function(activeProject) {
|
||||||
if (RED.settings.theme("projects.enabled",false)) {
|
RED.sidebar.info.refresh()
|
||||||
RED.projects.refresh(function(activeProject) {
|
if (!activeProject) {
|
||||||
RED.sidebar.info.refresh()
|
// Projects enabled but no active project
|
||||||
if (!activeProject) {
|
RED.menu.setDisabled('menu-item-projects-open',true);
|
||||||
// Projects enabled but no active project
|
RED.menu.setDisabled('menu-item-projects-settings',true);
|
||||||
RED.menu.setDisabled('menu-item-projects-open',true);
|
if (activeProject === false) {
|
||||||
RED.menu.setDisabled('menu-item-projects-settings',true);
|
// User previously decline the migration to projects.
|
||||||
if (activeProject === false) {
|
} else { // null/undefined
|
||||||
// User previously decline the migration to projects.
|
RED.projects.showStartup();
|
||||||
} else { // null/undefined
|
}
|
||||||
RED.projects.showStartup();
|
}
|
||||||
}
|
completeLoad();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Projects disabled by the user
|
||||||
|
RED.sidebar.info.refresh()
|
||||||
|
completeLoad();
|
||||||
}
|
}
|
||||||
completeLoad();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Projects disabled by the user
|
var config = configs.shift();
|
||||||
RED.sidebar.info.refresh()
|
appendNodeConfig(config,stepConfig);
|
||||||
completeLoad();
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
stepConfig();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
RED.i18n.init(function() {
|
RED.i18n.init({},function() {
|
||||||
var options = {
|
var options = {
|
||||||
messageMouseEnter: function(sourceId) {
|
messageMouseEnter: function(sourceId) {
|
||||||
window.opener.postMessage({event:"mouseEnter",id:sourceId},'*');
|
window.opener.postMessage({event:"mouseEnter",id:sourceId},'*');
|
||||||
|
@ -32,6 +32,14 @@ function init(_server,settings,storage,runtimeAPI) {
|
|||||||
server = _server;
|
server = _server;
|
||||||
if (settings.httpAdminRoot !== false) {
|
if (settings.httpAdminRoot !== false) {
|
||||||
adminApp = express();
|
adminApp = express();
|
||||||
|
|
||||||
|
var cors = require('cors');
|
||||||
|
var corsHandler = cors({
|
||||||
|
origin: "*",
|
||||||
|
methods: "GET,PUT,POST,DELETE"
|
||||||
|
});
|
||||||
|
adminApp.use(corsHandler);
|
||||||
|
|
||||||
auth.init(settings,storage);
|
auth.init(settings,storage);
|
||||||
|
|
||||||
var maxApiRequestSize = settings.apiMaxLength || '5mb';
|
var maxApiRequestSize = settings.apiMaxLength || '5mb';
|
||||||
|
Loading…
Reference in New Issue
Block a user