This commit is contained in:
Peter Maquiran
2023-09-19 10:21:23 +01:00
parent 527cc0f2a6
commit f51bd246fc
29 changed files with 754 additions and 261 deletions
+4 -5
View File
@@ -1,6 +1,6 @@
<ion-content class="height-100 container-wrapper">
<ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-refresher-content>
</ion-refresher-content>
</ion-refresher>
@@ -41,7 +41,7 @@
</ion-segment-button>
</ion-segment>
</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'">
@@ -142,7 +142,7 @@
<div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.id ==idSelected">
<div class="item-message font-13-em white-space-nowrap" *ngIf="group.otherUserType == false">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div>
<div class="font-13-em" *ngIf="group.otherUserType == true">{{group.userThatIsTyping}} está escrever ...</div>
<div class="item-files add-ellipsis" *ngIf="group.lastMessage.file">
<fa-icon *ngIf="group.lastMessage.file.type != 'application/meeting' && group.lastMessage.file.type != 'application/audio'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<fa-icon *ngIf="group.lastMessage.file.type == 'application/audio'" icon="file-audio" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
@@ -231,9 +231,8 @@
[roomId]="roomId"
(backToChat)="backToChat($event)"
(closeAllDesktopComponents)="closeAllDesktopComponents()"
[style.display]="showNewGroup ? 'flex' : 'none'"
*ngIf="showNewGroup"
class=" height-100 flex-column">
class=" height-100 flex-column d-flex">
</app-new-group>
<app-edit-group [roomId]="roomId"
+7 -5
View File
@@ -185,6 +185,7 @@ export class ChatPage implements OnInit {
setTimeout(() => {
this.ChatSystemService.subscribeToRoom()
this.RochetChatConnectorService.setStatus('online')
},1000);
/* const webSocketURL = environment.apiWsChatUrl;
@@ -193,13 +194,13 @@ export class ChatPage implements OnInit {
ws.addEventListener('open', () => {
console.log('WebSocket connection opened');
});
ws.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
// Handle incoming messages from the Rocket.Chat server.
console.log('Received message:', data);
});
ws.addEventListener('close', (event) => {
console.log('WebSocket connection closed', event);
// Optionally, attempt to reopen the connection when it's closed.
@@ -209,8 +210,8 @@ export class ChatPage implements OnInit {
}, 5000); // Reopen the connection after 5 seconds (adjust as needed).
});
this.RochetChatConnectorService.sendStreamNotifyRoom("26XgGhKghKN8fN6v8KvDfW9jrjhKhoAWhM", SessionStore.user.UserName, 'typing', true).catch((error) => console.error(error));
this.RochetChatConnectorService.sendStreamNotifyRoom("26XgGhKghKN8fN6v8KvDfW9jrjhKhoAWhM", SessionStore.user.UserName, 'typing', true).catch((error) => console.error(error));
ws.addEventListener('error', (error) => {
console.error('WebSocket error:', error);
// Handle WebSocket errors here.
@@ -365,6 +366,7 @@ export class ChatPage implements OnInit {
}
openNewGroupPage() {
this.segment = 'Grupos';
this.idSelected = '';
if (window.innerWidth < 701) {
this.newGroup();
@@ -518,7 +520,7 @@ export class ChatPage implements OnInit {
// }).catch((error) => {
// console.error('storage getchatusers: ',error)
// })
// }
// }
// // else {
// // this.sqlservice.getAllChatRoom().then((rooms: any) => {
// // //
@@ -36,7 +36,7 @@ export class GroupContactsPage implements OnInit {
objectUserSingleStone = []
userContainer = {}
constructor(
private modalController: ModalController,
private http: HttpClient,
@@ -61,8 +61,8 @@ export class GroupContactsPage implements OnInit {
// this.chatService.refreshtoken();
this.loadUsers();
// this.getMembers();
}
loadUsers(){
@@ -98,10 +98,10 @@ export class GroupContactsPage implements OnInit {
} else {
'not found'
}
}
const userContainer = {}
for(const user of this.objectUserSingleStone) {
const firstLetter = user.name.charAt(0)
@@ -111,11 +111,11 @@ export class GroupContactsPage implements OnInit {
} else {
userContainer[firstLetter].push(user)
}
}
this.userContainer = userContainer
this.showLoader = false;
});
@@ -155,16 +155,16 @@ export class GroupContactsPage implements OnInit {
"roomId": this.room._id,
"userId": data._id,
}
if(this.room.t == "p"){
this.chatService.removeGroupMember(body).subscribe(res=>{
this.getMembers();
});
}
else if(this.room.t == "c"){
this.chatService.removeChannelMember(body).subscribe(res=>{
this.getMembers();
});
}
@@ -195,7 +195,7 @@ export class GroupContactsPage implements OnInit {
});
const selectedUsers = this.users.filter( e => e?.isChecked == true)
users.forEach( (user, index) => {
if(user[index]) {
console.log({user, index})
@@ -215,7 +215,7 @@ export class GroupContactsPage implements OnInit {
let a = this.objectUserSingleStone.filter( e => e.name.toLowerCase().includes(this.textSearch.toLowerCase()))
let b = {}
for(const user of a) {
const firstLetter = user.name.charAt(0)
@@ -225,16 +225,16 @@ export class GroupContactsPage implements OnInit {
} else {
b[firstLetter].push(user)
}
}
this.userContainer = b
}
clicked(){
}
selectedContact(user:any) {
@@ -244,18 +244,18 @@ export class GroupContactsPage implements OnInit {
} else {
user.isChecked = true
}
const userIndex = this.objectUserSingleStone.findIndex((e) => e._id == user._id)
this.objectUserSingleStone[userIndex].isChecked = user.isChecked
}
addContacts(room:any){
this.selectedUserList = this.users.filter(function(contact) {
return contact.isChecked == true;
});
this.selectedUserList.forEach(user=>{
let body ={
"roomId":room._id,
@@ -263,7 +263,7 @@ export class GroupContactsPage implements OnInit {
}
this.chatService.addUserToGroup(body).subscribe(res=>{
});
});
}
@@ -271,12 +271,12 @@ export class GroupContactsPage implements OnInit {
loading = false
updateGroup(){
if(this.loading) {
return
return
}
this.loading = true
console.log('this.room', this.room)
this.chatService.getRoomInfo(this.room._id).subscribe(room=>{
this.room = room['room'];
this.addContacts(this.room);
@@ -288,8 +288,8 @@ export class GroupContactsPage implements OnInit {
}
async openGroupMessages(roomId:any){
this.close();
const modal = await this.modalController.create({
component: GroupMessagesPage,
componentProps: {
@@ -300,9 +300,11 @@ export class GroupContactsPage implements OnInit {
});
modal.onDidDismiss();
modal.onDidDismiss().then(() => {
this.close();
});
await modal.present();
}
}
+14 -17
View File
@@ -41,25 +41,24 @@ export class NewGroupPage implements OnInit {
ngOnInit() {
// this.chatService.refreshtoken();
// console.log(this.documents)
}
_ionChange(event){
_ionChange(event) {
this.showDuration = event.detail.checked;
if(event.detail.checked){
if(event.detail.checked) {
this.thedate = new Date();
}
else{
else {
this.thedate = '';
}
}
close(){
close() {
this.modalController.dismiss();
}
async createGroup(){
let name = this.groupName.split(' ').join('-');
//Take out all special characters in string
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
@@ -72,17 +71,15 @@ export class NewGroupPage implements OnInit {
"countDownDate": this.thedate
}
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
}
else{
res = await this.ChatSystemService.createPrivateRoom(name, SessionStore.user.UserName, customFields);
}
this.isGroupCreated = true;
this.addContacts(res.result);
this.ChatSystemService.getAllRooms();
setTimeout(() => {
this.ChatSystemService.subscribeToRoomUpdate(res.result.rid, res.result);
}, 10)
@@ -90,23 +87,23 @@ export class NewGroupPage implements OnInit {
if(res?.result?.rid) {
this.ChatSystemService.getAllRooms(() => {
if(!this.ChatSystemService.getGroupRoom(res.result.rid)) {
this.createGroupWithAttachmentsCath(res)
} else {
setTimeout(()=> {
this.createGroupWithAttachments(res)
}, 500)
}
}, res.result.rid);
} else {
this.toastService._badRequest('Existe um grupo com este nome!');
}
@@ -169,7 +166,7 @@ export class NewGroupPage implements OnInit {
this.close();
let name = this.groupName.split(' ').join('-');
const modal = await this.modalController.create({
component: GroupContactsPage,
@@ -206,7 +203,7 @@ export class NewGroupPage implements OnInit {
text: 'Ok',
cssClass: 'btn-cancel',
handler:(value:any) => {
let now = new Date();
this.thedate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + value.days.value, now.getHours() + value.hours.value, now.getMinutes() + value.minutes.value, now.getSeconds(), now.getMilliseconds());
@@ -215,7 +212,7 @@ export class NewGroupPage implements OnInit {
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) {