Compare commits

..

No commits in common. "1f6261dba0ceb085e32d6974b7a5874602214b7b" and "57901853a9c77dd2b8abfe7bfe196f17086c02f1" have entirely different histories.

8 changed files with 45 additions and 46 deletions

View File

@ -101,7 +101,6 @@
</div> </div>
<script> <script>
new Vue({ new Vue({
router, router,
el: '#api', el: '#api',
@ -112,7 +111,6 @@
// Locally registered variables // Locally registered variables
auth: auth, auth: auth,
}, },
computed:{ computed:{
// Methods to change data appearance, does cache results // Methods to change data appearance, does cache results
}, },
@ -122,7 +120,6 @@
}); });
</script> </script>
<!-- NOTE: Call SW registration --> <!-- NOTE: Call SW registration -->
<script src="registerSW.js"></script> <script src="registerSW.js"></script>

View File

@ -1,4 +1,9 @@
var tagArray = []; var tagArray = [];
const data=[
'th',
'efi',
'wichtig',
];
const CreateMsgRouter = { const CreateMsgRouter = {
template: ` template: `
<div class="content"> <div class="content">
@ -17,12 +22,12 @@ const CreateMsgRouter = {
<b-taginput <b-taginput
id="tag" id="tag"
v-model="selected" v-model="selected"
:data="filteredDataArray" :data=taglist
autocomplete autocomplete
allow-new:false allow-new:false
icon="label" icon="label"
placeholder="#" placeholder="#"
@typing="getFilteredTags"
@input="saveTagsToArray"> @input="saveTagsToArray">
</b-taginput> </b-taginput>
</b-field> </b-field>
@ -51,12 +56,12 @@ const CreateMsgRouter = {
<b-taginput <b-taginput
id="tag" id="tag"
v-model="selected" v-model="selected"
:data="filteredDataArray" :data=taglist
autocomplete autocomplete
allow-new:false allow-new:false
icon="label" icon="label"
placeholder="#" placeholder="#"
@typing="getFilteredTags"
@input="saveTagsToArray"> @input="saveTagsToArray">
</b-taginput> </b-taginput>
</b-field> </b-field>
@ -76,20 +81,9 @@ const CreateMsgRouter = {
auth: auth, auth: auth,
isDisabled: false, isDisabled: false,
selected: [], selected: [],
searchtext : "",
taglist: data, taglist: data,
}; };
}, },
computed:{
filteredDataArray() {
return this.taglist.filter((option) => {
return option
.toString()
.toLowerCase()
.indexOf(this.searchtext.toLowerCase()) >= 0
})
}
},
methods: { methods: {
saveTagsToArray: function() { saveTagsToArray: function() {
tagArray = this.selected; tagArray = this.selected;
@ -134,15 +128,12 @@ const CreateMsgRouter = {
$.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;
console.log("DATA: "+data); _taglist.splice(0, _taglist.length);
if(data == ""){ _taglist.push.apply(_taglist, jd);
_taglist.splice(0, _taglist.length); console.log("tag: jd: " + jd);
_taglist.push.apply(_taglist, jd); for (var e in jd) {
console.log("tag: jd: " + jd); if (!_tags[jd[e]]) {
for (var e in jd) { get_insert_tag(jd[e]);
if (!_tags[jd[e]]) {
get_insert_tag(jd[e]);
}
} }
} }
}).fail(function (e, f, g) { }).fail(function (e, f, g) {
@ -163,9 +154,17 @@ const CreateMsgRouter = {
userField.prop('disabled',false); userField.prop('disabled',false);
} }
//this.list_tags(); this.list_tags();
if ($(this).bootstrapMaterialDesign) if ($(this).bootstrapMaterialDesign)
$(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);
})
}

View File

@ -23,16 +23,16 @@ const FileRouter = {
</b-field> </b-field>
<b-field v-if="selectedOptions=='tags'"> <b-field v-if="selectedOptions=='tags'">
<b-autocomplete v-model="searchtext" <b-autocomplete rounded v-model="searchtext"
:data="filteredDataArray" :data="filteredDataArray"
placeholder="#" icon="label" placeholder="suche..." icon="magnify"
@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" v-if="isExtendedSearch==true"> <div id="om-msg-cards">
<MsgCard <MsgCard
v-for="id in messagelist.slice().reverse()" v-for="id in messagelist.slice().reverse()"
:key="id" :key="id"
@ -88,7 +88,6 @@ const FileRouter = {
taglist: data, taglist: data,
messagelist: _messagelist, messagelist: _messagelist,
messages: _messages, messages: _messages,
isExtendedSearch: false,
} }
}, },
computed: { computed: {
@ -105,6 +104,10 @@ const FileRouter = {
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
@ -112,6 +115,7 @@ const FileRouter = {
.toLowerCase() .toLowerCase()
.indexOf(text.toLowerCase()) >= 0 .indexOf(text.toLowerCase()) >= 0
}) })
this.search();
}, },
list_tags: function () { list_tags: function () {
$.ajax({ $.ajax({
@ -120,7 +124,6 @@ const FileRouter = {
}) })
.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);
@ -129,7 +132,6 @@ const FileRouter = {
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);
}); });
@ -140,7 +142,6 @@ const FileRouter = {
}, },
search: function () { search: function () {
searching(this.searchtext); searching(this.searchtext);
this.isExtendedSearch=true;
}, },
list_messages: function () { list_messages: function () {
messages(); messages();
@ -148,7 +149,7 @@ const FileRouter = {
}, },
mounted: function () { mounted: function () {
//this.search(); //this.search();
//this.list_tags(); this.list_tags();
//this.list_messages(); //this.list_messages();
}, },
}; };

View File

@ -1,7 +1,11 @@
var isSearchActive = false, var isSearchActive = false,
tagArray = ["lorem"]; tagArray = ["lorem"];
const data=[], const dat=[
'th',
'efi',
'wichtig',
],
search_data = []; search_data = [];
Vue.component('search',{ Vue.component('search',{
@ -23,7 +27,7 @@ Vue.component('search',{
return{ return{
searchtext: "", searchtext: "",
selected: [], selected: [],
taglist: data, taglist: dat,
}; };
}, },
computed:{ computed:{
@ -38,7 +42,7 @@ Vue.component('search',{
}, },
methods: { methods: {
getFilteredTags(text) { getFilteredTags(text) {
this.taglist = data.filter((option) => { this.taglist = dat.filter((option) => {
return option return option
.toString() .toString()
.toLowerCase() .toLowerCase()
@ -60,7 +64,6 @@ Vue.component('search',{
$.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;
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);
@ -69,7 +72,6 @@ Vue.component('search',{
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);
}); });
@ -94,7 +96,7 @@ function get_insert_tag(id) {
url: "api/tag/id/" + id, url: "api/tag/id/" + id,
method: "GET" method: "GET"
}).done(function(tag) { }).done(function(tag) {
data.push("#" + tag.name); dat.push("#" + tag.name);
}).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);
}) })

View File

@ -59,7 +59,7 @@ const dbs = {
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}) .sort({tag:1, user:1, message:1, subject:1})
.exec().then(results => { .exec().then(results => {
//selects id from message: //selects id from message:
var parsed = []; var parsed = [];