mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
add metods to update room name
This commit is contained in:
+7
-2
@@ -11,6 +11,7 @@ import { RoomByIdInputDTO, RoomByIdInputDTOSchema } from '../../dto/room/roomByI
|
||||
import { RoomByIdOutputDTO, RoomByIdOutputDTOSchema } from '../../dto/room/roomByIdOutputDTO';
|
||||
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
|
||||
import { UserRemoveListInputDTO, UserRemoveListInputDTOSchema } from '../../dto/room/userRemoveListInputDTO';
|
||||
import { RoomUpdateInputDTO } from '../../dto/room/roomUpdateInputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -40,8 +41,12 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
async updateRoom(id: string, room: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, room);
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
//@APIReturn(RoomByIdOutputDTOSchema,'update/Room/${id}')
|
||||
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateInputDTO>> {
|
||||
const id = data.roomId
|
||||
delete data.roomId
|
||||
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, data);
|
||||
}
|
||||
|
||||
async deleteRoom(id: string): Promise<Result<any ,any>> {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomUpdateInputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
roomId: z.string(),
|
||||
roomType: z.number(),
|
||||
});
|
||||
|
||||
export type RoomUpdateInputDTO = z.infer<typeof RoomUpdateInputDTOSchema>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RoomUpdateOutputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
roomType: z.number(),
|
||||
});
|
||||
|
||||
export type RoomUpdateOutputDTO = z.infer<typeof RoomUpdateOutputDTOSchema>
|
||||
@@ -10,6 +10,7 @@ import { roomListDetermineChanges } from '../async/rooms/roomListChangeDetector'
|
||||
import { UserRemoveListInputDTO } from '../dto/room/userRemoveListInputDTO';
|
||||
import { roomMemberListDetermineChanges } from '../async/rooms/roomMembersChangeDetector';
|
||||
import { captureAndReraiseAsync } from 'src/app/services/decorators/captureAndReraiseAsync';
|
||||
import { RoomUpdateInputDTO } from '../dto/room/roomUpdateInputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -53,6 +54,11 @@ export class RoomRepositoryService {
|
||||
}
|
||||
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/updateRoomBy')
|
||||
async updateRoomBy(data: RoomUpdateInputDTO) {
|
||||
this.roomRemoteDataSourceService.updateRoom(data)
|
||||
}
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/getRoomById')
|
||||
async getRoomById(id: RoomByIdInputDTO) {
|
||||
const result = await this.roomRemoteDataSourceService.getRoom(id)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="middle">
|
||||
<ion-label class="title">Alterar assunto</ion-label>
|
||||
</div>
|
||||
<app-btn-seguinte *ngIf="groupName" (click)="changeGroupName()"></app-btn-seguinte>
|
||||
<app-btn-seguinte (click)="changeGroupName()"></app-btn-seguinte>..1
|
||||
</div>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
@@ -38,7 +38,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -40,24 +40,24 @@ export class EditGroupPage implements OnInit {
|
||||
getRoomInfo(){
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
this.room = room['room'];
|
||||
|
||||
|
||||
try {
|
||||
this.groupName = this.room.name.split('-').join(' ');
|
||||
} catch (error) {
|
||||
this.groupName = this.room.name;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
close(){
|
||||
close() {
|
||||
//this.modalController.dismiss();
|
||||
this.closeAllDesktopComponents.emit();
|
||||
this.openGroupMessage.emit(this.roomId);
|
||||
}
|
||||
|
||||
changeGroupName(){
|
||||
if(this.groupName.trim().length > 1){
|
||||
changeGroupName() {
|
||||
if(this.groupName.trim().length > 1) {
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
let body = {
|
||||
"roomId": this.room._id,
|
||||
@@ -68,7 +68,7 @@ export class EditGroupPage implements OnInit {
|
||||
});
|
||||
}
|
||||
else{
|
||||
|
||||
|
||||
}
|
||||
this.updateGroup();
|
||||
}
|
||||
@@ -96,13 +96,13 @@ export class EditGroupPage implements OnInit {
|
||||
text: 'Ok',
|
||||
cssClass: 'btn-cancel',
|
||||
handler:(value:any)=>{
|
||||
|
||||
|
||||
this.selectedDuration = [
|
||||
value.days.value,
|
||||
value.hours.value,
|
||||
value.minutes.value,
|
||||
]
|
||||
|
||||
|
||||
if(value.days.value != null && value.hours.value != null && value.minutes.value != null){
|
||||
if(value.days.value > 0){
|
||||
if(value.days.value == 1){
|
||||
|
||||
@@ -10,6 +10,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { HttpRequest } from '@angular/common/http';
|
||||
import { ZodError } from 'zod';
|
||||
import { HttpResponse } from '@microsoft/signalr';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-contacts',
|
||||
@@ -39,6 +40,7 @@ export class GroupContactsPage implements OnInit {
|
||||
private contactsRepositoryService: ContactRepositoryService,
|
||||
private RoomRepositoryService: RoomRepositoryService,
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
private toastService: ToastService,
|
||||
)
|
||||
{}
|
||||
ngOnInit(): void {
|
||||
@@ -107,7 +109,7 @@ export class GroupContactsPage implements OnInit {
|
||||
} else if (getallChatUsers.isErr() && getallChatUsers.error instanceof HttpResponse) {
|
||||
this.httpErrorHandle.httpStatusHandle(getallChatUsers.error)
|
||||
} else {
|
||||
alert('else')
|
||||
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
|
||||
}
|
||||
|
||||
const currentMemberIds = this.currentMembers.map(e => e.wxUserId)
|
||||
|
||||
Reference in New Issue
Block a user