Merge remote-tracking branch 'origin/developer' into developer

# Conflicts:
#	public/routes/createMessage.js
#	public/routes/files.js
This commit is contained in:
Edwina Barbalan 2019-07-22 16:51:34 +02:00
commit b62927c28d
8 changed files with 44 additions and 45 deletions

View File

@ -101,6 +101,7 @@
</div> </div>
<script> <script>
new Vue({ new Vue({
router, router,
el: '#api', el: '#api',
@ -111,6 +112,7 @@
// 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
}, },
@ -120,6 +122,7 @@
}); });
</script> </script>
<!-- NOTE: Call SW registration --> <!-- NOTE: Call SW registration -->
<script src="registerSW.js"></script> <script src="registerSW.js"></script>

View File

@ -1,9 +1,4 @@
var tagArray = []; var tagArray = [];
const data=[
'th',
'efi',
'wichtig',
];
const CreateMsgRouter = { const CreateMsgRouter = {
template: ` template: `
<div class="content"> <div class="content">
@ -22,12 +17,12 @@ const CreateMsgRouter = {
<b-taginput <b-taginput
id="tag" id="tag"
v-model="selected" v-model="selected"
:data=taglist :data="filteredDataArray"
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>
@ -47,9 +42,20 @@ 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;
@ -94,12 +100,15 @@ 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;
_taglist.splice(0, _taglist.length); console.log("DATA: "+data);
_taglist.push.apply(_taglist, jd); if(data == ""){
console.log("tag: jd: " + jd); _taglist.splice(0, _taglist.length);
for (var e in jd) { _taglist.push.apply(_taglist, jd);
if (!_tags[jd[e]]) { console.log("tag: jd: " + jd);
get_insert_tag(jd[e]); for (var e in jd) {
if (!_tags[jd[e]]) {
get_insert_tag(jd[e]);
}
} }
} }
}).fail(function (e, f, g) { }).fail(function (e, f, g) {
@ -120,17 +129,9 @@ 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

@ -3,7 +3,6 @@ var tagArray = [];
const FileRouter = { const FileRouter = {
template: ` template: `
<div class="content"> <div class="content">
<div class="column is-four-fifths-desktop pull-right-sm"> <div class="column is-four-fifths-desktop pull-right-sm">
<h4>Erweiterte Suche</h4> <h4>Erweiterte Suche</h4>
<b-field label="Suche nach"> <b-field label="Suche nach">
@ -23,16 +22,16 @@ const FileRouter = {
</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"
@ -40,7 +39,6 @@ const FileRouter = {
></MsgCard> ></MsgCard>
</div> </div>
</div> </div>
</div> </div>
`, `,
data: function () { data: function () {
@ -51,6 +49,7 @@ const FileRouter = {
taglist: data, taglist: data,
messagelist: _messagelist, messagelist: _messagelist,
messages: _messages, messages: _messages,
isExtendedSearch: false,
} }
}, },
computed: { computed: {
@ -67,10 +66,6 @@ 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
@ -78,7 +73,6 @@ const FileRouter = {
.toLowerCase() .toLowerCase()
.indexOf(text.toLowerCase()) >= 0 .indexOf(text.toLowerCase()) >= 0
}) })
this.search();
}, },
list_tags: function () { list_tags: function () {
$.ajax({ $.ajax({
@ -87,6 +81,7 @@ 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);
@ -95,6 +90,7 @@ 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);
}); });
@ -105,6 +101,7 @@ const FileRouter = {
}, },
search: function () { search: function () {
searching(this.searchtext); searching(this.searchtext);
this.isExtendedSearch=true;
}, },
list_messages: function () { list_messages: function () {
messages(); messages();
@ -112,7 +109,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,11 +1,7 @@
var isSearchActive = false, var isSearchActive = false,
tagArray = ["lorem"]; tagArray = ["lorem"];
const dat=[ const data=[],
'th',
'efi',
'wichtig',
],
search_data = []; search_data = [];
Vue.component('search',{ Vue.component('search',{
@ -27,7 +23,7 @@ Vue.component('search',{
return{ return{
searchtext: "", searchtext: "",
selected: [], selected: [],
taglist: dat, taglist: data,
}; };
}, },
computed:{ computed:{
@ -42,7 +38,7 @@ Vue.component('search',{
}, },
methods: { methods: {
getFilteredTags(text) { getFilteredTags(text) {
this.taglist = dat.filter((option) => { this.taglist = data.filter((option) => {
return option return option
.toString() .toString()
.toLowerCase() .toLowerCase()
@ -64,6 +60,7 @@ 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);
@ -72,6 +69,7 @@ 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);
}); });
@ -96,7 +94,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) {
dat.push("#" + tag.name); data.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, 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 = [];