+
+

@@ -33,9 +33,61 @@
Hier werden dann die Chats angezeigt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Chats:
+
+
{{ chat.displayName }}
+
+
+
+
-
+
+
Nutzerdaten
+
+
{{ userStore.user?.firstName }}
+
{{ userStore.user?.lastName }}
+
{{ userStore.user?.username }}
+
{{ userStore.user?.id }}
+
@@ -115,6 +167,7 @@
import ProfileCardComponent from 'components/ProfileCardComponent.vue';
import {message} from 'src/models';
import {useUserStore} from 'stores/user-store';
+ import { useChatStore } from 'stores/chat-store';
defineOptions({
name: 'IndexPage'
@@ -123,29 +176,33 @@
const searchQuery = ref("")
const message = ref("");
const gifSearch = ref("");
+ const chatName = ref('');
+ const userSearch = ref('');
+ const usersForChat = ref([] as string[]);
+
const activeMenu = ref("search");
let loadedGifsAmount = 10;
let messages : message[] = [
- {content: "Halllo", timestamp: "13:38", isOwn: true, gif: false, link: false},
- {content: "https://www.google.com/", timestamp: "13:20", isOwn: false, gif: false, link: false},
- {content: "Halllo", timestamp: "13:15", isOwn: false, gif: false, link: false},
- {content: "Halllo", timestamp: "13:14", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:13", isOwn: true, gif: false, link: false},
- {content: "https://media.tenor.com/mtiOW6O-k8YAAAAd/shrek-shrek-rizz.gif", timestamp: "13:11", isOwn: false, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
- {content: "Hallo", timestamp: "13:10", isOwn: true, gif: false, link: false}
+ // {content: "Halllo", timestamp: "13:38", isOwn: true, gif: false, link: false},
+ // {content: "https://www.google.com/", timestamp: "13:20", isOwn: false, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:15", isOwn: false, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:14", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:13", isOwn: true, gif: false, link: false},
+ // {content: "https://media.tenor.com/mtiOW6O-k8YAAAAd/shrek-shrek-rizz.gif", timestamp: "13:11", isOwn: false, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Halllo", timestamp: "13:10", isOwn: true, gif: false, link: false},
+ // {content: "Hallo", timestamp: "13:10", isOwn: true, gif: false, link: false}
];
function isUrl(url : string) {
@@ -181,6 +238,8 @@
const tenorStore = useTenorStore();
const userStore = useUserStore();
+ const chatStore = useChatStore();
+
function getGifs() {
let query = gifSearch.value != "" ? gifSearch.value : "shrek";
@@ -200,12 +259,12 @@
}
function sendMessage() {
- messages.unshift({content: message.value, timestamp: new Date().toTimeString().split(' ')[0].substring(0, 5), isOwn: true, gif: false, link: false});
+ //messages.unshift({content: message.value, timestamp: new Date().toTimeString().split(' ')[0].substring(0, 5), isOwn: true, gif: false, link: false});
message.value = "";
}
function sendGif(url : string) {
- messages.unshift({content: url, timestamp: new Date().toTimeString().split(' ')[0].substring(0, 5), isOwn: true, gif: true, link: false});
+ //messages.unshift({content: url, timestamp: new Date().toTimeString().split(' ')[0].substring(0, 5), isOwn: true, gif: true, link: false});
toggleGifMenu();
}
@@ -221,7 +280,20 @@
userStore.getAllPtpUsers();
+ const logout = () => {
+ userStore.logout();
+ };
+ const createChat = async(chatName: string)=>{
+ if(chatName == ""){
+ chatName = "Chat";
+ }
+ await chatStore.createChat(chatName, usersForChat.value);
+ }
+
+ const loadChats = async() => {
+ await chatStore.loadChatsByUser();
+ };
diff --git a/src/stores/chat-store.ts b/src/stores/chat-store.ts
index 9b7a8f6..74e324f 100644
--- a/src/stores/chat-store.ts
+++ b/src/stores/chat-store.ts
@@ -3,11 +3,10 @@ import { chat } from 'src/models';
import { api } from 'src/boot/axios';
import { useUserStore } from 'stores/user-store';
-const userStore = useUserStore();
-
export const useChatStore = defineStore('chatStore',{
state:() => ({
chats: [] as chat[],
+ chatsLoaded: false
}),
actions: {
async getChatsByUser(): Promise {
@@ -17,10 +16,12 @@ export const useChatStore = defineStore('chatStore',{
return this.chats;
},
async loadChatsByUser() : Promise{
- this.chats = (await api.get("/users/chat/" + userStore.id)).data.response;
+ this.chats = (await api.get("/users/chat/" + useUserStore().id)).data.response;
+ this.chatsLoaded = true;
return this.chats;
},
async createChat(chatName: string, members: string[]){
+ const userStore = useUserStore();
if(userStore.id) {
if (!members.includes(userStore.id)) {
members.push(userStore.id);
diff --git a/src/stores/user-store.ts b/src/stores/user-store.ts
index 877b554..7ff9eb7 100644
--- a/src/stores/user-store.ts
+++ b/src/stores/user-store.ts
@@ -34,7 +34,6 @@ export const useUserStore = defineStore('userStore', {
usersLoaded: false,
keycloak: null as Keycloak | null,
id: "",
- users: [] as ptpUser[],
}),
actions: {
async getPtpUserById(id : string) {
@@ -46,18 +45,18 @@ export const useUserStore = defineStore('userStore', {
async loadPtpUsersById(id : string) : Promise {
return (await api.get("/users/login/"+id)).data;
},
-
+
getAllPtpUsers() {
this.loadAllPtpUsers().then((response : ptpUser[]) => {
this.users = response;
this.usersLoaded = true;
})
},
-
+
async loadAllPtpUsers() {
return (await api.get("/users/user")).data;
},
-
+
async initKeycloak() : Promise{
try {