added functions and web-socket to chat in group

This commit is contained in:
2026-05-13 23:01:13 +01:00
parent 90749ea55e
commit bd0d15bbf0
53 changed files with 798 additions and 1593 deletions
@@ -1,8 +1,10 @@
import {Component} from '@angular/core';
import {IonicModule} from "@ionic/angular";
import {Component, inject, input} from '@angular/core';
import {IonicModule, LoadingController, ToastController} from "@ionic/angular";
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {addIcons} from "ionicons";
import {sendOutline} from 'ionicons/icons';
import {GetGroupDetailsDto, MessagesService} from "../../services/api";
import {firstValueFrom} from "rxjs";
addIcons({
"send-outline" : sendOutline
})
@@ -17,7 +19,48 @@ addIcons({
]
})
export class MessageFormComponent {
private messagesService = inject(MessagesService);
private loadCtrl = inject(LoadingController);
private toastCtrl = inject(ToastController);
groupId = input.required<GetGroupDetailsDto["id"]>();
messageForm: FormGroup = new FormGroup({
libelle: new FormControl<string>(null, [Validators.required]),
})
async sendMessageOnGroup(){
const loading = await this.loadCtrl.create({
message: 'Envoi...',
spinner: 'lines-sharp-small'
});
await loading.present();
if (this.messageForm.invalid) {
this.messageForm.reset();
const toast = await this.toastCtrl.create({
message: 'Message incorrect',
duration: 2000,
color: 'danger'
});
await toast.present();
return;
}
try {
await firstValueFrom(this.messagesService.sendMessageEndpoint(this.groupId(), this.messageForm.getRawValue()));
this.messageForm.reset();
}
catch {
const toast = await this.toastCtrl.create({
message: 'Impossible d\'envoyer le messages.',
duration: 2000,
color: 'danger'
});
await toast.present();
this.messageForm.reset();
}
await loading.dismiss();
}
}