mirror of
https://github.com/node-red/node-red.git
synced 2025-12-28 07:41:42 +01:00
Merge branch 'dev' into export-module-info
This commit is contained in:
@@ -27,7 +27,6 @@ RED.i18n = (function() {
|
||||
apiRootUrl = options.apiRootUrl||"";
|
||||
var preferredLanguage = localStorage.getItem("editor-language") || detectLanguage();
|
||||
var opts = {
|
||||
compatibilityJSON: 'v3',
|
||||
backend: {
|
||||
loadPath: apiRootUrl+'locales/__ns__?lng=__lng__',
|
||||
},
|
||||
|
||||
@@ -583,7 +583,9 @@ RED.palette.editor = (function() {
|
||||
packageList.editableList('addItem',{count:loadedList.length})
|
||||
return;
|
||||
}
|
||||
// sort the filtered modules
|
||||
filteredList.sort(activeSort);
|
||||
// render the items in the package list
|
||||
for (var i=0;i<Math.min(10,filteredList.length);i++) {
|
||||
packageList.editableList('addItem',filteredList[i]);
|
||||
}
|
||||
@@ -595,15 +597,26 @@ RED.palette.editor = (function() {
|
||||
}
|
||||
}
|
||||
function sortModulesRelevance(A,B) {
|
||||
var currentFilter = searchInput.searchBox('value').trim();
|
||||
if (currentFilter === "") {
|
||||
return sortModulesAZ(A,B);
|
||||
const defaultSort = sortModulesDownloads(A,B);
|
||||
const currentFilter = searchInput.searchBox('value').trim();
|
||||
if (defaultSort === 0) {
|
||||
// same number of downloads
|
||||
if (currentFilter === "") {
|
||||
return sortModulesAZ(A,B);
|
||||
}
|
||||
var i = A.info.index.indexOf(currentFilter) - B.info.index.indexOf(currentFilter);
|
||||
if (i === 0) {
|
||||
return sortModulesAZ(A,B);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
var i = A.info.index.indexOf(currentFilter) - B.info.index.indexOf(currentFilter);
|
||||
if (i === 0) {
|
||||
return sortModulesAZ(A,B);
|
||||
}
|
||||
return i;
|
||||
return defaultSort;
|
||||
}
|
||||
function sortModulesDownloads(A,B) {
|
||||
// check A has the info.downloads property - if not exising, prioritise it (likely a custom user catalogue)
|
||||
const a = A.info && typeof A.info.downloads !== 'undefined' ? A.info.downloads.week : Number.MAX_SAFE_INTEGER;
|
||||
const b = B.info && typeof B.info.downloads !== 'undefined' ? B.info.downloads.week : Number.MAX_SAFE_INTEGER;
|
||||
return b - a;
|
||||
}
|
||||
function sortModulesAZ(A,B) {
|
||||
return A.info.id.localeCompare(B.info.id);
|
||||
@@ -1159,8 +1172,11 @@ RED.palette.editor = (function() {
|
||||
var descRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
|
||||
$('<div>',{class:"red-ui-palette-module-description"}).text(entry.description).appendTo(descRow);
|
||||
var metaRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
|
||||
$('<span class="red-ui-palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
|
||||
$('<span class="red-ui-palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
|
||||
$('<span class="red-ui-palette-module-version" title="Latest Version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
|
||||
$('<span class="red-ui-palette-module-updated" title="Last Updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
|
||||
if (entry.downloads?.week !== undefined) {
|
||||
$('<span class="red-ui-palette-module-downloads" title="Downloads - Last 7 Days"><i class="fa fa-download"></i> '+(new Intl.NumberFormat().format(entry.downloads.week))+'</span>').appendTo(metaRow);
|
||||
}
|
||||
if (loadedCatalogs.length > 1) {
|
||||
$('<span class="red-ui-palette-module-updated"><i class="fa fa-cubes"></i>' + (entry.catalog.name || entry.catalog.url) + '</span>').appendTo(metaRow);
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ RED.palette = (function() {
|
||||
} else {
|
||||
// Firefox doesn't do getIntersectionList and that
|
||||
// makes us sad
|
||||
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
|
||||
nodes = RED.view.getLinksAtPoint(mouseX / RED.view.scale(), mouseY / RED.view.scale());
|
||||
}
|
||||
var mx = mouseX / RED.view.scale();
|
||||
var my = mouseY / RED.view.scale();
|
||||
|
||||
@@ -140,6 +140,7 @@ RED.userSettings = (function() {
|
||||
title: "menu.label.nodes",
|
||||
options: [
|
||||
{setting:"view-node-status",oldSetting:"menu-menu-item-status",label:"menu.label.displayStatus",default: true, toggle:true,onchange:"core:toggle-status"},
|
||||
{setting:"view-node-info-icon", label:"menu.label.displayInfoIcon", default: true, toggle:true,onchange:"core:toggle-node-info-icon"},
|
||||
{setting:"view-node-show-label",label:"menu.label.showNodeLabelDefault",default: true, toggle:true}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -82,6 +82,7 @@ RED.view = (function() {
|
||||
var slicePathLast = null;
|
||||
var ghostNode = null;
|
||||
var showStatus = false;
|
||||
let showNodeInfo = true;
|
||||
var lastClickNode = null;
|
||||
var dblClickPrimed = null;
|
||||
var clickTime = 0;
|
||||
@@ -860,11 +861,51 @@ RED.view = (function() {
|
||||
toggleStatus(state);
|
||||
}
|
||||
});
|
||||
RED.actions.add("core:toggle-node-info-icon", function (state) {
|
||||
if (state === undefined) {
|
||||
RED.userSettings.toggle("view-node-info-icon");
|
||||
} else {
|
||||
toggleNodeInfo(state)
|
||||
}
|
||||
})
|
||||
|
||||
RED.view.annotations.init();
|
||||
RED.view.navigator.init();
|
||||
RED.view.tools.init();
|
||||
|
||||
RED.view.annotations.register("red-ui-flow-node-docs",{
|
||||
type: "badge",
|
||||
class: "red-ui-flow-node-docs",
|
||||
element: function(node) {
|
||||
|
||||
const docsBadge = document.createElementNS("http://www.w3.org/2000/svg","g")
|
||||
|
||||
const pageOutline = document.createElementNS("http://www.w3.org/2000/svg","rect");
|
||||
pageOutline.setAttribute("x",0);
|
||||
pageOutline.setAttribute("y",0);
|
||||
pageOutline.setAttribute("rx",2);
|
||||
pageOutline.setAttribute("width",7);
|
||||
pageOutline.setAttribute("height",10);
|
||||
docsBadge.appendChild(pageOutline)
|
||||
|
||||
const pageLines = document.createElementNS("http://www.w3.org/2000/svg","path");
|
||||
pageLines.setAttribute("d", "M 7 3 h -3 v -3 M 2 8 h 3 M 2 6 h 3 M 2 4 h 2")
|
||||
docsBadge.appendChild(pageLines)
|
||||
|
||||
$(docsBadge).on('click', function (evt) {
|
||||
if (node.type === "subflow") {
|
||||
RED.editor.editSubflow(activeSubflow, 'editor-tab-description');
|
||||
} else if (node.type === "group") {
|
||||
RED.editor.editGroup(node, 'editor-tab-description');
|
||||
} else {
|
||||
RED.editor.edit(node, 'editor-tab-description');
|
||||
}
|
||||
})
|
||||
|
||||
return docsBadge;
|
||||
},
|
||||
show: function(n) { return showNodeInfo && !!n.info }
|
||||
})
|
||||
|
||||
RED.view.annotations.register("red-ui-flow-node-changed",{
|
||||
type: "badge",
|
||||
@@ -1908,7 +1949,7 @@ RED.view = (function() {
|
||||
} else {
|
||||
// Firefox doesn"t do getIntersectionList and that
|
||||
// makes us sad
|
||||
nodes = RED.view.getLinksAtPoint(mouseX*scaleFactor,mouseY*scaleFactor);
|
||||
nodes = RED.view.getLinksAtPoint(mouseX, mouseY);
|
||||
}
|
||||
for (var i=0;i<nodes.length;i++) {
|
||||
if (d3.select(nodes[i]).classed("red-ui-flow-link-background")) {
|
||||
@@ -6030,6 +6071,11 @@ RED.view = (function() {
|
||||
//TODO: subscribe/unsubscribe here
|
||||
redraw();
|
||||
}
|
||||
function toggleNodeInfo(s) {
|
||||
showNodeInfo = s
|
||||
RED.nodes.eachNode(function(n) { n.dirty = true;});
|
||||
redraw();
|
||||
}
|
||||
function setSelectedNodeState(isDisabled) {
|
||||
if (mouse_mode === RED.state.SELECTING_NODE) {
|
||||
return;
|
||||
@@ -6356,6 +6402,12 @@ RED.view = (function() {
|
||||
var links = outer.selectAll(".red-ui-flow-link-background")[0];
|
||||
for (var i=0;i<links.length;i++) {
|
||||
var bb = links[i].getBBox();
|
||||
if (bb.height === 0) {
|
||||
// For horizontal links, add some real height to make them easier
|
||||
// to hit.
|
||||
bb.y -= Math.max(5, 5 / scaleFactor);
|
||||
bb.height = Math.max(10, 10 / scaleFactor);
|
||||
}
|
||||
if (x >= bb.x && y >= bb.y && x <= bb.x+bb.width && y <= bb.y+bb.height) {
|
||||
result.push(links[i])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user