Skip to content

Commit

Permalink
Add config node filter
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jan 12, 2016
1 parent 50399c6 commit a0cc1e6
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 54 deletions.
7 changes: 4 additions & 3 deletions editor/js/ui/deploy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015 IBM Corp.
* Copyright 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -242,8 +242,9 @@ RED.deploy = (function() {
}
}).done(function(data,textStatus,xhr) {
if (hasUnusedConfig) {
RED.notify(RED._("deploy.successfulDeploy")+
'<p><br>You have some unused configuration nodes. <a href="#" onclick="RED.sidebar.config.show(); return false;" >Click here</a> to see them</p>',"success",false,6000);
RED.notify(
'<p>'+RED._("deploy.successfulDeploy")+'</p>'+
'<p>'+RED._("deploy.unusedConfigNodes")+' <a href="#" onclick="RED.sidebar.config.show(true); return false;">'+RED._("deploy.unusedConfigNodesLink")+'</a></p>',"success",false,6000);
} else {
RED.notify(RED._("deploy.successfulDeploy"),"success");
}
Expand Down
9 changes: 8 additions & 1 deletion editor/js/ui/notifications.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013 IBM Corp.
* Copyright 2013, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,6 +48,13 @@ RED.notify = (function() {
});
};
})();
$(n).click((function() {
var nn = n;
return function() {
nn.close();
window.clearTimeout(nn.timeoutid);
};
})());
if (!fixed) {
n.timeoutid = window.setTimeout(n.close,timeout||3000);
}
Expand Down
65 changes: 39 additions & 26 deletions editor/js/ui/tab-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2013, 2015 IBM Corp.
* Copyright 2013, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,28 +19,24 @@ RED.sidebar.config = (function() {
var content = document.createElement("div");
content.className = "sidebar-node-config"

var toolbar = $('<div id="palette-footer">'+
//'<a class="sidebar-button text-button" id="workspace-config-node-filter-unused" href="#"><i class="fa fa-square-o"></i> <span data-i18n="sidebar.config.filterUnused"></span></a> '+
'<a class="sidebar-button" id="workspace-config-node-collapse-all" href="#"><i class="fa fa-angle-double-up"></i></a> '+
'<a class="sidebar-button" id="workspace-config-node-expand-all" href="#"><i class="fa fa-angle-double-down"></i></a>'+
'</div>');
$('<div id="sidebar-node-config-header">'+
'<a class="sidebar-header-button selected" id="workspace-config-node-filter-all" href="#"><span data-i18n="sidebar.config.filterAll"></span></a>'+
'<a class="sidebar-header-button" id="workspace-config-node-filter-unused" href="#"><span data-i18n="sidebar.config.filterUnused"></span></a> '+
'</div>'
).appendTo(content);


var toolbar = $('<div>'+
'<a class="sidebar-footer-button" id="workspace-config-node-collapse-all" href="#"><i class="fa fa-angle-double-up"></i></a> '+
'<a class="sidebar-footer-button" id="workspace-config-node-expand-all" href="#"><i class="fa fa-angle-double-down"></i></a>'+
'</div>');

var globalCategories = $("<div>").appendTo(content);
var flowCategories = $("<div>").appendTo(content);
var subflowCategories = $("<div>").appendTo(content);
var globalCategories = $("<div>").appendTo(content);

var showUnusedOnly = false;

// $('<div class="palette-category">'+
// '<div class="workspace-config-node-tray-header palette-header"><i class="fa fa-angle-down expanded"></i><span data-i18n="sidebar.config.local"></span></div>'+
// '<ul id="workspace-config-node-tray-locals" class="palette-content config-node-list"></ul>'+
// '</div>'+
// '<div class="palette-category">'+
// '<div class="workspace-config-node-tray-header palette-header"><i class="fa fa-angle-down expanded"></i><span data-i18n="sidebar.config.global"></span></div>'+
// '<ul id="workspace-config-node-tray-globals" class="palette-content config-node-list"></ul>'+
// '</div>').appendTo(content);

var categories = {};

function getOrCreateCategory(name,parent,label) {
Expand Down Expand Up @@ -80,11 +76,14 @@ RED.sidebar.config = (function() {
result.list.slideUp();
}
}
},
isOpen: function() {
return icon.hasClass("expanded");
}
};

header.on('click', function(e) {
if (icon.hasClass("expanded")) {
if (result.isOpen()) {
result.close();
} else {
result.open();
Expand All @@ -109,7 +108,6 @@ RED.sidebar.config = (function() {
return n.users.length === 0;
})
}
// console.log(list);
list.empty();
if (nodes.length === 0) {
$('<li class="config_node_none" data-i18n="sidebar.config.none">NONE</li>').i18n().appendTo(list);
Expand Down Expand Up @@ -237,20 +235,35 @@ RED.sidebar.config = (function() {
}
}
});
$('#workspace-config-node-filter-unused').on("click",function(e) {
$('#workspace-config-node-filter-all').on("click",function(e) {
e.preventDefault();
if (showUnusedOnly) {
$(this).find("i").addClass('fa-square-o').removeClass('fa-check-square-o');
} else {
$(this).find("i").removeClass('fa-square-o').addClass('fa-check-square-o');
$(this).addClass('selected');
$('#workspace-config-node-filter-unused').removeClass('selected');
showUnusedOnly = !showUnusedOnly;
refreshConfigNodeList();
}
showUnusedOnly = !showUnusedOnly;
refreshConfigNodeList();
})
});
$('#workspace-config-node-filter-unused').on("click",function(e) {
e.preventDefault();
if (!showUnusedOnly) {
$(this).addClass('selected');
$('#workspace-config-node-filter-all').removeClass('selected');
showUnusedOnly = !showUnusedOnly;
refreshConfigNodeList();
}
});


}
function show() {
function show(unused) {
if (unused !== undefined) {
if (unused) {
$('#workspace-config-node-filter-unused').click();
} else {
$('#workspace-config-node-filter-all').click();
}
}
refreshConfigNodeList();
RED.sidebar.show("config");
}
Expand Down
5 changes: 5 additions & 0 deletions editor/sass/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
background: $workspace-button-background-active;
text-decoration: none;
}
&.selected:not(.disabled) {
color: $workspace-button-color-active;
background: $workspace-button-background-active;
cursor: default;
}
}
@mixin component-footer {
border-top: 1px solid $primary-border-color;
Expand Down
6 changes: 6 additions & 0 deletions editor/sass/notifications.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
border: 1px solid #325C80;
border-left-width: 16px;
}
.notification a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}

