Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
node filtering now scans also note content (using backend)
azivner361e69d23667
diff --git a/TODO b/TODOindex 443a2808a2..6eae4d8c0f 100644--- a/TODO+++ b/TODO@@ -2,7 +2,6 @@- conflict detectionLater:-- collapse all button- context menu on items (add subnote etc.)- drag and drop for notes (currently only keyboard)- sync with sync server\ No newline at end of filediff --git a/src/app.py b/src/app.pyindex 781cbe4be1..1c4732cea5 100644--- a/src/app.py+++ b/src/app.py@@ -14,6 +14,7 @@ from move_before_note import MoveBeforeNotefrom move_to_note import MoveToNotefrom notes import Notesfrom notes_children import NotesChildren+from notes_search import NotesSearchfrom sql import connectfrom tree import Tree@@ -82,6 +83,7 @@ api.add_resource(MoveBeforeNote, '/notes/<string:note_id>/moveBefore/<string:befapi.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(Tree, '/tree')+api.add_resource(NotesSearch, '/notes')login_manager = LoginManager()login_manager.init_app(app)diff --git a/src/notes_search.py b/src/notes_search.pynew file mode 100644index 0000000000..2a35110036--- /dev/null+++ b/src/notes_search.py@@ -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\ No newline at end of filediff --git a/static/js/tree.js b/static/js/tree.jsindex 0e9e08def5..2019f69210 100644--- a/static/js/tree.js+++ b/static/js/tree.js@@ -185,16 +185,24 @@ $(function(){});$("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();return;}- // Pass a string to perform case insensitive matching- const tree = $("#tree").fancytree("getTree");- tree.filterBranches(match);+ if (e && e.which === $.ui.keyCode.ENTER) {+ $.get(baseUrl + 'notes?search=' + searchString).then(resp => {+ 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();$("button#btnResetSearch").click(function () {