mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 05:45:50 +00:00
Merge branch 'feature/chat' into developer
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ModalController, PickerController } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
|
||||
@Component({
|
||||
@@ -14,6 +15,7 @@ export class EditGroupPage implements OnInit {
|
||||
selectedDuration = ['','',''];
|
||||
groupName:string;
|
||||
room:any;
|
||||
loggedUser: any;
|
||||
@Input() roomId:string;
|
||||
@Output() openGroupContacts:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() openGroupMessage:EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -23,7 +25,9 @@ export class EditGroupPage implements OnInit {
|
||||
private modalController: ModalController,
|
||||
private pickerController: PickerController,
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -58,7 +62,7 @@ export class EditGroupPage implements OnInit {
|
||||
else{
|
||||
console.log("Invalid name!");
|
||||
}
|
||||
this.close();
|
||||
this.close();
|
||||
}
|
||||
|
||||
_ionChange(event){
|
||||
@@ -68,11 +72,11 @@ export class EditGroupPage implements OnInit {
|
||||
const picker = await this.pickerController.create({
|
||||
cssClass: '',
|
||||
buttons: [
|
||||
{
|
||||
{
|
||||
text: 'Cancelar', role: 'cancel', cssClass: 'btn-cancel'
|
||||
},
|
||||
{
|
||||
text: 'Ok',
|
||||
{
|
||||
text: 'Ok',
|
||||
cssClass: 'btn-cancel',
|
||||
handler:(value:any)=>{
|
||||
console.log('button done pressed');
|
||||
@@ -86,24 +90,24 @@ export class EditGroupPage implements OnInit {
|
||||
if(value.days.value > 0){
|
||||
if(value.days.value == 1){
|
||||
if(value.hours.value == 1){
|
||||
this.displayDuration = value.days.value + " day " +
|
||||
this.displayDuration = value.days.value + " day " +
|
||||
value.hours.value + " hora " +
|
||||
value.minutes.value + " minutos";
|
||||
}
|
||||
else{
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
value.hours.value + " horas " +
|
||||
value.minutes.value + " minutos";
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(value.hours.value == 1){
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
value.hours.value + " hora " +
|
||||
value.minutes.value + " minutos";
|
||||
}
|
||||
else{
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
this.displayDuration = value.days.value + " days " +
|
||||
value.hours.value + " horas " +
|
||||
value.minutes.value + " minutos";
|
||||
}
|
||||
@@ -119,7 +123,7 @@ export class EditGroupPage implements OnInit {
|
||||
value.minutes.value + " minutos";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -173,7 +177,7 @@ export class EditGroupPage implements OnInit {
|
||||
await picker.present();
|
||||
picker.onDidDismiss().then(async data =>{
|
||||
let day = await picker.getColumn('days');
|
||||
let hour = await picker.getColumn('hours');
|
||||
let hour = await picker.getColumn('hours');
|
||||
let minutes = await picker.getColumn('minutes');
|
||||
});
|
||||
|
||||
|
||||
@@ -40,11 +40,9 @@ export class GroupContactsPage implements OnInit {
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
//private navParams: NavParams,
|
||||
)
|
||||
)
|
||||
{
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
});
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.textSearch="";
|
||||
this.dm=null;
|
||||
this.room=null;
|
||||
@@ -56,9 +54,9 @@ export class GroupContactsPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
//this.getRoomInfo();
|
||||
//this.loadUsers();
|
||||
this.loadUsers();
|
||||
console.log(this.roomId);
|
||||
this.getChatInfo();
|
||||
this.getChatInfo();
|
||||
//console.log(this.isGroupCreated);
|
||||
}
|
||||
|
||||
@@ -72,7 +70,7 @@ export class GroupContactsPage implements OnInit {
|
||||
}
|
||||
deleteMember(data:any){
|
||||
console.log(data);
|
||||
|
||||
|
||||
let body = {
|
||||
"roomId": this.roomId,
|
||||
"userId": data._id,
|
||||
@@ -100,7 +98,7 @@ export class GroupContactsPage implements OnInit {
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(res=>{
|
||||
console.log(res);
|
||||
let room = res['room'];
|
||||
|
||||
|
||||
if(room.t == "p"){
|
||||
this.chatService.getGroupMembers(this.roomId).subscribe(res=>{
|
||||
this.members = res['members'];
|
||||
@@ -148,7 +146,7 @@ export class GroupContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
loadUsers1(members:any){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -161,7 +159,7 @@ export class GroupContactsPage implements OnInit {
|
||||
else{
|
||||
this.contacts = res.users.filter(data => data.username != this.loggedUser.me.username);
|
||||
}
|
||||
|
||||
|
||||
this.users = this.contacts.sort((a,b) => {
|
||||
if(a.name < b.name){
|
||||
return -1;
|
||||
@@ -172,13 +170,13 @@ export class GroupContactsPage implements OnInit {
|
||||
return 0;
|
||||
});
|
||||
console.log(this.users);
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
}
|
||||
|
||||
loadUsers(){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -191,7 +189,7 @@ export class GroupContactsPage implements OnInit {
|
||||
else{
|
||||
this.contacts = res.users.filter(data => data.username != this.loggedUser.me.username);
|
||||
}
|
||||
|
||||
|
||||
this.users = this.contacts.sort((a,b) => {
|
||||
if(a.name < b.name){
|
||||
return -1;
|
||||
@@ -202,7 +200,7 @@ export class GroupContactsPage implements OnInit {
|
||||
return 0;
|
||||
});
|
||||
console.log(this.users);
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
}
|
||||
@@ -228,7 +226,7 @@ export class GroupContactsPage implements OnInit {
|
||||
async close(){
|
||||
this.modalController.dismiss();
|
||||
if(this.isGroupCreated){
|
||||
console.log('go to conversa');
|
||||
console.log('go to conversa');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss();
|
||||
@@ -272,7 +270,7 @@ export class GroupContactsPage implements OnInit {
|
||||
}
|
||||
this.chatService.addUserToGroup(body).subscribe(res=>{
|
||||
console.log(res['success']);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -285,14 +283,14 @@ export class GroupContactsPage implements OnInit {
|
||||
console.log(res['group']);
|
||||
this.addContacts(res['group']);
|
||||
this.openGroupMessages(res['group']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
this.addContacts(this.room);
|
||||
this.close();
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
} */
|
||||
|
||||
async newGroup(){
|
||||
@@ -312,7 +310,7 @@ export class GroupContactsPage implements OnInit {
|
||||
component: GroupMessagesPage,
|
||||
componentProps: {
|
||||
room: room,
|
||||
},
|
||||
},
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<button class="btn-no-color" (click)="openGroupMessagesOptions()">
|
||||
<ion-icon src="assets/images/icons-menu.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div (click)="openGroupContactsPage()" class="header-bottom">
|
||||
<div class="header-bottom-icon">
|
||||
@@ -32,12 +32,13 @@
|
||||
<ion-refresher-content>
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="welcome-text">
|
||||
<ion-label> {{message}} 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">
|
||||
<div class="container-width-100" *ngFor="let msg of messages">
|
||||
|
||||
<div class="messages overflow-y-auto" #scrollMe>
|
||||
<div class="welcome-text">
|
||||
<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="container-width-100" *ngFor="let msg of messages" #scrollMe>
|
||||
<div *ngIf="msg.t != 'r'" class='incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
@@ -59,6 +60,7 @@
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-label>{{message}}</ion-label>
|
||||
<div class="container width-100 d-flex">
|
||||
<div>
|
||||
<button class="btn-no-color" (click)="openSendGroupMessageOptions()">
|
||||
@@ -67,8 +69,8 @@
|
||||
</div>
|
||||
<div class="width-80">
|
||||
<ion-item class="ion-no-padding type-message" lines="none">
|
||||
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
|
||||
<button class="btn-no-color" (click)="notImplemented()">
|
||||
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
|
||||
<button hidden class="btn-no-color">
|
||||
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
</button>
|
||||
</ion-item>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
padding: 30px 20px 0px 20px;
|
||||
color:#000;
|
||||
//transform: translate3d(0, 1px, 0);
|
||||
|
||||
|
||||
.header-top{
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
@@ -52,7 +52,7 @@
|
||||
margin: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.title{
|
||||
font-size: 25px;
|
||||
}
|
||||
@@ -66,7 +66,7 @@
|
||||
.div-icon ion-icon{
|
||||
float: right;
|
||||
padding-left: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ion-content{
|
||||
@@ -117,7 +117,8 @@
|
||||
.messages{
|
||||
font-size: 13px;
|
||||
font-family: Roboto;
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.incoming-true, .incoming-false{
|
||||
padding: 15px 20px;
|
||||
@@ -159,9 +160,9 @@
|
||||
.container{
|
||||
justify-content: center;
|
||||
justify-content: space-evenly;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
.chat-icon-options{
|
||||
display:block !important;
|
||||
font-size: 25px;
|
||||
@@ -183,10 +184,13 @@
|
||||
align-items: center;
|
||||
overflow: auto;
|
||||
|
||||
|
||||
ion-textarea{
|
||||
min-height: 50px;
|
||||
margin: 0 !important;
|
||||
align-self: center;
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnChanges, OnInit, Input, SimpleChanges, Output, EventEmitter} from '@angular/core';
|
||||
import { Component, OnChanges, OnInit, Input, SimpleChanges, Output, EventEmitter, ViewChild, ElementRef, AfterViewChecked} from '@angular/core';
|
||||
import { ActionSheetController, AnimationController, MenuController, ModalController, PopoverController } from '@ionic/angular';
|
||||
import { AlertService } from 'src/app/services/alert.service';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
@@ -8,31 +8,35 @@ import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popove
|
||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||
import { NewGroupPage } from '../new-group/new-group.page';
|
||||
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||
import { Router } from '@angular/router'
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
styleUrls: ['./group-messages.page.scss'],
|
||||
})
|
||||
export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
export class GroupMessagesPage implements OnInit, OnChanges, AfterViewChecked {
|
||||
showLoader: boolean;
|
||||
isGroupCreated:boolean;
|
||||
loggedUser: any;
|
||||
message:any;
|
||||
leaveStatus:any;
|
||||
messages:any;
|
||||
|
||||
|
||||
room:any;
|
||||
|
||||
room:any = new Array();
|
||||
roomName:any;
|
||||
members:any;
|
||||
|
||||
loggedUserChat:any;
|
||||
@Input() roomId:string;
|
||||
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() showEmptyContainer:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() openGroupContacts:EventEmitter<any> = new EventEmitter<any>();
|
||||
@Output() openEditGroupPage:EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
||||
|
||||
constructor(
|
||||
private menu: MenuController,
|
||||
private modalController: ModalController,
|
||||
@@ -42,24 +46,33 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
private authService: AuthService,
|
||||
private animationController: AnimationController,
|
||||
private alertService: AlertService,
|
||||
private route: Router
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
this.getRoomInfo();
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
this.loggedUser=this.loggedUserChat;
|
||||
this.getRoomInfo();
|
||||
this.serverLongPull();
|
||||
console.log(this.roomId);
|
||||
}
|
||||
|
||||
notImplemented(){
|
||||
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
||||
ngAfterViewChecked() {
|
||||
//this.scrollToBottom();
|
||||
}
|
||||
|
||||
scrollToBottom(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
finally {
|
||||
}
|
||||
}
|
||||
|
||||
openGroupContactsPage(){
|
||||
@@ -74,17 +87,20 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
this.getRoomInfo();
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
get watch(){
|
||||
this.getRoomInfo();
|
||||
console.log('here watching');
|
||||
|
||||
|
||||
return this.roomId;
|
||||
}
|
||||
getRoomInfo(){
|
||||
this.showLoader = true;
|
||||
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
|
||||
this.room = room['room'];
|
||||
this.roomName = this.room.name.split('-').join(' ');
|
||||
if(this.room.name){
|
||||
this.roomName = this.room.name.split('-').join(' ');
|
||||
}
|
||||
this.getGroupContacts(this.room);
|
||||
this.loadGroupMessages(this.room);
|
||||
this.showLoader = false;
|
||||
@@ -112,18 +128,18 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
}
|
||||
loadGroupMessages(room:any){
|
||||
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;
|
||||
});
|
||||
}
|
||||
@@ -138,14 +154,14 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
sendMessage(){
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
/* this.loadGroupMessages(); */
|
||||
/* this.loadGroupMessages(); */
|
||||
this.getRoomInfo();
|
||||
});
|
||||
this.message = "";
|
||||
@@ -174,7 +190,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
const leaveAnimation = (baseEl: any) => {
|
||||
return enterAnimation(baseEl).direction('reverse');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* const popover = await this.popoverController.create({
|
||||
component: MessagesOptionsPage,
|
||||
@@ -217,11 +233,11 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
else{
|
||||
this.roomName = res.data.name.split('-').join(' ');
|
||||
console.log(this.roomName);
|
||||
|
||||
|
||||
this.getRoomInfo();
|
||||
//this.modalController.dismiss();
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,9 +268,9 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
console.log(res);
|
||||
if(res.data){
|
||||
this.getRoomInfo();
|
||||
//this.modalController.dismiss();
|
||||
//this.modalController.dismiss();
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
async openChatOptions(ev: any) {
|
||||
@@ -271,7 +287,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
}
|
||||
async addContacts(){
|
||||
console.log(this.members);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupContactsPage,
|
||||
componentProps: {
|
||||
@@ -279,7 +295,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
room: this.room,
|
||||
members: this.members,
|
||||
name: this.room.name,
|
||||
},
|
||||
},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
@@ -310,7 +326,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
handler: () => {
|
||||
console.log('Play clicked');
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
await actionSheet.present();
|
||||
@@ -354,5 +370,37 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
return await modal.present();
|
||||
}
|
||||
|
||||
async serverLongPull(){
|
||||
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res => {
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.serverLongPull();
|
||||
} else if (res != 200) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
//this.loadMessages()
|
||||
this.messages = res['messages'].filter(data => data.t != 'au');
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
if(this.route.url != "/home/chat"){
|
||||
console.log("Timer message stop")
|
||||
} else {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.serverLongPull();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,9 @@ export class ContactsPage implements OnInit {
|
||||
private http: HttpClient,
|
||||
private chatService: ChatService,
|
||||
private authService: AuthService,
|
||||
)
|
||||
{
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
});
|
||||
)
|
||||
{
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.textSearch="";
|
||||
this.dm=null;
|
||||
this.room=null;
|
||||
@@ -65,7 +63,7 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
loadUsers(){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -105,7 +103,7 @@ export class ContactsPage implements OnInit {
|
||||
close(){
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
|
||||
clicked(){
|
||||
console.log('clicked');
|
||||
}
|
||||
@@ -122,7 +120,7 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
getDirectMessage(roomId:any){
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
this.chatService.getAllDirectMessages().subscribe(res=>{
|
||||
let result = res['ims'].filter(data => data._id == roomId);
|
||||
this.dm = result[0];
|
||||
@@ -133,7 +131,7 @@ export class ContactsPage implements OnInit {
|
||||
async openModal(dm:any){
|
||||
this.close();
|
||||
console.log(dm);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
@@ -155,8 +153,8 @@ export class ContactsPage implements OnInit {
|
||||
//Get direct messages (dm)
|
||||
/* this.getDirectMessage(this.room._id); */
|
||||
console.log(this.dm);
|
||||
|
||||
|
||||
|
||||
|
||||
/* const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<button class="btn-no-color" (click)="_openMessagesOptions()">
|
||||
<ion-icon src="assets/images/icons-menu.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div hidden class="header-bottom" (click)="addContacts()">
|
||||
<div class="header-bottom-icon">
|
||||
@@ -56,8 +56,8 @@
|
||||
</div>
|
||||
<div class="width-80">
|
||||
<ion-item class="ion-no-padding type-message" lines="none">
|
||||
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
|
||||
<button class="btn-no-color" (click)="notImplemented()">
|
||||
<ion-textarea clearOnEdit="true" placeholder="Escrever uma mensagem" class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
|
||||
<button hidden class="btn-no-color" (click)="notImplemented()">
|
||||
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
</button>
|
||||
</ion-item>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
color:#000;
|
||||
transform: translate3d(0, 1px, 0);
|
||||
padding: 30px 20px 0 20px !important;
|
||||
|
||||
|
||||
.header-top{
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
@@ -26,7 +26,7 @@
|
||||
margin: 2px 0 0 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
||||
}
|
||||
.right{
|
||||
padding: 0!important;
|
||||
@@ -39,7 +39,7 @@
|
||||
.header-bottom{
|
||||
width: 95%;
|
||||
overflow: auto;
|
||||
|
||||
|
||||
|
||||
.header-bottom-icon{
|
||||
width: 30px;
|
||||
@@ -60,7 +60,7 @@
|
||||
margin: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.title{
|
||||
font-size: 25px;
|
||||
overflow: auto;
|
||||
@@ -76,7 +76,7 @@
|
||||
.div-icon ion-icon{
|
||||
float: right;
|
||||
padding-left: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ion-content{
|
||||
@@ -96,6 +96,7 @@
|
||||
line-height: 1.2rem;
|
||||
//margin: 20px 39px 25px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
.messages{
|
||||
@@ -118,7 +119,7 @@
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.incoming-true, .incoming-false{
|
||||
padding: 15px 20px;
|
||||
@@ -157,9 +158,9 @@
|
||||
.container{
|
||||
justify-content: center;
|
||||
justify-content: space-evenly;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
.chat-icon-options{
|
||||
display:block !important;
|
||||
font-size: 25px;
|
||||
@@ -186,7 +187,7 @@
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.text-color-blue{
|
||||
@@ -231,5 +232,4 @@ display: block;
|
||||
float: left;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
|
||||
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
|
||||
import { ProfileComponent } from '../../headers/header-no-search/profile/profile.page';
|
||||
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
@@ -27,9 +28,11 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
dm:any;
|
||||
userPresence='';
|
||||
dmUsers:any;
|
||||
checktimeOut: boolean;
|
||||
|
||||
@Input() roomId:string;
|
||||
|
||||
@Input() showMessages:string;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -39,13 +42,15 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
private animationController: AnimationController,
|
||||
private alertService: AlertService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
private route: Router
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
|
||||
/* this.dm = this.navParams.get('dm'); */
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
console.log(this.roomId);
|
||||
this.load();
|
||||
|
||||
|
||||
//throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@@ -53,25 +58,30 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
|
||||
this.scrollToBottom();
|
||||
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
|
||||
/* setInterval(()=>{ */
|
||||
this.load();
|
||||
/* }, 9000); */
|
||||
console.log(this.roomId);
|
||||
|
||||
|
||||
console.log("Chat route", this.route.url)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy(){
|
||||
this.checktimeOut = false;
|
||||
console.log('On Destroy')
|
||||
|
||||
|
||||
}
|
||||
|
||||
notImplemented(){
|
||||
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
|
||||
}
|
||||
|
||||
load(){
|
||||
this.loadMessages();
|
||||
this.checktimeOut = true;
|
||||
this.serverLongPull();
|
||||
this.getChatMembers();
|
||||
}
|
||||
|
||||
@@ -80,54 +90,51 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
this.load();
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
console.log(this.roomId);
|
||||
}
|
||||
scrollToBottom(): void {
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
ngAfterViewChecked() {
|
||||
//this.scrollToBottom();
|
||||
}
|
||||
|
||||
scrollToBottom(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
} catch(err) { }
|
||||
finally {
|
||||
loader.remove()
|
||||
}
|
||||
|
||||
}
|
||||
loadMoreMessages(ev:any){
|
||||
|
||||
}
|
||||
|
||||
sendMessage(){
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
this.loadMessages();
|
||||
});
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
|
||||
loadMessages(){
|
||||
this.showLoader = true;
|
||||
//this.showLoader = true;
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(res => {
|
||||
/* console.log(res); */
|
||||
console.log(res);
|
||||
this.messages = res['messages'].reverse();
|
||||
console.log(this.messages);
|
||||
this.showLoader = false;
|
||||
//this.serverLongPull(res)
|
||||
/* this.chatService.subscribe(this.roomId).then(res => {
|
||||
console.log("Real fake msg", res)
|
||||
}); */
|
||||
//this.showLoader = false;
|
||||
})
|
||||
}
|
||||
|
||||
getChatMembers(){
|
||||
console.log(this.roomId);
|
||||
|
||||
this.showLoader = true;
|
||||
|
||||
//this.showLoader = true;
|
||||
this.chatService.getMembers(this.roomId).subscribe(res=> {
|
||||
this.dmUsers = res['members'].filter(data => data.username != this.loggedUser.me.username)
|
||||
console.log(res);
|
||||
@@ -152,7 +159,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
async addContacts(){
|
||||
const modal = await this.modalController.create({
|
||||
component: ContactsPage,
|
||||
componentProps: {},
|
||||
componentProps: {},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
@@ -209,7 +216,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
const leaveAnimation = (baseEl: any) => {
|
||||
return enterAnimation(baseEl).direction('reverse');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* const popover = await this.popoverController.create({
|
||||
component: MessagesOptionsPage,
|
||||
@@ -234,7 +241,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
return await modal.present();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
async _openChatOptions() {
|
||||
|
||||
@@ -260,7 +267,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
const leaveAnimation = (baseEl: any) => {
|
||||
return enterAnimation(baseEl).direction('reverse');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* const popover = await this.popoverController.create({
|
||||
component: MessagesOptionsPage,
|
||||
@@ -285,6 +292,37 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
return await modal.present();
|
||||
}
|
||||
|
||||
async serverLongPull(){
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.serverLongPull();
|
||||
} else if (res != 200) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
//this.loadMessages()
|
||||
this.messages = res['messages'].reverse();
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
if(this.route.url != "/home/chat"){
|
||||
console.log("Timer message stop")
|
||||
} else {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await this.serverLongPull();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ export class PedidosPage implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
|
||||
this.LoadList();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof NavigationStart && '/home/gabinete-digital?parecer=true'.startsWith(event.url) ||
|
||||
event instanceof NavigationStart && '/home/gabinete-digital?deferimento=true'.startsWith(event.url) ||
|
||||
if(event instanceof NavigationStart && '/home/gabinete-digital?parecer=true'.startsWith(event.url) ||
|
||||
event instanceof NavigationStart && '/home/gabinete-digital?deferimento=true'.startsWith(event.url) ||
|
||||
event instanceof NavigationStart && '/home/gabinete-digital?pedidos=true'.startsWith(event.url)
|
||||
) {
|
||||
|
||||
@@ -70,7 +70,7 @@ export class PedidosPage implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
segmentChanged(ev: any) {
|
||||
@@ -88,7 +88,7 @@ export class PedidosPage implements OnInit {
|
||||
|
||||
async LoadList() {
|
||||
|
||||
this.skeletonLoader = true
|
||||
this.skeletonLoader = true;
|
||||
|
||||
if(this.segment == 'parecer') {
|
||||
this.taskType = "Pedido de Parecer";
|
||||
@@ -132,7 +132,7 @@ export class PedidosPage implements OnInit {
|
||||
this.processes.GetTasksList("Pedido de Deferimento", false).subscribe(result => {
|
||||
|
||||
this.taskslist = result.filter(data => data.workflowInstanceDataFields.Status == "Active")
|
||||
|
||||
|
||||
this.skeletonLoader = false
|
||||
|
||||
this.deferimentoList = new Array();
|
||||
|
||||
@@ -48,11 +48,10 @@
|
||||
<span>Acções</span>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')" [class.active]="locationPathname() == '/home/chat'">
|
||||
<div class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')" [class.active]="locationPathname() == '/home/chat'">
|
||||
<ion-icon class="font-40" src='assets/images/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
|
||||
<span>Chat</span>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')" [class.active]="locationPathname() == '/home/chat'">
|
||||
<div class="tab mr-20 d-flex align-center cursor-pointer" (click)="changeRoute('/home/chat')" [class.active]="locationPathname() == '/home/chat'">
|
||||
<ion-icon class="font-40" src='assets/images/icons-nav-grupos-inactive-dk-white.svg'></ion-icon>
|
||||
<span>Chat</span>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user