mirror of https://github.com/node-red/node-red.git
Add 'no matches' message to package search results
parent
2e87ebe800
commit
e3b7c5fce7
|
@ -352,6 +352,10 @@ RED.palette.editor = (function() {
|
||||||
for (var i=0;i<Math.min(10,filteredList.length);i++) {
|
for (var i=0;i<Math.min(10,filteredList.length);i++) {
|
||||||
packageList.editableList('addItem',filteredList[i]);
|
packageList.editableList('addItem',filteredList[i]);
|
||||||
}
|
}
|
||||||
|
if (filteredList.length === 0) {
|
||||||
|
packageList.editableList('addItem',{});
|
||||||
|
}
|
||||||
|
|
||||||
if (filteredList.length > 10) {
|
if (filteredList.length > 10) {
|
||||||
packageList.editableList('addItem',{start:10,more:filteredList.length-10})
|
packageList.editableList('addItem',{start:10,more:filteredList.length-10})
|
||||||
}
|
}
|
||||||
|
@ -430,6 +434,7 @@ RED.palette.editor = (function() {
|
||||||
|
|
||||||
nodeList = $('<ol>',{id:"palette-module-list", style:"position: absolute;top: 35px;bottom: 0;left: 0;right: 0px;"}).appendTo(modulesTab).editableList({
|
nodeList = $('<ol>',{id:"palette-module-list", style:"position: absolute;top: 35px;bottom: 0;left: 0;right: 0px;"}).appendTo(modulesTab).editableList({
|
||||||
addButton: false,
|
addButton: false,
|
||||||
|
scrollOnAdd: false,
|
||||||
sort: function(A,B) {
|
sort: function(A,B) {
|
||||||
return A.info.name.localeCompare(B.info.name);
|
return A.info.name.localeCompare(B.info.name);
|
||||||
},
|
},
|
||||||
|
@ -442,90 +447,94 @@ RED.palette.editor = (function() {
|
||||||
},
|
},
|
||||||
addItem: function(container,i,object) {
|
addItem: function(container,i,object) {
|
||||||
var entry = object.info;
|
var entry = object.info;
|
||||||
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
|
if (entry) {
|
||||||
var titleRow = $('<div class="palette-module-meta palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
|
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
|
||||||
$('<span>').html(entry.name).appendTo(titleRow);
|
var titleRow = $('<div class="palette-module-meta palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
|
||||||
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
|
$('<span>').html(entry.name).appendTo(titleRow);
|
||||||
$('<span>').html(entry.version).appendTo(metaRow);
|
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
|
||||||
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
|
$('<span>').html(entry.version).appendTo(metaRow);
|
||||||
var setButton = $('<a href="#" class="editor-button editor-button-small palette-module-set-button"><i class="fa fa-angle-right palette-module-node-chevron"></i> </a>').appendTo(buttonRow);
|
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
|
||||||
var setCount = $('<span>').appendTo(setButton);
|
var setButton = $('<a href="#" class="editor-button editor-button-small palette-module-set-button"><i class="fa fa-angle-right palette-module-node-chevron"></i> </a>').appendTo(buttonRow);
|
||||||
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
|
var setCount = $('<span>').appendTo(setButton);
|
||||||
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.remove')).appendTo(buttonGroup);
|
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
|
||||||
removeButton.click(function() {
|
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.remove')).appendTo(buttonGroup);
|
||||||
shade.show();
|
removeButton.click(function() {
|
||||||
removeNodeModule(entry.name, function(xhr) {
|
shade.show();
|
||||||
console.log(xhr);
|
removeNodeModule(entry.name, function(xhr) {
|
||||||
|
console.log(xhr);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
if (!entry.local) {
|
||||||
if (!entry.local) {
|
removeButton.hide();
|
||||||
removeButton.hide();
|
|
||||||
}
|
|
||||||
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.disableall')).appendTo(buttonGroup);
|
|
||||||
|
|
||||||
var contentRow = $('<div>',{class:"palette-module-content"}).appendTo(container);
|
|
||||||
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
|
|
||||||
|
|
||||||
object.elements = {
|
|
||||||
removeButton: removeButton,
|
|
||||||
enableButton: enableButton,
|
|
||||||
setCount: setCount,
|
|
||||||
container: container,
|
|
||||||
shade: shade,
|
|
||||||
sets: {}
|
|
||||||
}
|
|
||||||
setButton.click(function() {
|
|
||||||
if (container.hasClass('expanded')) {
|
|
||||||
container.removeClass('expanded');
|
|
||||||
contentRow.slideUp();
|
|
||||||
} else {
|
|
||||||
container.addClass('expanded');
|
|
||||||
contentRow.slideDown();
|
|
||||||
}
|
}
|
||||||
})
|
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.disableall')).appendTo(buttonGroup);
|
||||||
|
|
||||||
var setList = Object.keys(entry.sets)
|
var contentRow = $('<div>',{class:"palette-module-content"}).appendTo(container);
|
||||||
setList.sort(function(A,B) {
|
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
|
||||||
return A.toLowerCase().localeCompare(B.toLowerCase());
|
|
||||||
});
|
object.elements = {
|
||||||
setList.forEach(function(setName) {
|
removeButton: removeButton,
|
||||||
var set = entry.sets[setName];
|
enableButton: enableButton,
|
||||||
var setRow = $('<div>',{class:"palette-module-set"}).appendTo(contentRow);
|
setCount: setCount,
|
||||||
var buttonGroup = $('<div>',{class:"palette-module-set-button-group"}).appendTo(setRow);
|
container: container,
|
||||||
var typeSwatches = {};
|
shade: shade,
|
||||||
set.types.forEach(function(t) {
|
sets: {}
|
||||||
var typeDiv = $('<div>',{class:"palette-module-type"}).appendTo(setRow);
|
}
|
||||||
typeSwatches[t] = $('<span>',{class:"palette-module-type-swatch"}).appendTo(typeDiv);
|
setButton.click(function() {
|
||||||
$('<span>',{class:"palette-module-type-node"}).html(t).appendTo(typeDiv);
|
if (container.hasClass('expanded')) {
|
||||||
|
container.removeClass('expanded');
|
||||||
|
contentRow.slideUp();
|
||||||
|
} else {
|
||||||
|
container.addClass('expanded');
|
||||||
|
contentRow.slideDown();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').appendTo(buttonGroup);
|
var setList = Object.keys(entry.sets)
|
||||||
|
setList.sort(function(A,B) {
|
||||||
|
return A.toLowerCase().localeCompare(B.toLowerCase());
|
||||||
|
});
|
||||||
|
setList.forEach(function(setName) {
|
||||||
|
var set = entry.sets[setName];
|
||||||
|
var setRow = $('<div>',{class:"palette-module-set"}).appendTo(contentRow);
|
||||||
|
var buttonGroup = $('<div>',{class:"palette-module-set-button-group"}).appendTo(setRow);
|
||||||
|
var typeSwatches = {};
|
||||||
|
set.types.forEach(function(t) {
|
||||||
|
var typeDiv = $('<div>',{class:"palette-module-type"}).appendTo(setRow);
|
||||||
|
typeSwatches[t] = $('<span>',{class:"palette-module-type-swatch"}).appendTo(typeDiv);
|
||||||
|
$('<span>',{class:"palette-module-type-node"}).html(t).appendTo(typeDiv);
|
||||||
|
})
|
||||||
|
|
||||||
|
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').appendTo(buttonGroup);
|
||||||
|
enableButton.click(function(evt) {
|
||||||
|
if (object.setUseCount[setName] === 0) {
|
||||||
|
var currentSet = RED.nodes.registry.getNodeSet(set.id);
|
||||||
|
shade.show();
|
||||||
|
changeNodeState(set.id,!currentSet.enabled,shade,function(xhr){
|
||||||
|
console.log(xhr)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
evt.preventDefault();
|
||||||
|
})
|
||||||
|
|
||||||
|
object.elements.sets[set.name] = {
|
||||||
|
setRow: setRow,
|
||||||
|
enableButton: enableButton,
|
||||||
|
swatches: typeSwatches
|
||||||
|
};
|
||||||
|
});
|
||||||
enableButton.click(function(evt) {
|
enableButton.click(function(evt) {
|
||||||
if (object.setUseCount[setName] === 0) {
|
if (object.totalUseCount === 0) {
|
||||||
var currentSet = RED.nodes.registry.getNodeSet(set.id);
|
changeNodeState(entry.name,(container.hasClass('disabled')),shade,function(xhr){
|
||||||
shade.show();
|
|
||||||
changeNodeState(set.id,!currentSet.enabled,shade,function(xhr){
|
|
||||||
console.log(xhr)
|
console.log(xhr)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
})
|
})
|
||||||
|
refreshNodeModule(entry.name);
|
||||||
object.elements.sets[set.name] = {
|
} else {
|
||||||
setRow: setRow,
|
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
|
||||||
enableButton: enableButton,
|
}
|
||||||
swatches: typeSwatches
|
|
||||||
};
|
|
||||||
});
|
|
||||||
enableButton.click(function(evt) {
|
|
||||||
if (object.totalUseCount === 0) {
|
|
||||||
changeNodeState(entry.name,(container.hasClass('disabled')),shade,function(xhr){
|
|
||||||
console.log(xhr)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
evt.preventDefault();
|
|
||||||
})
|
|
||||||
refreshNodeModule(entry.name);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -546,10 +555,9 @@ RED.palette.editor = (function() {
|
||||||
.appendTo(searchDiv)
|
.appendTo(searchDiv)
|
||||||
.searchBox({
|
.searchBox({
|
||||||
delay: 300,
|
delay: 300,
|
||||||
minimumLength: 2,
|
|
||||||
change: function() {
|
change: function() {
|
||||||
var searchTerm = $(this).val();
|
var searchTerm = $(this).val();
|
||||||
if (searchTerm.length >= 2) {
|
if (searchTerm.length > 0) {
|
||||||
filteredList = loadedList.filter(function(m) {
|
filteredList = loadedList.filter(function(m) {
|
||||||
return (m.index.indexOf(searchTerm) > -1);
|
return (m.index.indexOf(searchTerm) > -1);
|
||||||
}).map(function(f) { return {info:f}});
|
}).map(function(f) { return {info:f}});
|
||||||
|
@ -557,9 +565,7 @@ RED.palette.editor = (function() {
|
||||||
searchInput.searchBox('count',filteredList.length+" / "+loadedList.length);
|
searchInput.searchBox('count',filteredList.length+" / "+loadedList.length);
|
||||||
} else {
|
} else {
|
||||||
searchInput.searchBox('count',loadedList.length);
|
searchInput.searchBox('count',loadedList.length);
|
||||||
if (searchTerm.length === 0) {
|
packageList.editableList('empty');
|
||||||
packageList.editableList('empty');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -603,7 +609,9 @@ RED.palette.editor = (function() {
|
||||||
|
|
||||||
packageList = $('<ol>',{style:"position: absolute;top: 78px;bottom: 0;left: 0;right: 0px;"}).appendTo(installTab).editableList({
|
packageList = $('<ol>',{style:"position: absolute;top: 78px;bottom: 0;left: 0;right: 0px;"}).appendTo(installTab).editableList({
|
||||||
addButton: false,
|
addButton: false,
|
||||||
|
scrollOnAdd: false,
|
||||||
addItem: function(container,i,object) {
|
addItem: function(container,i,object) {
|
||||||
|
|
||||||
if (object.more) {
|
if (object.more) {
|
||||||
container.addClass('palette-module-more');
|
container.addClass('palette-module-more');
|
||||||
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
|
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
|
||||||
|
@ -620,37 +628,41 @@ RED.palette.editor = (function() {
|
||||||
})
|
})
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var entry = object.info;
|
if (object.info) {
|
||||||
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
|
var entry = object.info;
|
||||||
var titleRow = $('<div class="palette-module-meta"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
|
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
|
||||||
$('<span>',{class:"palette-module-name"}).html(entry.name||entry.id).appendTo(titleRow);
|
var titleRow = $('<div class="palette-module-meta"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
|
||||||
$('<a target="_blank" class="palette-module-link"><i class="fa fa-external-link"></i></a>').attr('href',entry.url).appendTo(titleRow);
|
$('<span>',{class:"palette-module-name"}).html(entry.name||entry.id).appendTo(titleRow);
|
||||||
var descRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
|
$('<a target="_blank" class="palette-module-link"><i class="fa fa-external-link"></i></a>').attr('href',entry.url).appendTo(titleRow);
|
||||||
$('<div>',{class:"palette-module-description"}).html(entry.description).appendTo(descRow);
|
var descRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
|
||||||
|
$('<div>',{class:"palette-module-description"}).html(entry.description).appendTo(descRow);
|
||||||
|
|
||||||
var metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
|
var metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
|
||||||
$('<span class="palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
|
$('<span class="palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
|
||||||
$('<span class="palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
|
$('<span class="palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
|
||||||
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
|
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
|
||||||
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
|
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
|
||||||
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
|
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
|
||||||
var installButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.install')).appendTo(buttonGroup);
|
var installButton = $('<a href="#" class="editor-button editor-button-small"></a>').html(RED._('palette.editor.install')).appendTo(buttonGroup);
|
||||||
installButton.click(function(e) {
|
installButton.click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
installNodeModule(entry.id,shade,function(xhr) {
|
installNodeModule(entry.id,shade,function(xhr) {
|
||||||
if (xhr) {
|
if (xhr) {
|
||||||
if (xhr.responseJSON) {
|
if (xhr.responseJSON) {
|
||||||
RED.notify(RED._('palette.editor.errors.installFailed',{module: entry.id,message:xhr.responseJSON.message}));
|
RED.notify(RED._('palette.editor.errors.installFailed',{module: entry.id,message:xhr.responseJSON.message}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
})
|
if (nodeEntries.hasOwnProperty(entry.id)) {
|
||||||
if (nodeEntries.hasOwnProperty(entry.id)) {
|
installButton.hide();
|
||||||
installButton.hide();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
object.elements = {
|
object.elements = {
|
||||||
installButton:installButton
|
installButton:installButton
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('<div>',{class:"red-ui-search-empty"}).html(RED._('search.empty')).appendTo(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,6 +101,5 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
background: $background-color;
|
|
||||||
color: $form-placeholder-color;
|
color: $form-placeholder-color;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue