const mongoose = require('mongoose'); | const mongoose = require('mongoose'); | ||||
const MessageSchema = mongoose.Schema({ | const MessageSchema = mongoose.Schema({ | ||||
_id: String, | |||||
subject: { type: String, required: true }, | subject: { type: String, required: true }, | ||||
message: { type: String, required: true }, | message: { type: String, required: true }, | ||||
user: { type: String, required: true }, | user: { type: String, required: true }, |
}, | }, | ||||
"finalhandler": { | "finalhandler": { | ||||
"version": "1.1.1", | "version": "1.1.1", | ||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", | |||||
"resolved": "http://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", | |||||
"integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", | "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", | ||||
"requires": { | "requires": { | ||||
"debug": "2.6.9", | "debug": "2.6.9", | ||||
} | } | ||||
}, | }, | ||||
"mongoose": { | "mongoose": { | ||||
"version": "5.4.3", | |||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.4.3.tgz", | |||||
"integrity": "sha512-zhfypQm63CPYHi43O/3lTcEPVucY3h6CqONbzreMKZIEXtwgkB9HCm4wn441Z9/CpM94G6/NA3wcaRb0N2kPYQ==", | |||||
"version": "5.4.10", | |||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.4.10.tgz", | |||||
"integrity": "sha512-yJl+A7p8QF++tyBl6fRGFON5GV57MTXLKNiaiqgX5vZs1qJpcZpPiUGU5odBiqTHFYPybuRp8dW9Qtv4K6SxBQ==", | |||||
"requires": { | "requires": { | ||||
"async": "2.6.1", | "async": "2.6.1", | ||||
"bson": "~1.1.0", | "bson": "~1.1.0", | ||||
"kareem": "2.3.0", | "kareem": "2.3.0", | ||||
"mongodb": "3.1.10", | |||||
"mongodb-core": "3.1.9", | |||||
"mongodb": "3.1.13", | |||||
"mongodb-core": "3.1.11", | |||||
"mongoose-legacy-pluralize": "1.0.2", | "mongoose-legacy-pluralize": "1.0.2", | ||||
"mpath": "0.5.1", | "mpath": "0.5.1", | ||||
"mquery": "3.2.0", | "mquery": "3.2.0", | ||||
"regexp-clone": "0.0.1", | "regexp-clone": "0.0.1", | ||||
"safe-buffer": "5.1.2", | "safe-buffer": "5.1.2", | ||||
"sliced": "1.0.1" | "sliced": "1.0.1" | ||||
}, | |||||
"dependencies": { | |||||
"mongodb": { | |||||
"version": "3.1.13", | |||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.13.tgz", | |||||
"integrity": "sha512-sz2dhvBZQWf3LRNDhbd30KHVzdjZx9IKC0L+kSZ/gzYquCF5zPOgGqRz6sSCqYZtKP2ekB4nfLxhGtzGHnIKxA==", | |||||
"requires": { | |||||
"mongodb-core": "3.1.11", | |||||
"safe-buffer": "^5.1.2" | |||||
} | |||||
}, | |||||
"mongodb-core": { | |||||
"version": "3.1.11", | |||||
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.11.tgz", | |||||
"integrity": "sha512-rD2US2s5qk/ckbiiGFHeu+yKYDXdJ1G87F6CG3YdaZpzdOm5zpoAZd/EKbPmFO6cQZ+XVXBXBJ660sSI0gc6qg==", | |||||
"requires": { | |||||
"bson": "^1.1.0", | |||||
"require_optional": "^1.0.1", | |||||
"safe-buffer": "^5.1.2", | |||||
"saslprep": "^1.0.0" | |||||
} | |||||
} | |||||
} | } | ||||
}, | }, | ||||
"mongoose-legacy-pluralize": { | "mongoose-legacy-pluralize": { |
"express": "^4.16.4", | "express": "^4.16.4", | ||||
"express-session": "^1.15.6", | "express-session": "^1.15.6", | ||||
"mongodb": "^3.1.10", | "mongodb": "^3.1.10", | ||||
"mongoose": "^5.4.3", | |||||
"mongoose": "^5.4.10", | |||||
"morgan": "^1.9.1", | "morgan": "^1.9.1", | ||||
"vue": "^2.5.17", | "vue": "^2.5.17", | ||||
"vue-router": "^3.0.2" | "vue-router": "^3.0.2" |
template: ` | template: ` | ||||
<div class="card om-card"> | <div class="card om-card"> | ||||
<h5>Neue Nachricht erstellen</h5> | <h5>Neue Nachricht erstellen</h5> | ||||
<form class="new-msg-form" action="#" methord="GET"> | |||||
<form class="new-msg-form" @submit.prevent=createMsg> | |||||
<div class="form-group bmd-form-group"> | <div class="form-group bmd-form-group"> | ||||
<label class="bmd-label-floating">Betreff</label> | <label class="bmd-label-floating">Betreff</label> | ||||
<input type="text" class="form-control" id="subject"> | <input type="text" class="form-control" id="subject"> | ||||
</div> | </div> | ||||
<div class="form-group bmd-form-group"> | <div class="form-group bmd-form-group"> | ||||
<label class="bmd-label-floating">Tags</label> | <label class="bmd-label-floating">Tags</label> | ||||
<input type="text" class="form-control" id="hashtags"> | |||||
<input type="text" class="form-control" id="tag"> | |||||
</div> | </div> | ||||
<div class="form-group"> | <div class="form-group"> | ||||
<label class="bmd-label-floating">Nachricht</label> | <label class="bmd-label-floating">Nachricht</label> | ||||
<textarea class="form-control" id="message" rows="5"></textarea> | <textarea class="form-control" id="message" rows="5"></textarea> | ||||
</div> | </div> | ||||
<div class="form-group"> | |||||
<label class="bmd-label-floating">User</label> | |||||
<textarea class="form-control" id="user"></textarea> | |||||
</div> | |||||
<div class="form-group"> | <div class="form-group"> | ||||
<div class="checkbox"> | <div class="checkbox"> | ||||
<label> | <label> | ||||
return {}; | return {}; | ||||
}, | }, | ||||
methods: { | methods: { | ||||
createMsg: function() { | |||||
var subject=$("#subject").val(); | |||||
var message=$("#message").val(); | |||||
var tag=$("#tag").val(); | |||||
var user=$("#user").val(); | |||||
console.log ("Message Created: "+id+" "+tag+" "+message+" "+user); | |||||
$.ajax ({ url: "/api/createMsg", data: {subject: subject, tag: tag, message: message, user: user}, method: "POST" }) .done (have_result) .fail (have_error); | |||||
function have_result (res) { | |||||
console.log (res); | |||||
} | |||||
function have_error (err) { | |||||
console.log ("error:" + err.responseText); | |||||
console.log (err); | |||||
} | |||||
}, | |||||
}, | }, | ||||
mounted: function() { | mounted: function() { | ||||
if ($(this).bootstrapMaterialDesign) | if ($(this).bootstrapMaterialDesign) |