Browse Source

Global refactor

master
Erik Römmelt 5 years ago
parent
commit
6a69bbcaf7

+ 4
- 4
mong_usr.js View File

@@ -1,8 +1,8 @@
db.users.insert([
// author,OHMNEWS2019
{"_id":"author","name":"Test Author","type":"author","roles":{"user":true,"author":true},"hash":"sha256","salt":"cy5CkPrplcEze6o4psURhw==","pwd":"Gc8ozlxjEGITkS+fW9tz2xLROzws44s04EOCWuP04qE=","abos":["wichtig","th"],"bookmarks":["th"],},
// admin,oZuse1
{"_id":"admin","name":"Test Admin","type":"admin","roles":{"user":true,"author":true,"admin":true},"hash":"sha256","salt":"PoIUHbDp7tP34ji31iQ0zw==","pwd":"mJpIfIksYs6LJJwYRBemFKqR6TacsSl2E0ZtpO1GMuk=","abos":["wichtig","th"],"bookmarks":["wichtig"],},
// User: author, Pwd: author
{"_id":"author","name":"Author","type":"MA@EFI;","roles":'{"user":true,"author":true}',"hash":"sha256","salt":"SIzKNsNKsCRVr8a9U90q6A==","pwd":"HZly68TSAKHioz6Kz0QCbXVTHpT6hMmabUbFYVlCMeE=","abos":["nulla","tempor","veniam","ipsum"],"bookmarks":[],},
// User: admin, Pwd: SwenMho
{"_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'),

+ 3
- 4
public/index.html View File

@@ -77,7 +77,6 @@
<script src="routes/bookmark.js"></script>
<script src="routes/profil.js"></script>
<script src="routes/msgCard.js"></script>
<script src="routes/majorData.js"></script>
<script src="routes/profilCard.js"></script>
<script src="routes/navRoutes.js"></script>
<script src="search.js"></script>
@@ -88,13 +87,13 @@
<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-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 class="om-content">
<div id=xxx></div>
<nav-router></nav-router>
<nav-router :key="auth.user"></nav-router>
<router-view :key="vueRender.key"></router-view>
</div>
</div>
@@ -104,8 +103,8 @@
router,
el: '#api',
data: {
// Locally registered variables
vueRender : vueRender,
auth: auth,
},
});
</script>

+ 1
- 1
public/routes/auth.js View File

@@ -152,7 +152,7 @@ Vue.component('login-panel', {
function successful_login(res) {
console.info("Re-Auth: Correct credentials");
this.closeLoginPanel;
vueForceRender();
vueForceRender('key');

//console.log(res);
router.push('/home')

+ 38
- 34
public/routes/createMessage.js View File

@@ -4,10 +4,11 @@ const CreateMsgRouter = {
<div class="column pull-right-sm is-four-fifths-desktop">
<div id="mobile" class="om-card card">
<h4>Neue Nachricht erstellen</h4>
<b-field>
<b-input placeholder="User" id="user"></b-input>
</b-field>
<!--<b-field>
<b-input placeholder="User" id="user"></b-input>
</b-field>-->

<label class="label">{{ userName }}</label>
<b-field>
<b-input placeholder="Betreff" id="subject"></b-input>
</b-field>
@@ -38,6 +39,7 @@ const CreateMsgRouter = {

data: function () {
return {
auth: auth,
isDisabled: false,
selected: [],
searchtext : "",
@@ -45,13 +47,16 @@ const CreateMsgRouter = {
};
},
computed:{
filteredDataArray() {
filteredDataArray: function() {
return this.taglist.filter((option) => {
return option
.toString()
.toLowerCase()
.indexOf(this.searchtext.toLowerCase()) >= 0
})
},
userName: function() {
return 'User: '+auth.name;
}
},
methods: {
@@ -62,8 +67,19 @@ const CreateMsgRouter = {
createMsg: function () {
var _subject = $("#subject").val();
var _message = $("#message").val();
var _tag = tagArray;
var _user = auth.name != '' ? auth.name : $("#user").val();
var tmpArr = [];
tagArray.forEach(function(tag) {
console.info(tag);
tmpArr.push(tag.replace(/#/g, ''));
});
tagArray = tmpArr;
var _tag = tagArray;
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);
$.ajax({
url: "api/msg",
@@ -95,38 +111,26 @@ const CreateMsgRouter = {
})
},
list_tags: function () {
$.ajax({url: "api/tag/ids",method: "GET"})
.done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
console.log("DATA: "+data);
if(data == ""){
_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]);
}
$.ajax({url: "api/tag/ids",method: "GET"})
.done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
console.log("DATA: "+data);
if(data == ""){
_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);
});
}
}
}).fail(function (e, f, g) {
console.log("err: " + e + f + g);
});
},
},
mounted: function () {
var userField = $('#user');
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)
$(this).bootstrapMaterialDesign();

+ 48
- 21
public/routes/home.js View File

@@ -1,16 +1,26 @@
const HomeRouter = {
template: `
<div>
<div id="om-msg-cards" class="column pull-right-sm is-four-fifths-desktop">
<a id="escape-search-link" @click="goBackToDashboard">< zurück zu allen Einträgen</a>
<b-button id="subscribe-btn" type="is-primary" @click="changeSubscribtion"><div id="btn-text"></div></b-button><br><br>
<MsgCard
v-for="id in messagelist.slice().reverse()"
:key="id"
:msg="messages[id] || {}"
:isBookmark="bookmarkArray[id]"
></MsgCard>
</div>
<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
v-for="id in messagelist.slice().reverse()"
:key="id"
:msg="messages[id] || {}"
:isBookmark="bookmarkArray[id]">
</MsgCard>
</div>
</div>`,
data: function () {
return {
@@ -18,34 +28,51 @@ const HomeRouter = {
messages: _messages,
isSearchActiv: _isSearchActiv,
isSubscripeButtonActiv: _isSubscripeButtonActiv,
isSubscriped: false,
subscripeTagName: '',
bookmarkArray: auth.bookmarks,
vueRender: vueRender,
};
},
methods: {
updateHomeAboButton: function(content) {
this.subscripeTagName = content;
console.info( this.subscripeTagName);
vueForceRender('key');
},
toggleEscapeSearchLink: function() {
console.info('got called');
this.isSearchActive = !this.isSearchActive;
vueForceRender('key');
console.info( this.isSearchActive);
},
list_messages: function() {
messages();
},
goBackToDashboard: function() {
vueForceRender();
$("#escape-search-link").css("visibility", "hidden");
$("#subscribe-btn").css("visibility", "hidden");
_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($("#btn-text").hasClass("subscribed")){
$("#btn-text").removeClass("subscribed");
var newBtnString = btnString.replace(/deabonnieren/g, '') + "abonnieren";
if(this.isSubscriped){
this.subscripeTagName.replace(/deabonnieren/g, '') + "abonnieren";
//console.log(btnString);
$("#btn-text").text(newBtnString);
// $("#btn-text").text(newBtnString);
}else{
$("#btn-text").addClass("subscribed");
var newBtnString = btnString.replace(/abonnieren/g, '') + "deabonnieren";
this.subscripeTagName.replace(/abonnieren/g, '') + "deabonnieren";
//console.log(newBtnString);
$("#btn-text").text(newBtnString);

// $("#btn-text").text(newBtnString);
}
this.isSubscriped = !this.isSubscriped;
vueForceRender('key');
}

},

+ 70
- 8
public/routes/initGlobals.js View File

@@ -1,7 +1,6 @@
// Global Variables
// User
var auth = {},
majorList = [],

// Message
_messagelist = [],
@@ -14,19 +13,82 @@ var auth = {},

// Search
_isSearchActiv = false,
_isSubscripeButtonActiv = true,
_isSubscripeButtonActiv = false,
data = [],
search_data = [],

// Vue Rerender Key
vueRender = { key:0 };
vueRender = {
key: 0,
search: 0,
};

const authorRole = 'author';
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() {
if (vueRender.key >= 10) {
vueRender.key = 0;
function vueForceRender(keyName) {
if (vueRender[keyName] >= 10) {
vueRender[keyName] = 0;
}
vueRender.key++;
vueRender[keyName]++;
}

+ 0
- 46
public/routes/majorData.js View File

@@ -1,46 +0,0 @@
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'},
];

+ 3
- 12
public/routes/navRoutes.js View File

@@ -11,7 +11,7 @@ Vue.component('nav-router', {
<i class="material-icons">search</i>
</router-link>

<router-link v-if="isAuthor" 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>
</router-link>

@@ -37,7 +37,7 @@ Vue.component('nav-router', {
<i class="material-icons">search</i> Search
</router-link></li>

<li><router-link v-if="isAuthor" to="/createMessage">
<li><router-link v-if="auth.roles.author" to="/createMessage">
<i class="material-icons">add_circle</i> Create Message
</router-link></li>

@@ -55,18 +55,9 @@ Vue.component('nav-router', {
</div>`,
data: function() {
return {
isAuthor: this.isAuthorCheck(),
auth: auth,
};
},
methods: {
isAuthorCheck: function() {
console.info(auth.roles.author === authorRole);
return (auth.roles.author === authorRole);
},
},
updated: function() {
this.isAuthorChecked();
}
});

const routes = [

+ 35
- 13
public/routes/profilCard.js View File

@@ -11,7 +11,9 @@ Vue.component('profil-card', {

<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: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>
</div>

@@ -57,25 +59,45 @@ Vue.component('profil-card', {
};
},
computed: {
major: function() {
majorOrFaculty: function() {
// e.g. ST@B-ME;ST@EFI;
var majorID = auth.type.split(';')[0].split('@')[1];
//console.info(majorID);
//console.info(majorList);
var majorName = 'Studiengang Unbekannt';
majorList.forEach(function(major) {
if (major.id == majorID) {
majorName = major.name;
}
});
return majorName;
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];
//console.info(majorID);
//console.info(majorList);
var majorName = 'Studiengang Unbekannt';
majorList.forEach(function(major) {
if (major.id == majorID) {
majorName = major.name;
}
});
return majorName;
}
},
labelMajorOrFaculty: function() {
if (auth.roles.author) {
return 'Fakultät:'
} else {
return 'Studiengang:'
}
}
},
methods: {
logout: function() {
clearAuthState();
$.ajax({ url: "api/logout", method: "POST" });
vueForceRender();
vueForceRender('key');
router.push('/profil');
},
}

+ 50
- 35
public/search.js View File

@@ -8,30 +8,34 @@ Vue.component('search',{
:data="filteredDataArray"
placeholder="suche..."
icon="magnify"
@reset-searchtext="resetSearchtext($event)"
@select="option => selected = option">
</b-autocomplete>
<button class="clearButton" @click="clear">x</button>
</b-field>
</form>`,
data: function() {
return{
return {
searchtext: "",
selected: [],
taglist: data,
};
},
computed:{
filteredDataArray() {
filteredDataArray: function() {
return this.taglist.filter((option) => {
return option
.toString()
.toLowerCase()
.indexOf(this.searchtext.toLowerCase()) >= 0
})
}
});
},
},
methods: {
getFilteredTags(text) {
resetSearchtext: function(param) {
this.searchtext = param;
},
getFilteredTags: function(text) {
this.taglist = data.filter((option) => {
return option
.toString()
@@ -41,7 +45,12 @@ Vue.component('search',{
this.search();
},
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() {
tagArray = this.selected;
@@ -69,13 +78,17 @@ Vue.component('search',{
});
},
clear: function() {
//_isSearchActiv = false;
this.searchtext = "";
this.list_messages();
//router.push('/files')
//router.push('/home')
$("#escape-search-link").css("visibility", "hidden");
$("#subscribe-btn").css("visibility", "hidden");
_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() {
@@ -90,44 +103,46 @@ function get_insert_tag(id) {
url: "api/tag/id/" + id,
method: "GET"
}).done(function(tag) {
data.push("#" + tag.name);
data.push('#'+tag.name);
}).fail(function(e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g);
})
}

function searching(searchtext) {
function searching(searchtext,btnString) {
_isSearchActiv = true;
$("#escape-search-link").css("visibility", "visible");
// $("#escape-search-link").css("visibility", "visible");
//console.log(_tags);
console.log(data);

// console.log(data);
if(data.indexOf(searchtext) > -1){
var btnString = "#" + searchtext.replace(/#/g, '') + " abonnieren";
$("#btn-text").text(btnString);
$("#subscribe-btn").css("visibility", "visible");
btnString = searchtext + " abonnieren";
// $("#btn-text").text(btnString);
// $("#subscribe-btn").css("visibility", "visible");
_isSubscripeButtonActiv = true;
}else{
$("#subscribe-btn").css("visibility", "hidden");
// $("#subscribe-btn").css("visibility", "hidden");
_isSubscripeButtonActiv = false;
}


$.ajax({
url: "api/msg/search/" + searchtext.replace(/#/g, ''),
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 (searchtext !== '') {
$.ajax({
url: "api/msg/search/" + searchtext.replace(/#/g, ''),
method: "GET"
}).done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
_messagelist.splice(0, _messagelist.length);
_messagelist.push.apply(_messagelist, jd);
//console.log("jd: "+jd);
for (var e in jd) {
if (!_messages[jd[e]]) {
get_insert_message(jd[e]);
}
}
}
}).fail(function(e, f, g) {
console.log("searching: err: " + e + f + g);
})
}).fail(function(e, f, g) {
console.log("searching: err: " + e + f + g);
})
}
return btnString;
}

function messages() {

+ 2
- 2
public/style/style.css View File

@@ -243,10 +243,10 @@ button.clearButton {
}
#subscribe-btn {
float: right;
visibility: hidden;
-visibility: hidden;
}
#escape-search-link {
visibility: hidden;
-visibility: hidden;
}
#bockmark-not-active {
visibility: visible;

+ 2
- 2
public/style/style.less View File

@@ -287,10 +287,10 @@ button.clearButton{

#subscribe-btn{
float: right;
visibility: hidden;
-visibility: hidden;
}
#escape-search-link{
visibility: hidden;
-visibility: hidden;
}
#bockmark-not-active{
visibility: visible;

+ 3
- 2
server/authorization.js View File

@@ -20,7 +20,7 @@ function getUserRole(found) {
// Mail contains no number
roles += ',"author"';
}
return roles;
return JSON.stringify('{'+roles+'}');
}

// Fill in session object
@@ -37,6 +37,7 @@ function fillSession (req, user, roles, cb) {
req.session.user = user._id;
}
req.session.roles = roles;
console.info(req.session);
}
return cb (err);
});
@@ -128,7 +129,7 @@ const authorization = {
if (entry != null && entry.pwd) {
if (crypto.checkLocalAuth (entry, req.body.pwd)) {
console.info(entry.roles);
return fillSession (req, entry, JSON.stringify(entry.roles), returnSession);
return fillSession (req, entry, JSON.parse(entry.roles), returnSession);
}
return returnError ();
}

+ 27
- 30
server/dbs.js View File

@@ -81,35 +81,6 @@ const dbs = {
});
},
},

"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.")
}
});
},
},
"msg": {
/* POST /api/msg
* <- Message schema
@@ -190,6 +161,32 @@ const dbs = {
});
},
},
"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": {
params: ":id",
/* GET /api/usr/[usr-id]
@@ -380,7 +377,7 @@ const dbs = {
bookmarks: { type: [String],
_comment: "" },
sessionid: { type: String },
roles: { type: [String], required: true,
roles: { type: String, required: true,
_comment: "" },
});
model.Users = common.mongoose.model('users', userSchema);

Loading…
Cancel
Save