Merge branch 'feature/downloadFile' of bitbucket.org:equilibriumito/gabinete-digital into tempFile

This commit is contained in:
tiago.kayaya
2022-03-21 21:14:41 +01:00
7 changed files with 87 additions and 67 deletions
@@ -63,7 +63,8 @@
<span class="time">{{msg.duration}}</span> <span class="time">{{msg.duration}}</span>
</div> </div>
<div class="message"> <div class="message">
<ion-label>{{msg.msg}}</ion-label> <ion-label *ngIf="msg.delate == false">{{msg.msg}}</ion-label>
<ion-label *ngIf="msg.delate == true">{{msg.msg}}</ion-label>
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
</div> </div>
@@ -92,7 +93,7 @@
</div> </div>
</div> --> </div> -->
<div *ngIf="msg.file"> <div *ngIf="msg.file && msg.delate == false">
<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='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"> <div class="title">
<ion-label>{{msg.u.name ?? ""}}</ion-label> <ion-label>{{msg.u.name ?? ""}}</ion-label>
@@ -148,7 +149,9 @@
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</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> </div>
<div *ngIf="msg.file && msg.delate == true">
Apagou a mensagem
</div>
<div *ngIf="msg.t == 'r'" class="info-text"> <div *ngIf="msg.t == 'r'" class="info-text">
<ion-label>Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"</ion-label><br /> <ion-label>Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"</ion-label><br />
+27 -18
View File
@@ -13,10 +13,12 @@
</div> </div>
<div class="middle-container" *ngIf="!showMessageOptions"> <div class="middle-container" *ngIf="!showMessageOptions">
<div class="middle"> <div class="middle">
<ion-label class="title">{{wsChatMethodsService.getDmRoom(roomId).name}}</ion-label> <!-- <ion-label class="title">{{wsChatMethodsService.getDmRoom(roomId).name}}</ion-label> -->
<!-- <span><ion-icon class="{{users.status}}" name="ellipse"></ion-icon></span> --> <!-- <span><ion-icon class="{{users.status}}" name="ellipse"></ion-icon></span> -->
</div> </div>
</div> </div>
<div (click)="wsChatMethodsService.getDmRoom(roomId).deleteAll()" >delete all</div>
<div class="middle-container-options" *ngIf="showMessageOptions"> <div class="middle-container-options" *ngIf="showMessageOptions">
<fa-icon (click)="deleteMessage(selectedMsgId)" icon="trash" class="middle-container-options-icons"></fa-icon> <fa-icon (click)="deleteMessage(selectedMsgId)" icon="trash" class="middle-container-options-icons"></fa-icon>
<!-- <ion-icon name="trash"></ion-icon> --> <!-- <ion-icon name="trash"></ion-icon> -->
@@ -60,6 +62,7 @@
<span class="time">{{msg.duration}}</span> <span class="time">{{msg.duration}}</span>
</div> </div>
<div> <div>
<<<<<<< HEAD
<ion-label>{{msg.msg}}</ion-label> <ion-label>{{msg.msg}}</ion-label>
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
@@ -73,27 +76,29 @@
</div> </div>
<div> <div>
<ion-label>{{msg.msg}}</ion-label> <ion-label>{{msg.msg}}</ion-label>
=======
<ion-label *ngIf="msg.delate == false">{{msg.msg}}</ion-label>
<ion-label *ngIf="msg.delate == true">{{msg.msg}}</ion-label>
>>>>>>> c9af986ae8181cf24741ac7407264daea648d27e
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
</div> </div>
<div *ngIf="msg.file"> <div *ngIf="msg.file && msg.delate == false">
<div (press)="handlePress(msg._id)" <div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.file.type != 'application/meeting'">
class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' <div class="title">
*ngIf="msg.file.type != 'application/meeting'"> <ion-label>{{msg.u.name}}</ion-label>
<div class="title"> <span class="time">{{msg.duration}}</span>
<ion-label>{{msg.u.name}}</ion-label> </div>
<span class="time">{{msg.duration}}</span> <div>
</div> <div *ngIf="msg.attachments" class="message-attachments">
<div> <div *ngFor="let file of msg.attachments let i = index">
<div *ngIf="msg.attachments" class="message-attachments"> <div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)">
<div *ngFor="let file of msg.attachments let i = index"> <img *ngIf="msg.attachments[0].image_url" src="{{msg.attachments[0].image_url}}" alt="image">
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)"> <ion-icon *ngIf="msg.attachments[0].image_url == null" name="download-outline"></ion-icon>
<img *ngIf="msg.attachments[0].image_url" src="{{msg.attachments[0].image_url}}" alt="image"> </div>
<ion-icon *ngIf="msg.attachments[0].image_url == null" name="download-outline"></ion-icon> <div *ngIf="msg.file.type != 'application/img'">
</div>
<div *ngIf="msg.file.type != 'application/img'">
<div class="file add-attachment-bg-color" *ngIf="msg.file.type != 'application/audio'"> <div class="file add-attachment-bg-color" *ngIf="msg.file.type != 'application/audio'">
<div (click)="docIndex(i); viewDocument(msg, file.title_link)" <div (click)="docIndex(i); viewDocument(msg, file.title_link)"
class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file"> class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
@@ -153,7 +158,7 @@
</div> </div>
<div *ngIf="msg.file"> <div *ngIf="msg.file && msg.delate == false">
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting"> <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 /> <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"> <button (click)="goToEvent(msg.file.id)" class="btn-no-color info-meeting-normal">
@@ -170,6 +175,10 @@
</div> </div>
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
<div *ngIf="msg.file && msg.delate == true">
Apagou a mensagem
</div>
</div> </div>
</div> </div>
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> <ion-fab horizontal="end" vertical="bottom" slot="fixed">
+1
View File
@@ -242,6 +242,7 @@ export class MessageService {
async delateDB() { async delateDB() {
// alert('delete data')
const message = await MessageModel.get({_id: this._id}) const message = await MessageModel.get({_id: this._id})
await message.delete() await message.delete()
+38 -6
View File
@@ -313,8 +313,6 @@ export class RoomService {
async deleteMessageToReceive(userId) { async deleteMessageToReceive(userId) {
const allDeleteMessages = await DeleteMessageModel.filter({rid: this.id}).execute() const allDeleteMessages = await DeleteMessageModel.filter({rid: this.id}).execute()
for(let message_ of allDeleteMessages) { for(let message_ of allDeleteMessages) {
@@ -392,6 +390,15 @@ export class RoomService {
} }
deleteAll() {
this.messages.forEach((message)=>{
if(message?._id) {
this.sendDeleteRequest(message._id)
}
})
}
async delateMessageToSendToOthers(userId) { async delateMessageToSendToOthers(userId) {
const deleteMessage = await DeleteMessageModel.all() const deleteMessage = await DeleteMessageModel.all()
@@ -410,10 +417,12 @@ export class RoomService {
(response: any) => { (response: any) => {
message.delateRequest = true message.delateRequest = true
message.save() message.save()
this.deleteMessage(msgId)
}, },
(response) => { (response) => {
if (response.error.error.startsWith('No message found with the id of')) { if (response.error.error.startsWith('No message found with the id of')) {
// alert('not found')
this.deleteMessage(msgId) this.deleteMessage(msgId)
} else { } else {
// this.deleteMessage(DeletedMessageId) // this.deleteMessage(DeletedMessageId)
@@ -429,6 +438,7 @@ export class RoomService {
} }
) )
} }
@@ -553,7 +563,7 @@ export class RoomService {
const wewMessage = await this.simplePrepareMessage(ChatMessage) const wewMessage = await this.simplePrepareMessage(ChatMessage)
if(wewMessage.offline == false) { if(wewMessage.offline == false) {
const message = await this.prepareMessageCreateIfNotExist({message:ChatMessage}) const message = await this.prepareMessageCreateIfNotExist_iD({message:ChatMessage})
message?.decryptMessage() message?.decryptMessage()
} else { } else {
@@ -584,7 +594,7 @@ export class RoomService {
} }
// runs onces only // runs onces only
async loadHistory({limit = 10000000, forceUpdate = false }) { async loadHistory({limit = 1000, forceUpdate = false }) {
if(forceUpdate == false) { if(forceUpdate == false) {
if (this.hasLoadHistory) { if (this.hasLoadHistory) {
@@ -599,12 +609,14 @@ export class RoomService {
await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => { await this.WsChatService.loadHistory(this.id, limit).then( async (chatHistory:chatHistory) => {
console.log('load chatHistory', JSON.stringify(chatHistory))
const messagesId = this.messages.map((message)=> message._id) const messagesId = this.messages.map((message)=> message._id)
chatHistory.result.messages.reverse().forEach(async(message: any) => { chatHistory.result.messages.reverse().forEach(async(message: any) => {
if (!messagesId.includes(message._id)) { if (!messagesId.includes(message._id)) {
const messagesToSave = await this.prepareMessageCreateIfNotExist({message: message}); const messagesToSave = await this.prepareMessageCreateIfNotExist_iD({message: message});
if(messagesToSave) { if(messagesToSave) {
await messagesToSave.addMessageDB() await messagesToSave.addMessageDB()
} }
@@ -612,7 +624,6 @@ export class RoomService {
}) })
// console.log('load chatHistory', chatHistory)
}) })
@@ -755,6 +766,27 @@ export class RoomService {
} }
} }
async prepareMessageCreateIfNotExist_iD({message}) {
message = this.fix_updatedAt(message)
const found = this.messages.find((MessageService, index) => {
if (MessageService._id == message._id ) {
return true
} else {
return false
}
})
if (!found) {
const wewMessage = this.simplePrepareMessage(message)
this.messages.push(wewMessage)
return wewMessage
} else {
return null
}
}
private calDateDuration(date = null) { private calDateDuration(date = null) {
this.duration = showDateDuration(date || this._updatedAt); this.duration = showDateDuration(date || this._updatedAt);
this._updatedAt = date || this._updatedAt this._updatedAt = date || this._updatedAt
@@ -23,10 +23,7 @@
</ion-label> </ion-label>
</div> </div>
</div> </div>
<!-- <div *ngIf="room.customFields.countDownDate" class="d-flex align-items-center yellow-orange pl-10">
<i class="far fa-clock font-15" ></i>
<ion-label class="font-15 pl-10" color="warning">{{countDownDate()}}</ion-label>
</div> -->
</div> </div>
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
@@ -57,12 +54,13 @@
<span class="time">{{msg.duration}}</span> <span class="time">{{msg.duration}}</span>
</div> </div>
<div class="message"> <div class="message">
<ion-label>{{msg.msg}}</ion-label> <ion-label *ngIf="msg.delate == false">{{msg.msg}}</ion-label>
<ion-label *ngIf="msg.delate == true">{{msg.msg}}</ion-label>
{{last ? scrollToBottom() : ''}} {{last ? scrollToBottom() : ''}}
</div> </div>
</div> </div>
<div *ngIf="msg.file"> <div *ngIf="msg.file && msg.delate == false">
<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 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 *ngIf="msg.file.type != 'application/meeting'">
<div class="message-item-options d-flex justify-content-end"> <div class="message-item-options d-flex justify-content-end">
@@ -126,35 +124,10 @@
<ion-label class="info-meeting-medium"><ion-icon></ion-icon><ion-icon name="location-outline"></ion-icon> {{msg.file.venue}}</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> </div>
<div *ngIf="msg.file && msg.delate == true">
<!-- <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg ==''"> Apagou a mensagem
<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">
</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">{{msg.duration}}</span>
</div>
<div>
<ion-label>{{msg.msg}}</ion-label>
<div *ngIf="msg.file" class="message-attachments">
<div>
<div (click)="openPreview(msg)">
<img *ngIf="msg.attachments[0].image_url" src="{{msg.attachments[0].image_url}}" alt="image">
</div>
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
</div>
</div> </div>
-->
<div *ngIf="msg.t == 'r'" class="info-text"> <div *ngIf="msg.t == 'r'" class="info-text">
<ion-label>Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"</ion-label><br /> <ion-label>Alterou o nome do grupo para "{{msg.msg.split('-').join(' ')}}"</ion-label><br />
@@ -14,10 +14,6 @@
</button> </button>
</div> </div>
</div> </div>
<!-- <div *ngIf="frameUrl" class="width-100">
<iframe id="iframe" [src]="frameUrl" height="20%" width="100%" title="Iframe Example">
</iframe>
</div> -->
<div hidden class="header-bottom" (click)="addContacts()"> <div hidden class="header-bottom" (click)="addContacts()">
<div class="header-bottom-icon"> <div class="header-bottom-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/icon/icons-user.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/icon/icons-user.svg"></ion-icon>
@@ -68,7 +64,7 @@
</div> </div>
</div> </div>
<div *ngIf="msg.file"> <div *ngIf="msg.file && msg.delate == false">
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' <div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'
*ngIf="msg.file.type != 'application/meeting'"> *ngIf="msg.file.type != 'application/meeting'">
<div class="message-item-options d-flex justify-content-end"> <div class="message-item-options d-flex justify-content-end">
@@ -159,8 +155,14 @@
</ion-label><br /> </ion-label><br />
</div> </div>
</div> </div>
<div *ngIf="msg.file && msg.delate == true">
Apagou a mensagem
</div>
</div> </div>
</div> </div>
<ion-fab horizontal="end" vertical="bottom" slot="fixed"> <ion-fab horizontal="end" vertical="bottom" slot="fixed">
<ion-fab-button *ngIf="scrollToBottomBtn" (click)="scrollToBottomClicked()" color="light" size="small"> <ion-fab-button *ngIf="scrollToBottomBtn" (click)="scrollToBottomClicked()" color="light" size="small">
<ion-icon name="chevron-down"></ion-icon> <ion-icon name="chevron-down"></ion-icon>
+1 -1
View File
@@ -6,5 +6,5 @@ export const environment = {
domain: 'gabinetedigital.local', domain: 'gabinetedigital.local',
defaultuser: '',//paulo.pinto paulo.pinto@gabinetedigital.local defaultuser: '',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: '', //tabteste@006, defaultuserpwd: '', //tabteste@006,
chatOffline: false chatOffline: true
}; };