diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue
index 433300c..92c9c49 100644
--- a/frontend/src/Apps/Msg.vue
+++ b/frontend/src/Apps/Msg.vue
@@ -7,9 +7,9 @@
@@ -17,18 +17,18 @@
{{ discussion.name }}
-
+
@@ -56,6 +56,11 @@ div#discList{
}
+.InputTitle{
+ all: inherit;
+ margin: auto;
+}
+
.discItem{
color: darkorange;
display: flex;
@@ -91,7 +96,7 @@ div#discussion{
#msgName{
text-align: center;
display: block;
- background-color: #0202f755;
+ background-color: #2a1981;
border-radius: 5px;
color: white;
width: 75%;
diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js
index 1cecd42..d1a9521 100644
--- a/frontend/src/rest/msg.js
+++ b/frontend/src/rest/msg.js
@@ -5,78 +5,47 @@
* 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({});
-
/**
- * @return array of
* - id
* - name
* - members
*/
-export async function getDiscussions(){
- return restGet("/discussions");
-}
+export const discussionsList = ref({});
+export const currentDiscussion = ref({});
-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 = restGet("/discussion/" + id);
-}
export async function createDiscussion(name){
- return restPost("/discussion", {name: name});
+ let disc = await restPost("/discussion", {name: name});
+ discussionsList.value.push(disc);
}
export async function invite(id, regNo){
restPost("/discussion/"+ id+ "/invite", {user: regNo});
}
+
+export async function sendMessage(id, content, responseId){
+ let data = {
+ content: content,
+ response: responseId,
+ }
+ restPost("/discussion/" + id, data);
+}
+
+export async function updateDiscussionName(id, name){
+ restPatch("/discussion/" + id, {name: name}).then(() => fetchDiscussions());
+}
+
+
+async function fetchDiscussions(){
+ discussionsList.value = await restGet("/discussions");
+}
+
+export async function fetchDiscussion(id){
+ currentDiscussion.value = await restGet("/discussion/" + id);
+}
+
+await fetchDiscussions();