mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
fix merge
This commit is contained in:
@@ -254,7 +254,7 @@ export class DespachoService {
|
||||
});
|
||||
|
||||
despachoList = this.sortService.sortDate(despachoList, 'CreateDate')
|
||||
|
||||
|
||||
if(updateStore) {
|
||||
this.despachoStore.reset(despachoList);
|
||||
}
|
||||
|
||||
@@ -67,19 +67,27 @@
|
||||
<div class="item-date" [class.item-date-active]="room.value.id == idSelected">{{room.value.duration}}</div>
|
||||
</div>
|
||||
<div *ngIf="room.value.lastMessage" class="item-description" [class.item-description-active]="room.value.id == idSelected">
|
||||
|
||||
<ion-label *ngIf="room.value.lastMessage && room.value.otherUserType == false">{{room.value.lastMessage.msg}}</ion-label>
|
||||
<ion-label *ngIf="room.value.otherUserType == true">A escrever ...</ion-label>
|
||||
<ion-label *ngIf="room.value.lastMessage.file">
|
||||
<fa-icon *ngIf="room.value.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon>
|
||||
</ion-label>
|
||||
|
||||
<div *ngIf="room.value.lastMessage.file">
|
||||
<fa-icon *ngIf="room.value.lastMessage.file.type != 'application/meeting' && room.value.lastMessage.file.type != 'application/img'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon>
|
||||
|
||||
<fa-icon *ngIf="room.value.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon>
|
||||
<span> {{room.value.lastMessage.file.name || room.value.lastMessage.file.subject }}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
|
||||
<ion-label *ngIf="room.value.lastMessage.attachments">
|
||||
<div *ngIf="room.value.lastMessage.attachments[0].image_url">
|
||||
<fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon>
|
||||
<span> Fotografia</span>
|
||||
</div>
|
||||
</ion-label>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -122,11 +130,10 @@
|
||||
<div class="item-date" [class.item-date-active]="group.value.id ==idSelected" *ngIf="group.value.customFields.countDownDate">{{countDownDate(group.value.customFields.countDownDate, group.value.id)}}</div>
|
||||
</div>
|
||||
<div *ngIf="group.value.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.value.id ==idSelected">
|
||||
<div class="item-message" *ngIf="group.value.otherUserType == false">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div>
|
||||
|
||||
<div class="item-message" *ngIf="group.value.otherUserType == false">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div>
|
||||
<div *ngIf="group.value.otherUserType == true">{{group.value.userThatIsTyping}} A escrever ...</div>
|
||||
|
||||
<div *ngIf="group.value.lastMessage.u.name" class="item-message">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div>
|
||||
<div class="item-files add-ellipsis" *ngIf="group.value.file">
|
||||
<fa-icon *ngIf="group.value.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon>
|
||||
<fa-icon *ngIf="group.value.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon>
|
||||
|
||||
@@ -143,6 +143,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
console.log(this.wsChatMethodsService.dm);
|
||||
console.log(this.wsChatMethodsService.group);
|
||||
|
||||
|
||||
@@ -548,7 +549,7 @@ export class ChatPage implements OnInit {
|
||||
return dateB - dateA;
|
||||
});
|
||||
|
||||
|
||||
|
||||
//console.log('GROUPS FROM DB', this.allGroups)
|
||||
})
|
||||
|
||||
|
||||
@@ -56,49 +56,20 @@
|
||||
<ion-label>Esta conversa passou a grupo</ion-label><br />
|
||||
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
|
||||
</div>
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
|
||||
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
|
||||
<div class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name ?? ""}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div class="message">
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div (click)="openPreview(msg)">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" >
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
|
||||
<!-- <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
<div *ngIf="msg.file.type == 'application/img'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
</div>
|
||||
@@ -111,7 +82,6 @@
|
||||
<div *ngIf="msg.file" class="message-attachments">
|
||||
<div>
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
File
|
||||
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
|
||||
</div>
|
||||
@@ -120,22 +90,22 @@
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.alias =='documento'" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
|
||||
<div *ngIf="msg.file">
|
||||
<div class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.file.type != 'application/meeting'" (press)="handlePress(msg._id)">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name ?? ""}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div class="message">
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div (click)="openPreview(msg)">
|
||||
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)">
|
||||
<img *ngIf="msg.image_url" src="{{msg.image_url}}" alt="image" >
|
||||
<ion-icon *ngIf="msg.file.image_url == null" name="download-outline"></ion-icon>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
@@ -154,13 +124,19 @@
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name ?? ""}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon name="calendar-outline"></ion-icon> De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}</ion-label><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="msg.t == 'r'" class="info-text">
|
||||
@@ -191,7 +167,7 @@
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
<div *ngIf="msg.file">
|
||||
<!-- <div *ngIf="msg.file">
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name ?? ""}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
@@ -199,7 +175,7 @@
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
|
||||
@@ -137,7 +137,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"asUser": false,
|
||||
}
|
||||
if(msgId){
|
||||
this.alertService.confirmDeleteMessage(body);
|
||||
//this.alertService.confirmDeleteMessage(body);
|
||||
}
|
||||
else{
|
||||
this.toastService.badRequest('Não foi possível apagar');
|
||||
@@ -336,12 +336,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
cssClass: 'chat-popover',
|
||||
componentProps: {
|
||||
roomId: this.roomId,
|
||||
members: this.members,
|
||||
},
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(res=>{
|
||||
if(res.data == 'leave'){
|
||||
console.log('saiu do grupo');
|
||||
//this.wsChatMethodsService.subscribeToRoomUpdate(this.roomId, this.room);
|
||||
}
|
||||
else if(res.data == 'cancel'){
|
||||
console.log('cancel');
|
||||
|
||||
@@ -49,46 +49,14 @@
|
||||
</ion-refresher-content>
|
||||
</ion-refresher> -->
|
||||
<div (click)="handleClick()" class="messages" #scrollMe>
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(this.roomId).massages; let last = last"
|
||||
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="downloadFileMsg(msg)">
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(this.roomId).massages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="downloadFileMsg(msg)" *ngIf="msg.msg !=''">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments let i = index">
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="docIndex(i); downloadFileMsg(msg)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file && msg.file != ''">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -104,7 +72,9 @@
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.alias =='documento'">
|
||||
|
||||
<div *ngIf="msg.file">
|
||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.file.type != 'application/meeting'">
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
@@ -112,15 +82,12 @@
|
||||
<div>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments let i = index">
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
File
|
||||
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)">
|
||||
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
|
||||
<ion-icon *ngIf="msg.file.image_url == null" name="download-outline"></ion-icon>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="docIndex(i); viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
@@ -138,15 +105,22 @@
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon name="calendar-outline"></ion-icon> De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}</ion-label><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
|
||||
<div *ngIf="msg.file">
|
||||
</div>
|
||||
|
||||
<!-- <div *ngIf="msg.file">
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
@@ -154,7 +128,7 @@
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
|
||||
@@ -114,7 +114,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory()
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
|
||||
|
||||
setTimeout(()=>{
|
||||
this.scrollToBottomClicked()
|
||||
}, 50)
|
||||
@@ -245,7 +245,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"asUser": false,
|
||||
}
|
||||
if (msgId) {
|
||||
this.alertService.confirmDeleteMessage(body);
|
||||
//this.alertService.confirmDeleteMessage(body);
|
||||
}
|
||||
else {
|
||||
this.toastService.badRequest('Não foi possível apagar');
|
||||
@@ -580,11 +580,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
this.fileService.downloadFile(element.file.guid).subscribe(async (event) => {
|
||||
var name = element.file.guid;
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
|
||||
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
var base64 = btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), '')
|
||||
);
|
||||
@@ -604,14 +604,14 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
console.log('error LAKE FS FILE', error)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
const readFile = await Filesystem.readFile({
|
||||
path: `${IMAGE_DIR}/${name}`,
|
||||
directory: Directory.Data,
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});*/
|
||||
|
||||
getRoomMessageDB(roomId) {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { GroupContactsPage } from '../group-messages/group-contacts/group-contac
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-new-group',
|
||||
@@ -21,6 +23,7 @@ export class NewGroupPage implements OnInit {
|
||||
thedate:any;
|
||||
groupName:string;
|
||||
documents:any;
|
||||
loggedUserChat: any;
|
||||
|
||||
constructor(
|
||||
private pickerController: PickerController,
|
||||
@@ -30,8 +33,11 @@ export class NewGroupPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private chatService: ChatService,
|
||||
private processesService: ProcessesService,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
private authService: AuthService,
|
||||
)
|
||||
{
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = false;
|
||||
this.groupName = this.navParams.get('name');
|
||||
this.documents = this.navParams.get('documents');
|
||||
@@ -55,10 +61,34 @@ export class NewGroupPage implements OnInit {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
createGroup(){
|
||||
async createGroup(){
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
//Take out all special characters in string
|
||||
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
|
||||
let customFields = {}
|
||||
let res:any;
|
||||
|
||||
if(this.thedate){
|
||||
let customFields = {
|
||||
"countDownDate":this.thedate
|
||||
}
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
else{
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
this.isGroupCreated = true;
|
||||
this.addContacts(res.result);
|
||||
|
||||
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
|
||||
|
||||
//this.addGroupMessage.emit(res.result.rid);
|
||||
|
||||
/*
|
||||
let body = { "name":name, }
|
||||
this.chatService.addGroup(body).subscribe(res=>{
|
||||
console.log('group created');
|
||||
@@ -112,7 +142,7 @@ export class NewGroupPage implements OnInit {
|
||||
this.chatService.sendMessage(body).toPromise();
|
||||
});
|
||||
}
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
async addContacts(room){
|
||||
|
||||
@@ -144,16 +144,16 @@ export class ViewPublicationsPage implements OnInit {
|
||||
console.log('publications ids', res)
|
||||
this.publicationList = new Array();
|
||||
|
||||
for(let i of res) {
|
||||
/* for(let i of res) {
|
||||
this.publications.GetPublicationById(i).subscribe(ress => {
|
||||
console.log('publications by ids', ress)
|
||||
let item: Publication = this.publicationPipe.itemList(ress)
|
||||
console.log('publications by ids 2', item)
|
||||
this.publicationList.push(item);
|
||||
})
|
||||
}
|
||||
} */
|
||||
|
||||
/* res.forEach(element => {
|
||||
res.forEach(element => {
|
||||
console.log('publications elements', element)
|
||||
this.publications.GetPublicationById(element).subscribe(ress => {
|
||||
console.log('publications by ids', ress)
|
||||
@@ -162,7 +162,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.publicationList.push(ress);
|
||||
})
|
||||
|
||||
}); */
|
||||
});
|
||||
|
||||
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlertController, AnimationController } from '@ionic/angular';
|
||||
import { ChatService } from './chat.service';
|
||||
import { WsChatMethodsService } from './chat/ws-chat-methods.service';
|
||||
import { ToastService } from './toast.service';
|
||||
|
||||
@Injectable({
|
||||
@@ -13,6 +14,7 @@ export class AlertService {
|
||||
private animationController: AnimationController,
|
||||
private chatService: ChatService,
|
||||
private toastService: ToastService,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
) { }
|
||||
|
||||
async presentAlert(message:string) {
|
||||
@@ -40,7 +42,9 @@ export class AlertService {
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
async confirmDeleteMessage(body:any) {
|
||||
async confirmDeleteMessage(msgId:any, room:any) {
|
||||
console.log(room);
|
||||
|
||||
const alert = await this.alertController.create({
|
||||
cssClass: 'my-custom-class',
|
||||
header: 'Apagar a mensagem?',
|
||||
@@ -55,10 +59,10 @@ export class AlertService {
|
||||
}, {
|
||||
text: 'Apagar',
|
||||
handler: () => {
|
||||
const loader = this.toastService.loading();
|
||||
this.chatService.deleteMessage(body).subscribe(res=>{
|
||||
loader.remove();
|
||||
});
|
||||
//const loader = this.toastService.loading();
|
||||
this.wsChatMethodsService.deleteMessage(msgId);
|
||||
//this.wsChatMethodsService.subscribeToRoomUpdate(room._id, room);
|
||||
//loader.remove();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -11,12 +11,13 @@ import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { capitalizeTxt } from 'src/plugin/text'
|
||||
import { SortService } from '../functions/sort.service';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomService {
|
||||
|
||||
massages: MessageService[] = []
|
||||
messages: MessageService[] = []
|
||||
storageMessage: any[] = [];
|
||||
lastMessage: MessageService;
|
||||
|
||||
@@ -46,12 +47,12 @@ export class RoomService {
|
||||
private storage: Storage,
|
||||
private platform: Platform,
|
||||
private sqlservice: SqliteService,
|
||||
private NativeNotificationService: NativeNotificationService
|
||||
private NativeNotificationService: NativeNotificationService,
|
||||
) {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
}
|
||||
|
||||
setData({ customFields, id, name, t, lastMessage, _updatedAt }) {
|
||||
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
|
||||
this.customFields = customFields
|
||||
this.id = id
|
||||
this.name = name
|
||||
@@ -64,8 +65,9 @@ export class RoomService {
|
||||
|
||||
receiveMessage() {
|
||||
|
||||
this.WsChatService.receiveLiveMessageFromRoom(
|
||||
this.WsChatService.upateRoomEvents(
|
||||
this.id,
|
||||
"stream-room-messages",
|
||||
(ChatMessage) => {
|
||||
ChatMessage = ChatMessage.fields.args[0]
|
||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||
@@ -74,15 +76,17 @@ export class RoomService {
|
||||
/* this.ToastService._chatMessage({message:'Nova mensagem', sender:'Gilson'}) */
|
||||
const message = new MessageService()
|
||||
message.setData(ChatMessage)
|
||||
this.lastMessage.msg = message.msg
|
||||
|
||||
this.lastMessage = message
|
||||
if (message.t == 'r') { this.name = message.msg }
|
||||
this.calDateDuration(ChatMessage._updatedAt)
|
||||
this.massages.push(message)
|
||||
this.messages.push(message)
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
}, 100)
|
||||
|
||||
//this.sortService.sortDate(this.messages, '')
|
||||
|
||||
if(SessionStore.user.RochetChatUser != ChatMessage.u.username) {
|
||||
this.NativeNotificationService.sendNotificationChat({
|
||||
@@ -118,6 +122,36 @@ export class RoomService {
|
||||
} else if (message.fields.eventName == this.id+'/'+'deleteMessage') {}
|
||||
|
||||
})
|
||||
this.WsChatService.registerCallback
|
||||
}
|
||||
|
||||
async receiveMessageDelete() {
|
||||
|
||||
this.WsChatService.upateRoomEvents(
|
||||
this.id,
|
||||
"stream-notify-room",
|
||||
async (ChatMessage) => {
|
||||
console.log(ChatMessage.fields.args[0]._id);
|
||||
const messageId = ChatMessage.fields.args[0]._id;
|
||||
this.messages.forEach((message, index)=>{
|
||||
if(message._id == messageId){
|
||||
this.messages.splice(index, 1)
|
||||
this.storage.set('chatmsg' + this.id, this.messages).then((value) => {
|
||||
//console.log('MSG DELETE ON STORAGE', value)
|
||||
});
|
||||
|
||||
//Get previous last message from room
|
||||
const previousLastMessage = this.messages.slice(-1)[0];
|
||||
|
||||
this.lastMessage = previousLastMessage;
|
||||
this.calDateDuration(previousLastMessage._updatedAt)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
)
|
||||
this.WsChatService.registerCallback
|
||||
}
|
||||
|
||||
send() {
|
||||
@@ -199,8 +233,8 @@ export class RoomService {
|
||||
console.log('FROM DB WEB', mmessage)
|
||||
const wewMessage = new MessageService()
|
||||
wewMessage.setData(mmessage)
|
||||
this.massages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.massages)
|
||||
this.messages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.messages)
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -223,7 +257,7 @@ export class RoomService {
|
||||
if (message.file) {
|
||||
if (message.file.guid) {
|
||||
this.storage.get(message.file.guid).then((image) => {
|
||||
console.log('IMAGE FROM STORAGE', image)
|
||||
//console.log('IMAGE FROM STORAGE', image)
|
||||
message.file.image_url = image
|
||||
});
|
||||
}
|
||||
@@ -233,8 +267,8 @@ export class RoomService {
|
||||
console.log('FROM DB WEB', mmessage)
|
||||
const wewMessage = new MessageService()
|
||||
wewMessage.setData(mmessage)
|
||||
this.massages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.massages)
|
||||
this.messages.push(wewMessage)
|
||||
console.log('loadHistory 222', this.messages)
|
||||
});
|
||||
})
|
||||
}
|
||||
@@ -263,6 +297,8 @@ export class RoomService {
|
||||
this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => {
|
||||
|
||||
const mgsArray = chatHistory.result.messages.reverse();
|
||||
console.log(mgsArray);
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await this.storage.remove('chatmsg' + this.id).then(() => {
|
||||
console.log('MSG REMOVE ON STORAGE')
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Storage } from '@ionic/storage';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { SortService } from '../functions/sort.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -28,7 +29,8 @@ export class WsChatMethodsService {
|
||||
private storage: Storage,
|
||||
private platform: Platform,
|
||||
private sqlservice: SqliteService,
|
||||
private NativeNotificationService: NativeNotificationService
|
||||
private NativeNotificationService: NativeNotificationService,
|
||||
private sortService: SortService
|
||||
) {
|
||||
(async()=>{
|
||||
await this.getAllRooms();
|
||||
@@ -46,30 +48,7 @@ export class WsChatMethodsService {
|
||||
// console.log("ROOMS" + JSON.stringify(rooms))
|
||||
|
||||
rooms.result.update.forEach((roomData: room) => {
|
||||
let room:RoomService;
|
||||
|
||||
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice, this.NativeNotificationService)
|
||||
room.setData({
|
||||
customFields: roomData.customFields,
|
||||
id: this.getRoomId(roomData),
|
||||
name: this.getRoomName(roomData),
|
||||
t: roomData.t,
|
||||
lastMessage: this.getRoomLastMessage(roomData),
|
||||
_updatedAt: new Date(roomData._updatedAt['$date'])
|
||||
})
|
||||
|
||||
room.receiveMessage()
|
||||
|
||||
let roomId = this.getRoomId(roomData)
|
||||
|
||||
if(this.isIndividual(roomData)) {
|
||||
this.dm[roomId] = room
|
||||
this.dmCount++
|
||||
} else {
|
||||
this.group[roomId] = room
|
||||
this.groupCount++
|
||||
}
|
||||
|
||||
this.prepareRoom(roomData);
|
||||
});
|
||||
|
||||
this.loadingWholeList = false
|
||||
@@ -83,6 +62,9 @@ export class WsChatMethodsService {
|
||||
})
|
||||
|
||||
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
|
||||
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
|
||||
console.log('streamNotifyRoomDeleteMessage', subscription);
|
||||
})
|
||||
}
|
||||
|
||||
for (const id in this.group) {
|
||||
@@ -91,13 +73,69 @@ export class WsChatMethodsService {
|
||||
})
|
||||
|
||||
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
|
||||
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
|
||||
console.log('streamNotifyRoomDeleteMessage', subscription);
|
||||
})
|
||||
}
|
||||
|
||||
this.WsChatService.streamNotifyLogged().then((subscription=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
subscribeToRoomUpdate(id, roomData) {
|
||||
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
})
|
||||
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
})
|
||||
this.WsChatService.streamNotifyLogged().then((subscription=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
}))
|
||||
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
|
||||
console.log('streamNotifyRoomDeleteMessage', subscription);
|
||||
})
|
||||
|
||||
this.prepareRoom(roomData);
|
||||
|
||||
this.getGroupRoom(id).loadHistory();
|
||||
|
||||
}
|
||||
|
||||
prepareRoom(roomData){
|
||||
let room:RoomService;
|
||||
|
||||
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice, this.NativeNotificationService)
|
||||
room.setData({
|
||||
customFields: roomData.customFields,
|
||||
id: this.getRoomId(roomData),
|
||||
name: this.getRoomName(roomData),
|
||||
t: roomData.t,
|
||||
lastMessage: this.getRoomLastMessage(roomData),
|
||||
_updatedAt: new Date(roomData._updatedAt['$date'])
|
||||
})
|
||||
|
||||
room.receiveMessage()
|
||||
room.receiveMessageDelete();
|
||||
|
||||
let roomId = this.getRoomId(roomData)
|
||||
|
||||
if(this.isIndividual(roomData)) {
|
||||
console.log(room);
|
||||
|
||||
this.dm[roomId] = room
|
||||
this.dmCount++
|
||||
} else {
|
||||
this.group[roomId] = room
|
||||
this.groupCount++
|
||||
}
|
||||
}
|
||||
|
||||
deleteMessage(id?) {
|
||||
return this.WsChatService.deleteMessage(id);
|
||||
}
|
||||
|
||||
leaveRoom(id?) {
|
||||
return this.WsChatService.leaveRoom(id);
|
||||
}
|
||||
@@ -110,6 +148,10 @@ export class WsChatMethodsService {
|
||||
return this.WsChatService.addRoomOwner(roomid, userId);
|
||||
}
|
||||
|
||||
createPrivateRoom(groupName, username, customFields){
|
||||
return this.WsChatService.createPrivateRoom(groupName, username, customFields);
|
||||
}
|
||||
|
||||
getDmRoom(id): RoomService {
|
||||
try {
|
||||
return this.dm[id]
|
||||
@@ -141,7 +183,7 @@ export class WsChatMethodsService {
|
||||
return roomData._id
|
||||
}
|
||||
|
||||
getRoomLastMessage(roomData: room) {
|
||||
getRoomLastMessage(roomData: room):any {
|
||||
return roomData.lastMessage
|
||||
}
|
||||
|
||||
|
||||
@@ -228,8 +228,59 @@ export class WsChatService {
|
||||
}
|
||||
|
||||
joinRoom(){}
|
||||
deleteMessage() {}
|
||||
createRoom() {}
|
||||
|
||||
deleteMessage(msgId) {
|
||||
const requestId = uuidv4();
|
||||
|
||||
var message = {
|
||||
msg: "method",
|
||||
method: "deleteMessage",
|
||||
id: requestId,
|
||||
params:[{"_id":msgId}]
|
||||
}
|
||||
|
||||
this.ws.send({message, requestId});
|
||||
|
||||
return new Promise ((resolve, reject) => {
|
||||
this.ws.registerCallback({type:'Onmessage', funx:(message) =>{
|
||||
if(message.id == requestId || deepFind(message, 'result') == requestId){
|
||||
resolve(message)
|
||||
return true
|
||||
}
|
||||
}})
|
||||
});
|
||||
}
|
||||
|
||||
createPrivateRoom(groupName, username, customFields) {
|
||||
const requestId = uuidv4()
|
||||
|
||||
var message = {
|
||||
msg: "method",
|
||||
method: "createPrivateGroup",
|
||||
id: requestId,
|
||||
params: [
|
||||
groupName,
|
||||
[username],
|
||||
false,
|
||||
customFields,
|
||||
{
|
||||
"broadcast":false,
|
||||
"encrypted":false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.ws.send({message, requestId});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
||||
resolve(message)
|
||||
return true
|
||||
}
|
||||
}})
|
||||
});
|
||||
}
|
||||
|
||||
sendStreamNotifyRoom(roomId : string, username, event: 'typing', param: any) {
|
||||
|
||||
@@ -374,15 +425,20 @@ export class WsChatService {
|
||||
|
||||
}
|
||||
|
||||
receiveLiveMessageFromRoom(roomId, funx: Function) {
|
||||
upateRoomEvents(roomId, collection:string, funx: Function, ) {
|
||||
|
||||
this.ws.registerCallback({
|
||||
type:'Onmessage',
|
||||
funx:(message)=>{
|
||||
if(message.msg =='changed' && message.collection == 'stream-room-messages') {
|
||||
//console.log(message);
|
||||
|
||||
if(message.msg =='changed' && message.collection == collection) {
|
||||
if(message.fields.args[0].rid == roomId) {
|
||||
funx(message)
|
||||
}
|
||||
else if(message.fields.eventName ==`${roomId}/deleteMessage`){
|
||||
funx(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -469,6 +525,33 @@ export class WsChatService {
|
||||
|
||||
}
|
||||
|
||||
streamNotifyRoomDeleteMessage(roomId:string) {
|
||||
|
||||
const requestId = uuidv4()
|
||||
|
||||
let message = {
|
||||
"msg": "sub",
|
||||
"id": requestId,
|
||||
"name": "stream-notify-room",
|
||||
"params": [
|
||||
`${roomId}/deleteMessage`,
|
||||
true
|
||||
]
|
||||
};
|
||||
|
||||
this.ws.send({message, requestId})
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
||||
resolve(message)
|
||||
return true
|
||||
}
|
||||
}})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
registerCallback(data:wsCallbacksParams) {
|
||||
return this.ws.registerCallback(data)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { HttpClient, HttpEventType, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
|
||||
import { Storage } from '@ionic/storage';
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ export class FileService {
|
||||
private platform: Platform,
|
||||
private loadingCtrl: LoadingController,
|
||||
private http: HttpClient,
|
||||
private storage: Storage
|
||||
) {
|
||||
this.headers = new HttpHeaders();
|
||||
}
|
||||
@@ -253,43 +254,64 @@ export class FileService {
|
||||
this.capturedImage = this.images[0].data
|
||||
|
||||
this.capturedImageTitle = new Date().getTime() + '.jpeg';
|
||||
const base64 = await fetch(this.capturedImage);
|
||||
const blob = await base64.blob();
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", this.capturedImage);
|
||||
let guid: any = await this.uploadFile(this.capturedImage).toPromise()
|
||||
formData.append("blobFile", blob);
|
||||
console.log('ALL IMAGE', formData)
|
||||
let guid: any = await this.uploadFile(formData).toPromise()
|
||||
console.log(guid.path);
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": roomid,
|
||||
"msg": "",
|
||||
"attachments": [{
|
||||
"title": this.capturedImageTitle,
|
||||
"title_link_download": false,
|
||||
"image_url": this.capturedImage,
|
||||
}],
|
||||
"file":{
|
||||
"type": "application/img",
|
||||
"guid": guid.path,
|
||||
"image_url": ""
|
||||
|
||||
this.downloadFile(guid.path).subscribe(async (event) => {
|
||||
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
//console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
console.log('add picture to chat',fileImage);
|
||||
await this.storage.set(guid.path, fileImage).then(() => {
|
||||
console.log('add picture to chat IMAGE SAVED')
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": roomid,
|
||||
"msg": "",
|
||||
"attachments": [{
|
||||
"title": this.capturedImageTitle,
|
||||
"title_link_download": false,
|
||||
"image_url": fileImage,
|
||||
}],
|
||||
"file":{
|
||||
"type": "application/img",
|
||||
"guid": guid.path,
|
||||
"image_url": fileImage
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('BODY TAKE PICTURE CHAT', body)
|
||||
const loader = this.toastService.loading();
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
console.log(res);
|
||||
loader.remove();
|
||||
},(error) => {
|
||||
loader.remove();
|
||||
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('BODY TAKE PICTURE CHAT', body)
|
||||
const loader = this.toastService.loading();
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
console.log(res);
|
||||
loader.remove();
|
||||
},(error) => {
|
||||
loader.remove();
|
||||
this.toastService.badRequest("Não foi possível adicionar a fotografia!");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
async addCameraPictureToChat(roomId){
|
||||
|
||||
console.log('add camera to picture')
|
||||
|
||||
const image = await Camera.getPhoto({
|
||||
quality: 50,
|
||||
allowEditing: false,
|
||||
@@ -299,6 +321,8 @@ export class FileService {
|
||||
|
||||
if (image) {
|
||||
await this.saveImage(image,roomId)
|
||||
} else {
|
||||
console.log('Error saving image')
|
||||
}
|
||||
|
||||
//this.capturedImage = this.capturedImage;
|
||||
@@ -354,70 +378,84 @@ export class FileService {
|
||||
//loader.remove();
|
||||
});
|
||||
*/ }
|
||||
addPictureToChat(roomId) {
|
||||
|
||||
addPictureToChat(roomId) {
|
||||
console.log('add picture to chat')
|
||||
|
||||
console.log('add picture to chat')
|
||||
|
||||
const input = this.fileLoaderService.createInput({
|
||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
||||
})
|
||||
const input = this.fileLoaderService.createInput({
|
||||
accept: ['image/apng', 'image/jpeg', 'image/png']
|
||||
})
|
||||
|
||||
|
||||
setInterval(()=>{
|
||||
console.log(input.value)
|
||||
}, 550)
|
||||
setInterval(() => {
|
||||
console.log(input.value)
|
||||
}, 550)
|
||||
|
||||
|
||||
input.onchange = async () => {
|
||||
input.onchange = async () => {
|
||||
|
||||
//alert('Onchange AQUI')
|
||||
//alert('Onchange AQUI')
|
||||
|
||||
const file = this.fileLoaderService.getFirstFile(input)
|
||||
const file = this.fileLoaderService.getFirstFile(input)
|
||||
|
||||
console.log(file);
|
||||
console.log('first file',file);
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", file);
|
||||
let guid: any = await this.uploadFile(formData).toPromise()
|
||||
console.log('add picture to chat',guid.path);
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", file);
|
||||
let guid: any = await this.uploadFile(formData).toPromise()
|
||||
console.log('ADD IMAGE FORM DATA', formData)
|
||||
console.log('add picture to chat', guid.path);
|
||||
this.downloadFile(guid.path).subscribe(async (event) => {
|
||||
|
||||
/* const imageData = await this.fileToBase64Service.convert(file)
|
||||
this.capturedImage = imageData; */
|
||||
this.capturedImageTitle = file.name;
|
||||
if (event.type === HttpEventType.DownloadProgress) {
|
||||
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
|
||||
//console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
console.log('add picture to chat',fileImage);
|
||||
await this.storage.set(guid.path, fileImage).then(() => {
|
||||
console.log('add picture to chat IMAGE SAVED')
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": roomId,
|
||||
"msg": "",
|
||||
"attachments": [{
|
||||
//"title": this.capturedImageTitle ,
|
||||
//"text": "description",
|
||||
"title_link_download": false,
|
||||
//"image_url": this.capturedImage,
|
||||
}],
|
||||
"file":{
|
||||
"type": "application/img",
|
||||
"guid": guid.path,
|
||||
"image_url": ""
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": roomId,
|
||||
"msg": "",
|
||||
"attachments": [{
|
||||
//"title": this.capturedImageTitle ,
|
||||
//"text": "description",
|
||||
"title_link_download": false,
|
||||
//"image_url": this.capturedImage,
|
||||
}],
|
||||
"file": {
|
||||
"type": "application/img",
|
||||
"guid": guid.path,
|
||||
"image_url": fileImage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('SELECT PICTURE GALLERY', body)
|
||||
console.log(this.capturedImage)
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res => {
|
||||
|
||||
console.log('Msg after send image', res);
|
||||
}, (error) => {
|
||||
console.log('Msg after send image error', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log('SELECT PICTURE GALLERY', body)
|
||||
console.log(this.capturedImage)
|
||||
});
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
/* const imageData = await this.fileToBase64Service.convert(file)
|
||||
this.capturedImage = imageData; */
|
||||
|
||||
console.log('Msg after send image',res);
|
||||
},(error) => {
|
||||
console.log('Msg after send image error',error);
|
||||
});
|
||||
//console.log(this.capturedImage)
|
||||
};
|
||||
}
|
||||
//console.log(this.capturedImage)
|
||||
};
|
||||
}
|
||||
|
||||
addDocumentToChat(roomId:string) {
|
||||
const input = this.fileLoaderService.createInput({
|
||||
|
||||
@@ -15,7 +15,7 @@ export class SortService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortArrayByDate(myArray: any) {
|
||||
console.log(myArray[0].taskStartDate);
|
||||
if(myArray.length > 0){
|
||||
@@ -26,13 +26,8 @@ export class SortService {
|
||||
}
|
||||
|
||||
sortDate(array = [], path: string) {
|
||||
|
||||
return array.sort( (a,b)=> {
|
||||
|
||||
return new Date(this.ObjectService.deepFind(b, path)).getTime() -
|
||||
new Date(this.ObjectService.deepFind(a, path)).getTime()
|
||||
|
||||
return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,12 +134,9 @@ export class GroupContactsPage implements OnInit {
|
||||
|
||||
updateGroup(){
|
||||
this.showLoader = true;
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
this.room = room['room'];
|
||||
this.addContacts(this.room);
|
||||
this.showLoader = false;
|
||||
this.openGroupMessage.emit(this.room._id);
|
||||
});
|
||||
this.addContacts(this.roomId);
|
||||
this.openGroupMessage.emit(this.roomId);
|
||||
this.showLoader = false;
|
||||
}
|
||||
openGroupMessagesPage(){
|
||||
this.showLoader = true;
|
||||
@@ -259,15 +256,15 @@ export class GroupContactsPage implements OnInit {
|
||||
user.isChecked = !user.isChecked;
|
||||
}
|
||||
|
||||
addContacts(room:any){
|
||||
console.log(room);
|
||||
addContacts(roomId:any){
|
||||
console.log(roomId);
|
||||
this.selectedUserList = this.users.filter(function(contact) {
|
||||
return contact.isChecked == true;
|
||||
});
|
||||
console.log( this.selectedUserList);
|
||||
this.selectedUserList.forEach(user=>{
|
||||
let body ={
|
||||
"roomId":room._id,
|
||||
"roomId":roomId,
|
||||
"userId":user._id,
|
||||
}
|
||||
this.chatService.addUserToGroup(body).subscribe(res=>{
|
||||
|
||||
@@ -44,12 +44,12 @@
|
||||
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
|
||||
</div>
|
||||
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last">
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).messages; let last = last">
|
||||
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" >
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
|
||||
<button (click)="deleteMessage(msg._id, msg)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
@@ -58,89 +58,64 @@
|
||||
</div>
|
||||
<div class="message">
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div (click)="openPreview(msg)">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.alias =='documento'" >
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div class="message">
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div (click)="openPreview(msg)">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div *ngIf="msg.file">
|
||||
<div class="message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.file.type != 'application/meeting'" >
|
||||
<div *ngIf="msg.file.type != 'application/meeting'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id, msg)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div class="message">
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
|
||||
<ion-icon *ngIf="msg.file.image_url == null" name="download-outline"></ion-icon>
|
||||
</div>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon name="calendar-outline"></ion-icon> De {{showDateDuration(msg.file.start_date)}} a {{showDateDuration(msg.file.end_date)}}</ion-label><br />
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
<!-- <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
<div *ngIf="msg.file.type == 'application/img'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
||||
@@ -158,7 +133,6 @@
|
||||
<div *ngIf="msg.file" class="message-attachments">
|
||||
<div>
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
|
||||
</div>
|
||||
</div>
|
||||
@@ -167,7 +141,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<div *ngIf="msg.t == 'r'" class="info-text">
|
||||
@@ -198,7 +172,7 @@
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
<div *ngIf="msg.file" >
|
||||
<!-- <div *ngIf="msg.file" >
|
||||
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal"><ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label></button><br />
|
||||
@@ -206,7 +180,7 @@
|
||||
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</ion-label><br />
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
@@ -242,7 +216,7 @@
|
||||
<ion-fab-button title="Nova Reunião" (click)="bookMeeting()" color="light">
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button title="Adicionar Documento" (click)="addFile()" color="light">
|
||||
<ion-fab-button hidden title="Adicionar Documento" (click)="addFile()" color="light">
|
||||
<ion-icon name="document"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button title="Anexar Fotografia" (click)="addImage()" color="light">
|
||||
|
||||
@@ -80,9 +80,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
downloadFile: any;
|
||||
|
||||
constructor(
|
||||
private menu: MenuController,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
private modalController: ModalController,
|
||||
private actionSheetController: ActionSheetController,
|
||||
public popoverController: PopoverController,
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
@@ -97,8 +96,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
public ThemeService: ThemeService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private storage: Storage,
|
||||
public wsChatMethodsService: WsChatMethodsService
|
||||
|
||||
) {
|
||||
console.log('OnCONSTRUCTOR');
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
this.roomCountDownDate = "";
|
||||
@@ -106,11 +106,13 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
console.log('OnCHANGES');
|
||||
|
||||
this.getRoomInfo();
|
||||
//this.scrollToBottom();
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).getMsgFromDB();
|
||||
console.log('MESSAGES'+this.wsChatMethodsService.getGroupRoom(this.roomId).massages);
|
||||
console.log('MESSAGES'+ this.wsChatMethodsService.getGroupRoom(this.roomId).messages);
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
||||
|
||||
setTimeout(()=>{
|
||||
@@ -120,11 +122,13 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.roomId);
|
||||
this.loggedUser = this.loggedUserChat;
|
||||
//console.log(this.wsChatMethodsService.getRoom(this.roomId).massages);
|
||||
|
||||
this.loggedUser=this.loggedUserChat;
|
||||
this.getRoomInfo();
|
||||
setTimeout(() => {
|
||||
this.getRoomInfo();
|
||||
}, 1000);
|
||||
this.setStatus('online');
|
||||
this.getChatMembers();
|
||||
//this.getMessageDB();
|
||||
@@ -259,6 +263,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
}
|
||||
|
||||
async getRoomInfo() {
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
|
||||
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
|
||||
this.room = room['room'];
|
||||
if (this.room.name) {
|
||||
@@ -293,42 +298,20 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
}
|
||||
|
||||
loadGroupMessages(roomId) {
|
||||
//console.log('here'+room.t);
|
||||
|
||||
this.showLoader = true;
|
||||
//If group is private call getGroupMembers
|
||||
/* if(room.t === 'p'){
|
||||
console.log('private'); */
|
||||
|
||||
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res => {
|
||||
console.log(res);
|
||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
||||
//this.messages = msgOnly.reverse();
|
||||
//console.log(res);
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
/* } */
|
||||
//Otherwise call getChannelMembers for públic groups
|
||||
/* else{
|
||||
this.chatService.getPublicGroupMessages(this.roomId).subscribe(res=>{
|
||||
console.log(res);
|
||||
this.messages = res['messages'].reverse();
|
||||
});
|
||||
} */
|
||||
}
|
||||
|
||||
sendMessage() {
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
|
||||
}
|
||||
|
||||
deleteMessage(msgId: string) {
|
||||
let body = {
|
||||
"roomId": this.roomId,
|
||||
"msgId": msgId,
|
||||
"asUser": false,
|
||||
}
|
||||
this.alertService.confirmDeleteMessage(body);
|
||||
deleteMessage(msgId: string, room:any) {
|
||||
this.alertService.confirmDeleteMessage(msgId, room);
|
||||
}
|
||||
|
||||
async openGroupMessagesOptions() {
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="messages" #scrollMe>
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).massages; let last = last">
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(roomId).messages; let last = last">
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
||||
</fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
|
||||
<button (click)="deleteMessage(msg._id, msg)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
@@ -56,63 +56,74 @@
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'
|
||||
*ngIf="msg.alias == 'documento'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
||||
</fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<!-- <ion-label>{{msg.msg}}</ion-label> -->
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
|
||||
<div (click)="downloadFileMsg(msg)" dfsdvsvs>
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
<img src={{msg.image_url}} alt="image">
|
||||
<!-- <div (click)="openPreview(msg)">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image"> -->
|
||||
</div>
|
||||
<div *ngIf="msg.file">
|
||||
<div class="file">
|
||||
<div (click)="viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer"
|
||||
*ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon
|
||||
*ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
|
||||
icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/meeting'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
<div *ngIf="msg.file">
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.file.type != 'application/meeting'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer">
|
||||
</fa-icon>
|
||||
<mat-menu #beforeMenu="matMenu" xPosition="before">
|
||||
<button (click)="deleteMessage(msg._id, msg)" class="menuButton">Apagar mensagem</button>
|
||||
</mat-menu>
|
||||
</div>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<div *ngIf="msg.file.type == 'application/img'" (click)="downloadFileMsg(msg)" dfsdvsvs>
|
||||
<img src={{msg.file.image_url}} alt="image">
|
||||
<ion-icon *ngIf="msg.file.image_url == null" name="download-outline"></ion-icon>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span
|
||||
*ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
<div *ngIf="msg.file.type != 'application/img'">
|
||||
<div class="file">
|
||||
<div (click)="viewDocument(msg, file.title_link)" class="file-details add-ellipsis cursor-pointer"
|
||||
*ngIf="msg.file">
|
||||
<span *ngIf="msg.file.type">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<fa-icon
|
||||
*ngIf="msg.file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"
|
||||
icon="file-word" class="excel-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/meeting'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
</span>
|
||||
<ion-label class="file-title">{{file.title}}</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span
|
||||
*ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
|
||||
<div class="info-meeting" *ngIf="msg.file.type == 'application/meeting'">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal">
|
||||
<ion-label class="info-meeting-normal">{{msg.file.subject}}</ion-label>
|
||||
</button><br />
|
||||
<ion-label class="info-meeting-medium">
|
||||
<ion-icon name="calendar-outline"></ion-icon> De {{showDateDuration(msg.file.start_date)}} a
|
||||
{{showDateDuration(msg.file.end_date)}}
|
||||
</ion-label><br />
|
||||
<ion-label class="info-meeting-medium">
|
||||
<ion-icon></ion-icon>
|
||||
<ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}
|
||||
</ion-label><br />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
<!-- <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''">
|
||||
<div *ngIf="msg.file">
|
||||
<div *ngIf="msg.file.type == 'application/img'">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
@@ -131,7 +142,6 @@
|
||||
<div *ngIf="msg.file" class="message-attachments">
|
||||
<div>
|
||||
<div (click)="openPreview(msg)">
|
||||
<!-- <img *ngIf="file.image_url" src="{{file.image_url}}" alt="image" (click)="imageSize(file.image_url)"> -->
|
||||
File
|
||||
<img *ngIf="msg.file.image_url" src="{{msg.file.image_url}}" alt="image">
|
||||
</div>
|
||||
@@ -141,10 +151,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<div *ngIf="msg.file">
|
||||
<!-- <div *ngIf="msg.file">
|
||||
<div class="info-meeting" *ngIf="msg.file.type == 'application/meeting'">
|
||||
<ion-label class="info-meeting-small">{{msg.u.name}} criou esta reunião</ion-label><br />
|
||||
<button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal">
|
||||
@@ -160,7 +170,7 @@
|
||||
</ion-label><br />
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
|
||||
@@ -106,8 +106,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).massages.forEach((element) => {
|
||||
console.log('DATATATA 11', element)
|
||||
}) */
|
||||
|
||||
|
||||
|
||||
|
||||
//this.transformData(this.wsChatMethodsService.getDmRoom(this.roomId).massages)
|
||||
//this.getMessageDB()
|
||||
|
||||
@@ -252,16 +252,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).send()
|
||||
}
|
||||
|
||||
deleteMessage(msgId: string) {
|
||||
let body = {
|
||||
"roomId": this.roomId,
|
||||
"msgId": msgId,
|
||||
"asUser": false,
|
||||
}
|
||||
this.alertService.confirmDeleteMessage(body);
|
||||
/* this.chatService.deleteMessage(body).subscribe(res=>{
|
||||
console.log(res);
|
||||
}); */
|
||||
deleteMessage(msgId: string, room:any) {
|
||||
this.alertService.confirmDeleteMessage(msgId, room);
|
||||
}
|
||||
|
||||
async viewDocument(msg: any, url?: string) {
|
||||
@@ -639,7 +631,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
console.log('FILE TYPE 33', msg.file.type)
|
||||
} else if (event.type === HttpEventType.Response) {
|
||||
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
|
||||
|
||||
msg.file = {
|
||||
guid: msg.file.guid,
|
||||
image_url: this.downloadFile,
|
||||
|
||||
@@ -2,7 +2,9 @@ import { analyzeAndValidateNgModules } from '@angular/compiler';
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||
import { DataService } from 'src/app/services/data.service';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
|
||||
@@ -25,6 +27,7 @@ export class NewGroupPage implements OnInit{
|
||||
//groupName:string;
|
||||
task:any;
|
||||
documents: any;
|
||||
loggedUserChat: any;
|
||||
|
||||
@Input() groupName:string;
|
||||
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -37,8 +40,11 @@ export class NewGroupPage implements OnInit{
|
||||
private dataService:DataService,
|
||||
private processesService: ProcessesService,
|
||||
private router: Router,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
private authService: AuthService,
|
||||
)
|
||||
{
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = false;
|
||||
//this.groupName = this.navParams.get('name');
|
||||
}
|
||||
@@ -86,16 +92,38 @@ export class NewGroupPage implements OnInit{
|
||||
this.addGroupMessage.emit();
|
||||
}
|
||||
|
||||
createGroup(){
|
||||
async createGroup(){
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
//Take out all special characters in string
|
||||
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
|
||||
let customFields = {}
|
||||
let res:any;
|
||||
|
||||
if(this.thedate){
|
||||
let customFields = {
|
||||
"countDownDate":this.thedate
|
||||
}
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
else{
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
|
||||
this.addGroupMessage.emit(res.result.rid);
|
||||
|
||||
/*
|
||||
let body = { "name":name, }
|
||||
this.chatService.addGroup(body).subscribe(res=>{
|
||||
console.log('group created');
|
||||
console.log(res['group']);
|
||||
|
||||
this.addGroupMessage.emit(res['group']._id);
|
||||
this.addGroupMessage.emit(res['group']._id); */
|
||||
|
||||
/* this.addGroupMessage.emit(res['group']._id);
|
||||
|
||||
if(this.thedate){
|
||||
let countDownBody = {
|
||||
@@ -139,11 +167,11 @@ export class NewGroupPage implements OnInit{
|
||||
}
|
||||
this.chatService.sendMessage(body).toPromise();
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
|
||||
});
|
||||
//});
|
||||
}
|
||||
|
||||
async addContacts(){
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button (click)="takePicture()" full class="btn-ok" shape="round" >Tirar Fotografia</button>
|
||||
<button (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button>
|
||||
<button (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button>
|
||||
<button hidden (click)="addFile()" class="btn-ok" shape="round" >Anexar Documento</button>
|
||||
<button hidden (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button>
|
||||
<button (click)="addDocGestaoDocumental()" class="btn-ok" shape="round" >Gestão Documental</button>
|
||||
<div class="solid"></div>
|
||||
<button (click)="bookMeeting()" class="btn-ok" shape="round" >Novo Evento</button>
|
||||
|
||||
@@ -96,6 +96,7 @@ export class ChatPopoverPage implements OnInit {
|
||||
}
|
||||
|
||||
this.close('leave');
|
||||
//this.wsChatMethodsService.subscribeToRoomUpdate(this.roomId, res.result);
|
||||
|
||||
|
||||
/* this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
|
||||
Reference in New Issue
Block a user