Add deployment types in runtime

- removes ui option as it needs work
This commit is contained in:
Nick O'Leary
2015-01-08 22:34:26 +00:00
parent 89fff339d5
commit cf1371bfdf
11 changed files with 839 additions and 415 deletions

View File

@@ -15,6 +15,14 @@
**/
var RED = (function() {
var deploymentTypes = {
"full":"Deploy",
"nodes":"Deploy changed nodes",
"flows":"Deploy changed flows"
}
var deploymentType = "full";
function hideDropTarget() {
$("#dropTarget").hide();
RED.keyboard.remove(/* ESCAPE */ 27);
@@ -82,7 +90,10 @@ var RED = (function() {
url:"flows",
type: "POST",
data: JSON.stringify(nns),
contentType: "application/json; charset=utf-8"
contentType: "application/json; charset=utf-8",
headers: {
"Node-RED-Deployment-Type":deploymentType
}
}).done(function(data,textStatus,xhr) {
RED.notify("Successfully deployed","success");
RED.nodes.eachNode(function(node) {
@@ -280,6 +291,12 @@ var RED = (function() {
dialog.modal();
}
function changeDeploymentType(type) {
deploymentType = type;
$("#btn-deploy span").text(deploymentTypes[type]);
}
$(function() {
RED.menu.init({id:"btn-sidemenu",
options: [
@@ -312,6 +329,15 @@ var RED = (function() {
{id:"btn-help",icon:"fa fa-question",label:"Help...", href:"http://nodered.org/docs"}
]
});
//RED.menu.init({id:"btn-deploy-options",
// options: [
// {id:"btn-deploy-select",label:"Select deployment type"},
// {id:"btn-deploy-full",icon:null,label:"Full deploy",tip:"Deploys all nodes",onselect:function() { changeDeploymentType("full")}},
// {id:"btn-deploy-node",icon:null,label:"Deploy changed nodes",tip:"Deploys all nodes that have been changed",onselect:function() { changeDeploymentType("nodes")}},
// {id:"btn-deploy-flow",icon:null,label:"Deploy changed flows",tip:"Deploys all nodes in flows that contain changes",onselect:function() { changeDeploymentType("flows")}}
// ]
//});
RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
loadSettings();

View File

@@ -394,7 +394,7 @@ RED.nodes = (function() {
var wires = links.filter(function(d) { return d.source === p });
for (var i=0;i<wires.length;i++) {
var w = wires[i];
if (w.target.id != p.id) {
if (w.target.type != "subflow") {
nIn.wires.push({id:w.target.id})
}
}

View File

@@ -47,8 +47,8 @@ RED.menu = (function() {
item = $('<li></li>');
var link = $('<a '+(opt.id?'id="'+opt.id+'" ':'')+'tabindex="-1" href="#">'+
(opt.toggle?'<i class="fa fa-check pull-right"></i>':'')+
(opt.icon?'<i class="'+opt.icon+'"></i> ':'')+
opt.label+
(opt.icon!==undefined?'<i class="'+(opt.icon?opt.icon:'" style="display: inline-block;"')+'"></i> ':"")+
'<span class="menu-label">'+opt.label+'</span>'+
'</a>').appendTo(item);
menuItems[opt.id] = opt;
@@ -67,6 +67,11 @@ RED.menu = (function() {
setState();
} else if (opt.href) {
link.attr("target","_blank").attr("href",opt.href);
} else if (!opt.options) {
item.addClass("disabled");
link.click(function(event) {
event.preventDefault();
});
}
if (opt.options) {
item.addClass("dropdown-submenu pull-left");
@@ -79,6 +84,17 @@ RED.menu = (function() {
if (opt.disabled) {
item.addClass("disabled");
}
if (opt.tip) {
item.popover({
placement:"left",
trigger: "hover",
delay: { show: 350, hide: 20 },
html: true,
container:'body',
content: opt.tip
});
}
}
@@ -88,8 +104,8 @@ RED.menu = (function() {
function createMenu(options) {
var button = $("#"+options.id);
var topMenu = $("<ul/>",{class:"dropdown-menu"}).insertAfter(button);
var topMenu = $("<ul/>",{id:options.id+"-submenu", class:"dropdown-menu pull-right"}).insertAfter(button);
for (var i=0;i<options.options.length;i++) {
var opt = options.options[i];