.notification-success {
border-color: #4B8400;
Expand Down
8 changes: 7 additions & 1 deletion editor/sass/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
@include component-footer;
}

.sidebar-button {
.sidebar-footer-button {
@include component-footer-button;
}
.sidebar-header-button {
@include workspace-button;
font-size: 13px;
line-height: 13px;
padding: 5px 8px;
}
51 changes: 31 additions & 20 deletions editor/sass/tab-config.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,34 @@
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
}
.config_node_type {
color: #999;
text-align: right;
padding-right: 3px;
&:not(:first-child) {
margin-top: 20px;
}
}
.config_node_none {
color: #ddd;
text-align:right;
padding-right: 3px;
}
.config_node_unused {
border-color: #aaa;
background: #f9f9f9;
border-style: dashed;
color: #aaa;
}
}
.config_node_type {
color: #999;
text-align: right;
padding-right: 3px;
&:not(:first-child) {
margin-top: 20px;
}
}
.config_node_none {
color: #ddd;
text-align:right;
padding-right: 3px;
}
.config_node_unused {
border-color: #aaa;
background: #f9f9f9;
border-style: dashed;
color: #aaa;
}

#sidebar-node-config-header {
color: #666;
text-align: right;
padding: 8px 10px;
background: #f3f3f3;
border-bottom: 1px solid $secondary-border-color;
}
.sidebar-header-button:not(:first-child) {
border-left: none;
}
8 changes: 5 additions & 3 deletions red/api/locales/en-US/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
"modifiedNodes": "Modified Nodes",
"modifiedNodesDesc": "Only deploys nodes that have changed",
"successfulDeploy": "Successfully deployed",

"unusedConfigNodes":"You have some unused configuration nodes.",
"unusedConfigNodesLink":"Click here to see them",
"errors": {
"noResponse": "no response from server"
},
Expand Down Expand Up @@ -201,11 +202,12 @@
"config": {
"name": "Configuration nodes",
"label": "config",
"global": "Global Nodes",
"global": "Global",
"none": "none",
"subflows": "subflows",
"flows": "flows",
"filterUnused":"show unused only"
"filterUnused":"unused",
"filterAll":"all"
}
},
"typedInput": {
Expand Down

0 comments on commit a0cc1e6

Please sign in to comment.