mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
add implementation
This commit is contained in:
+2
-2
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
# . "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run build:version && git add version/git-version.ts
|
||||
#npm run build:version && git add version/git-version.ts
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
<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 ChatSystemService.getGroupRoom(roomId).messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
|
||||
<div class='message-container incoming-{{msg.u.username!=sessionStore.user.UserName}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)">
|
||||
<div class="title">
|
||||
<div class='message-container incoming-{{msg.u.username!=sessionStore.user.UserName}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" [class.dateLabel]="msg.dateLabel">
|
||||
<div class="title" *ngIf="!msg.dateLabel">
|
||||
<ion-label>{{msg.u.name ?? ""}}</ion-label>
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
|
||||
@@ -426,3 +426,12 @@ ion-footer {
|
||||
.font-40-rem {
|
||||
font-size: 2.5rem !important;
|
||||
}
|
||||
|
||||
|
||||
.dateLabel {
|
||||
background: #ebebeb !important;
|
||||
float: unset !important;
|
||||
margin: 0px auto !important;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
*ngFor="let msg of ChatSystemService.getDmRoom(this.roomId).messages; let last = last"
|
||||
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
|
||||
<div (press)="handlePress(msg._id)" class='file message-container incoming-{{msg.u.username!=sessionStore.user.UserName}}'
|
||||
*ngIf="msg.msg !=''">
|
||||
<div class="title file">
|
||||
*ngIf="msg.msg !=''" [class.dateLabel]="msg.dateLabel">
|
||||
<div class="title file" *ngIf="!msg.dateLabel">
|
||||
<ion-label >{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
|
||||
@@ -407,3 +407,12 @@ button::-moz-focus-inner {
|
||||
.font-40-rem {
|
||||
font-size: 2.5rem !important;
|
||||
}
|
||||
|
||||
|
||||
.dateLabel {
|
||||
background: #ebebeb !important;
|
||||
float: unset !important;
|
||||
margin: 0px auto !important;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ export class MessageService {
|
||||
messageModelInstance: MessageModel
|
||||
attachmentsModelData: any
|
||||
|
||||
dateLabel = false
|
||||
|
||||
|
||||
constructor(
|
||||
private NfService: NfService,
|
||||
@@ -708,3 +710,289 @@ export class MessageService {
|
||||
incomingFromCurrentUser = false
|
||||
hasMessage = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class MessageServiceDateLabel {
|
||||
|
||||
customFields
|
||||
channels = []
|
||||
mentions = []
|
||||
msg = ''
|
||||
rid = ''
|
||||
ts = {}
|
||||
|
||||
u = {
|
||||
name: '',
|
||||
username: '',
|
||||
_id: ""
|
||||
}
|
||||
|
||||
t = ''
|
||||
_id = ''
|
||||
id = '' // table id
|
||||
_updatedAt
|
||||
file
|
||||
attachments
|
||||
displayType = ''
|
||||
temporaryData: any
|
||||
hasFile = false
|
||||
hasSendAttachment = false
|
||||
sendAttempt = 0
|
||||
uploadingFile = false
|
||||
errorUploadingAttachment = false
|
||||
loadHistory = false
|
||||
from: 'Offline'|'History'|'stream'| 'send'
|
||||
duration = ''
|
||||
localReference = null
|
||||
viewed: string[] = []
|
||||
received: string[]= []
|
||||
addToDb = false
|
||||
|
||||
messageSend = false
|
||||
delate = false
|
||||
delateRequest = false
|
||||
downloadLoader: boolean = false
|
||||
downloadAttachments = false;
|
||||
downloadAttachmentsTemp = 0;
|
||||
UploadAttachmentsTemp = 0;
|
||||
manualRetry = false
|
||||
origin: 'history' | 'stream' | 'local'
|
||||
|
||||
messageModelInstance: MessageModel
|
||||
attachmentsModelData: any
|
||||
ChatSystemService
|
||||
dateLabel = false
|
||||
|
||||
|
||||
constructor() {}
|
||||
|
||||
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference = 'out-'+uuidv4() , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0, origin, attachmentsModelData, hasFile = false, UploadAttachmentsTemp = 0 }:Message) {
|
||||
|
||||
this.channels = []
|
||||
this.mentions = []
|
||||
this.rid = rid
|
||||
this.ts = ts
|
||||
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.UserName), username: SessionStore.user.UserName, _id: ""}
|
||||
this.t = t
|
||||
this._id = ""
|
||||
this._updatedAt = _updatedAt || new Date().getTime()
|
||||
this.file = file
|
||||
this.temporaryData = temporaryData
|
||||
this.localReference = localReference || null
|
||||
this.id = id
|
||||
this.delate = delate
|
||||
this.delateRequest = delateRequest
|
||||
this.sendAttempt = 0
|
||||
this.origin = origin
|
||||
this.attachmentsModelData = attachmentsModelData
|
||||
this.UploadAttachmentsTemp = UploadAttachmentsTemp
|
||||
|
||||
if(this.attachments?.length >= 1 && attachments?.length >= 1) {
|
||||
this.attachments[0] = Object.assign(this.attachments[0], attachments[0])
|
||||
} else {
|
||||
this.attachments = attachments
|
||||
}
|
||||
|
||||
this.viewed = [];
|
||||
this.received = [];
|
||||
|
||||
this.messageSend = true
|
||||
this.hasFile = hasFile
|
||||
|
||||
this.hasFile = false
|
||||
|
||||
if(!this.u.name && this.u.username) {
|
||||
const user = this.ChatSystemService.users.find((u)=> u.username == this.u.username)
|
||||
if(user) {
|
||||
this.u.name = user.name
|
||||
} else if( this.u.username == SessionStore.user.UserName) {
|
||||
this.u.name = SessionStore.user.FullName
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
this.calDateDuration()
|
||||
}
|
||||
|
||||
|
||||
get offline () {
|
||||
if(!this._id) {
|
||||
return true
|
||||
}
|
||||
|
||||
if(!this.ts) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Message is on the server
|
||||
*/
|
||||
get online() {
|
||||
return !this.offline
|
||||
}
|
||||
|
||||
/**
|
||||
* if Message is already saved on database
|
||||
*/
|
||||
get save() {
|
||||
return this.id != ''
|
||||
}
|
||||
|
||||
|
||||
private usernameToDisplayName(username) {
|
||||
|
||||
try {
|
||||
const firstName = capitalizeTxt(username.split('.')[0])
|
||||
const lastName = capitalizeTxt(username.split('.')[1])
|
||||
return firstName + ' ' + lastName
|
||||
} catch (error) {
|
||||
return username
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async send(): Promise<any> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
functionTimer = null;
|
||||
|
||||
async sendRequestAttachment() {
|
||||
|
||||
}
|
||||
|
||||
async sendRequest(params) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
async redefinedMessage(ChatMessage , update = true) {
|
||||
|
||||
}
|
||||
|
||||
sendNotificaton
|
||||
|
||||
downloadFileMsg() {
|
||||
|
||||
}
|
||||
|
||||
private calDateDuration(date = null) {
|
||||
this.duration = showDateDuration(date || this._updatedAt);
|
||||
}
|
||||
|
||||
|
||||
async delateStatusFalse() {
|
||||
|
||||
}
|
||||
|
||||
addViewed(id: string) {
|
||||
|
||||
}
|
||||
|
||||
addReceived(id: string) {
|
||||
|
||||
}
|
||||
|
||||
async delateDB() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
isSenderIsNotMe(ChatMessage) {
|
||||
return SessionStore.user.ChatData.data.userId != ChatMessage.u._id
|
||||
}
|
||||
|
||||
messageOwner() {
|
||||
return SessionStore.user.ChatData.data.userId == this.u._id
|
||||
}
|
||||
|
||||
getChatObj() {
|
||||
|
||||
}
|
||||
|
||||
earlySave = false
|
||||
|
||||
async addMessageDB() {
|
||||
|
||||
}
|
||||
|
||||
async addFileToDb() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getFileFromDB() {
|
||||
|
||||
}
|
||||
|
||||
async generateTemporaryData () {
|
||||
|
||||
}
|
||||
|
||||
|
||||
get instanceHasAttachment() {
|
||||
return false
|
||||
}
|
||||
|
||||
get instanceHasAttachmentBase64() {
|
||||
if (this.file) {
|
||||
if(this.file.type) {
|
||||
if(this.file?.image_url) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
get instanceHasTemporaryData() {
|
||||
if (!this.temporaryData) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
base64StringToBlob(base64Data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async getRowInstance () {
|
||||
|
||||
|
||||
}
|
||||
|
||||
async saveChanges() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
decryptMessage() {
|
||||
try {
|
||||
// this.msg = this.AESEncrypt.decrypt(this.msg, SessionStore.user.UserName)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
UIdata() {
|
||||
this.incomingFromCurrentUser = this.u.username!= SessionStore.user.UserName
|
||||
this.hasMessage = this.msg !=''
|
||||
}
|
||||
|
||||
incomingFromCurrentUser = false
|
||||
hasMessage = false
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
|
||||
import { MessageService } from 'src/app/services/chat/message.service';
|
||||
import { MessageService, MessageServiceDateLabel } from 'src/app/services/chat/message.service';
|
||||
import { showDateDuration } from 'src/plugin/showDateDuration';
|
||||
import { chatHistory } from 'src/app/models/chatMethod';
|
||||
import { Storage } from '@ionic/storage';
|
||||
@@ -350,9 +350,7 @@ export class RoomService {
|
||||
this.messagesBeforeOfflineAPI.push(message)
|
||||
}
|
||||
|
||||
if(this.chatOpen == false) {
|
||||
this.messageUnread = true
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.scrollDown()
|
||||
@@ -708,17 +706,68 @@ export class RoomService {
|
||||
}
|
||||
|
||||
|
||||
sortArrayISODate(messages: any): any[] {
|
||||
|
||||
return messages.sort((a,b) =>
|
||||
new Date(b._updatedAt ).getTime()
|
||||
-
|
||||
new Date(a._updatedAt).getTime())
|
||||
}
|
||||
|
||||
restoreOnce = false
|
||||
labelDates = []
|
||||
|
||||
|
||||
goshPush(ChatMessage) {
|
||||
let currentDateMessage = new Date(ChatMessage._updatedAt).toLocaleDateString()
|
||||
|
||||
if(currentDateMessage) {
|
||||
if(!this.labelDates.find( e => e == currentDateMessage)) {
|
||||
this.labelDates.push(currentDateMessage)
|
||||
|
||||
const newMessage = this.fix_updatedAt({...ChatMessage})
|
||||
newMessage.msg = currentDateMessage
|
||||
const cloneMessage = new MessageServiceDateLabel()
|
||||
|
||||
cloneMessage.ChatSystemService = this.ChatSystemService
|
||||
cloneMessage.setData({...newMessage} as any)
|
||||
//
|
||||
cloneMessage._id = ""
|
||||
cloneMessage._updatedAt = ""
|
||||
cloneMessage.msg = currentDateMessage
|
||||
cloneMessage.dateLabel = true
|
||||
cloneMessage.delate = false
|
||||
|
||||
if(new Date().toLocaleDateString() == currentDateMessage) {
|
||||
|
||||
cloneMessage.msg = "hoje"
|
||||
} else {
|
||||
cloneMessage.msg = currentDateMessage
|
||||
}
|
||||
|
||||
this.messages.push(cloneMessage as any)
|
||||
|
||||
console.log(currentDateMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async restoreMessageFromDB() {
|
||||
if(environment.chatOffline && this.restoreOnce == false) {
|
||||
this.restoreOnce = true
|
||||
|
||||
const messages = await MessageModel.filter({rid:this.id}).execute()
|
||||
const messages = this.sortArrayISODate(await MessageModel.filter({rid:this.id}).execute()).reverse()
|
||||
|
||||
|
||||
|
||||
console.log('MessageModel', messages)
|
||||
|
||||
for (let ChatMessage of messages) {
|
||||
|
||||
|
||||
this.goshPush(ChatMessage)
|
||||
|
||||
|
||||
const wewMessage = await this.simplePrepareMessage(ChatMessage)
|
||||
wewMessage.from = 'Offline'
|
||||
wewMessage.loadHistory = this.hasLoadHistory
|
||||
@@ -799,7 +848,10 @@ export class RoomService {
|
||||
if(messagesToSave != null) {
|
||||
|
||||
messagesToSave.received = users.map((user) => user._id)
|
||||
messagesToSave.addMessageDB()
|
||||
|
||||
|
||||
this.goshPush(messagesToSave)
|
||||
this.addMessageDB.push(messagesToSave)
|
||||
}
|
||||
}
|
||||
this.messagesBeforeOfflineAPI = []
|
||||
@@ -820,6 +872,13 @@ export class RoomService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
addMessageDB = FIFOProcessQueue(async ({messagesToSave}, callback) => {
|
||||
|
||||
await messagesToSave.addMessageDB()
|
||||
callback()
|
||||
})
|
||||
|
||||
async readAllMessage() {
|
||||
|
||||
this.ViewedMessageService.requestReadAll(this)
|
||||
|
||||
@@ -42,14 +42,14 @@
|
||||
</div>
|
||||
|
||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of ChatSystemService.getGroupRoom(roomId).messages; let last = last">
|
||||
<div class="message-item incoming-{{msg.u.username!=sessionStore.user.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">
|
||||
<div class="message-item incoming-{{msg.u.username!=sessionStore.user.UserName}} max-width-45" *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" [class.dateLabel]="msg.dateLabel">
|
||||
<div class="message-item-options d-flex justify-content-end" *ngIf="!msg.dateLabel">
|
||||
<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 d-flex">
|
||||
<div class="title d-flex" *ngIf="!msg.dateLabel">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
|
||||
@@ -329,3 +329,12 @@
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.dateLabel {
|
||||
background: #ebebeb !important;
|
||||
float: unset !important;
|
||||
margin: 0px auto !important;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -39,15 +39,16 @@
|
||||
|
||||
<div class="messages-list-item-wrapper container-width-100"
|
||||
*ngFor="let msg of ChatSystemService.getDmRoom(roomId).messages; index as i; let last = last" >
|
||||
<div class='message-item incoming-{{msg.u.username!=sessionStore.user.UserName}} max-width-45' *ngIf="msg.msg !=''">
|
||||
<div class="message-item-options d-flex justify-content-end">
|
||||
|
||||
<div class='message-item incoming-{{msg.u.username!=sessionStore.user.UserName}} max-width-45' *ngIf="msg.msg !=''" [class.dateLabel]="msg.dateLabel">
|
||||
<div class="message-item-options d-flex justify-content-end" *ngIf="!msg.dateLabel">
|
||||
<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 d-flex">
|
||||
<div class="title d-flex" *ngIf="!msg.dateLabel">
|
||||
<ion-label >{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{msg.duration}}</span>
|
||||
</div>
|
||||
|
||||
@@ -410,3 +410,12 @@ ion-footer {
|
||||
.lido, .enviado {
|
||||
font-size: rem(11);
|
||||
}
|
||||
|
||||
|
||||
.dateLabel {
|
||||
background: #ebebeb !important;
|
||||
float: unset !important;
|
||||
margin: 0px auto !important;
|
||||
width: 110px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -1654,3 +1654,8 @@ h5, .buttons{
|
||||
.lowercase {
|
||||
text-transform: lowercase;
|
||||
}
|
||||
|
||||
|
||||
.welcome-text {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user