diff --git a/message.model.js b/message.model.js deleted file mode 100644 index f914fb7..0000000 --- a/message.model.js +++ /dev/null @@ -1,15 +0,0 @@ -const mongoose = require('mongoose'); - -//const Schema = mongoose.Schema, -//ObjectId = Schema.ObjectId; - -const MessageSchema = mongoose.Schema({ - subject: { type: String, required: true }, - message: { type: String, required: true }, - user: { type: String, required: true }, - tag: [{type: String }], - //createtime: { type: Date, default: Date.now }, -}); -MessageSchema.index({tag:'text'}); - -module.exports = mongoose.model('Message', MessageSchema); diff --git a/mongodb.config.js.example b/mongodb.config.js.example deleted file mode 100644 index 36a4a1a..0000000 --- a/mongodb.config.js.example +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - url: 'mongodb://localhost:27017/mydb' -} diff --git a/public/index.html b/public/index.html index 50a68ea..cdb2bc2 100644 --- a/public/index.html +++ b/public/index.html @@ -58,8 +58,8 @@ - - + + @@ -84,6 +84,7 @@ + @@ -97,12 +98,36 @@
-
@@ -161,6 +186,12 @@
diff --git a/public/lib/vue.js b/public/lib/vue-2.6.10.js similarity index 100% rename from public/lib/vue.js rename to public/lib/vue-2.6.10.js diff --git a/public/lib/vue-router.js b/public/lib/vue-router-3.0.1.js similarity index 100% rename from public/lib/vue-router.js rename to public/lib/vue-router-3.0.1.js diff --git a/public/main.js b/public/main.js index 6cecedc..6c87b3a 100644 --- a/public/main.js +++ b/public/main.js @@ -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 diff --git a/public/routes/createMessage.js b/public/routes/createMessage.js index b59b7f5..749bf25 100644 --- a/public/routes/createMessage.js +++ b/public/routes/createMessage.js @@ -1,7 +1,8 @@ +var tagArray = []; const data=[ - '#th', - '#efi', - '#wichtig', + 'th', + 'efi', + 'wichtig', ]; const CreateMsgRouter = { template: ` @@ -18,13 +19,15 @@ const CreateMsgRouter = { + @typing="getFilteredTags" + @input="saveTagsToArray"> @@ -33,38 +36,41 @@ const CreateMsgRouter = { ABBRECHEN - SENDEN - - + SENDEN `, data: function () { return { selected: [], - items: data + taglist: data, }; }, methods: { + saveTagsToArray: function() { + tagArray = this.selected; + console.info(tagArray); + }, createMsg: function () { - var subject = $("#subject").val(); - var message = $("#message").val(); - var tag = $("#tag").val(); - var user = $("#user").val(); - console.log("Message Created: " + tag + " " + message + " " + user); + var _subject = $("#subject").val(); + var _message = $("#message").val(); + var _tag = tagArray; + var _user = $("#user").val(); + //console.log("Message Created: " + _tag + " " + _message + " " + _user); $.ajax({ - url: "api/createMsg", + url: "api/msg", data: { - sub: subject, - mess: message, - use: user, - ta: tag + subject: _subject, + message: _message, + user: _user, + tag: _tag }, method: "POST" }).done(have_result).fail(have_error); function have_result(res) { - console.log(res); + //console.log(res); + router.push('/home') } function have_error(err) { @@ -73,16 +79,42 @@ const CreateMsgRouter = { } }, getFilteredTags(text) { - this.items = data.filter((option) => { + this.taglist = data.filter((option) => { return option .toString() .toLowerCase() .indexOf(text.toLowerCase()) >= 0 }) - }, + }, + list_tags: function () { + $.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]); + } + } + }).fail(function (e, f, g) { + console.log("err: " + e + f + g); + }); + } }, mounted: function () { + this.list_tags(); if ($(this).bootstrapMaterialDesign) $(this).bootstrapMaterialDesign(); }, }; + +function get_insert_tag(id){ + $.ajax({ url: "api/tag/"+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); + }) +} diff --git a/public/routes/home.js b/public/routes/home.js index 630eeb6..d120b9f 100644 --- a/public/routes/home.js +++ b/public/routes/home.js @@ -24,12 +24,12 @@ const HomeRouter = { }); },*/ list_messages: function () { - $.ajax({url: "api/ids", method: "GET"}) + $.ajax({url: "api/msg/ids", method: "GET"}) .done(jd => { // NICHT SO wg. Vue: _messagelist = jd; _messagelist.splice(0, _messagelist.length); _messagelist.push.apply(_messagelist, jd); - console.log("jd: "+jd); + //console.log("jd: "+jd); for (var e in jd) { if (!_messages[jd[e]]) { get_insert_message(jd[e]); @@ -49,7 +49,7 @@ const HomeRouter = { } }*/ }).fail(function (e, f, g) { - console.log("err: " + e + f + g); + console.log("list_msg: err: " + e + f + g); }); } }, @@ -61,7 +61,7 @@ const HomeRouter = { }; function get_insert_message(id) { - $.ajax({ url: "api/msg/"+id, method: "GET" }).done(function (msg) { + $.ajax({ url: "api/msg/id/"+id, method: "GET" }).done(function (msg) { Vue.set(_messages, id, msg); }).fail(function (e, f, g) { console.log("cannot load " + id + ".json: " + e + f + g); diff --git a/public/routes/msgCard.js b/public/routes/msgCard.js index f3e398f..ffd77a0 100644 --- a/public/routes/msgCard.js +++ b/public/routes/msgCard.js @@ -5,7 +5,8 @@ Vue.component('MsgCard', { {{ msg.message }}

- {{ msg.tag }}

+ #{{ tag }} +