From 5a4faca86fcd6ec68816a16509f83028d13164f2 Mon Sep 17 00:00:00 2001 From: senta_mandutz Date: Sun, 21 Jul 2019 14:12:16 +0200 Subject: [PATCH] extended search --- public/index.html | 29 ++++++++++++++--------------- public/routes/createMessage.js | 23 +++++++++++------------ public/routes/files.js | 23 ++++++++++++----------- server/dbs.js | 2 +- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/public/index.html b/public/index.html index 71de540..280c350 100644 --- a/public/index.html +++ b/public/index.html @@ -182,11 +182,6 @@ @@ -211,7 +206,7 @@ searchtext: "", //isSearchActiv: false, selected: [], - taglist: dat, + taglist: data, }; }, computed: { @@ -227,7 +222,7 @@ methods: { getFilteredTags(text) { - this.taglist = dat.filter((option) => { + this.taglist = data.filter((option) => { return option .toString() .toLowerCase() @@ -240,7 +235,8 @@ console.info(tagArray); }, search: function() { - searching(this.searchtext); + + searching(this.searchtext); }, list_messages: function() { messages(); @@ -252,12 +248,14 @@ }) .done(jd => { // NICHT SO wg. Vue: _messagelist = jd; - _taglist.splice(0, _taglist.length); - _taglist.push.apply(_taglist, jd); - console.log("tag: jd: " + jd); - for (var e in jd) { - if (!_tags[jd[e]]) { - get_insert_tag(jd[e]); + if(data == ""){ + _taglist.splice(0, _taglist.length); + _taglist.push.apply(_taglist, jd); + console.log("tag: jd: " + jd); + for (var e in jd) { + if (!_tags[jd[e]]) { + get_insert_tag(jd[e]); + } } } }).fail(function(e, f, g) { @@ -285,7 +283,7 @@ url: "api/tag/" + id, method: "GET" }).done(function(tag) { - dat.push("#" + tag.name); + data.push("#" + tag.name); console.log("it worked!"); }).fail(function(e, f, g) { console.log("cannot load " + id + ".json: " + e + f + g); @@ -300,6 +298,7 @@ method: "GET" }).done(jd => { // NICHT SO wg. Vue: _messagelist = jd; + router.push('/home'); _messagelist.splice(0, _messagelist.length); _messagelist.push.apply(_messagelist, jd); //console.log("jd: "+jd); diff --git a/public/routes/createMessage.js b/public/routes/createMessage.js index 749bf25..e0739d0 100644 --- a/public/routes/createMessage.js +++ b/public/routes/createMessage.js @@ -1,9 +1,5 @@ var tagArray = []; -const data=[ - 'th', - 'efi', - 'wichtig', - ]; +const data=[]; const CreateMsgRouter = { template: `
@@ -90,12 +86,15 @@ const CreateMsgRouter = { $.ajax({url: "api/tag/ids",method: "GET"}) .done(jd => { // NICHT SO wg. Vue: _messagelist = jd; - _taglist.splice(0, _taglist.length); - _taglist.push.apply(_taglist, jd); - console.log("tag: jd: " + jd); - for (var e in jd) { - if (!_tags[jd[e]]) { - get_insert_tag(jd[e]); + console.log("DATA: "+data); + if(data == ""){ + _taglist.splice(0, _taglist.length); + _taglist.push.apply(_taglist, jd); + console.log("tag: jd: " + jd); + for (var e in jd) { + if (!_tags[jd[e]]) { + get_insert_tag(jd[e]); + } } } }).fail(function (e, f, g) { @@ -104,7 +103,7 @@ const CreateMsgRouter = { } }, mounted: function () { - this.list_tags(); + //this.list_tags(); if ($(this).bootstrapMaterialDesign) $(this).bootstrapMaterialDesign(); }, diff --git a/public/routes/files.js b/public/routes/files.js index 64e32d8..971db53 100644 --- a/public/routes/files.js +++ b/public/routes/files.js @@ -2,8 +2,10 @@ var tagArray = []; const FileRouter = { template: ` -
-

Erweiterte Suche

+
+
+

Erweiterte Suche

+
- SUCHE -
+
{ return option @@ -74,7 +73,6 @@ const FileRouter = { .toLowerCase() .indexOf(text.toLowerCase()) >= 0 }) - this.search(); }, list_tags: function () { $.ajax({ @@ -83,6 +81,7 @@ const FileRouter = { }) .done(jd => { // NICHT SO wg. Vue: _messagelist = jd; + if(data == ""){ _taglist.splice(0, _taglist.length); _taglist.push.apply(_taglist, jd); console.log("tag: jd: " + jd); @@ -91,6 +90,7 @@ const FileRouter = { get_insert_tag(jd[e]); } } + } }).fail(function (e, f, g) { console.log("err: " + e + f + g); }); @@ -101,6 +101,7 @@ const FileRouter = { }, search: function () { searching(this.searchtext); + this.isExtendedSearch=true; }, list_messages: function () { messages(); @@ -108,7 +109,7 @@ const FileRouter = { }, mounted: function () { //this.search(); - this.list_tags(); + //this.list_tags(); //this.list_messages(); }, }; diff --git a/server/dbs.js b/server/dbs.js index 069fc19..afa75e9 100644 --- a/server/dbs.js +++ b/server/dbs.js @@ -59,7 +59,7 @@ const dbs = { get: function(req, res) { model.Messages.find( {$text: {$search: req.params.phrase}}) - .sort({tag:1, user:1, message:1, subject:1}) + .sort({tag:-1}) .exec().then(results => { //selects id from message: var parsed = [];