mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add sidebar menu and migrate existing panels to new api
This commit is contained in:
parent
6cfa4976fe
commit
6359b90352
@ -160,7 +160,10 @@ var RED = (function() {
|
||||
function loadEditor() {
|
||||
RED.menu.init({id:"btn-sidemenu",
|
||||
options: [
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar"),toggle:true,onselect:RED.sidebar.toggleSidebar, selected: true},
|
||||
{id:"menu-item-sidebar-menu",label:RED._("menu.label.sidebar.sidebar"),options:[
|
||||
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:RED.sidebar.toggleSidebar, selected: true},
|
||||
null
|
||||
]},
|
||||
{id:"menu-item-status",label:RED._("menu.label.displayStatus"),toggle:true,onselect:toggleStatus, selected: true},
|
||||
null,
|
||||
{id:"menu-item-import",label:RED._("menu.label.import"),options:[
|
||||
@ -172,8 +175,6 @@ var RED = (function() {
|
||||
{id:"menu-item-export-library",label:RED._("menu.label.library"),disabled:true,onselect:RED.library.export}
|
||||
]},
|
||||
null,
|
||||
{id:"menu-item-config-nodes",label:RED._("menu.label.configurationNodes"),onselect:RED.sidebar.config.show},
|
||||
null,
|
||||
{id:"menu-item-subflow",label:RED._("menu.label.subflows"), options: [
|
||||
{id:"menu-item-subflow-create",label:RED._("menu.label.createSubflow"),onselect:RED.subflow.createSubflow},
|
||||
{id:"menu-item-subflow-convert",label:RED._("menu.label.selectionToSubflow"),disabled:true,onselect:RED.subflow.convertToSubflow},
|
||||
|
@ -20,24 +20,65 @@ RED.sidebar = (function() {
|
||||
id:"sidebar-tabs",
|
||||
onchange:function(tab) {
|
||||
$("#sidebar-content").children().hide();
|
||||
$("#"+tab.id).show();
|
||||
if (tab.onchange) {
|
||||
tab.onchange.call(tab);
|
||||
}
|
||||
$(tab.content).show();
|
||||
},
|
||||
onremove: function(tab) {
|
||||
$("#"+tab.id).remove();
|
||||
$(tab.content).remove();
|
||||
if (tab.onremove) {
|
||||
tab.onremove.call(tab);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function addTab(title,content,closeable) {
|
||||
$("#sidebar-content").append(content);
|
||||
$(content).hide();
|
||||
var id = content.id || "tab-"+title.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, "\\$1" );
|
||||
sidebar_tabs.addTab({id:id,label:title,closeable:closeable});
|
||||
//content.style.position = "absolute";
|
||||
//$('#sidebar').tabs("refresh");
|
||||
var knownTabs = {
|
||||
|
||||
};
|
||||
|
||||
function addTab(title,content,closeable,visible) {
|
||||
var options;
|
||||
if (typeof title === "string") {
|
||||
// TODO: legacy support in case anyone uses this...
|
||||
options = {
|
||||
id: content.id,
|
||||
label: title,
|
||||
name: title,
|
||||
content: content,
|
||||
closeable: closeable,
|
||||
visible: visible
|
||||
}
|
||||
} else if (typeof title === "object") {
|
||||
options = title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#sidebar-content").append(options.content);
|
||||
$(options.content).hide();
|
||||
var id = options.id;
|
||||
|
||||
RED.menu.addItem("menu-item-sidebar-menu",{
|
||||
id:"menu-item-sidebar-menu-"+options.id,
|
||||
label:options.name,
|
||||
onselect:function() {
|
||||
showSidebar(options.id);
|
||||
}
|
||||
});
|
||||
|
||||
knownTabs[options.id] = options;
|
||||
|
||||
if (options.visible !== false) {
|
||||
sidebar_tabs.addTab(knownTabs[options.id]);
|
||||
}
|
||||
}
|
||||
|
||||
function removeTab(title) {
|
||||
sidebar_tabs.removeTab("tab-"+title);
|
||||
function removeTab(id) {
|
||||
sidebar_tabs.removeTab(id);
|
||||
delete knownTabs[id];
|
||||
RED.menu.removeItem("menu-item-sidebar-menu-"+id);
|
||||
//TODO: remove menu item
|
||||
}
|
||||
|
||||
var sidebarSeparator = {};
|
||||
@ -130,18 +171,25 @@ RED.sidebar = (function() {
|
||||
|
||||
function showSidebar(id) {
|
||||
if (id) {
|
||||
sidebar_tabs.activateTab("tab-"+id);
|
||||
if (!containsTab(id)) {
|
||||
sidebar_tabs.addTab(knownTabs[id]);
|
||||
}
|
||||
sidebar_tabs.activateTab(id);
|
||||
if (!RED.menu.isSelected("menu-item-sidebar")) {
|
||||
RED.menu.setSelected("menu-item-sidebar",true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function containsTab(id) {
|
||||
return sidebar_tabs.contains("tab-"+id);
|
||||
return sidebar_tabs.contains(id);
|
||||
}
|
||||
|
||||
function init () {
|
||||
RED.keyboard.add(/* SPACE */ 32,{ctrl:true},function(){RED.menu.setSelected("menu-item-sidebar",!RED.menu.isSelected("menu-item-sidebar"));d3.event.preventDefault();});
|
||||
showSidebar();
|
||||
RED.sidebar.info.show();
|
||||
RED.sidebar.info.init();
|
||||
RED.sidebar.config.init();
|
||||
// hide info bar at start if screen rather narrow...
|
||||
if ($(window).width() < 600) { toggleSidebar(); }
|
||||
}
|
||||
|
@ -16,17 +16,24 @@
|
||||
RED.sidebar.config = (function() {
|
||||
|
||||
var content = document.createElement("div");
|
||||
content.id = "tab-config";
|
||||
content.style.paddingTop = "4px";
|
||||
content.style.paddingLeft = "4px";
|
||||
content.style.paddingRight = "4px";
|
||||
|
||||
var list = $("<ul>",{class:"tab-config-list"}).appendTo(content);
|
||||
|
||||
function init() {
|
||||
RED.sidebar.addTab({
|
||||
id: "config",
|
||||
label: RED._("sidebar.config.label"),
|
||||
name: RED._("sidebar.config.name"),
|
||||
content: content,
|
||||
closeable: true,
|
||||
visible: false,
|
||||
onchange: function() { refresh(); }
|
||||
});
|
||||
}
|
||||
function show() {
|
||||
if (!RED.sidebar.containsTab("config")) {
|
||||
RED.sidebar.addTab(RED._("sidebar.config.title"),content,true);
|
||||
}
|
||||
refresh();
|
||||
RED.sidebar.show("config");
|
||||
}
|
||||
@ -78,6 +85,7 @@ RED.sidebar.config = (function() {
|
||||
});
|
||||
}
|
||||
return {
|
||||
init:init,
|
||||
show:show,
|
||||
refresh:refresh
|
||||
}
|
||||
|
@ -27,17 +27,23 @@ RED.sidebar.info = (function() {
|
||||
});
|
||||
|
||||
var content = document.createElement("div");
|
||||
content.id = "tab-info";
|
||||
content.style.paddingTop = "4px";
|
||||
content.style.paddingLeft = "4px";
|
||||
content.style.paddingRight = "4px";
|
||||
|
||||
var propertiesExpanded = false;
|
||||
|
||||
function init() {
|
||||
RED.sidebar.addTab({
|
||||
id: "info",
|
||||
label: RED._("sidebar.info.label"),
|
||||
name: RED._("sidebar.info.name"),
|
||||
content: content
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (!RED.sidebar.containsTab("info")) {
|
||||
RED.sidebar.addTab(RED._("sidebar.info.title"),content,false);
|
||||
}
|
||||
RED.sidebar.show("info");
|
||||
}
|
||||
|
||||
@ -184,6 +190,7 @@ RED.sidebar.info = (function() {
|
||||
});
|
||||
|
||||
return {
|
||||
init: init,
|
||||
show: show,
|
||||
refresh:refresh,
|
||||
clear: clear
|
||||
|
@ -28,6 +28,7 @@ RED.workspaces = (function() {
|
||||
var tabId = RED.nodes.id();
|
||||
do {
|
||||
workspaceIndex += 1;
|
||||
//TODO: nls of Sheet
|
||||
} while($("#workspace-tabs a[title='Sheet "+workspaceIndex+"']").size() !== 0);
|
||||
|
||||
ws = {type:"tab",id:tabId,label:"Sheet "+workspaceIndex};
|
||||
|
@ -16,16 +16,18 @@
|
||||
},
|
||||
"menu": {
|
||||
"label": {
|
||||
"sidebar": "Sidebar",
|
||||
"displayStatus": "Display node status",
|
||||
"sidebar": {
|
||||
"sidebar": "Sidebar",
|
||||
"show": "Toggle Sidebar"
|
||||
},
|
||||
"displayStatus": "Display Node Status",
|
||||
"import": "Import",
|
||||
"export": "Export",
|
||||
"clipboard": "Clipboard",
|
||||
"library": "Library",
|
||||
"configurationNodes": "Configuration nodes",
|
||||
"subflows": "Subflows",
|
||||
"createSubflow": "Create subflow",
|
||||
"selectionToSubflow": "Selection to subflow",
|
||||
"createSubflow": "Create Subflow",
|
||||
"selectionToSubflow": "Selection to Subflow",
|
||||
"workspaces": "Workspaces",
|
||||
"add": "Add",
|
||||
"rename": "Rename",
|
||||
@ -175,7 +177,8 @@
|
||||
},
|
||||
"sidebar": {
|
||||
"info": {
|
||||
"title": "info",
|
||||
"name": "Node Information",
|
||||
"label": "info",
|
||||
"node": "Node",
|
||||
"type": "Type",
|
||||
"id": "ID",
|
||||
@ -186,7 +189,8 @@
|
||||
"arrayItems": "__count__ items"
|
||||
},
|
||||
"config": {
|
||||
"title": "config"
|
||||
"name": "Configuration nodes",
|
||||
"label": "config"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,6 @@
|
||||
},
|
||||
onpaletteadd: function() {
|
||||
var content = document.createElement("div");
|
||||
content.id = "tab-debug";
|
||||
|
||||
var toolbar = document.createElement("div");
|
||||
toolbar.id = "debug-toolbar";
|
||||
@ -140,7 +139,12 @@
|
||||
messages.id = "debug-content";
|
||||
content.appendChild(messages);
|
||||
|
||||
RED.sidebar.addTab(this._("debug.sidebarTitle"),content);
|
||||
RED.sidebar.addTab({
|
||||
id: "debug",
|
||||
label: this._("debug.sidebar.label"),
|
||||
name: this._("debug.sidebar.name"),
|
||||
content: content
|
||||
});
|
||||
|
||||
function getTimestamp() {
|
||||
var d = new Date();
|
||||
|
@ -81,7 +81,10 @@
|
||||
"activated": "Successfully activated: __label__",
|
||||
"deactivated": "Successfully deactivated: __label__"
|
||||
},
|
||||
"sidebarTitle": "debug"
|
||||
"sidebar": {
|
||||
"label": "debug",
|
||||
"name": "Debug messages"
|
||||
}
|
||||
},
|
||||
"exec": {
|
||||
"spawnerr": "Spawn command must be just the command - no spaces or extra parameters",
|
||||
|
Loading…
Reference in New Issue
Block a user