Update 'userField' from createMsg after Login; Add API for user get, post, put; Refactor API /tag/id

This commit is contained in:
2019-07-20 23:16:42 +02:00
parent 633dbc90f0
commit 92220fc11c
8 changed files with 120 additions and 17 deletions
+5
View File
@@ -42,6 +42,7 @@ Vue.component('login-panel', {
type="password"
placeholder="Password"
:value="pwd"
@change="pwd_changed"
@keyup.enter.native="login"
required>
</b-input>
@@ -62,6 +63,10 @@ Vue.component('login-panel', {
error: false,
};
},
// TODO: Check if enough for session cookie re-login; checkbox
// mounted: function() {
// this.checkData();
// },
methods: {
closeLoginPanel: function() {
this.$emit('close-login-panel');
+19 -5
View File
@@ -8,7 +8,7 @@ const CreateMsgRouter = {
template: `
<div class="content">
<div class="is-hidden-desktop">
<div class="content card om-card">
<div id="mobile" class="content card om-card">
<h4>Neue Nachricht erstellen</h4>
<b-field>
<b-input placeholder="User" id="user"></b-input>
@@ -41,8 +41,8 @@ const CreateMsgRouter = {
</div>
</div>
<div class=" column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
<div class="content card om-card">
<div class="column is-three-quarters is-pulled-right is-hidden-touch content-desktop">
<div id="desktop" class="content card om-card">
<h4>Neue Nachricht erstellen</h4>
<b-field>
<b-input placeholder="User" id="user"></b-input>
@@ -78,6 +78,8 @@ const CreateMsgRouter = {
data: function () {
return {
auth: auth,
isDisabled: false,
selected: [],
taglist: data,
};
@@ -91,7 +93,7 @@ const CreateMsgRouter = {
var _subject = $("#subject").val();
var _message = $("#message").val();
var _tag = tagArray;
var _user = $("#user").val();
var _user = auth.name ? auth.name : $("#user").val();
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
$.ajax({
url: "api/msg",
@@ -140,6 +142,18 @@ const CreateMsgRouter = {
}
},
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();
@@ -147,7 +161,7 @@ const CreateMsgRouter = {
};
function get_insert_tag(id){
$.ajax({ url: "api/tag/"+id, method: "GET" }).done(function (tag) {
$.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) {