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

Allow linking to individual flow via url hash

This commit is contained in:
Nick O'Leary 2016-09-24 22:57:41 +01:00
parent a0f91aa814
commit 1866c9c7ef
2 changed files with 7 additions and 0 deletions

View File

@ -72,9 +72,13 @@ var RED = (function() {
cache: false, cache: false,
url: 'flows', url: 'flows',
success: function(nodes) { success: function(nodes) {
var currentHash = window.location.hash;
RED.nodes.import(nodes); RED.nodes.import(nodes);
RED.nodes.dirty(false); RED.nodes.dirty(false);
RED.view.redraw(true); RED.view.redraw(true);
if (/^#flow\/.+$/.test(currentHash)) {
RED.workspaces.show(currentHash.substring(6));
}
RED.comms.subscribe("status/#",function(topic,msg) { RED.comms.subscribe("status/#",function(topic,msg) {
var parts = topic.split("/"); var parts = topic.split("/");
var node = RED.nodes.node(parts[1]); var node = RED.nodes.node(parts[1]);

View File

@ -137,6 +137,7 @@ RED.workspaces = (function() {
activeWorkspace = tab.id; activeWorkspace = tab.id;
event.workspace = activeWorkspace; event.workspace = activeWorkspace;
RED.events.emit("workspace:change",event); RED.events.emit("workspace:change",event);
window.location.hash = 'flow/'+tab.id;
RED.sidebar.config.refresh(); RED.sidebar.config.refresh();
}, },
ondblclick: function(tab) { ondblclick: function(tab) {
@ -222,6 +223,8 @@ RED.workspaces = (function() {
var sf = RED.nodes.subflow(id); var sf = RED.nodes.subflow(id);
if (sf) { if (sf) {
addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.png",label:sf.name, closeable: true}); addWorkspace({type:"subflow",id:id,icon:"red/images/subflow_tab.png",label:sf.name, closeable: true});
} else {
return;
} }
} }
workspace_tabs.activateTab(id); workspace_tabs.activateTab(id);