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

Merge pull request #3590 from Steve-Mcl/search-current-flow

Add ability to search in current flow
This commit is contained in:
Stephen McLaughlin 2022-05-10 08:08:28 +01:00 committed by GitHub
commit 1af56a7f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 21 deletions

View File

@ -907,7 +907,8 @@
"uknownNodes": "Unknown nodes",
"unusedSubflows": "Unused subflows",
"hiddenFlows": "Hidden flows",
"modifiedNodes": "Modified nodes and flows"
"modifiedNodes": "Modified nodes and flows",
"thisFlow": "Current flow"
}
},
"expressionEditor": {

View File

@ -108,7 +108,6 @@ RED.search = (function() {
function search(val) {
var results = [];
var keys = [];
var typeFilter;
var m = /(?:^| )type:([^ ]+)/.exec(val);
if (m) {
@ -122,19 +121,24 @@ RED.search = (function() {
val = extractFlag(val,"subflow",flags);
val = extractFlag(val,"hidden",flags);
val = extractFlag(val,"modified",flags);
// uses:<node-id>
val = extractValue(val,"uses",flags);
var hasFlags = Object.keys(flags).length > 0;
val = extractValue(val,"flow",flags);// flow:active or flow:<flow-id>
val = extractValue(val,"uses",flags);// uses:<node-id>
val = val.trim();
var hasFlags = Object.keys(flags).length > 0;
if (flags.flow && flags.flow.indexOf("current") >= 0) {
let idx = flags.flow.indexOf("current");
flags.flow[idx] = RED.workspaces.active();//convert active to flow ID
}
if (flags.flow && flags.flow.length) {
flags.flow = [ ...new Set(flags.flow) ]; //deduplicate
}
if (val.length > 0 || typeFilter || hasFlags) {
val = val.toLowerCase();
var i;
var j;
var list = [];
var nodes = {};
let keys = [];
if (flags.uses) {
keys = flags.uses;
} else {
@ -188,6 +192,11 @@ RED.search = (function() {
continue;
}
}
if (flags.hasOwnProperty("flow")) {
if (flags.flow.indexOf(node.node.z || node.node.id) < 0) {
continue;
}
}
if (!typeFilter || node.node.type === typeFilter) {
nodes[node.node.id] = nodes[node.node.id] = {
node: node.node,
@ -592,8 +601,8 @@ RED.search = (function() {
{label:RED._("search.options.uknownNodes"), value: "type:unknown"},
{label:RED._("search.options.unusedSubflows"), value:"is:subflow is:unused"},
{label:RED._("search.options.hiddenFlows"), value:"is:hidden"},
{label:RED._("search.options.thisFlow"), value:"flow:current"},
]
}
function init() {

View File

@ -93,7 +93,6 @@ RED.view = (function() {
var selectNodesOptions;
let flashingNodeId;
let flashingNodeTimer;
var clipboard = "";
@ -5853,27 +5852,26 @@ RED.view = (function() {
if(typeof node === "string") { node = RED.nodes.node(n); }
if(!node) { return; }
const flashingNode = flashingNodeTimer && flashingNodeId && RED.nodes.node(flashingNodeId);
const flashingNode = flashingNodeId && RED.nodes.node(flashingNodeId);
if(flashingNode) {
//cancel current flashing node before flashing new node
clearInterval(flashingNodeTimer);
flashingNodeTimer = null;
clearInterval(flashingNode.__flashTimer);
delete flashingNode.__flashTimer;
flashingNode.dirty = true;
flashingNode.highlighted = false;
}
flashingNodeTimer = setInterval(function(flashEndTime) {
node.dirty = true;
node.__flashTimer = setInterval(function(flashEndTime, n) {
n.dirty = true;
if (flashEndTime >= Date.now()) {
node.highlighted = !node.highlighted;
n.highlighted = !n.highlighted;
} else {
clearInterval(flashingNodeTimer);
flashingNodeTimer = null;
node.highlighted = false;
clearInterval(n.__flashTimer);
delete n.__flashTimer;
flashingNodeId = null;
n.highlighted = false;
}
RED.view.redraw();
}, 100, Date.now() + 2200)
}, 100, Date.now() + 2200, node)
flashingNodeId = node.id;
node.highlighted = true;
RED.view.redraw();