From c01654c59c68be46b2f3a76e2cc58efef9b59f1c Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 08:40:58 +0200 Subject: [PATCH 01/16] Message timestamp now adds a leading zero to values under ten (minutes only) --- src/components/MessageComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/MessageComponent.vue b/src/components/MessageComponent.vue index 81d3314..00eaaf8 100644 --- a/src/components/MessageComponent.vue +++ b/src/components/MessageComponent.vue @@ -11,7 +11,7 @@ import { decodedTextSpanIntersectsWith } from 'typescript'; }) const date = new Date(Number(props.timestamp)); - const timestampFormatted = date.getDay() + "." + date.getMonth() + "." + date.getFullYear() + ", " + date.getHours() + ":" + date.getMinutes(); + const timestampFormatted = date.getDay() + "." + date.getMonth() + "." + date.getFullYear() + ", " + date.getHours() + ":" + (date.getMinutes() + '').padStart(2, '0'); \ No newline at end of file From 3c3098f323d6524baa7d825eec63ba552d0c6b8a Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 11:56:02 +0200 Subject: [PATCH 06/16] User-Search in CreateChatComponent now displays the correct profile pictures --- src/components/CreateChatComponent.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CreateChatComponent.vue b/src/components/CreateChatComponent.vue index 1e02fba..8c8351a 100644 --- a/src/components/CreateChatComponent.vue +++ b/src/components/CreateChatComponent.vue @@ -11,7 +11,7 @@
{{ user.firstName }} {{ user.lastName }}
From a225aaace3786562640969be77d06ed0ccbb5535 Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 11:56:25 +0200 Subject: [PATCH 07/16] Deleted the unused ExampleStore --- src/stores/example-store.ts | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/stores/example-store.ts diff --git a/src/stores/example-store.ts b/src/stores/example-store.ts deleted file mode 100644 index 83e8390..0000000 --- a/src/stores/example-store.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineStore } from 'pinia'; - -export const useCounterStore = defineStore('counter', { - state: () => ({ - counter: 0, - }), - getters: { - doubleCount: (state) => state.counter * 2, - }, - actions: { - increment() { - this.counter++; - }, - }, -}); From 0403a48a304c429d2f8cbcc881b83f5ed93f9656 Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 11:56:50 +0200 Subject: [PATCH 08/16] Removed default values for status and profile picture and added updateUser call --- src/stores/user-store.ts | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/stores/user-store.ts b/src/stores/user-store.ts index 60a530d..cbb51e9 100644 --- a/src/stores/user-store.ts +++ b/src/stores/user-store.ts @@ -43,14 +43,6 @@ export const useUserStore = defineStore('userStore', { await this.loadPtpUsersById(id).then((response : responseModel) => { this.user = response.response; this.userLoaded = true; - - if(this.user!.profilePictureUrl == null) { - this.user!.profilePictureUrl = "https://th.bing.com/th/id/R.487fe8708797950ab745a3800c31b7a4?rik=qW3zkDdZfweqmQ&pid=ImgRaw&r=0"; - } - - if(this.user!.status == null) { - this.user!.status = "Hey there, I am using ptpChat!"; - } }).catch(error => { console.error("Ein Netzwerkfehler ist aufgetreten"); }); @@ -61,7 +53,6 @@ export const useUserStore = defineStore('userStore', { async loadProfilePictures() { (await api.get("/users/profilePictures")).data.forEach((element: string) => { this.profilePictures.push({ shortName: element.split(" ")[0].replace(":", ""), url: element.split(" ")[1]}); - console.log("Hallo ich mache hier was"); }); this.profilePicturesLoaded = true; }, @@ -69,23 +60,28 @@ export const useUserStore = defineStore('userStore', { getAllPtpUsers() { this.loadAllPtpUsers().then((response : ptpUser[]) => { this.users = response; - - this.users.forEach((user : ptpUser) => { - if(user.profilePictureUrl == null) { - user.profilePictureUrl = "https://th.bing.com/th/id/R.487fe8708797950ab745a3800c31b7a4?rik=qW3zkDdZfweqmQ&pid=ImgRaw&r=0"; - } - - if(user.status == null) { - user.status = "Hey there, I am using ptpChat!"; - } - }) }) this.usersLoaded = true; }, async loadAllPtpUsers() { - return (await api.get("/users/user")).data; + return (await api.get("/users")).data; + }, + + async updateUser() { + // Find corerspoding short name for link + + const updatedUser : ptpUser = {...this.user!}; + + this.profilePictures.forEach((element: profilePicture) => { + if(element.url === this.user!.profilepicture){ + updatedUser.profilepicture = element.shortName; + } + }); + + + await api.post("/users/update", updatedUser); }, async initKeycloak() : Promise{ From 9f516b56196e59c14f223f109cbd4ae9f5a86c4c Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Wed, 29 May 2024 11:57:19 +0200 Subject: [PATCH 09/16] chat store now uses dedicated ProfilePicture model --- src/stores/chat-store.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/stores/chat-store.ts b/src/stores/chat-store.ts index 6df4c80..4e8a60d 100644 --- a/src/stores/chat-store.ts +++ b/src/stores/chat-store.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import {chat, responseModel} from 'src/models'; +import {chat, profilePicture, responseModel} from 'src/models'; import { api } from 'src/boot/axios'; import { useUserStore } from 'stores/user-store'; @@ -8,7 +8,7 @@ export const useChatStore = defineStore('chatStore',{ chats: [] as chat[], chatsLoaded: false, chatExistsReponse: false, - profilePictures : [] as string[], + profilePictures : [] as profilePicture[], profilePicturesLoaded: false }), actions: { @@ -24,7 +24,9 @@ export const useChatStore = defineStore('chatStore',{ return this.chats; }, async loadProfilePictures(){ - this.profilePictures = (await api.get("/users/profilePictures")).data; + (await api.get("/chats/profilePictures")).data.forEach((element: string) => { + this.profilePictures.push({shortName: element.split(" ")[0].replace(":", ""), url: element.split(" ")[1]}); + }); this.profilePicturesLoaded = true; }, async createChat(chatName: string, members: string[]){ From d12ca80375a3b30466f5d7ea4ca46de154e9a17b Mon Sep 17 00:00:00 2001 From: joschuatonn Date: Thu, 30 May 2024 09:15:51 +0200 Subject: [PATCH 10/16] Users can now be removed from chats --- src/components/ChatSettingsComponent.vue | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/ChatSettingsComponent.vue b/src/components/ChatSettingsComponent.vue index cfb48b6..6db68f9 100644 --- a/src/components/ChatSettingsComponent.vue +++ b/src/components/ChatSettingsComponent.vue @@ -16,7 +16,7 @@ - + @@ -67,8 +67,10 @@ import { computed, ref } from 'vue'; import ProfileCardComponent from './ProfileCardComponent.vue'; import { useUserStore } from 'src/stores/user-store'; -import { profilePicture } from 'src/models'; +import { profilePicture, responseModel } from 'src/models'; import { useChatStore } from 'src/stores/chat-store'; +import { useQuasar } from 'quasar'; +import { sendNotification } from 'src/utils'; const showDialog = ref(true); const userStore = useUserStore(); @@ -92,6 +94,19 @@ import { useChatStore } from 'src/stores/chat-store'; const selectProfilePicture = (image: profilePicture) => { props.chat!.profilepicture = image.url; } + + const $q = useQuasar(); + + const removeUser = (keycloakID : string) => { + chatStore.removeUserFromChat(keycloakID, props.chat!.id).then((response : responseModel) => { + reloadChats(); + sendNotification(response.message, response.success); + }); + } + + const reloadChats = async() => { + await chatStore.loadChatsByUser(); + };