mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
change room name
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ion-toolbar [class.block-button]="showNewEvent || showNewGroup || showContacts">
|
||||
<!-- <ion-toolbar [class.block-button]="showNewEvent || showNewGroup || showContacts">
|
||||
<ion-segment [(ngModel)]="segment" (ionChange)="onSegmentChange()">
|
||||
<ion-segment-button value="Contactos" class="font-14-em">
|
||||
Conversas
|
||||
@@ -37,36 +37,43 @@
|
||||
Grupos
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
</ion-toolbar>
|
||||
</ion-toolbar> -->
|
||||
|
||||
<div class=" aside overflow-y-auto d-flex flex-wrap flex-grow-1">
|
||||
<div class="width-100" [ngSwitch]="segment">
|
||||
<ion-list *ngSwitchCase="'Contactos'">
|
||||
<ion-item-sliding >
|
||||
<div *ngFor="let room of ChatSystemService._dm"
|
||||
|
||||
[class.item-active]="room.id ==idSelected"
|
||||
class="item item-hover d-flex">
|
||||
|
||||
<div class="item-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon>
|
||||
</div>
|
||||
<div (click)="openMessagesPage(room.id)" class="item-content flex-grow-1 cursor-pointer">
|
||||
<div class="item-title-time">
|
||||
<div class="item-title add-ellipsis" [class.item-title-active]="room.id ==idSelected">
|
||||
<p class="font-15-em add-ellipsis mb-0 white-space-nowrap" [class.bold-message]="room.messageUnread == true">{{room.name.split('-').join(' ')}}</p>
|
||||
<ion-item-sliding>
|
||||
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
|
||||
*ngFor="let room of (items$ | async)"
|
||||
[class.item-active]="room.id == idSelected">
|
||||
<div class="item-icon">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon>
|
||||
</div>
|
||||
<div
|
||||
(click)="openMessagesPage(room.id)"
|
||||
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
|
||||
<div class="item-title-time">
|
||||
<div class="item-title" [class.item-title-active]="room.id == idSelected">
|
||||
<ion-label >
|
||||
<span >
|
||||
<div >
|
||||
<div class="font-15-em" [class.bold-message]="true">
|
||||
{{room.roomName}}
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
<!-- <div class="item-date font-13-em" [class.item-date-active]="room.id == idSelected">{{room.duration}}</div> -->
|
||||
</div>
|
||||
<div class="item-date font-13-em" [class.item-date-active]="room.id ==idSelected" *ngIf="room.lastMessage && !room.customFields.countDownDate">{{room.duration }}</div>
|
||||
<div class="item-date font-13-em" [class.item-date-active]="room.id ==idSelected" *ngIf="room.customFields.countDownDate">{{room.countDownTime }}</div>
|
||||
</div>
|
||||
<div *ngIf="room.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
|
||||
<div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false">{{room.lastMessage.u.name}} <span *ngIf="room.lastMessage.u.name">:</span> {{room.lastMessage.msg}} </div>
|
||||
<div class="font-13-em" *ngIf="room.otherUserType == true">{{room.userThatIsTyping}} está escrever ...</div>
|
||||
<!-- <div *ngIf="room.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="room.id ==idSelected">
|
||||
<div class="item-message font-13-em add-ellipsis white-space-nowrap" *ngIf="room.otherUserType == false"> {{room.lastMessage.msg}} </div>
|
||||
<div class="font-13-em" *ngIf="room.otherUserType == true">está escrever ...</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ion-item-sliding>
|
||||
</ion-item-sliding>
|
||||
</ion-list>
|
||||
<ion-list *ngSwitchCase="'Grupos'">
|
||||
<ion-item-sliding>
|
||||
|
||||
@@ -24,12 +24,9 @@ import { environment } from 'src/environments/environment';
|
||||
import { TimeService } from 'src/app/services/functions/time.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { DataService } from 'src/app/services/data.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ChatDebuggingPage } from 'src/app/shared/popover/chat-debugging/chat-debugging.page';
|
||||
import { EventTrigger } from 'src/app/services/eventTrigger.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
@@ -39,8 +36,6 @@ import { RoomListOutPutDTO } from 'src/app/services/Repositorys/chat/dto/room/ro
|
||||
import { Observable as DexieObservable } from 'Dexie';
|
||||
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@Component({
|
||||
selector: 'app-chat',
|
||||
templateUrl: './chat.page.html',
|
||||
@@ -56,7 +51,7 @@ export class ChatPage implements OnInit {
|
||||
X_Auth_Token: any;
|
||||
|
||||
loggedUser: any;
|
||||
segment: string;
|
||||
segment: string = 'Grupos'
|
||||
allGroups: any[];
|
||||
privateGroups: any[];
|
||||
publicGroups: any[];
|
||||
@@ -149,7 +144,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
this.showLoader = true;
|
||||
|
||||
this.segment = 'Contactos'
|
||||
this.segment = 'Grupos'
|
||||
|
||||
/* this.eventTriger.getObservable().subscribe((event) => {
|
||||
if (event.notification == "recive") {
|
||||
@@ -167,7 +162,6 @@ export class ChatPage implements OnInit {
|
||||
this.items$ = this.RoomRepositoryService.getItemsLive()
|
||||
this.RoomRepositoryService.list();
|
||||
|
||||
this.segment = "Contactos";
|
||||
|
||||
this.authService.userData$.subscribe((res: any) => {
|
||||
this.loggedUser = res;
|
||||
|
||||
+4
-3
@@ -11,7 +11,8 @@ 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';
|
||||
import { RoomUpdateInputDTO, RoomUpdateInputDTOSchema } from '../../dto/room/roomUpdateInputDTO';
|
||||
import { RoomUpdateOutputDTO } from '../../dto/room/roomUpdateOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -41,9 +42,9 @@ export class RoomRemoteDataSourceService {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
@ValidateSchema(RoomUpdateInputDTOSchema)
|
||||
//@APIReturn(RoomByIdOutputDTOSchema,'update/Room/${id}')
|
||||
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateInputDTO>> {
|
||||
async updateRoom(data: RoomUpdateInputDTO): Promise<DataSourceReturn<RoomUpdateOutputDTO>> {
|
||||
const id = data.roomId
|
||||
delete data.roomId
|
||||
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, data);
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const UserSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string().nullable(),
|
||||
});
|
||||
|
||||
const MemberSchema = z.object({
|
||||
id: z.string(),
|
||||
user: UserSchema,
|
||||
joinAt: z.string(),
|
||||
});
|
||||
|
||||
export const RoomUpdateOutputDTOSchema = z.object({
|
||||
roomName: z.string(),
|
||||
roomType: z.number(),
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
roomName: z.string(),
|
||||
createdBy: UserSchema,
|
||||
createdAt: z.string(),
|
||||
expirationDate: z.string().nullable(),
|
||||
roomType: z.number(),
|
||||
members: z.array(MemberSchema),
|
||||
}),
|
||||
});
|
||||
|
||||
export type RoomUpdateOutputDTO = z.infer<typeof RoomUpdateOutputDTOSchema>
|
||||
|
||||
@@ -28,17 +28,11 @@ export class RoomRepositoryService {
|
||||
async list() {
|
||||
const result = await this.roomRemoteDataSourceService.getRoomList()
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log(result.value)
|
||||
}
|
||||
|
||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
|
||||
if(result.isOk()) {
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges(result.value.data, localList)
|
||||
|
||||
console.log({roomsToDelete, roomsToInsert, roomsToUpdate})
|
||||
|
||||
for( const roomData of roomsToInsert) {
|
||||
this.roomLocalDataSourceService.createRoom(roomData)
|
||||
}
|
||||
@@ -54,10 +48,22 @@ export class RoomRepositoryService {
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/updateRoomBy')
|
||||
async updateRoomBy(data: RoomUpdateInputDTO) {
|
||||
this.roomRemoteDataSourceService.updateRoom(data)
|
||||
|
||||
const result = await this.roomRemoteDataSourceService.updateRoom(data)
|
||||
|
||||
if(result.isOk()) {
|
||||
const localList = await this.roomLocalDataSourceService.getRoomList()
|
||||
const { roomsToDelete, roomsToInsert, roomsToUpdate } = roomListDetermineChanges([result.value.data], localList)
|
||||
|
||||
for( const roomData of roomsToUpdate) {
|
||||
this.roomLocalDataSourceService.updateRoom(roomData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@captureAndReraiseAsync('RoomRepositoryService/getRoomById')
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</ion-toolbar>
|
||||
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content class="width-100">
|
||||
@@ -41,4 +42,3 @@
|
||||
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -4,7 +4,11 @@ import { ModalController, PickerController } from '@ionic/angular';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
|
||||
import { RoomRepositoryService } from 'src/app/services/Repositorys/chat/repository/room-repository.service'
|
||||
import { HttpResponse } from '@microsoft/signalr';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ZodError } from 'zod';
|
||||
@Component({
|
||||
selector: 'app-edit-group',
|
||||
templateUrl: './edit-group.page.html',
|
||||
@@ -23,11 +27,15 @@ export class EditGroupPage implements OnInit {
|
||||
@Output() openGroupMessage:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private pickerController: PickerController,
|
||||
private chatService: ChatService,
|
||||
public ThemeService: ThemeService
|
||||
public ThemeService: ThemeService,
|
||||
private RoomRepositoryService: RoomRepositoryService,
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
this.loggedUser = SessionStore.user.ChatData['data'];
|
||||
}
|
||||
@@ -56,24 +64,32 @@ export class EditGroupPage implements OnInit {
|
||||
this.openGroupMessage.emit(this.roomId);
|
||||
}
|
||||
|
||||
changeGroupName() {
|
||||
if(this.groupName.trim().length > 1) {
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
let body = {
|
||||
"roomId": this.room._id,
|
||||
"name": name,
|
||||
}
|
||||
this.chatService.renameGroup(body).subscribe(res=>{
|
||||
this.modalController.dismiss(res['group']);
|
||||
});
|
||||
}
|
||||
else{
|
||||
async changeGroupName() {
|
||||
|
||||
this.showLoader = true
|
||||
const result = await this.RoomRepositoryService.updateRoomBy({
|
||||
roomId: this.roomId,
|
||||
roomName: this.groupName,
|
||||
roomType: 0
|
||||
})
|
||||
|
||||
if(result.isOk()) {
|
||||
this.openGroupMessage.emit(this.roomId);
|
||||
} else if (result.error instanceof HttpResponse) {
|
||||
this.httpErrorHandle.httpStatusHandle(result.error)
|
||||
} else if (result.error instanceof ZodError) {
|
||||
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
|
||||
console.log(result.error.errors)
|
||||
} else {
|
||||
this.toastService._badRequest("Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.")
|
||||
console.log(result.error)
|
||||
}
|
||||
this.updateGroup();
|
||||
|
||||
this.showLoader = false
|
||||
|
||||
}
|
||||
|
||||
updateGroup(){
|
||||
updateGroup() {
|
||||
this.showLoader = true;
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
this.room = room['room'];
|
||||
|
||||
Reference in New Issue
Block a user