idk what do
This commit is contained in:
parent
384bd106be
commit
d29cf8a51e
@ -49,12 +49,26 @@ public class MessagesController {
|
||||
|
||||
@PatchMapping("/discussion/{id}")
|
||||
public ResponseEntity<Discussion> AlterDiscussion(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Discussion data){
|
||||
return new ResponseEntity<>(discRepo.findById(id).orElse(null), HttpStatus.OK);
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
disc.setName(data.getName());
|
||||
discRepo.save(disc);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/discussion/{id}")
|
||||
public ResponseEntity<Discussion> sendMessage(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Message msg){
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null){
|
||||
return new UnauthorizedResponse<>(null);
|
||||
}
|
||||
|
||||
Discussion disc = discRepo.findById(id).orElse(null);
|
||||
msg.setAuthor(user);
|
||||
if(disc != null)
|
||||
discServ.CreateMessage(disc, msg);
|
||||
return new ResponseEntity<>(disc, HttpStatus.OK);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { getDiscussions, currentDiscussion, fetchDiscussion, createDiscussion, sendMessage} from '@/rest/msg.js'
|
||||
import { getDiscussions, currentDiscussion, fetchDiscussion, createDiscussion, sendMessage, updateDiscussionName} from '@/rest/msg.js'
|
||||
|
||||
const discussionsList = reactive(await getDiscussions());
|
||||
const msgContent = ref("");
|
||||
@ -21,10 +21,10 @@
|
||||
<button id="createDiscussion" @click="createDiscussion('New Discussion').then( e => discussionsList.push(e) )">+</button>
|
||||
</div>
|
||||
<div id="discussion">
|
||||
<h1 id=msgName >{{currentDiscussion.name}}</h1>
|
||||
<h1 id=msgName ><input class="InputTitle" type="text" @blur="updateDiscussionName(currentDiscussion.id, currentDiscussion.name).then(e => { getDiscussions().then(e => { discussionsList = e }) })" v-model="currentDiscussion.name"></h1>
|
||||
<div id=msgs>
|
||||
<div class="msg" v-for="msg in currentDiscussion.msgs" :sender="msg.sender" :key="msg.id">
|
||||
{{ msg.text }}
|
||||
{{ msg.content }}
|
||||
</div>
|
||||
</div>
|
||||
<div id=messageBox>
|
||||
@ -57,6 +57,14 @@ div#discList{
|
||||
|
||||
}
|
||||
|
||||
.InputTitle{
|
||||
background: inherit;
|
||||
border: inherit;
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
text-align: inherit;
|
||||
}
|
||||
|
||||
.discItem{
|
||||
color: darkorange;
|
||||
display: flex;
|
||||
@ -92,7 +100,7 @@ div#discussion{
|
||||
#msgName{
|
||||
text-align: center;
|
||||
display: block;
|
||||
background-color: #0202f755;
|
||||
background-color: #2a1981;
|
||||
border-radius: 5px;
|
||||
color: white;
|
||||
width: 75%;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Description: Messages frontend api consumer
|
||||
*******************************************************/
|
||||
|
||||
import { restGet, restPost } from './restConsumer.js'
|
||||
import { restGet, restPost, restPatch } from './restConsumer.js'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const currentDiscussion = ref({});
|
||||
@ -21,54 +21,6 @@ export async function getDiscussions(){
|
||||
}
|
||||
|
||||
export async function fetchDiscussion(id){
|
||||
// currentDiscussion.value = {
|
||||
// id: id,
|
||||
// name: "Discussion#2",
|
||||
// msgs: [
|
||||
// {
|
||||
// id: 1,
|
||||
// author: 1,
|
||||
// sender: true,
|
||||
// attachment: null,
|
||||
// text: "Hello world!"
|
||||
// },
|
||||
// {
|
||||
// id: 2,
|
||||
// author: 2,
|
||||
// sender: false,
|
||||
// attachment: null,
|
||||
// text: "Hello What?"
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// author: 2,
|
||||
// sender: false,
|
||||
// attachment: null,
|
||||
// text: "You morron"
|
||||
// },
|
||||
// {
|
||||
// id: 4,
|
||||
// author: 1,
|
||||
// sender: true,
|
||||
// attachment: null,
|
||||
// text: "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. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
// },
|
||||
// // {
|
||||
// // id: 5,
|
||||
// // author: 1,
|
||||
// // sender: true,
|
||||
// // attachment: null,
|
||||
// // text: "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. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
// // },
|
||||
// {
|
||||
// id: 6,
|
||||
// author: 2,
|
||||
// sender: false,
|
||||
// attachment: null,
|
||||
// text: "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. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
currentDiscussion.value = await restGet("/discussion/" + id);
|
||||
}
|
||||
|
||||
@ -86,7 +38,9 @@ export async function sendMessage(id, content, responseId){
|
||||
content: content,
|
||||
response: responseId,
|
||||
}
|
||||
console.log(content)
|
||||
console.log(data)
|
||||
restPost("/discussion/" + id, data);
|
||||
}
|
||||
|
||||
export async function updateDiscussionName(id, name){
|
||||
return restPatch("/discussion/" + id, {name: name});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user