Compare commits
26
Commits
57901853a9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a69bbcaf7 | ||
|
|
577f041928 | ||
|
|
285249254a | ||
|
|
9f9d3c1480 | ||
|
|
9a16ed0480 | ||
|
|
ce740b61ec | ||
|
|
499f0764da | ||
|
|
bac8786ab4 | ||
|
|
6529b1d937 | ||
|
|
2d4850520d | ||
|
|
b1d0a0f095 | ||
|
|
ae5360386a | ||
|
|
85bca37a8c | ||
|
|
a6dd34cf81 | ||
|
|
9eaf71ec3d | ||
|
|
6eb741760f | ||
|
|
3550f1558b | ||
|
|
b62927c28d | ||
|
|
0f06d8fcd7 | ||
|
|
613041d5cb | ||
|
|
783938821c | ||
|
|
1f6261dba0 | ||
|
|
4aa5856fbc | ||
|
|
d003166e33 | ||
|
|
0097de5122 | ||
|
|
5a4faca86f |
No files matched your search
@@ -1,13 +1,16 @@
|
|||||||
var db = db.getSiblingDB('omdb');
|
var db = db.getSiblingDB('omdb');
|
||||||
|
|
||||||
|
// Delete all collections + all records
|
||||||
|
db.messages.deleteMany({});
|
||||||
|
db.tags.deleteMany({});
|
||||||
|
db.users.deleteMany({});
|
||||||
|
db.sessions.deleteMany({});
|
||||||
|
|
||||||
// Insert data in collections
|
// Insert data in collections
|
||||||
load('mong_msg.js');
|
load('mong_msg.js');
|
||||||
load('mong_tag.js');
|
load('mong_tag.js');
|
||||||
load('mong_usr.js');
|
load('mong_usr.js');
|
||||||
|
|
||||||
// Delete all collections + all records
|
|
||||||
//db.messages.drop(); db.tags.drop(); db.user.drop(); db.sessions.drop()
|
|
||||||
|
|
||||||
// Print all collections + records count
|
// Print all collections + records count
|
||||||
var collections = db.getCollectionNames();
|
var collections = db.getCollectionNames();
|
||||||
print('Collections inside the db:');
|
print('Collections inside the db:');
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
db.tags.insert([
|
db.tags.insert([
|
||||||
{"name":"Lorem"},{"name":"fugiat"},{"name":"aliqua"},{"name":"consequat"},{"name":"mollit"},{"name":"aet"},{"name":"consectetur"},{"name":"dolore"},{"name":"nulla"},{"name":"tempor"},{"name":"veniam"},{"name":"ipsum"},{"name":"adipisicing"},{"name":"qui"},{"name":"sint"},{"name":"ullamco"},{"name":"incididunt"},{"name":"nisi"},{"name":"sit"},{"name":"minim"},{"name":"labore"},{"name":"sunt"},{"name":"in"}
|
{"name":"efi"},{"name":"wichtig"},{"name":"Wintersemester19/20"},{"name":"Rückmeldung"},{"name":"bme6"},{"name":"Mkz"},{"name":"Freizeit"},{"name":"Prüfungsanmeldung"},{"name":"THNürnberg"},{"name":"Prüfung"},{"name":"Stundenplan"}
|
||||||
])
|
])
|
||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
db.user.insert([
|
db.users.insert([
|
||||||
// author,OHMNEWS2019
|
// User: author, Pwd: author
|
||||||
{"_id":"author","name":"Test Author","type":"author","roles":["user","author"],"hash":"sha256","salt":"cy5CkPrplcEze6o4psURhw==","pwd":"Gc8ozlxjEGITkS+fW9tz2xLROzws44s04EOCWuP04qE=","tags":["wichtig","th"],"bookmarks":["th"],},
|
{"_id":"author","name":"Author","type":"MA@EFI;","roles":'{"user":true,"author":true}',"hash":"sha256","salt":"SIzKNsNKsCRVr8a9U90q6A==","pwd":"HZly68TSAKHioz6Kz0QCbXVTHpT6hMmabUbFYVlCMeE=","abos":["nulla","tempor","veniam","ipsum"],"bookmarks":[],},
|
||||||
// admin,oZuse1
|
// User: admin, Pwd: SwenMho
|
||||||
{"_id":"admin","name":"Test Admin","type":"admin","roles":["user","author","admin"],"hash":"sha256","salt":"PoIUHbDp7tP34ji31iQ0zw==","pwd":"mJpIfIksYs6LJJwYRBemFKqR6TacsSl2E0ZtpO1GMuk=","tags":["wichtig","th"],"bookmarks":["wichtig"],},
|
{"_id":"admin","name":"Test Admin","type":"MA@AMP;","roles":'{"user":true,"author":true,"admin":true}',"hash":"sha256","salt":"z3PNXGmQaWvaT7m2ZlT+0w==","pwd":"nfUfNv032J745xj3Hzya3Mkk43Dz/H0BmNTZhtx8UM0=","abos":["veniam","ipsum"],"bookmarks":[],},
|
||||||
])
|
])
|
||||||
|
|
||||||
//var c = require('./server/crypto.js'),
|
//var c = require('./server/crypto.js'),
|
||||||
|
|||||||
+6
-16
@@ -69,6 +69,7 @@
|
|||||||
<script src="lib/jquery-3.3.1.min.js"></script>
|
<script src="lib/jquery-3.3.1.min.js"></script>
|
||||||
|
|
||||||
<!-- NOTE: Include .js Routes -->
|
<!-- NOTE: Include .js Routes -->
|
||||||
|
<script src="routes/initGlobals.js"></script>
|
||||||
<script src="routes/auth.js"></script><!-- Must load before profile.js -->
|
<script src="routes/auth.js"></script><!-- Must load before profile.js -->
|
||||||
<script src="routes/home.js"></script>
|
<script src="routes/home.js"></script>
|
||||||
<script src="routes/files.js"></script>
|
<script src="routes/files.js"></script>
|
||||||
@@ -76,9 +77,6 @@
|
|||||||
<script src="routes/bookmark.js"></script>
|
<script src="routes/bookmark.js"></script>
|
||||||
<script src="routes/profil.js"></script>
|
<script src="routes/profil.js"></script>
|
||||||
<script src="routes/msgCard.js"></script>
|
<script src="routes/msgCard.js"></script>
|
||||||
<script src="routes/messageData.js"></script>
|
|
||||||
<script src="routes/tagData.js"></script>
|
|
||||||
<script src="routes/majorData.js"></script>
|
|
||||||
<script src="routes/profilCard.js"></script>
|
<script src="routes/profilCard.js"></script>
|
||||||
<script src="routes/navRoutes.js"></script>
|
<script src="routes/navRoutes.js"></script>
|
||||||
<script src="search.js"></script>
|
<script src="search.js"></script>
|
||||||
@@ -89,14 +87,14 @@
|
|||||||
<div class="om-header">
|
<div class="om-header">
|
||||||
<a class="logo-img is-hidden-desktop" href="index.html"><img src="img/app_icon.png" width=45px height=45px></a>
|
<a class="logo-img is-hidden-desktop" href="index.html"><img src="img/app_icon.png" width=45px height=45px></a>
|
||||||
<a class="logo-img is-hidden-touch" href="index.html"><img src="img/app_icon_desk.png" width=100px height=100px></a>
|
<a class="logo-img is-hidden-touch" href="index.html"><img src="img/app_icon_desk.png" width=100px height=100px></a>
|
||||||
<search></search>
|
<search :key="vueRender.search"></search>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="om-content">
|
<div class="om-content">
|
||||||
<div id=xxx></div>
|
<div id=xxx></div>
|
||||||
<nav-router></nav-router>
|
<nav-router :key="auth.user"></nav-router>
|
||||||
<router-view :key="auth.user"></router-view>
|
<router-view :key="vueRender.key"></router-view>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -104,22 +102,14 @@
|
|||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
el: '#api',
|
el: '#api',
|
||||||
components: {
|
|
||||||
// Locally registered components
|
|
||||||
},
|
|
||||||
data: {
|
data: {
|
||||||
// Locally registered variables
|
vueRender : vueRender,
|
||||||
auth: auth,
|
auth: auth,
|
||||||
},
|
},
|
||||||
computed:{
|
|
||||||
// Methods to change data appearance, does cache results
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// Methods to change data content, run always again
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- NOTE: Call SW registration -->
|
<!-- NOTE: Call SW registration -->
|
||||||
<script src="registerSW.js"></script>
|
<script src="registerSW.js"></script>
|
||||||
|
|
||||||
|
|||||||
@@ -4148,7 +4148,7 @@ a.list-item {
|
|||||||
font-size: 1.5rem; }
|
font-size: 1.5rem; }
|
||||||
|
|
||||||
.menu-list {
|
.menu-list {
|
||||||
line-height: 1.25;
|
line-height: 1.5;
|
||||||
float: left;
|
float: left;
|
||||||
width: 230px;
|
width: 230px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -4161,6 +4161,7 @@ a.list-item {
|
|||||||
color: white; }
|
color: white; }
|
||||||
.menu-list a {
|
.menu-list a {
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
|
padding-bottom: 5px;
|
||||||
display: block;
|
display: block;
|
||||||
padding: 0.5em 0.75em;
|
padding: 0.5em 0.75em;
|
||||||
background-color: #0046a0;
|
background-color: #0046a0;
|
||||||
@@ -4176,9 +4177,8 @@ a.list-item {
|
|||||||
margin: 0.75em;
|
margin: 0.75em;
|
||||||
padding-left: 0.75em;
|
padding-left: 0.75em;
|
||||||
background-color: #0046a0; }
|
background-color: #0046a0; }
|
||||||
.menu-item li a {
|
.menu-item li {
|
||||||
display: block;
|
line-height: 1.5;
|
||||||
padding: 8px 16px;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-16
@@ -1,12 +1,12 @@
|
|||||||
var auth = {};
|
|
||||||
|
|
||||||
function clearAuthState() {
|
function clearAuthState() {
|
||||||
auth.user = ''; // Login name
|
auth.user = ''; // Login name
|
||||||
auth.name = ''; // Full name
|
auth.name = ''; // Full name
|
||||||
auth.type = ''; // type of login (domain specific)
|
|
||||||
auth.mail = ''; // Full mail address
|
auth.mail = ''; // Full mail address
|
||||||
|
auth.type = ''; // type of login (domain specific)
|
||||||
auth.roles = {}; // Role authorizations e.g. {user: true}
|
auth.roles = {}; // Role authorizations e.g. {user: true}
|
||||||
auth.gender = ''; // Gender (e.g. Frau)
|
auth.gender = ''; // Gender (e.g. Frau)
|
||||||
|
auth.abos = []; // Followed tags
|
||||||
|
auth.bookmarks = []; // Ids of bookmarks
|
||||||
}
|
}
|
||||||
clearAuthState();
|
clearAuthState();
|
||||||
|
|
||||||
@@ -20,6 +20,33 @@ function fillAuthState(state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateUserInDB() {
|
||||||
|
$.ajax({
|
||||||
|
url: "api/usr",
|
||||||
|
data: {
|
||||||
|
_id: auth.user,
|
||||||
|
name: auth.name,
|
||||||
|
mail: auth.mail,
|
||||||
|
type: auth.type,
|
||||||
|
gender: auth.gender,
|
||||||
|
roles: JSON.stringify(auth.roles),
|
||||||
|
abos: JSON.stringify(auth.abos),
|
||||||
|
bookmarks: JSON.stringify(auth.bookmarks),
|
||||||
|
},
|
||||||
|
method: "PUT"
|
||||||
|
}).done(successful_save).fail(failed_save);
|
||||||
|
|
||||||
|
function successful_save(res) {
|
||||||
|
console.info("User-save: Successful.");
|
||||||
|
console.info(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
function failed_save(err) {
|
||||||
|
console.info("User-save: Failed.");
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Login component: Login panel (if not logged in) or Logout element (if logged in)
|
// Login component: Login panel (if not logged in) or Logout element (if logged in)
|
||||||
Vue.component('login-panel', {
|
Vue.component('login-panel', {
|
||||||
template: `
|
template: `
|
||||||
@@ -48,7 +75,7 @@ Vue.component('login-panel', {
|
|||||||
</b-input>
|
</b-input>
|
||||||
</b-field>
|
</b-field>
|
||||||
<b-checkbox>Eingeloggt bleiben</b-checkbox>
|
<b-checkbox>Eingeloggt bleiben</b-checkbox>
|
||||||
<div v-if="error" style="color:red;"> Versuche es nochmal.</div>
|
<div v-if="error" :key="error" style="color:red;"> Versuche es nochmal.</div>
|
||||||
</section>
|
</section>
|
||||||
<footer class="modal-card-foot">
|
<footer class="modal-card-foot">
|
||||||
<button class="button" type="button" @click.prevent="$parent.close()">Close</button>
|
<button class="button" type="button" @click.prevent="$parent.close()">Close</button>
|
||||||
@@ -57,16 +84,16 @@ Vue.component('login-panel', {
|
|||||||
</div>`,
|
</div>`,
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
auth: auth,
|
|
||||||
user: '',
|
user: '',
|
||||||
pwd: '',
|
pwd: '',
|
||||||
error: false,
|
error: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// TODO: Check if enough for session cookie re-login; checkbox
|
// TODO: Check if enough for session cookie re-login; checkbox
|
||||||
// mounted: function() {
|
// Doesn't work
|
||||||
// this.checkData();
|
beforeMount: function() {
|
||||||
// },
|
this.checkData();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeLoginPanel: function() {
|
closeLoginPanel: function() {
|
||||||
this.$emit('close-login-panel');
|
this.$emit('close-login-panel');
|
||||||
@@ -94,6 +121,9 @@ Vue.component('login-panel', {
|
|||||||
|
|
||||||
function successful_login(resData) {
|
function successful_login(resData) {
|
||||||
fillAuthState(resData);
|
fillAuthState(resData);
|
||||||
|
// updateUserInDB();
|
||||||
|
auth.abos = [];
|
||||||
|
auth.bookmarks = [];
|
||||||
console.info("Correct credentials");
|
console.info("Correct credentials");
|
||||||
this.closeLoginPanel;
|
this.closeLoginPanel;
|
||||||
|
|
||||||
@@ -103,7 +133,7 @@ Vue.component('login-panel', {
|
|||||||
|
|
||||||
function failed_login(err) {
|
function failed_login(err) {
|
||||||
console.info("Wrong credentials");
|
console.info("Wrong credentials");
|
||||||
this.showError=true;
|
this.error=true;
|
||||||
this.showLoginPanel;
|
this.showLoginPanel;
|
||||||
|
|
||||||
console.log("error: " + err.responseText);
|
console.log("error: " + err.responseText);
|
||||||
@@ -122,6 +152,7 @@ Vue.component('login-panel', {
|
|||||||
function successful_login(res) {
|
function successful_login(res) {
|
||||||
console.info("Re-Auth: Correct credentials");
|
console.info("Re-Auth: Correct credentials");
|
||||||
this.closeLoginPanel;
|
this.closeLoginPanel;
|
||||||
|
vueForceRender('key');
|
||||||
|
|
||||||
//console.log(res);
|
//console.log(res);
|
||||||
router.push('/home')
|
router.push('/home')
|
||||||
@@ -129,17 +160,11 @@ Vue.component('login-panel', {
|
|||||||
|
|
||||||
function failed_login(err) {
|
function failed_login(err) {
|
||||||
console.info("Re-Auth: Wrong credentials");
|
console.info("Re-Auth: Wrong credentials");
|
||||||
this.showError=true;
|
this.error=true;
|
||||||
this.showLoginPanel;
|
this.showLoginPanel;
|
||||||
|
|
||||||
console.log("error: " + err.responseText);
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout: function() {
|
|
||||||
clearAuthState();
|
|
||||||
$.ajax({ url: "api/logout", method: "POST" });
|
|
||||||
this.closeLoginPanel;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
+69
-104
@@ -1,120 +1,85 @@
|
|||||||
const BookmarkRouter = {
|
const BookmarkRouter = {
|
||||||
template: `
|
template: `
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="is-hidden-desktop">
|
<div id="om-msg-cards" class="column pull-right-sm is-four-fifths-desktop">
|
||||||
<div class="bookmark-headline"><h4>Gepeicherte Beiträge</h4></div>
|
<h3>Gespeicherte Nachrichten </h3>
|
||||||
<div class="om-card card">
|
<MsgCard
|
||||||
<h6 class="msg-head">
|
v-for="id in msgDisplay"
|
||||||
<b>Betreff</b>
|
:key="id"
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
:msg="messages[id] || {}"
|
||||||
</h6>
|
:isBookmark="bookmarkArray[id]"
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. <br><br>
|
></MsgCard>
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 1
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="om-card card">
|
|
||||||
<h6 class="msg-head">
|
|
||||||
<b>Betreff</b>
|
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
|
||||||
</h6>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. <br><br>
|
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 2
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="om-card card">
|
|
||||||
<h6 class="msg-head">
|
|
||||||
<b>Betreff</b>
|
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
|
||||||
</h6>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. <br><br>
|
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 3
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
|
|
||||||
<div class="bookmark-headline"><h4>Gepeicherte Beiträge</h4></div>
|
|
||||||
<div class="om-card card">
|
|
||||||
<h6 class="msg-head">
|
|
||||||
<b>Betreff</b>
|
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
|
||||||
</h6>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. <br><br>
|
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 1
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="om-card card">
|
|
||||||
<h6 class="msg-head">
|
|
||||||
<b>Betreff</b>
|
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
|
||||||
</h6>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. <br><br>
|
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 2
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="om-card card">
|
|
||||||
<h6 class="msg-head">
|
|
||||||
<b>Betreff</b>
|
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
|
||||||
</h6>
|
|
||||||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. <br><br>
|
|
||||||
<a href="#">#beispiel #tag</a>
|
|
||||||
<div class="om-card-footer">
|
|
||||||
<div class="om-user-line">
|
|
||||||
<i class="material-icons">account_circle</i>
|
|
||||||
Erstellt von User 3
|
|
||||||
</div>
|
|
||||||
<i class="material-icons" @click="myFilter" v-if="!isActive">bookmark_border</i>
|
|
||||||
<i class="material-icons" @click="myFilter" v-else="isActive">bookmark</i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
messagelist: _messagelist,
|
||||||
messages: _messages,
|
messages: _messages,
|
||||||
isActive: false,
|
isActive: true,
|
||||||
|
messageId: '',
|
||||||
|
bookmarkArray: auth.bookmarks,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
msgDisplay: function(){
|
||||||
|
return (this.messagelist.slice().reverse());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
myFilter () {
|
myFilter: function() {
|
||||||
this.isActive = !this.isActive;
|
this.isActive = !this.isActive;
|
||||||
|
},
|
||||||
|
getMessageId: function(){
|
||||||
|
|
||||||
|
},
|
||||||
|
getMessages: function(){
|
||||||
|
var arr = auth.bookmarks;
|
||||||
|
console.log("arr: "+arr+" auth.bookmarks: "+auth.bookmarks);
|
||||||
|
_messagelist.splice(0, _messagelist.length);
|
||||||
|
_messagelist.push.apply(_messagelist, arr);
|
||||||
|
for (var e in arr) {
|
||||||
|
if (!_messages[arr[e]]) {
|
||||||
|
//arr[e] =arr[e].replace(/\[/g, '').replace(/\"/g, '').replace(/\]/g, '')
|
||||||
|
console.log("getinsertmessage: "+ arr[e]);
|
||||||
|
get_insert_message(arr[e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*var _usrid = auth.user;
|
||||||
|
$.ajax({
|
||||||
|
url: "api/usr/id/" + _usrid,
|
||||||
|
method: "GET"
|
||||||
|
})
|
||||||
|
.done(have_result).fail(have_error);
|
||||||
|
|
||||||
|
function have_result(res) {
|
||||||
|
var str = JSON.stringify(res[0].bookmarks).split(",");
|
||||||
|
_messagelist.splice(0, _messagelist.length);
|
||||||
|
for (var e in str) {
|
||||||
|
if (!_messages[str[e]]) {
|
||||||
|
str[e] =str[e].replace(/\[/g, '').replace(/\"/g, '').replace(/\]/g, '')
|
||||||
|
get_insert_message(str[e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_messagelist.push.apply(_messagelist, str);
|
||||||
|
//console.log("bookmark str: "+str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function have_error(err) {
|
||||||
|
console.log("error: " + err.responseText);
|
||||||
|
console.log(err);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeMount: function(){
|
||||||
|
|
||||||
|
},
|
||||||
|
mounted: function (){
|
||||||
|
this.getMessages();
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
var tagArray = [];
|
|
||||||
const data=[
|
|
||||||
'th',
|
|
||||||
'efi',
|
|
||||||
'wichtig',
|
|
||||||
];
|
|
||||||
const CreateMsgRouter = {
|
const CreateMsgRouter = {
|
||||||
template: `
|
template: `
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="is-hidden-desktop">
|
<div class="column pull-right-sm is-four-fifths-desktop">
|
||||||
<div id="mobile" class="content card om-card">
|
<div id="mobile" class="om-card card">
|
||||||
<h4>Neue Nachricht erstellen</h4>
|
<h4>Neue Nachricht erstellen</h4>
|
||||||
<b-field>
|
<!--<b-field>
|
||||||
<b-input placeholder="User" id="user"></b-input>
|
<b-input placeholder="User" id="user"></b-input>
|
||||||
</b-field>
|
</b-field>-->
|
||||||
|
|
||||||
|
<label class="label">{{ userName }}</label>
|
||||||
<b-field>
|
<b-field>
|
||||||
<b-input placeholder="Betreff" id="subject"></b-input>
|
<b-input placeholder="Betreff" id="subject"></b-input>
|
||||||
</b-field>
|
</b-field>
|
||||||
@@ -22,46 +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">
|
|
||||||
</b-taginput>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-field>
|
|
||||||
<b-input placeholder="Nachricht" id="message" type="textarea"></b-input>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-button @click="$router.go(-1)">ABBRECHEN</b-button>
|
|
||||||
<b-button type="is-primary" @click="createMsg">SENDEN</b-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
|
|
||||||
<div id="desktop" class="content">
|
|
||||||
<h4>Neue Nachricht erstellen</h4>
|
|
||||||
<b-field>
|
|
||||||
<b-input placeholder="User" id="user"></b-input>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-field>
|
|
||||||
<b-input placeholder="Betreff" id="subject"></b-input>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-field label="Tags">
|
|
||||||
<b-taginput
|
|
||||||
id="tag"
|
|
||||||
v-model="selected"
|
|
||||||
:data=taglist
|
|
||||||
autocomplete
|
|
||||||
allow-new:false
|
|
||||||
icon="label"
|
|
||||||
placeholder="#"
|
|
||||||
@typing="getFilteredTags"
|
|
||||||
@input="saveTagsToArray">
|
@input="saveTagsToArray">
|
||||||
</b-taginput>
|
</b-taginput>
|
||||||
</b-field>
|
</b-field>
|
||||||
@@ -81,9 +42,23 @@ const CreateMsgRouter = {
|
|||||||
auth: auth,
|
auth: auth,
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
selected: [],
|
selected: [],
|
||||||
|
searchtext : "",
|
||||||
taglist: data,
|
taglist: data,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed:{
|
||||||
|
filteredDataArray: function() {
|
||||||
|
return this.taglist.filter((option) => {
|
||||||
|
return option
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.indexOf(this.searchtext.toLowerCase()) >= 0
|
||||||
|
})
|
||||||
|
},
|
||||||
|
userName: function() {
|
||||||
|
return 'User: '+auth.name;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveTagsToArray: function() {
|
saveTagsToArray: function() {
|
||||||
tagArray = this.selected;
|
tagArray = this.selected;
|
||||||
@@ -92,8 +67,19 @@ const CreateMsgRouter = {
|
|||||||
createMsg: function () {
|
createMsg: function () {
|
||||||
var _subject = $("#subject").val();
|
var _subject = $("#subject").val();
|
||||||
var _message = $("#message").val();
|
var _message = $("#message").val();
|
||||||
|
var tmpArr = [];
|
||||||
|
tagArray.forEach(function(tag) {
|
||||||
|
console.info(tag);
|
||||||
|
tmpArr.push(tag.replace(/#/g, ''));
|
||||||
|
});
|
||||||
|
tagArray = tmpArr;
|
||||||
var _tag = tagArray;
|
var _tag = tagArray;
|
||||||
var _user = auth.name ? auth.name : $("#user").val();
|
var _user = auth.name.split(' ');
|
||||||
|
if (_user.length < 2) {
|
||||||
|
_user = _user[0];
|
||||||
|
} else {
|
||||||
|
_user = _user[1] + ', ' + _user[0];
|
||||||
|
}
|
||||||
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
|
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "api/msg",
|
url: "api/msg",
|
||||||
@@ -128,6 +114,8 @@ 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);
|
||||||
|
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);
|
||||||
@@ -136,35 +124,16 @@ const CreateMsgRouter = {
|
|||||||
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);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
var userField = $('#user');
|
//this.list_tags();
|
||||||
if (auth != null && auth.mail != '') {
|
|
||||||
// userField.prop('placeholder',auth.name);
|
|
||||||
var authorName = auth.name.split(' ');
|
|
||||||
authorName = authorName[1] + ', ' + authorName[0];
|
|
||||||
userField.val(authorName);
|
|
||||||
userField.prop('disabled',true);
|
|
||||||
} else {
|
|
||||||
userField.prop('placeholder','User');
|
|
||||||
userField.prop('disabled',false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
+9
-51
@@ -1,10 +1,7 @@
|
|||||||
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="is-hidden-desktop">
|
|
||||||
<h4>Erweiterte Suche</h4>
|
<h4>Erweiterte Suche</h4>
|
||||||
<b-field label="Suche nach">
|
<b-field label="Suche nach">
|
||||||
<b-select
|
<b-select
|
||||||
@@ -23,16 +20,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,44 +37,6 @@ const FileRouter = {
|
|||||||
></MsgCard>
|
></MsgCard>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
|
|
||||||
<h4>Erweiterte Suche</h4>
|
|
||||||
<b-field label="Suche nach">
|
|
||||||
<b-select
|
|
||||||
placeholder="Wähle eine Suchform"
|
|
||||||
v-model="selectedOptions">
|
|
||||||
<option value="freeSearch">Freie Suche</option>
|
|
||||||
<option value="subject">Betreff</option>
|
|
||||||
<option value="tags">Tags</option>
|
|
||||||
<option value="text">Nachrichtentext</option>
|
|
||||||
<option value="user">User</option>
|
|
||||||
</b-select>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-field v-if="selectedOptions=='freeSearch'||selectedOptions=='subject'|| selectedOptions=='text' || selectedOptions=='user'">
|
|
||||||
<b-input id="freeSe"></b-input>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-field v-if="selectedOptions=='tags'">
|
|
||||||
<b-autocomplete rounded v-model="searchtext"
|
|
||||||
:data="filteredDataArray"
|
|
||||||
placeholder="suche..." icon="magnify"
|
|
||||||
@select="option => selected = option">
|
|
||||||
</b-autocomplete>
|
|
||||||
</b-field>
|
|
||||||
|
|
||||||
<b-button type="is-primary" @click="search">SUCHE</b-button>
|
|
||||||
|
|
||||||
<div id="om-msg-cards">
|
|
||||||
<MsgCard
|
|
||||||
v-for="id in messagelist.slice().reverse()"
|
|
||||||
:key="id"
|
|
||||||
:msg="messages[id] || {}"
|
|
||||||
></MsgCard>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
data: function () {
|
data: function () {
|
||||||
@@ -88,6 +47,7 @@ const FileRouter = {
|
|||||||
taglist: data,
|
taglist: data,
|
||||||
messagelist: _messagelist,
|
messagelist: _messagelist,
|
||||||
messages: _messages,
|
messages: _messages,
|
||||||
|
isExtendedSearch: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -104,10 +64,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
|
||||||
@@ -115,7 +71,6 @@ const FileRouter = {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.indexOf(text.toLowerCase()) >= 0
|
.indexOf(text.toLowerCase()) >= 0
|
||||||
})
|
})
|
||||||
this.search();
|
|
||||||
},
|
},
|
||||||
list_tags: function () {
|
list_tags: function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -124,6 +79,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);
|
||||||
@@ -132,6 +88,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);
|
||||||
});
|
});
|
||||||
@@ -142,6 +99,7 @@ const FileRouter = {
|
|||||||
},
|
},
|
||||||
search: function () {
|
search: function () {
|
||||||
searching(this.searchtext);
|
searching(this.searchtext);
|
||||||
|
this.isExtendedSearch=true;
|
||||||
},
|
},
|
||||||
list_messages: function () {
|
list_messages: function () {
|
||||||
messages();
|
messages();
|
||||||
@@ -149,7 +107,7 @@ const FileRouter = {
|
|||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
//this.search();
|
//this.search();
|
||||||
this.list_tags();
|
//this.list_tags();
|
||||||
//this.list_messages();
|
//this.list_messages();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
+58
-74
@@ -1,72 +1,81 @@
|
|||||||
const HomeRouter = {
|
const HomeRouter = {
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<div id="om-msg-cards" class="is-hidden-desktop">
|
<div id="om-msg-cards" class="column pull-right-sm is-four-fifths-desktop">
|
||||||
|
<b-button id="escape-search-link"
|
||||||
|
v-if="_isSearchActiv"
|
||||||
|
@click="goBackToDashboard"
|
||||||
|
icon-left="arrow-left"
|
||||||
|
type="is-primary"
|
||||||
|
@toggle-escape-search-link="toggleEscapeSearchLink"
|
||||||
|
outlined>
|
||||||
|
zurück zu allen Einträgen
|
||||||
|
</b-button>
|
||||||
|
<!--<b-button id="subscribe-btn" type="is-primary" v-if="_isSubscripeButtonActiv" @update-home-abo-button="updateHomeAboButton" @click="changeSubscribtion">
|
||||||
|
{{ subscripeTagName }}
|
||||||
|
</b-button>--><br><br>
|
||||||
<MsgCard
|
<MsgCard
|
||||||
v-for="id in messagelist.slice().reverse()"
|
v-for="id in messagelist.slice().reverse()"
|
||||||
:key="id"
|
:key="id"
|
||||||
:msg="messages[id] || {}"
|
:msg="messages[id] || {}"
|
||||||
></MsgCard>
|
:isBookmark="bookmarkArray[id]">
|
||||||
</div>
|
</MsgCard>
|
||||||
|
|
||||||
<div id="om-msg-cards" class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
|
|
||||||
<MsgCard
|
|
||||||
v-for="id in messagelist.slice().reverse()"
|
|
||||||
:key="id"
|
|
||||||
:msg="messages[id] || {}"
|
|
||||||
></MsgCard>
|
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`,
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
messagelist: _messagelist,
|
messagelist: _messagelist,
|
||||||
messages: _messages,
|
messages: _messages,
|
||||||
|
isSearchActiv: _isSearchActiv,
|
||||||
|
isSubscripeButtonActiv: _isSubscripeButtonActiv,
|
||||||
|
isSubscriped: false,
|
||||||
|
subscripeTagName: '',
|
||||||
|
bookmarkArray: auth.bookmarks,
|
||||||
|
vueRender: vueRender,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/*refresh_messages: function () {
|
updateHomeAboButton: function(content) {
|
||||||
_messages.push({ //////// alt
|
this.subscripeTagName = content;
|
||||||
id: 42,
|
console.info( this.subscripeTagName);
|
||||||
subject: "xxx",
|
vueForceRender('key');
|
||||||
message: "warum habt ihr auch so viel",
|
},
|
||||||
user: "nobody",
|
toggleEscapeSearchLink: function() {
|
||||||
tags: "foo"
|
console.info('got called');
|
||||||
});
|
this.isSearchActive = !this.isSearchActive;
|
||||||
},*/
|
vueForceRender('key');
|
||||||
|
console.info( this.isSearchActive);
|
||||||
|
},
|
||||||
list_messages: function() {
|
list_messages: function() {
|
||||||
messages();
|
messages();
|
||||||
}
|
|
||||||
/*list_messages: function () {
|
|
||||||
$.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);
|
|
||||||
for (var e in jd) {
|
|
||||||
if (!_messages[jd[e]]) {
|
|
||||||
get_insert_message(jd[e]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!($".om-searchbar" = "")){
|
|
||||||
for (var e in jd) {
|
|
||||||
if (!_messages[jd[e]]) {
|
|
||||||
get_insert_message(jd[e]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for (var e in jd) {
|
|
||||||
if (!_messages[jd[e]]) {
|
|
||||||
get_search_message(jd[e]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).fail(function (e, f, g) {
|
|
||||||
console.log("list_msg: err: " + e + f + g);
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
},
|
},
|
||||||
|
goBackToDashboard: function() {
|
||||||
|
_isSearchActiv = false;
|
||||||
|
this.$emit('reset-searchtext','');
|
||||||
|
// $("#escape-search-link").css("visibility", "hidden");
|
||||||
|
// $("#subscribe-btn").css("visibility", "hidden");
|
||||||
|
_isSubscripeButtonActiv = false;
|
||||||
|
vueForceRender('key');
|
||||||
|
vueForceRender('search');
|
||||||
|
},
|
||||||
|
changeSubscribtion: function(){
|
||||||
|
var btnString = $("#btn-text").text();
|
||||||
|
console.log(btnString);
|
||||||
|
|
||||||
|
if(this.isSubscriped){
|
||||||
|
this.subscripeTagName.replace(/deabonnieren/g, '') + "abonnieren";
|
||||||
|
//console.log(btnString);
|
||||||
|
// $("#btn-text").text(newBtnString);
|
||||||
|
}else{
|
||||||
|
this.subscripeTagName.replace(/abonnieren/g, '') + "deabonnieren";
|
||||||
|
//console.log(newBtnString);
|
||||||
|
// $("#btn-text").text(newBtnString);
|
||||||
|
}
|
||||||
|
this.isSubscriped = !this.isSubscriped;
|
||||||
|
vueForceRender('key');
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.list_messages();
|
this.list_messages();
|
||||||
//this.refresh_messages();
|
//this.refresh_messages();
|
||||||
@@ -80,28 +89,3 @@ function get_insert_message(id) {
|
|||||||
console.log("cannot load " + id + ".json: " + e + f + g);
|
console.log("cannot load " + id + ".json: " + e + f + g);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*function get_search_message(phrase) {
|
|
||||||
$.ajax({ url: "api/msg/search/"+phrase, method: "GET" }).done(function (msg) {
|
|
||||||
Vue.set(_messages, id, msg);
|
|
||||||
}).fail(function (e, f, g) {
|
|
||||||
console.log("cannot load " + id + ".json: " + e + f + g);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
$(document).ready(function () {
|
|
||||||
console.log("egal");
|
|
||||||
$.get('list.json').done(function (jd) {
|
|
||||||
// _messagelist = jd;
|
|
||||||
_messagelist.splice(0, _messagelist.length);
|
|
||||||
_messagelist.push.apply(_messagelist, jd);
|
|
||||||
console.log("egal2");
|
|
||||||
//$('#xxx').text(jd[0]);
|
|
||||||
for (var e in jd) {
|
|
||||||
if (!_messages[jd[e]]) {
|
|
||||||
get_insert_message(jd[e]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).fail(function (e, f, g) {
|
|
||||||
console.log("egal3: " + e + f + g);
|
|
||||||
});
|
|
||||||
});*/
|
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// Global Variables
|
||||||
|
// User
|
||||||
|
var auth = {},
|
||||||
|
|
||||||
|
// Message
|
||||||
|
_messagelist = [],
|
||||||
|
_messages = {},
|
||||||
|
|
||||||
|
// Tag
|
||||||
|
_taglist = [],
|
||||||
|
_tags = [],
|
||||||
|
tagArray = [],
|
||||||
|
|
||||||
|
// Search
|
||||||
|
_isSearchActiv = false,
|
||||||
|
_isSubscripeButtonActiv = false,
|
||||||
|
data = [],
|
||||||
|
search_data = [],
|
||||||
|
|
||||||
|
// Vue Rerender Key
|
||||||
|
vueRender = {
|
||||||
|
key: 0,
|
||||||
|
search: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const authorRole = 'author',
|
||||||
|
majorList = [
|
||||||
|
{id:'B-AC',name:'Bachelor Angewandte Chemie'},
|
||||||
|
{id:'B-AMP',name:'Bachelor Angewandte Mathematik und Physik'},
|
||||||
|
{id:'B-TJ',name:'Bachelor Technikjournalismus/Technik-PR'},
|
||||||
|
{id:'B-AR',name:'Bachelor Architektur'},
|
||||||
|
{id:'B-BI',name:'Bachelor Bauingenieurwesen'},
|
||||||
|
{id:'B-BW',name:'Bachelor Betriebswirtschaft'},
|
||||||
|
{id:'B-BIO',name:'Bachelor Management in der Biobranche'},
|
||||||
|
{id:'B-IB',name:'Bachelor International Business'},
|
||||||
|
{id:'B-IBT',name:'Bachelor International Business and Technology'},
|
||||||
|
{id:'B-DE',name:'Bachelor Design'},
|
||||||
|
{id:'B-EI',name:'Bachelor Elektrotechnik und Informationstechnik'},
|
||||||
|
{id:'B-MED',name:'Bachelor Medizintechnik'},
|
||||||
|
{id:'B-MF',name:'Bachelor Mechatronik/Feinwerktechnik'},
|
||||||
|
{id:'B-ME',name:'Bachelor Media Engineering'},
|
||||||
|
{id:'B-IN',name:'Bachelor Informatik'},
|
||||||
|
{id:'B-MIN',name:'Bachelor Medieninformatik'},
|
||||||
|
{id:'B-WIN',name:'Bachelor Wirtschaftsinformatik'},
|
||||||
|
{id:'B-MB',name:'Bachelor Maschinenbau'},
|
||||||
|
{id:'B-EGT',name:'Bachelor Energie- und Gebäudetechnik'},
|
||||||
|
{id:'B-EBL',name:'Bachelor Soziale Arbeit: Erziehung und Bildung im Lebenslauf'},
|
||||||
|
{id:'B-SA',name:'Bachelor Soziale Arbeit'},
|
||||||
|
{id:'B-EPT',name:'Bachelor Energieprozesstechnik'},
|
||||||
|
{id:'B-VT',name:'Bachelor Verfahrenstechnik'},
|
||||||
|
{id:'B-WT',name:'Bachelor Werkstofftechnik'},
|
||||||
|
{id:'M-AMP',name:'Master Angewandte Mathematik und Physik'},
|
||||||
|
{id:'M-AR',name:'Master Architektur'},
|
||||||
|
{id:'M-BI',name:'Master Internationales Bauwesen'},
|
||||||
|
{id:'M-URB',name:'Master Urbane Mobilität (Verkehrsingenieurwesen)'},
|
||||||
|
{id:'M-BW',name:'Master Betriebswirtschaft'},
|
||||||
|
{id:'M-TAX',name:'Master Steuerberatung'},
|
||||||
|
{id:'M-WR',name:'Master Wirtschaftsrecht'},
|
||||||
|
{id:'M-IFE',name:'Master International Finance and Economics'},
|
||||||
|
{id:'M-IMA',name:'Master International Marketing'},
|
||||||
|
{id:'M-APR',name:'Master Applied Research in Engineering Sciences'},
|
||||||
|
{id:'M-SY',name:'Master Elektronische und Mechatronische Systeme'},
|
||||||
|
{id:'M-IN',name:'Master Informatik'},
|
||||||
|
{id:'M-MIN',name:'Master Medieninformatik'},
|
||||||
|
{id:'M-WIN',name:'Master Wirtschaftsinformatik'},
|
||||||
|
{id:'M-MB',name:'Master Maschinenbau'},
|
||||||
|
{id:'M-EE',name:'Master Energiemanagement und Energietechnik'},
|
||||||
|
{id:'M-GT',name:'Master Gebäudetechnik'},
|
||||||
|
{id:'M-SA',name:'Master Soziale Arbeit'},
|
||||||
|
{id:'M-VT',name:'Master Chemieingenieurwesen und Verfahrenstechnik'},
|
||||||
|
{id:'M-WT',name:'Master Werkstofftechnik'},
|
||||||
|
],
|
||||||
|
facultyList = [
|
||||||
|
{id:'AC',name:'Angewandte Chemie'},
|
||||||
|
{id:'AMP',name:'Angewandte Mathematik, Physik und Allgemeinwissenschaften'},
|
||||||
|
{id:'AR',name:'Architektur'},
|
||||||
|
{id:'BI',name:'Bauingeneurwesen'},
|
||||||
|
{id:'BW',name:'Betriebswirtschaft'},
|
||||||
|
{id:'D',name:'Design'},
|
||||||
|
{id:'EFI',name:'Elektrotechnik Feinwerktechnik Informationstechnik'},
|
||||||
|
{id:'IN',name:'Informatik'},
|
||||||
|
{id:'MB-VS',name:'Maschinenbau und Versorgungstechnik'},
|
||||||
|
{id:'SW',name:'Sozialwissenschaften'},
|
||||||
|
{id:'VT',name:'Verfahrenstechnik'},
|
||||||
|
{id:'WT',name:'Werkstofftechnik'},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Global Functions
|
||||||
|
function vueForceRender(keyName) {
|
||||||
|
if (vueRender[keyName] >= 10) {
|
||||||
|
vueRender[keyName] = 0;
|
||||||
|
}
|
||||||
|
vueRender[keyName]++;
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
var majorList = [
|
|
||||||
{id:'B-AC',name:'Bachelor Angewandte Chemie'},
|
|
||||||
{id:'B-AMP',name:'Bachelor Angewandte Mathematik und Physik'},
|
|
||||||
{id:'B-TJ',name:'Bachelor Technikjournalismus/Technik-PR'},
|
|
||||||
{id:'B-AR',name:'Bachelor Architektur'},
|
|
||||||
{id:'B-BI',name:'Bachelor Bauingenieurwesen'},
|
|
||||||
{id:'B-BW',name:'Bachelor Betriebswirtschaft'},
|
|
||||||
{id:'B-BIO',name:'Bachelor Management in der Biobranche'},
|
|
||||||
{id:'B-IB',name:'Bachelor International Business'},
|
|
||||||
{id:'B-IBT',name:'Bachelor International Business and Technology'},
|
|
||||||
{id:'B-DE',name:'Bachelor Design'},
|
|
||||||
{id:'B-EI',name:'Bachelor Elektrotechnik und Informationstechnik'},
|
|
||||||
{id:'B-MED',name:'Bachelor Medizintechnik'},
|
|
||||||
{id:'B-MF',name:'Bachelor Mechatronik/Feinwerktechnik'},
|
|
||||||
{id:'B-ME',name:'Bachelor Media Engineering'},
|
|
||||||
{id:'B-IN',name:'Bachelor Informatik'},
|
|
||||||
{id:'B-MIN',name:'Bachelor Medieninformatik'},
|
|
||||||
{id:'B-WIN',name:'Bachelor Wirtschaftsinformatik'},
|
|
||||||
{id:'B-MB',name:'Bachelor Maschinenbau'},
|
|
||||||
{id:'B-EGT',name:'Bachelor Energie- und Gebäudetechnik'},
|
|
||||||
{id:'B-EBL',name:'Bachelor Soziale Arbeit: Erziehung und Bildung im Lebenslauf'},
|
|
||||||
{id:'B-SA',name:'Bachelor Soziale Arbeit'},
|
|
||||||
{id:'B-EPT',name:'Bachelor Energieprozesstechnik'},
|
|
||||||
{id:'B-VT',name:'Bachelor Verfahrenstechnik'},
|
|
||||||
{id:'B-WT',name:'Bachelor Werkstofftechnik'},
|
|
||||||
{id:'M-AMP',name:'Master Angewandte Mathematik und Physik'},
|
|
||||||
{id:'M-AR',name:'Master Architektur'},
|
|
||||||
{id:'M-BI',name:'Master Internationales Bauwesen'},
|
|
||||||
{id:'M-URB',name:'Master Urbane Mobilität (Verkehrsingenieurwesen)'},
|
|
||||||
{id:'M-BW',name:'Master Betriebswirtschaft'},
|
|
||||||
{id:'M-TAX',name:'Master Steuerberatung'},
|
|
||||||
{id:'M-WR',name:'Master Wirtschaftsrecht'},
|
|
||||||
{id:'M-IFE',name:'Master International Finance and Economics'},
|
|
||||||
{id:'M-IMA',name:'Master International Marketing'},
|
|
||||||
{id:'M-APR',name:'Master Applied Research in Engineering Sciences'},
|
|
||||||
{id:'M-SY',name:'Master Elektronische und Mechatronische Systeme'},
|
|
||||||
{id:'M-IN',name:'Master Informatik'},
|
|
||||||
{id:'M-MIN',name:'Master Medieninformatik'},
|
|
||||||
{id:'M-WIN',name:'Master Wirtschaftsinformatik'},
|
|
||||||
{id:'M-MB',name:'Master Maschinenbau'},
|
|
||||||
{id:'M-EE',name:'Master Energiemanagement und Energietechnik'},
|
|
||||||
{id:'M-GT',name:'Master Gebäudetechnik'},
|
|
||||||
{id:'M-SA',name:'Master Soziale Arbeit'},
|
|
||||||
{id:'M-VT',name:'Master Chemieingenieurwesen und Verfahrenstechnik'},
|
|
||||||
{id:'M-WT',name:'Master Werkstofftechnik'},
|
|
||||||
];
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
_messagelist = [];
|
|
||||||
_messages = {};
|
|
||||||
+71
-11
@@ -1,5 +1,6 @@
|
|||||||
Vue.component('MsgCard', {
|
Vue.component('MsgCard', {
|
||||||
template: `<div class="om-card card">
|
template: `
|
||||||
|
<div class="om-card card">
|
||||||
<h6 class="msg-head">
|
<h6 class="msg-head">
|
||||||
<b>{{ msg.subject }}</b>
|
<b>{{ msg.subject }}</b>
|
||||||
<img src="favicon.ico" width=20px height=20px>
|
<img src="favicon.ico" width=20px height=20px>
|
||||||
@@ -7,28 +8,87 @@ Vue.component('MsgCard', {
|
|||||||
{{ msg.message }}<br>
|
{{ msg.message }}<br>
|
||||||
<a v-for="tag in msg.tag" @click="filterForTag(tag)">#{{ tag }} </a>
|
<a v-for="tag in msg.tag" @click="filterForTag(tag)">#{{ tag }} </a>
|
||||||
<br>
|
<br>
|
||||||
</p>
|
<div class="om-card-footer">
|
||||||
<div class="om-card-footer"> <div class="om-user-line">
|
<div class="om-user-line">
|
||||||
<i class="material-icons">account_circle</i>
|
<i class="material-icons">account_circle</i>
|
||||||
Erstellt von {{ msg.user }}</div>
|
Erstellt von {{ msg.user }}
|
||||||
<i class="material-icons" @click="myFilter()" v-if="!isActive">bookmark_border</i>
|
</div>
|
||||||
<i class="material-icons" @click="myFilter()" v-else="isActive">bookmark</i>
|
<i id="bockmark-not-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-if="!isActive">bookmark_border</i>
|
||||||
</div></div>`,
|
<i id="bockmark-active" class="material-icons" :key="vueRender.key" @click="myFilter(msg._id)" v-else>bookmark</i>
|
||||||
props: ['msg'],
|
</div>
|
||||||
|
</div>`,
|
||||||
|
props: ['msg', 'isBookmark'],
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
isActive: false,
|
isActive: this.isBookmark,
|
||||||
|
msgid: this.msg._id,
|
||||||
|
bookmarkArray: auth.bookmarks,
|
||||||
|
vueRender: vueRender,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
myFilter: function() {
|
myFilter: function (_messageid) {
|
||||||
|
//var _messageid = $("#msgid").text();
|
||||||
|
if (this.isActive == true) {
|
||||||
|
var index = this.bookmarkArray.indexOf(_messageid);
|
||||||
|
|
||||||
|
if (index > -1) {
|
||||||
|
this.bookmarkArray.splice(index, 1);
|
||||||
|
}
|
||||||
|
this.isActive = false;
|
||||||
|
} else {
|
||||||
|
console.log("_messsageid: "+_messageid+" bookmarks: "+this.bookmarkArray);
|
||||||
|
this.bookmarkArray.push(_messageid);
|
||||||
|
this.isActive =true;
|
||||||
|
}
|
||||||
|
/*console.log("msgid"+_bookmark);
|
||||||
|
var _userid = auth.user;
|
||||||
this.isActive = !this.isActive;
|
this.isActive = !this.isActive;
|
||||||
|
if(this.isActive){
|
||||||
|
$.ajax({
|
||||||
|
url: "api/usr",
|
||||||
|
data: {
|
||||||
|
userid: _userid,
|
||||||
|
bookmark: _bookmark
|
||||||
|
},
|
||||||
|
method: "PUT"
|
||||||
|
}).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);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
},
|
},
|
||||||
filterForTag: function (tag) {
|
filterForTag: function (tag) {
|
||||||
console.log("link: " +tag);
|
var btnString = "#" + tag + " abonnieren";
|
||||||
|
$("#btn-text").text(btnString);
|
||||||
|
$("#subscribe-btn").css("visibility", "visible");
|
||||||
|
//console.log("link: " + tag);
|
||||||
searching(tag);
|
searching(tag);
|
||||||
|
var btnString = "#" + tag + " abonnieren";
|
||||||
|
$("#btn-text").text(btnString);
|
||||||
|
$("#subscribe-btn").css("visibility", "visible");
|
||||||
},
|
},
|
||||||
|
isBookmarkActive: function (msgid) {
|
||||||
|
//console.log("isBookmarkActive(): " + msgid);
|
||||||
|
if (this.bookmarkArray.indexOf(msgid) > -1) {
|
||||||
|
// $("#bockmark-not-active").css("visibility","hidden");
|
||||||
|
// $("#bockmark-active").css("visibility","visible");
|
||||||
|
this.isActive = true;
|
||||||
|
//console.log("isBookmarkActive(): " + this.isActive);
|
||||||
|
this.isActive_ = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeMount: function () {
|
||||||
|
//this.isBookmarkActive();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -11,7 +11,7 @@ Vue.component('nav-router', {
|
|||||||
<i class="material-icons">search</i>
|
<i class="material-icons">search</i>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
<router-link to="/createMessage" class="navbar-item is-primary is-expanded is-hidden-desktop">
|
<router-link v-if="auth.roles.author" to="/createMessage" class="navbar-item is-primary is-expanded is-hidden-desktop">
|
||||||
<i class="material-icons">add_circle</i>
|
<i class="material-icons">add_circle</i>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ Vue.component('nav-router', {
|
|||||||
<i class="material-icons">search</i> Search
|
<i class="material-icons">search</i> Search
|
||||||
</router-link></li>
|
</router-link></li>
|
||||||
|
|
||||||
<li><router-link to="/createMessage">
|
<li><router-link v-if="auth.roles.author" to="/createMessage">
|
||||||
<i class="material-icons">add_circle</i> Create Message
|
<i class="material-icons">add_circle</i> Create Message
|
||||||
</router-link></li>
|
</router-link></li>
|
||||||
|
|
||||||
@@ -53,6 +53,11 @@ Vue.component('nav-router', {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
data: function() {
|
||||||
|
return {
|
||||||
|
auth: auth,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|||||||
+1
-20
@@ -1,26 +1,7 @@
|
|||||||
const ProfilRouter = {
|
const ProfilRouter = {
|
||||||
template: `
|
template: `
|
||||||
<div>
|
<div>
|
||||||
<div class="is-hidden-desktop">
|
<div class="column pull-right-sm is-four-fifths-desktop">
|
||||||
<div v-if="isAuth">
|
|
||||||
<profil-card></profil-card>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<button class="button is-primary is-medium"
|
|
||||||
@click="isLPVisible = true">
|
|
||||||
Login
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<b-modal :active.sync="isLPVisible"
|
|
||||||
@close-login-panel="closeLoginPanel"
|
|
||||||
@show-login-panel="showLoginPanel"
|
|
||||||
has-modal-card>
|
|
||||||
<login-panel></login-panel>
|
|
||||||
</b-modal>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
|
|
||||||
<div v-if="isAuth">
|
<div v-if="isAuth">
|
||||||
<profil-card></profil-card>
|
<profil-card></profil-card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,22 +11,24 @@ Vue.component('profil-card', {
|
|||||||
|
|
||||||
<div class="profil-text">
|
<div class="profil-text">
|
||||||
<span style="font-size:120%; display:inline-block; margin: 0.8rem 0 0 0;"><b>{{ auth.name }}</b></span><br><br>
|
<span style="font-size:120%; display:inline-block; margin: 0.8rem 0 0 0;"><b>{{ auth.name }}</b></span><br><br>
|
||||||
<span style="font-size:90%; display:inline-block; margin: 0 0 0.8rem 0;"><b>{{ major }}</b></span>
|
<span style="font-size:100%; display:inline-block; margin: 0 0 0.8rem 0;"><b>{{ labelMajorOrFaculty }}</b></span>
|
||||||
|
<br>
|
||||||
|
<span style="font-size:90%; display:inline-block; margin: 0 0 0.8rem 0;"><b>{{ majorOrFaculty }}</b></span>
|
||||||
<br><br>
|
<br><br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr class="first">
|
<hr class="first">
|
||||||
|
|
||||||
<div class="btnprofil">
|
<div class="btnprofil">
|
||||||
<button @click="isCardModalActive = true"><b>Abonniert: <br/>{{ abo }}</b> <br/></button>
|
<button @click="isCardModalActive = true"><b>Abonniert: <br/>{{ abos }}</b> <br/></button>
|
||||||
<button @click="$router.push('/bookmark')"><b>Gespeichert:<br/> {{ saved }}</b><br/></button>
|
<button @click="$router.push('/bookmark')"><b>Gespeichert:<br/> {{ bookmarks }}</b><br/></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<b-modal :active.sync="isCardModalActive" :width="600" scroll="keep">
|
<b-modal :active.sync="isCardModalActive" :width="600" scroll="keep">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<header class="modal-card-head">
|
<header class="modal-card-head">
|
||||||
<p class="modal-card-title">Abonnierte Kanäle</p>
|
<p class="modal-card-title">Abonnierte Tags</p>
|
||||||
</header>
|
</header>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@@ -51,14 +53,26 @@ Vue.component('profil-card', {
|
|||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
auth: auth,
|
auth: auth,
|
||||||
abo: 7,
|
abos: auth.abos ? auth.abos.length : '-',
|
||||||
saved: 3,
|
bookmarks: auth.bookmarks ? auth.bookmarks.length : '-',
|
||||||
isCardModalActive: false,
|
isCardModalActive: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
major: function() {
|
majorOrFaculty: function() {
|
||||||
// e.g. ST@B-ME;ST@EFI;
|
// e.g. ST@B-ME;ST@EFI;
|
||||||
|
if (auth.roles.author) {
|
||||||
|
var facultyID = auth.type.split(';');
|
||||||
|
console.info(facultyID[facultyID.length-2]);
|
||||||
|
facultyID = facultyID[facultyID.length-2].split('@')[1];
|
||||||
|
var facultyName = '';
|
||||||
|
facultyList.forEach(function(faculty) {
|
||||||
|
if (faculty.id == facultyID) {
|
||||||
|
facultyName = faculty.name;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return facultyName;
|
||||||
|
} else {
|
||||||
var majorID = auth.type.split(';')[0].split('@')[1];
|
var majorID = auth.type.split(';')[0].split('@')[1];
|
||||||
//console.info(majorID);
|
//console.info(majorID);
|
||||||
//console.info(majorList);
|
//console.info(majorList);
|
||||||
@@ -69,12 +83,21 @@ Vue.component('profil-card', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return majorName;
|
return majorName;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
labelMajorOrFaculty: function() {
|
||||||
|
if (auth.roles.author) {
|
||||||
|
return 'Fakultät:'
|
||||||
|
} else {
|
||||||
|
return 'Studiengang:'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logout: function() {
|
logout: function() {
|
||||||
clearAuthState();
|
clearAuthState();
|
||||||
$.ajax({ url: "api/logout", method: "POST" });
|
$.ajax({ url: "api/logout", method: "POST" });
|
||||||
|
vueForceRender('key');
|
||||||
router.push('/profil');
|
router.push('/profil');
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
_taglist = [];
|
|
||||||
_tags = [];
|
|
||||||
+46
-24
@@ -1,13 +1,3 @@
|
|||||||
var isSearchActive = false,
|
|
||||||
tagArray = ["lorem"];
|
|
||||||
|
|
||||||
const dat=[
|
|
||||||
'th',
|
|
||||||
'efi',
|
|
||||||
'wichtig',
|
|
||||||
],
|
|
||||||
search_data = [];
|
|
||||||
|
|
||||||
Vue.component('search',{
|
Vue.component('search',{
|
||||||
template: `
|
template: `
|
||||||
<form class="om-searchbar" @submit.prevent="search()">
|
<form class="om-searchbar" @submit.prevent="search()">
|
||||||
@@ -18,6 +8,7 @@ Vue.component('search',{
|
|||||||
:data="filteredDataArray"
|
:data="filteredDataArray"
|
||||||
placeholder="suche..."
|
placeholder="suche..."
|
||||||
icon="magnify"
|
icon="magnify"
|
||||||
|
@reset-searchtext="resetSearchtext($event)"
|
||||||
@select="option => selected = option">
|
@select="option => selected = option">
|
||||||
</b-autocomplete>
|
</b-autocomplete>
|
||||||
<button class="clearButton" @click="clear">x</button>
|
<button class="clearButton" @click="clear">x</button>
|
||||||
@@ -27,22 +18,25 @@ Vue.component('search',{
|
|||||||
return {
|
return {
|
||||||
searchtext: "",
|
searchtext: "",
|
||||||
selected: [],
|
selected: [],
|
||||||
taglist: dat,
|
taglist: data,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
filteredDataArray() {
|
filteredDataArray: function() {
|
||||||
return this.taglist.filter((option) => {
|
return this.taglist.filter((option) => {
|
||||||
return option
|
return option
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.indexOf(this.searchtext.toLowerCase()) >= 0
|
.indexOf(this.searchtext.toLowerCase()) >= 0
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getFilteredTags(text) {
|
resetSearchtext: function(param) {
|
||||||
this.taglist = dat.filter((option) => {
|
this.searchtext = param;
|
||||||
|
},
|
||||||
|
getFilteredTags: function(text) {
|
||||||
|
this.taglist = data.filter((option) => {
|
||||||
return option
|
return option
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
@@ -51,7 +45,12 @@ Vue.component('search',{
|
|||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
search: function() {
|
search: function() {
|
||||||
searching(this.searchtext);
|
var btnString = '';
|
||||||
|
btnString = searching(this.searchtext, btnString);
|
||||||
|
console.info(btnString);
|
||||||
|
this.$emit('update-home-abo-button', btnString);
|
||||||
|
vueForceRender('key');
|
||||||
|
|
||||||
},
|
},
|
||||||
saveTagsToArray: function() {
|
saveTagsToArray: function() {
|
||||||
tagArray = this.selected;
|
tagArray = this.selected;
|
||||||
@@ -64,6 +63,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,16 +72,23 @@ 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);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
console.log("clear");
|
|
||||||
|
|
||||||
isSearchActiv = false;
|
|
||||||
this.searchtext = "";
|
this.searchtext = "";
|
||||||
this.list_messages();
|
this.list_messages();
|
||||||
|
//router.push('/files')
|
||||||
|
//router.push('/home')
|
||||||
|
_isSearchActiv = false;
|
||||||
|
_isSubscripeButtonActiv = false;
|
||||||
|
this.$emit('toggle-escape-search-link');
|
||||||
|
vueForceRender('key');
|
||||||
|
console.info('done');
|
||||||
|
// $("#escape-search-link").css("visibility", "hidden");
|
||||||
|
// $("#subscribe-btn").css("visibility", "hidden");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
@@ -96,15 +103,28 @@ 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);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function searching(searchtext) {
|
function searching(searchtext,btnString) {
|
||||||
isSearchActiv = true;
|
_isSearchActiv = true;
|
||||||
console.log("Searchtext: " + searchtext.replace(/#/g, ''));
|
// $("#escape-search-link").css("visibility", "visible");
|
||||||
|
//console.log(_tags);
|
||||||
|
// console.log(data);
|
||||||
|
if(data.indexOf(searchtext) > -1){
|
||||||
|
btnString = searchtext + " abonnieren";
|
||||||
|
// $("#btn-text").text(btnString);
|
||||||
|
// $("#subscribe-btn").css("visibility", "visible");
|
||||||
|
_isSubscripeButtonActiv = true;
|
||||||
|
}else{
|
||||||
|
// $("#subscribe-btn").css("visibility", "hidden");
|
||||||
|
_isSubscripeButtonActiv = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchtext !== '') {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "api/msg/search/" + searchtext.replace(/#/g, ''),
|
url: "api/msg/search/" + searchtext.replace(/#/g, ''),
|
||||||
method: "GET"
|
method: "GET"
|
||||||
@@ -122,6 +142,8 @@ function searching(searchtext) {
|
|||||||
console.log("searching: err: " + e + f + g);
|
console.log("searching: err: " + e + f + g);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
return btnString;
|
||||||
|
}
|
||||||
|
|
||||||
function messages() {
|
function messages() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
+15
-6
@@ -36,12 +36,6 @@
|
|||||||
.om-content a:hover {
|
.om-content a:hover {
|
||||||
color: #0046a0;
|
color: #0046a0;
|
||||||
}
|
}
|
||||||
.om-content a .menu-list {
|
|
||||||
color: white !important;
|
|
||||||
}
|
|
||||||
.om-content a .menu-list:hover {
|
|
||||||
color: white !important;
|
|
||||||
}
|
|
||||||
.content-desktop {
|
.content-desktop {
|
||||||
margin-right: 30px;
|
margin-right: 30px;
|
||||||
}
|
}
|
||||||
@@ -242,3 +236,18 @@ button.clearButton {
|
|||||||
.taglink {
|
.taglink {
|
||||||
color: #0046a0;
|
color: #0046a0;
|
||||||
}
|
}
|
||||||
|
@media (min-width: 1088px) {
|
||||||
|
.pull-right-sm {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#subscribe-btn {
|
||||||
|
float: right;
|
||||||
|
-visibility: hidden;
|
||||||
|
}
|
||||||
|
#escape-search-link {
|
||||||
|
-visibility: hidden;
|
||||||
|
}
|
||||||
|
#bockmark-not-active {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
+20
-4
@@ -39,10 +39,7 @@
|
|||||||
a{
|
a{
|
||||||
color: #0046a0;
|
color: #0046a0;
|
||||||
&:hover{color: #0046a0;}
|
&:hover{color: #0046a0;}
|
||||||
.menu-list {
|
}
|
||||||
color: white !important;
|
|
||||||
&:hover{color: white !important; }
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-desktop {
|
.content-desktop {
|
||||||
@@ -282,3 +279,22 @@ button.clearButton{
|
|||||||
color: @color;
|
color: @color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1088px) {
|
||||||
|
.pull-right-sm {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#subscribe-btn{
|
||||||
|
float: right;
|
||||||
|
-visibility: hidden;
|
||||||
|
}
|
||||||
|
#escape-search-link{
|
||||||
|
-visibility: hidden;
|
||||||
|
}
|
||||||
|
#bockmark-not-active{
|
||||||
|
visibility: visible;
|
||||||
|
}
|
||||||
|
#bockmark-active{
|
||||||
|
//visibility: hidden;
|
||||||
|
}
|
||||||
@@ -53,8 +53,8 @@ app.disable('x-powered-by');
|
|||||||
app.set('trust proxy', 1) // trust first proxy, neccessary for cookie secure: true flag
|
app.set('trust proxy', 1) // trust first proxy, neccessary for cookie secure: true flag
|
||||||
app.use(session({
|
app.use(session({
|
||||||
secret: 'ahhgylhuvh', // caesar(3) 2 letter surname
|
secret: 'ahhgylhuvh', // caesar(3) 2 letter surname
|
||||||
resave: false,
|
saveUninitialized: false, // don't create session until something stored
|
||||||
saveUninitialized: false,
|
resave: false, //don't save session if unmodified
|
||||||
cookie: {
|
cookie: {
|
||||||
maxAge: 30 * 24 * 3600 * 1000, // TODO: ttl for session as well (Store)
|
maxAge: 30 * 24 * 3600 * 1000, // TODO: ttl for session as well (Store)
|
||||||
secure: true, // true for https only (since our app works only with https)
|
secure: true, // true for https only (since our app works only with https)
|
||||||
|
|||||||
+68
-2
@@ -12,21 +12,76 @@ const ldap = require ('./ldap_ohm'),
|
|||||||
const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true, deactivated: true, host: true };
|
const serverVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true, deactivated: true, host: true };
|
||||||
const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true };
|
const clientVisibleSession = { user: true, name: true, type: true, mail: true, roles: true, gender: true };
|
||||||
|
|
||||||
|
// Return user role, query from found.mail
|
||||||
|
function getUserRole(found) {
|
||||||
|
var roles = "user";
|
||||||
|
var mail = found.mail;
|
||||||
|
if (!/\d/.test(mail)) {
|
||||||
|
// Mail contains no number
|
||||||
|
roles += ',"author"';
|
||||||
|
}
|
||||||
|
return JSON.stringify('{'+roles+'}');
|
||||||
|
}
|
||||||
|
|
||||||
// Fill in session object
|
// Fill in session object
|
||||||
function fillSession (req, user, roles, cb) {
|
function fillSession (req, user, roles, cb) {
|
||||||
if (req.session === undefined)
|
if (req.session === undefined)
|
||||||
next (common.genError (500, "Error"));
|
next (common.genError (500, "Error"));
|
||||||
|
// regenerate a new session-id with clean instance
|
||||||
|
if (user !== undefined && roles !== undefined) {
|
||||||
req.session.regenerate (function (err) {
|
req.session.regenerate (function (err) {
|
||||||
if (user !== undefined && ! err) {
|
if (user !== undefined && ! err) {
|
||||||
common.shallowCopy (user, serverVisibleSession, {roles: true}, req.session);
|
common.shallowCopy (user, serverVisibleSession, {roles: true}, req.session);
|
||||||
|
// console.info(req.session);
|
||||||
if (user._id) {
|
if (user._id) {
|
||||||
req.session.user = user._id;
|
req.session.user = user._id;
|
||||||
}
|
}
|
||||||
req.session.roles = roles;
|
req.session.roles = roles;
|
||||||
|
console.info(req.session);
|
||||||
}
|
}
|
||||||
return cb (err);
|
return cb (err);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
return cb ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save found user into DB, if not already exists
|
||||||
|
function saveFoundToDB(found, cb) {
|
||||||
|
// console.info(found);
|
||||||
|
Users.findById(found.user)
|
||||||
|
.exec(function(err, result){
|
||||||
|
if (err) {
|
||||||
|
console.error("Error: Users collection.");
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
// User doesn't exist
|
||||||
|
if (found !== undefined && !result) {
|
||||||
|
Users.create({
|
||||||
|
_id: found.user,
|
||||||
|
name: found.name,
|
||||||
|
mail: found.mail,
|
||||||
|
type: found.type,
|
||||||
|
gender: found.gender,
|
||||||
|
abos: '',
|
||||||
|
bookmarks: '',
|
||||||
|
roles: getUserRole(found),
|
||||||
|
}, function(err, done) {
|
||||||
|
if (err) {
|
||||||
|
console.error("User creation: Failed");
|
||||||
|
console.error(err);
|
||||||
|
} else {
|
||||||
|
console.info("User created: "+ found.user);
|
||||||
|
}
|
||||||
|
if (done == null) {
|
||||||
|
console.error("Can not create user.");
|
||||||
|
}
|
||||||
|
return cb(err);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const authorization = {
|
const authorization = {
|
||||||
@@ -62,7 +117,7 @@ const authorization = {
|
|||||||
|
|
||||||
// Check whether to just validate current session ID
|
// Check whether to just validate current session ID
|
||||||
if (user === '' && pwd === '') {
|
if (user === '' && pwd === '') {
|
||||||
console.log ("auth revalidate: " + req.session.user);
|
console.log ("auth revalidate: " + req.session._id);
|
||||||
if (req.session.user === undefined)
|
if (req.session.user === undefined)
|
||||||
return returnError();
|
return returnError();
|
||||||
return returnSession ();
|
return returnSession ();
|
||||||
@@ -73,7 +128,8 @@ const authorization = {
|
|||||||
// If there is a local user AND it has a password associated, test against this, and only this
|
// If there is a local user AND it has a password associated, test against this, and only this
|
||||||
if (entry != null && entry.pwd) {
|
if (entry != null && entry.pwd) {
|
||||||
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
|
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
|
||||||
return fillSession (req, entry, common.arrayToHash(entry.roles), returnSession);
|
console.info(entry.roles);
|
||||||
|
return fillSession (req, entry, JSON.parse(entry.roles), returnSession);
|
||||||
}
|
}
|
||||||
return returnError ();
|
return returnError ();
|
||||||
}
|
}
|
||||||
@@ -97,13 +153,23 @@ const authorization = {
|
|||||||
entry.orclgender = found.orclgender;
|
entry.orclgender = found.orclgender;
|
||||||
return fillSession (req, entry, entry.roles.length > 0 ? common.arrayToHash(entry.roles) : {user:true}, returnSession);
|
return fillSession (req, entry, entry.roles.length > 0 ? common.arrayToHash(entry.roles) : {user:true}, returnSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise create standard user entry
|
// Otherwise create standard user entry
|
||||||
|
saveFoundToDB(found, function() {
|
||||||
return fillSession (req, found, {user:true}, returnSession);
|
return fillSession (req, found, {user:true}, returnSession);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
logout: function (req, res, next) {
|
logout: function (req, res, next) {
|
||||||
fillSession (req, undefined, undefined, function (err) {
|
fillSession (req, undefined, undefined, function (err) {
|
||||||
|
// Session delete, exists further in db
|
||||||
|
req.session.destroy(function(err) {
|
||||||
|
if (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// console.info(req.session);
|
||||||
return res.json ({});
|
return res.json ({});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
+120
-37
@@ -17,7 +17,9 @@ const dbs = {
|
|||||||
* Get ALL known message ids
|
* Get ALL known message ids
|
||||||
*/
|
*/
|
||||||
get: function (req, res) {
|
get: function (req, res) {
|
||||||
model.Messages.find({},{_id: true}).exec()
|
model.Messages.find({}, {
|
||||||
|
_id: true
|
||||||
|
}).exec()
|
||||||
.then(results => {
|
.then(results => {
|
||||||
//selects id from message:
|
//selects id from message:
|
||||||
var parsed = [];
|
var parsed = [];
|
||||||
@@ -57,9 +59,14 @@ const dbs = {
|
|||||||
* Get a particular message
|
* Get a particular message
|
||||||
*/
|
*/
|
||||||
get: function (req, res) {
|
get: function (req, res) {
|
||||||
model.Messages.find(
|
model.Messages.find({
|
||||||
{$text: {$search: req.params.phrase}})
|
$text: {
|
||||||
.sort({tag:1, user:1, message:1, subject:1})
|
$search: req.params.phrase
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sort({
|
||||||
|
tag: -1
|
||||||
|
})
|
||||||
.exec().then(results => {
|
.exec().then(results => {
|
||||||
//selects id from message:
|
//selects id from message:
|
||||||
var parsed = [];
|
var parsed = [];
|
||||||
@@ -96,7 +103,9 @@ const dbs = {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return res.status(401).json(err.message);
|
return res.status(401).json(err.message);
|
||||||
} else {
|
} else {
|
||||||
res.json({message: "Message created!!"});
|
res.json({
|
||||||
|
message: "Message created!!"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return res.status(500).json("Can not create message.")
|
return res.status(500).json("Can not create message.")
|
||||||
@@ -116,7 +125,9 @@ const dbs = {
|
|||||||
* Get ALL known tag ids
|
* Get ALL known tag ids
|
||||||
*/
|
*/
|
||||||
get: function (req, res) {
|
get: function (req, res) {
|
||||||
model.Tags.find({},{_id: true}).exec()
|
model.Tags.find({}, {
|
||||||
|
_id: true
|
||||||
|
}).exec()
|
||||||
.then(results => {
|
.then(results => {
|
||||||
//selects id from tag:
|
//selects id from tag:
|
||||||
var parsed = [];
|
var parsed = [];
|
||||||
@@ -144,12 +155,38 @@ const dbs = {
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(404).json(err);
|
res.status(404).json(err);
|
||||||
} else {
|
} else {
|
||||||
//console.log(JSON.stringify(result));
|
//console.log(req.params.id);
|
||||||
res.json(result);
|
res.json(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"usr/bookmark/ids": {
|
||||||
|
/* GET /api/usr/bookmark/ids [no args]
|
||||||
|
* -> Array of message schema object ids
|
||||||
|
* Get bookmark message ids
|
||||||
|
*/
|
||||||
|
|
||||||
|
get: function (req, res) {
|
||||||
|
model.Users.find({
|
||||||
|
},
|
||||||
|
function (err, result) {
|
||||||
|
if (err) {
|
||||||
|
return res.status(401).json(err.message);
|
||||||
|
} else {
|
||||||
|
var parsed = [];
|
||||||
|
for (var i in result) {
|
||||||
|
parsed.push(result[i].bookmarks);
|
||||||
|
}
|
||||||
|
console.log("bookmarks:" + JSON.stringify(parsed));
|
||||||
|
res.send(parsed);
|
||||||
|
}
|
||||||
|
if (result == null) {
|
||||||
|
return res.status(500).json("Can save bookmark.")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
"usr/id": {
|
"usr/id": {
|
||||||
params: ":id",
|
params: ":id",
|
||||||
/* GET /api/usr/[usr-id]
|
/* GET /api/usr/[usr-id]
|
||||||
@@ -157,13 +194,15 @@ const dbs = {
|
|||||||
* Get a particular user
|
* Get a particular user
|
||||||
*/
|
*/
|
||||||
get: function (req, res) {
|
get: function (req, res) {
|
||||||
model.Users.findById(req.params.id)
|
model.Users.find({
|
||||||
|
_id: req.params.id
|
||||||
|
})
|
||||||
.exec(function (err, result) {
|
.exec(function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
res.status(404).json(err);
|
res.status(404).json(err);
|
||||||
} else {
|
} else {
|
||||||
//console.log(JSON.stringify(result));
|
console.log(result);
|
||||||
res.json(result);
|
res.json(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -176,22 +215,22 @@ const dbs = {
|
|||||||
* Create a new user
|
* Create a new user
|
||||||
*/
|
*/
|
||||||
post: function(req, res) {
|
post: function(req, res) {
|
||||||
model.User.create({
|
// console.info(req.body);
|
||||||
_id: req.body.id,
|
model.Users.create({
|
||||||
|
_id: req.body._id,
|
||||||
name: req.body.name,
|
name: req.body.name,
|
||||||
|
mail: req.body.mail,
|
||||||
type: req.body.type,
|
type: req.body.type,
|
||||||
roles: req.body.roles,
|
gender: req.body.gender,
|
||||||
hash: req.body.hash,
|
|
||||||
salt: req.body.salt,
|
|
||||||
pwd: req.body.pwd,
|
|
||||||
abos: req.body.abos,
|
abos: req.body.abos,
|
||||||
bookmarks: req.body.bookmarks,
|
bookmarks: req.body.bookmarks,
|
||||||
|
roles: req.body.roles,
|
||||||
}, function(err, result) {
|
}, function(err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return res.status(401).json(err.message);
|
return res.status(401).json(err.message);
|
||||||
} else {
|
} else {
|
||||||
res.json({message: "User created!!"});
|
res.json({message: "User created!", user: req.body});
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return res.status(500).json("Can not create user.")
|
return res.status(500).json("Can not create user.")
|
||||||
@@ -204,14 +243,40 @@ const dbs = {
|
|||||||
* Change a user
|
* Change a user
|
||||||
*/
|
*/
|
||||||
put: function (req, res) {
|
put: function (req, res) {
|
||||||
model.Users.findById(reg.body._id)
|
|
||||||
|
model.Users.find({
|
||||||
|
_id: req.body.userid
|
||||||
|
})
|
||||||
.exec(function (err, entry) {
|
.exec(function (err, entry) {
|
||||||
if (err)
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
model.Users.update({
|
||||||
|
_id: req.body.userid
|
||||||
|
}, {
|
||||||
|
bookmarks: req.body.bookmark
|
||||||
|
}, function (err, data) {
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
res.json({
|
||||||
|
id: "Bookmark saved"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (data == null) {
|
||||||
|
return res.status(404).json(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return res.status(404).json(err.message);
|
return res.status(404).json(err.message);
|
||||||
// TODO Catch edge cases
|
// TODO Catch edge cases
|
||||||
entry.save(function(err, data) {
|
|
||||||
// TODO Save/Update user
|
// TODO Save/Update user
|
||||||
/*
|
/*
|
||||||
_id: req.body.id,
|
_id: req.body.id,
|
||||||
@@ -224,8 +289,7 @@ const dbs = {
|
|||||||
abos: req.body.abos,
|
abos: req.body.abos,
|
||||||
bookmarks: req.body.bookmarks,
|
bookmarks: req.body.bookmarks,
|
||||||
*/
|
*/
|
||||||
res.json(data);
|
// res.json(data);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -258,44 +322,63 @@ const dbs = {
|
|||||||
* - per entry: _comment: Comment for Admin UI - TODO: not working yet
|
* - per entry: _comment: Comment for Admin UI - TODO: not working yet
|
||||||
*/
|
*/
|
||||||
var messageSchema = common.mongoose.Schema({
|
var messageSchema = common.mongoose.Schema({
|
||||||
subject: { type: String, required: true,
|
subject: {
|
||||||
_comment: "" },
|
type: String,
|
||||||
message: { type: String, required: true,
|
required: true,
|
||||||
_comment: "" },
|
_comment: ""
|
||||||
user: { type: String, required: true,
|
},
|
||||||
_comment: "" },
|
message: {
|
||||||
tag: { type: [String],
|
type: String,
|
||||||
_comment: "" },
|
required: true,
|
||||||
|
_comment: ""
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
_comment: ""
|
||||||
|
},
|
||||||
|
tag: {
|
||||||
|
type: [String],
|
||||||
|
_comment: ""
|
||||||
|
},
|
||||||
//createtime: { type: Date, default: Date.now },
|
//createtime: { type: Date, default: Date.now },
|
||||||
});
|
});
|
||||||
messageSchema.index({ "$**":'text' });
|
messageSchema.index({
|
||||||
|
"$**": 'text'
|
||||||
|
});
|
||||||
model.Messages = common.mongoose.model('messages', messageSchema);
|
model.Messages = common.mongoose.model('messages', messageSchema);
|
||||||
model.Messages._list = [""];
|
model.Messages._list = [""];
|
||||||
|
|
||||||
var tagSchema = common.mongoose.Schema({
|
var tagSchema = common.mongoose.Schema({
|
||||||
name: { type: String, required: true,
|
name: {
|
||||||
_comment: "" }, //unique
|
type: String,
|
||||||
|
required: true,
|
||||||
|
_comment: ""
|
||||||
|
}, //unique
|
||||||
});
|
});
|
||||||
model.Tags = common.mongoose.model('tags', messageSchema);
|
model.Tags = common.mongoose.model('tags', messageSchema);
|
||||||
model.Tags._list = [""];
|
model.Tags._list = [""];
|
||||||
|
|
||||||
var userSchema = common.mongoose.Schema({
|
var userSchema = common.mongoose.Schema({
|
||||||
_id: { type: String },
|
_id: { type: String, required: true },
|
||||||
name: { type: String, required: true,
|
name: { type: String,
|
||||||
_comment: "" },
|
_comment: "" },
|
||||||
|
mail: { type: String },
|
||||||
|
type: { type: String },
|
||||||
|
gender: { type: String },
|
||||||
pwd: { type: String,
|
pwd: { type: String,
|
||||||
_comment: "" },
|
_comment: "" },
|
||||||
hash: { type: String },
|
hash: { type: String },
|
||||||
salt: { type: String },
|
salt: { type: String },
|
||||||
type: { type: String },
|
|
||||||
roles: { type: [String], required: true,
|
|
||||||
_comment: "" },
|
|
||||||
abos: { type: [String],
|
abos: { type: [String],
|
||||||
_comment: "" },
|
_comment: "" },
|
||||||
//deactivated: { type: Boolean },
|
//deactivated: { type: Boolean },
|
||||||
//host: { type: Boolean },
|
//host: { type: Boolean },
|
||||||
bookmarks: { type: [String],
|
bookmarks: { type: [String],
|
||||||
_comment: "" },
|
_comment: "" },
|
||||||
|
sessionid: { type: String },
|
||||||
|
roles: { type: String, required: true,
|
||||||
|
_comment: "" },
|
||||||
});
|
});
|
||||||
model.Users = common.mongoose.model('users', userSchema);
|
model.Users = common.mongoose.model('users', userSchema);
|
||||||
model.Users._list = [""];
|
model.Users._list = [""];
|
||||||
|
|||||||
Reference in new issue
Block a user