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

<script> <script>
var isSearchActive = false; var isSearchActive = false;
var tagArray = ["lorem"]; var tagArray = ["lorem"];
const dat = [
'th',
'efi',
'wichtig',
];


</script> </script>


searchtext: "", searchtext: "",
//isSearchActiv: false, //isSearchActiv: false,
selected: [], selected: [],
taglist: dat,
taglist: data,
}; };
}, },
computed: { computed: {
methods: { methods: {


getFilteredTags(text) { getFilteredTags(text) {
this.taglist = dat.filter((option) => {
this.taglist = data.filter((option) => {
return option return option
.toString() .toString()
.toLowerCase() .toLowerCase()
console.info(tagArray); console.info(tagArray);
}, },
search: function() { search: function() {
searching(this.searchtext);

searching(this.searchtext);
}, },
list_messages: function() { list_messages: function() {
messages(); messages();
}) })
.done(jd => { .done(jd => {
// NICHT SO wg. Vue: _messagelist = 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) { }).fail(function(e, f, g) {
url: "api/tag/" + id, url: "api/tag/" + id,
method: "GET" method: "GET"
}).done(function(tag) { }).done(function(tag) {
dat.push("#" + tag.name);
data.push("#" + tag.name);
console.log("it worked!"); console.log("it worked!");
}).fail(function(e, f, g) { }).fail(function(e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g); console.log("cannot load " + id + ".json: " + e + f + g);
method: "GET" method: "GET"
}).done(jd => { }).done(jd => {
// NICHT SO wg. Vue: _messagelist = jd; // NICHT SO wg. Vue: _messagelist = jd;
router.push('/home');
_messagelist.splice(0, _messagelist.length); _messagelist.splice(0, _messagelist.length);
_messagelist.push.apply(_messagelist, jd); _messagelist.push.apply(_messagelist, jd);
//console.log("jd: "+jd); //console.log("jd: "+jd);

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

var tagArray = []; var tagArray = [];
const data=[
'th',
'efi',
'wichtig',
];
const data=[];
const CreateMsgRouter = { const CreateMsgRouter = {
template: ` template: `
<div class="content card om-card"> <div class="content card om-card">
$.ajax({url: "api/tag/ids",method: "GET"}) $.ajax({url: "api/tag/ids",method: "GET"})
.done(jd => { .done(jd => {
// NICHT SO wg. Vue: _messagelist = 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) { }).fail(function (e, f, g) {
} }
}, },
mounted: function () { mounted: function () {
this.list_tags();
//this.list_tags();
if ($(this).bootstrapMaterialDesign) if ($(this).bootstrapMaterialDesign)
$(this).bootstrapMaterialDesign(); $(this).bootstrapMaterialDesign();
}, },

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



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


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


<b-button type="is-primary" @click="search">SUCHE</b-button> <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 <MsgCard
v-for="id in messagelist.slice().reverse()" v-for="id in messagelist.slice().reverse()"
:key="id" :key="id"
taglist: data, taglist: data,
messagelist: _messagelist, messagelist: _messagelist,
messages: _messages, messages: _messages,
isExtendedSearch: false,
} }
}, },
computed: { computed: {
list_messages: function () { list_messages: function () {
messages(); messages();
}, },
saveTagsToArray: function () {
tagArray = this.selected;
console.info(tagArray);
},
getFilteredTags(text) { getFilteredTags(text) {
this.taglist = data.filter((option) => { this.taglist = data.filter((option) => {
return option return option
.toLowerCase() .toLowerCase()
.indexOf(text.toLowerCase()) >= 0 .indexOf(text.toLowerCase()) >= 0
}) })
this.search();
}, },
list_tags: function () { list_tags: function () {
$.ajax({ $.ajax({
}) })
.done(jd => { .done(jd => {
// NICHT SO wg. Vue: _messagelist = jd; // NICHT SO wg. Vue: _messagelist = jd;
if(data == ""){
_taglist.splice(0, _taglist.length); _taglist.splice(0, _taglist.length);
_taglist.push.apply(_taglist, jd); _taglist.push.apply(_taglist, jd);
console.log("tag: jd: " + jd); console.log("tag: jd: " + jd);
get_insert_tag(jd[e]); get_insert_tag(jd[e]);
} }
} }
}
}).fail(function (e, f, g) { }).fail(function (e, f, g) {
console.log("err: " + e + f + g); console.log("err: " + e + f + g);
}); });
}, },
search: function () { search: function () {
searching(this.searchtext); searching(this.searchtext);
this.isExtendedSearch=true;
}, },
list_messages: function () { list_messages: function () {
messages(); messages();
}, },
mounted: function () { mounted: function () {
//this.search(); //this.search();
this.list_tags();
//this.list_tags();
//this.list_messages(); //this.list_messages();
}, },
}; };

+ 1
- 1
server/dbs.js View File

get: function(req, res) { get: function(req, res) {
model.Messages.find( model.Messages.find(
{$text: {$search: req.params.phrase}}) {$text: {$search: req.params.phrase}})
.sort({tag:1, user:1, message:1, subject:1})
.sort({tag:-1})
.exec().then(results => { .exec().then(results => {
//selects id from message: //selects id from message:
var parsed = []; var parsed = [];

Loading…
Cancel
Save