Merge branch 'developer' of bitbucket.org:equilibriumito/gabinete-digital into developer

This commit is contained in:
Peter Maquiran
2021-09-29 15:28:08 +01:00
12 changed files with 113 additions and 29 deletions
+1 -1
View File
@@ -384,7 +384,7 @@ hideRefreshButton(){
this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{ this.chatService.getAllDirectMessages().subscribe(async (res:any)=>{
if(res != 200){ if(res != 200){
console.log(res.ims); //console.log(res.ims);
this.userDirectMessages = res.ims.sort((a,b)=>{ this.userDirectMessages = res.ims.sort((a,b)=>{
var dateA = new Date(a._updatedAt).getTime(); var dateA = new Date(a._updatedAt).getTime();
var dateB = new Date(b._updatedAt).getTime(); var dateB = new Date(b._updatedAt).getTime();
@@ -18,7 +18,7 @@
Parecer Parecer
</ion-segment-button> </ion-segment-button>
<ion-segment-button value="deferimento"> <ion-segment-button value="deferimento">
Defereimento Deferimento
</ion-segment-button> </ion-segment-button>
</ion-segment> </ion-segment>
</ion-toolbar> </ion-toolbar>
+31
View File
@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { AlertController, AnimationController } from '@ionic/angular'; import { AlertController, AnimationController } from '@ionic/angular';
import { ChatService } from './chat.service';
import { ToastService } from './toast.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -9,6 +11,8 @@ export class AlertService {
constructor( constructor(
public alertController: AlertController, public alertController: AlertController,
private animationController: AnimationController, private animationController: AnimationController,
private chatService: ChatService,
private toastService: ToastService,
) { } ) { }
async presentAlert(message:string) { async presentAlert(message:string) {
@@ -36,4 +40,31 @@ export class AlertService {
}, 2500); }, 2500);
} }
async confirmDeleteMessage(body:any) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Apagar a mensagem?',
buttons: [
{
text: 'Cancelar',
role: 'cancel',
cssClass: 'secondary',
handler: () => {
//console.log('Confirm Cancel');
}
}, {
text: 'Apagar',
handler: () => {
const loader = this.toastService.loading();
this.chatService.deleteMessage(body).subscribe(res=>{
loader.remove();
});
}
}
]
});
await alert.present();
}
} }
+10
View File
@@ -52,6 +52,7 @@ export class ChatService {
getAllChannels(){ getAllChannels(){
return this.http.get(environment.apiChatUrl+'channels.list', this.options); return this.http.get(environment.apiChatUrl+'channels.list', this.options);
} }
getAllUserChannels(){ getAllUserChannels(){
return this.http.get(environment.apiChatUrl+'channels.list.joined', this.options); return this.http.get(environment.apiChatUrl+'channels.list.joined', this.options);
} }
@@ -59,6 +60,7 @@ export class ChatService {
getAllRooms(){ getAllRooms(){
return this.http.get(environment.apiChatUrl+'rooms.get', this.options); return this.http.get(environment.apiChatUrl+'rooms.get', this.options);
} }
getRoomInfo(roomId:any){ getRoomInfo(roomId:any){
let params = new HttpParams(); let params = new HttpParams();
params = params.set("roomId", roomId); params = params.set("roomId", roomId);
@@ -110,6 +112,14 @@ export class ChatService {
} }
return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts); return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts);
} }
deleteMessage(body:any){
let opts = {
headers: this.headers,
}
return this.http.post(environment.apiChatUrl+'chat.delete', body, opts);
}
leaveRoom(body:any){ leaveRoom(body:any){
let opts = { let opts = {
headers: this.headers, headers: this.headers,
@@ -13,6 +13,7 @@ import { ChatPopoverPageModule } from '../../popover/chat-popover/chat-popover.m
import { NewEventPageModule } from '../../agenda/new-event/new-event.module'; import { NewEventPageModule } from '../../agenda/new-event/new-event.module';
import { PdfViewerModule } from 'ng2-pdf-viewer'; import { PdfViewerModule } from 'ng2-pdf-viewer';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import {MatMenuModule} from '@angular/material/menu';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -23,6 +24,7 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
PdfViewerModule, PdfViewerModule,
ChatPopoverPageModule, ChatPopoverPageModule,
GroupMessagesPageRoutingModule, GroupMessagesPageRoutingModule,
MatMenuModule
// //
], ],
exports: [GroupMessagesPage], exports: [GroupMessagesPage],
@@ -32,14 +32,20 @@
</ion-refresher-content> </ion-refresher-content>
</ion-refresher> </ion-refresher>
<div class="messages overflow-y-auto" #scrollMe> <div class="messages" #scrollMe>
<div class="welcome-text"> <div class="welcome-text">
<ion-label> Esta conversa passou a grupo</ion-label><br /> <ion-label> Esta conversa passou a grupo</ion-label><br />
<ion-label>A conversa original mantêm-se como chat individual</ion-label> <ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div> </div>
<div class="container-width-100" *ngFor="let msg of messages; let last = last" #scrollMe> <div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" class='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.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" >
<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"> <div class="title">
<ion-label>{{msg.u.name}}</ion-label> <ion-label>{{msg.u.name}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span> <span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -131,8 +131,18 @@
.messages{ .messages{
font-size: 13px; font-size: 13px;
font-family: Roboto; font-family: Roboto;
overflow: auto;
//set scroll do bottom
position: absolute;
top: 0;
left: 0;
overflow-x: hidden;
overflow-y: auto;
width: 100%; width: 100%;
height: 100%; height: 100%;
word-wrap: break-word;
-webkit-overflow-scrolling: touch;
.incoming-true, .incoming-false{ .incoming-true, .incoming-false{
padding: 15px 20px; padding: 15px 20px;
@@ -319,6 +319,16 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}); });
this.message = ""; this.message = "";
} }
deleteMessage(msgId:string){
let body = {
"roomId": this.roomId,
"msgId": msgId,
"asUser": false,
}
this.alertService.confirmDeleteMessage(body);
}
async openGroupMessagesOptions() { async openGroupMessagesOptions() {
const enterAnimation = (baseEl: any) => { const enterAnimation = (baseEl: any) => {
@@ -9,6 +9,8 @@ import { MessagesPageRoutingModule } from './messages-routing.module';
import { MessagesPage } from './messages.page'; import { MessagesPage } from './messages.page';
import { SharedModule } from 'src/app/shared/shared.module'; import { SharedModule } from 'src/app/shared/shared.module';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { MatButtonModule } from '@angular/material/button';
import {MatMenuModule} from '@angular/material/menu';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -16,7 +18,10 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
FormsModule, FormsModule,
IonicModule, IonicModule,
FontAwesomeModule, FontAwesomeModule,
MessagesPageRoutingModule MessagesPageRoutingModule,
MatButtonModule,
MatMenuModule
], ],
exports: [MessagesPage], exports: [MessagesPage],
declarations: [MessagesPage] declarations: [MessagesPage]
@@ -34,14 +34,10 @@
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last"> <div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last">
<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'>
<div class="message-item-options d-flex justify-content-end"> <div class="message-item-options d-flex justify-content-end">
<fa-icon (click)="mesageItemDropdownOptions=true" icon="chevron-down" class="message-options-icon"></fa-icon> <fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
<!-- <div class="mesage-item-dropdown-options" *ngIf="mesageItemDropdownOptions"> <mat-menu #beforeMenu="matMenu" xPosition="before">
<ion-label>Apagar mensagem</ion-label> <button (click)="deleteMessage(msg._id)" class="menuButton">Apagar mensagem</button>
</div> --> </mat-menu>
<ion-select hidden class="message-options-icon" interface="popover">
<ion-select-option value="nes">Apagar mensagem</ion-select-option>
</ion-select>
</div> </div>
<div class="title"> <div class="title">
<ion-label>{{msg.u.name}}</ion-label> <ion-label>{{msg.u.name}}</ion-label>
+15 -3
View File
@@ -192,6 +192,18 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.message = ""; this.message = "";
} }
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);
}); */
}
loadMessages(){ loadMessages(){
//this.showLoader = true; //this.showLoader = true;
const roomId = this.roomId const roomId = this.roomId
@@ -400,17 +412,17 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const roomId = this.roomId; const roomId = this.roomId;
this.chatService.getRoomMessages(this.roomId).subscribe(async res => { this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
console.log(res['success']); //console.log(res['success']);
if (res['success'] == true) { if (res['success'] == true) {
// Show Error // Show Error
//showMessage(response.statusText); //showMessage(response.statusText);
//this.loadMessages() this.loadMessages()
this.messages = res['messages'].reverse(); this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages) this.chatMessageStore.add(roomId, this.messages)
console.log(this.messages); //console.log(this.messages);
// Reconnect in one second // Reconnect in one second
if(this.route.url != "/home/chat"){ if(this.route.url != "/home/chat"){
console.log("Timer message stop") console.log("Timer message stop")
+12 -10
View File
@@ -1080,16 +1080,7 @@ ngx-mat-datetime-content{
display: none; display: none;
padding-left: 10px; padding-left: 10px;
padding-right: 0px; padding-right: 0px;
position: absolute; position: absolute !important;
//background-color: red;
//box-shadow: rgba(0, 30, 0, 0.15) 1.95px 1.95px 2.6px;
}
.mesage-item-dropdown-options{
display: none;
margin-top: 15px;
position: absolute;
border: 1px solid red;
} }
} }
@@ -1112,6 +1103,17 @@ ngx-mat-datetime-content{
} }
} }
.menuButton{
font-size: 14px;
width: 100%;
background: none;
padding: 10px 5px 10px 5px;
}
.menuButton:hover{
background: #e6f6ff75;
//font-weight: 400;
}
.message-attachments{ .message-attachments{
border-radius: 5px; border-radius: 5px;
background-color: #42b9fe13; background-color: #42b9fe13;