Browse Source

extended search

master
Senta Mandutz 4 years ago
parent
commit
5a4faca86f
4 changed files with 38 additions and 39 deletions
  1. 14
    15
      public/index.html
  2. 11
    12
      public/routes/createMessage.js
  3. 12
    11
      public/routes/files.js
  4. 1
    1
      server/dbs.js

+ 14
- 15
public/index.html View File

@@ -182,11 +182,6 @@
<script>
var isSearchActive = false;
var tagArray = ["lorem"];
const dat = [
'th',
'efi',
'wichtig',
];

</script>

@@ -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);

+ 11
- 12
public/routes/createMessage.js View File

@@ -1,9 +1,5 @@
var tagArray = [];
const data=[
'th',
'efi',
'wichtig',
];
const data=[];
const CreateMsgRouter = {
template: `
<div class="content card om-card">
@@ -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();
},

+ 12
- 11
public/routes/files.js View File

@@ -2,8 +2,10 @@ var tagArray = [];

const FileRouter = {
template: `
<div class="content">
<h4>Erweiterte Suche</h4>
<div>
<div class="content">
<h4 >Erweiterte Suche</h4>
</div>
<b-field label="Suche nach">
<b-select
placeholder="Wähle eine Suchform"
@@ -21,16 +23,16 @@ const FileRouter = {
</b-field>

<b-field v-if="selectedOptions=='tags'">
<b-autocomplete rounded v-model="searchtext"
<b-autocomplete v-model="searchtext"
:data="filteredDataArray"
placeholder="suche..." icon="magnify"
placeholder="#" icon="label"
@select="option => selected = option">
</b-autocomplete>
</b-field>

<b-button type="is-primary" @click="search">SUCHE</b-button>

<div id="om-msg-cards">
<div id="om-msg-cards" v-if="isExtendedSearch==true">
<MsgCard
v-for="id in messagelist.slice().reverse()"
:key="id"
@@ -47,6 +49,7 @@ const FileRouter = {
taglist: data,
messagelist: _messagelist,
messages: _messages,
isExtendedSearch: false,
}
},
computed: {
@@ -63,10 +66,6 @@ const FileRouter = {
list_messages: function () {
messages();
},
saveTagsToArray: function () {
tagArray = this.selected;
console.info(tagArray);
},
getFilteredTags(text) {
this.taglist = data.filter((option) => {
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();
},
};

+ 1
- 1
server/dbs.js View File

@@ -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 = [];

Loading…
Cancel
Save