@@ -97,10 +97,11 @@ | |||
<div class="om-header-container"> | |||
<div class="om-header"> | |||
<a class="logo-img" href="index.html"><img src="img/app_icon.png" width=45px height=45px></a> | |||
<form class="om-searchbar"> | |||
<form class="om-searchbar" @submit.prevent="search()"> | |||
<b-field> | |||
<b-input | |||
type="search" | |||
v-model="searchtext" | |||
icon="magnify" | |||
placeholder="Suche..."> | |||
</b-input> | |||
@@ -183,11 +184,39 @@ | |||
var app = new Vue({ | |||
router, | |||
el: '#api', | |||
data: { | |||
data: function() { | |||
return{ | |||
searchtext: "ipsum", | |||
}; | |||
}, | |||
methods: { | |||
} | |||
search: function() { | |||
console.log("Searchtext: " +this.searchtext); | |||
$.ajax({ | |||
url: "api/msg/search/" + this.searchtext, | |||
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("searching: err: " + e + f + g); | |||
}) | |||
} | |||
}, | |||
mounted: function () { | |||
//this.search(); | |||
}, | |||
}); | |||
const search_data = []; | |||
/* | |||
export.default { |
@@ -4,7 +4,7 @@ | |||
// Wait until page loaded | |||
window.addEventListener('load', () => { | |||
if ('serviceWorker' in navigator) { | |||
/*if ('serviceWorker' in navigator) { | |||
// NOTE: ServiceWorker Registration | |||
return navigator.serviceWorker.register('serviceWorker.js', { | |||
scope: '/' | |||
@@ -16,7 +16,7 @@ window.addEventListener('load', () => { | |||
} else { | |||
console.log('[ServiceWorker] are not supported.'); | |||
return; | |||
} | |||
}*/ | |||
}); | |||
// NOTE: Set Bootstrap materialdesign |
@@ -50,7 +50,28 @@ const dbs = { | |||
}); | |||
}, | |||
}, | |||
"msg/search": {}, | |||
"msg/search": { | |||
params: ":phrase", | |||
/* GET /api/msg/id/[massage-id] | |||
* -> Message schema | |||
* Get a particular message | |||
*/ | |||
get: function(req, res) { | |||
model.Messages.find({$text: {$search: req.params.phrase}}) | |||
.exec().then(results => { | |||
//selects id from message: | |||
var parsed = []; | |||
for (var i in results) { | |||
parsed.push (results[i]._id); | |||
} | |||
res.send(parsed); | |||
} ) | |||
.catch(err => { | |||
console.log (err); | |||
res.status(500).json(err); | |||
}); | |||
}, | |||
}, | |||
"msg": { | |||
/* POST /api/msg | |||
* <- Message schema | |||
@@ -163,7 +184,7 @@ const dbs = { | |||
_comment: "" }, | |||
//createtime: { type: Date, default: Date.now }, | |||
}); | |||
messageSchema.index({ tag:'text' }); | |||
messageSchema.index({ tag:'text', subject:'text', message:'text', user:'text' }); | |||
model.Messages = common.mongoose.model('messages', messageSchema); | |||
model.Messages._list = [ "" ]; | |||