mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
node filtering now scans also note content (using backend)
This commit is contained in:
parent
540c28eb3a
commit
361e69d236
1
TODO
1
TODO
@ -2,7 +2,6 @@
|
|||||||
- conflict detection
|
- conflict detection
|
||||||
|
|
||||||
Later:
|
Later:
|
||||||
- collapse all button
|
|
||||||
- context menu on items (add subnote etc.)
|
- context menu on items (add subnote etc.)
|
||||||
- drag and drop for notes (currently only keyboard)
|
- drag and drop for notes (currently only keyboard)
|
||||||
- sync with sync server
|
- sync with sync server
|
@ -14,6 +14,7 @@ from move_before_note import MoveBeforeNote
|
|||||||
from move_to_note import MoveToNote
|
from move_to_note import MoveToNote
|
||||||
from notes import Notes
|
from notes import Notes
|
||||||
from notes_children import NotesChildren
|
from notes_children import NotesChildren
|
||||||
|
from notes_search import NotesSearch
|
||||||
from sql import connect
|
from sql import connect
|
||||||
from tree import Tree
|
from tree import Tree
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ api.add_resource(MoveBeforeNote, '/notes/<string:note_id>/moveBefore/<string:bef
|
|||||||
api.add_resource(MoveToNote, '/notes/<string:note_id>/moveTo/<string:parent_id>')
|
api.add_resource(MoveToNote, '/notes/<string:note_id>/moveTo/<string:parent_id>')
|
||||||
api.add_resource(ExpandedNote, '/notes/<string:note_id>/expanded/<int:expanded>')
|
api.add_resource(ExpandedNote, '/notes/<string:note_id>/expanded/<int:expanded>')
|
||||||
api.add_resource(Tree, '/tree')
|
api.add_resource(Tree, '/tree')
|
||||||
|
api.add_resource(NotesSearch, '/notes')
|
||||||
|
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
login_manager.init_app(app)
|
login_manager.init_app(app)
|
||||||
|
18
src/notes_search.py
Normal file
18
src/notes_search.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from flask import request
|
||||||
|
from flask_restful import Resource
|
||||||
|
|
||||||
|
from sql import getResults
|
||||||
|
|
||||||
|
|
||||||
|
class NotesSearch(Resource):
|
||||||
|
def get(self):
|
||||||
|
search = '%' + request.args['search'] + '%'
|
||||||
|
|
||||||
|
result = getResults("select note_id from notes where note_title like ? or note_text like ?", [search, search])
|
||||||
|
|
||||||
|
noteIdList = [];
|
||||||
|
|
||||||
|
for res in result:
|
||||||
|
noteIdList.append(res['note_id'])
|
||||||
|
|
||||||
|
return noteIdList
|
@ -185,16 +185,24 @@ $(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("input[name=search]").keyup(function (e) {
|
$("input[name=search]").keyup(function (e) {
|
||||||
const match = $(this).val();
|
const searchString = $(this).val();
|
||||||
|
|
||||||
if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === "") {
|
if (e && e.which === $.ui.keyCode.ESCAPE || $.trim(searchString) === "") {
|
||||||
$("button#btnResetSearch").click();
|
$("button#btnResetSearch").click();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass a string to perform case insensitive matching
|
if (e && e.which === $.ui.keyCode.ENTER) {
|
||||||
const tree = $("#tree").fancytree("getTree");
|
$.get(baseUrl + 'notes?search=' + searchString).then(resp => {
|
||||||
tree.filterBranches(match);
|
console.log("search: ", resp);
|
||||||
|
|
||||||
|
// Pass a string to perform case insensitive matching
|
||||||
|
const tree = $("#tree").fancytree("getTree");
|
||||||
|
tree.filterBranches(function(node) {
|
||||||
|
return resp.includes(node.data.note_id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}).focus();
|
}).focus();
|
||||||
|
|
||||||
$("button#btnResetSearch").click(function () {
|
$("button#btnResetSearch").click(function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user