From 5a4faca86fcd6ec68816a16509f83028d13164f2 Mon Sep 17 00:00:00 2001 From: senta_mandutz Date: Sun, 21 Jul 2019 14:12:16 +0200 Subject: [PATCH 1/3] 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 = []; From d003166e33b104d546bb0d03b8a54c19afe8fff3 Mon Sep 17 00:00:00 2001 From: senta_mandutz Date: Sun, 21 Jul 2019 14:22:37 +0200 Subject: [PATCH 2/3] merge conflict --- public/index.html | 414 +++++++-------------------------- public/routes/createMessage.js | 112 ++++++--- 2 files changed, 160 insertions(+), 366 deletions(-) diff --git a/public/index.html b/public/index.html index 280c350..d737f5b 100644 --- a/public/index.html +++ b/public/index.html @@ -1,82 +1,75 @@ - - + - - - - - - + OHM News + + + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + - - - - + + - - + + - - + - - - - - - + + - - - - - - - - - + + @@ -85,302 +78,53 @@ - - - + + - - OHM News + -
- - + + +
- +
- - - - - - - - function get_insert_tag(id) { - $.ajax({ - url: "api/tag/" + id, - method: "GET" - }).done(function(tag) { - data.push("#" + tag.name); - console.log("it worked!"); - }).fail(function(e, f, g) { - console.log("cannot load " + id + ".json: " + e + f + g); - }) - } - function searching(searchtext) { - isSearchActiv = true; - console.log("Searchtext: " + searchtext.replace(/#/g, '')); - $.ajax({ - url: "api/msg/search/" + searchtext.replace(/#/g, ''), - 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); - for (var e in jd) { - if (!_messages[jd[e]]) { - get_insert_message(jd[e]); - } - } - }).fail(function(e, f, g) { - console.log("searching: err: " + e + f + g); - }) - } - function messages() { - $.ajax({ - url: "api/msg/ids", - method: "GET" - }) - .done(jd => { - // NICHT SO wg. Vue: _messagelist = jd; - _messagelist.splice(0, _messagelist.length); - _messagelist.push.apply(_messagelist, jd); - //console.log("jd: "+jd); - for (var e in jd) { - if (!_messages[jd[e]]) { - get_insert_message(jd[e]); - } - } - }).fail(function(e, f, g) { - console.log("list_msg: err: " + e + f + g); - }); - } - - const search_data = []; - /* - export.default { - data: function () { - return { - selected: [], - taglist: data, - }; - }, - computed: { - filteredTagArray() { - this.taglist = data.filter((option) => { - return option - .toString() - .toLowerCase() - .indexOf(this.name.toLowerCase()) >= 0 - }) - }, - - }, - methods: { - evaluate(text) { - this.taglist = data.filter((option) => { - return option - .toString() - .toLowerCase() - .indexOf(text.toLowerCase()) >= 0 - }) - }, - }, - mounted: function () { - if ($(this).bootstrapMaterialDesign) - $(this).bootstrapMaterialDesign(); - }, - }; - */ - - - - - - - - - - - - - + + - diff --git a/public/routes/createMessage.js b/public/routes/createMessage.js index e0739d0..6a0c8da 100644 --- a/public/routes/createMessage.js +++ b/public/routes/createMessage.js @@ -2,42 +2,80 @@ var tagArray = []; const data=[]; const CreateMsgRouter = { template: ` -
-

Neue Nachricht erstellen

+
+
+
+

Neue Nachricht erstellen

+ + + - - - + + + - - - + + + + - - - - + + + - - - + ABBRECHEN + SENDEN +
+
- ABBRECHEN - SENDEN +
+
+

Neue Nachricht erstellen

+ + + + + + + + + + + + + + + + + + ABBRECHEN + SENDEN +
+
+
`, -
-`, data: function () { return { + auth: auth, + isDisabled: false, selected: [], taglist: data, }; @@ -51,7 +89,7 @@ const CreateMsgRouter = { var _subject = $("#subject").val(); var _message = $("#message").val(); var _tag = tagArray; - var _user = $("#user").val(); + var _user = auth.name ? auth.name : $("#user").val(); //console.log("Message Created: " + _tag + " " + _message + " " + _user); $.ajax({ url: "api/msg", @@ -103,14 +141,26 @@ const CreateMsgRouter = { } }, mounted: function () { - //this.list_tags(); + var userField = $('#user'); + if (auth != null && auth.mail != '') { +// userField.prop('placeholder',auth.name); + var authorName = auth.name.split(' '); + authorName = authorName[1] + ', ' + authorName[0]; + userField.val(authorName); + userField.prop('disabled',true); + } else { + userField.prop('placeholder','User'); + userField.prop('disabled',false); + } + + this.list_tags(); if ($(this).bootstrapMaterialDesign) $(this).bootstrapMaterialDesign(); }, }; function get_insert_tag(id){ - $.ajax({ url: "api/tag/"+id, method: "GET" }).done(function (tag) { + $.ajax({ url: "api/tag/id/"+id, method: "GET" }).done(function (tag) { data.push("#" + tag.name); console.log("Array:"+this.data); }).fail(function (e, f, g) { From 4aa5856fbc1649ac97f41534b720ddd598fbfdda Mon Sep 17 00:00:00 2001 From: senta_mandutz Date: Sun, 21 Jul 2019 15:24:40 +0200 Subject: [PATCH 3/3] fixed createMessage/ files Tag autocomplete --- public/routes/createMessage.js | 30 ++++++++++++++++-------------- public/search.js | 14 ++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/public/routes/createMessage.js b/public/routes/createMessage.js index 6a0c8da..8cb167a 100644 --- a/public/routes/createMessage.js +++ b/public/routes/createMessage.js @@ -1,5 +1,4 @@ var tagArray = []; -const data=[]; const CreateMsgRouter = { template: `
@@ -18,12 +17,12 @@ const CreateMsgRouter = { @@ -52,12 +51,12 @@ const CreateMsgRouter = { @@ -77,9 +76,20 @@ const CreateMsgRouter = { auth: auth, isDisabled: false, selected: [], + searchtext : "", taglist: data, }; }, + computed:{ + filteredDataArray() { + return this.taglist.filter((option) => { + return option + .toString() + .toLowerCase() + .indexOf(this.searchtext.toLowerCase()) >= 0 + }) + } + }, methods: { saveTagsToArray: function() { tagArray = this.selected; @@ -153,17 +163,9 @@ const CreateMsgRouter = { userField.prop('disabled',false); } - this.list_tags(); + //this.list_tags(); if ($(this).bootstrapMaterialDesign) $(this).bootstrapMaterialDesign(); }, }; -function get_insert_tag(id){ - $.ajax({ url: "api/tag/id/"+id, method: "GET" }).done(function (tag) { - data.push("#" + tag.name); - console.log("Array:"+this.data); - }).fail(function (e, f, g) { - console.log("cannot load " + id + ".json: " + e + f + g); - }) -} diff --git a/public/search.js b/public/search.js index dd86a98..9aba881 100644 --- a/public/search.js +++ b/public/search.js @@ -1,11 +1,7 @@ var isSearchActive = false, tagArray = ["lorem"]; -const dat=[ - 'th', - 'efi', - 'wichtig', - ], +const data=[], search_data = []; Vue.component('search',{ @@ -27,7 +23,7 @@ Vue.component('search',{ return{ searchtext: "", selected: [], - taglist: dat, + taglist: data, }; }, computed:{ @@ -42,7 +38,7 @@ Vue.component('search',{ }, methods: { getFilteredTags(text) { - this.taglist = dat.filter((option) => { + this.taglist = data.filter((option) => { return option .toString() .toLowerCase() @@ -64,6 +60,7 @@ Vue.component('search',{ $.ajax({url: "api/tag/ids", method: "GET"}) .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); @@ -72,6 +69,7 @@ Vue.component('search',{ get_insert_tag(jd[e]); } } + } }).fail(function (e, f, g) { console.log("err: " + e + f + g); }); @@ -96,7 +94,7 @@ function get_insert_tag(id) { url: "api/tag/id/" + id, method: "GET" }).done(function(tag) { - dat.push("#" + tag.name); + data.push("#" + tag.name); }).fail(function(e, f, g) { console.log("cannot load " + id + ".json: " + e + f + g); })