mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
save
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import {
|
||||
Component,
|
||||
import {
|
||||
Component,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
ViewContainerRef,
|
||||
@@ -36,7 +36,7 @@ export class ChatPage implements OnInit {
|
||||
options:any;
|
||||
X_User_Id:any;
|
||||
X_Auth_Token:any;
|
||||
|
||||
|
||||
loggedUser: any;
|
||||
/* Set segment variable */
|
||||
segment:string;
|
||||
@@ -76,7 +76,7 @@ export class ChatPage implements OnInit {
|
||||
/*
|
||||
|
||||
Websockets variables
|
||||
|
||||
|
||||
*/
|
||||
|
||||
subject: any;
|
||||
@@ -100,7 +100,7 @@ export class ChatPage implements OnInit {
|
||||
private authService: AuthService,
|
||||
private storage:Storage,
|
||||
private resolver: ComponentFactoryResolver,
|
||||
){
|
||||
){
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.headers = new HttpHeaders();
|
||||
this.loadMessage();
|
||||
@@ -108,7 +108,7 @@ export class ChatPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this.loggedUserChat);
|
||||
|
||||
|
||||
this.segment = "Contactos";
|
||||
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
@@ -116,12 +116,12 @@ export class ChatPage implements OnInit {
|
||||
console.log(this.loggedUser);
|
||||
this.load();
|
||||
});
|
||||
|
||||
|
||||
/* websocket functions */
|
||||
//this.sendMsg();
|
||||
|
||||
/* Fim websocket functions */
|
||||
this.hideRefreshButton();
|
||||
this.hideRefreshButton();
|
||||
}
|
||||
|
||||
hideRefreshButton(){
|
||||
@@ -193,7 +193,7 @@ sendMsg() {
|
||||
openContactsPage() {
|
||||
console.log('OK');
|
||||
this.closeAllDesktopComponents();
|
||||
|
||||
|
||||
if( window.innerWidth <= 1024){
|
||||
this.selectContact();
|
||||
}
|
||||
@@ -222,16 +222,17 @@ sendMsg() {
|
||||
}
|
||||
}
|
||||
|
||||
openGroupMessagesPage(data) {
|
||||
console.log('HERE');
|
||||
|
||||
openGroupMessagesPage(rid) {
|
||||
console.log(rid);
|
||||
|
||||
if( window.innerWidth <= 1024){
|
||||
this.openGroupMessagesModal(data);
|
||||
this.openGroupMessagesModal(rid);
|
||||
}
|
||||
else{
|
||||
this.closeAllDesktopComponents();
|
||||
this.showEmptyComponent = false;
|
||||
this.roomId = data;
|
||||
this.roomId = rid;
|
||||
console.log(this.roomId);
|
||||
this.showGroupMessages=true;
|
||||
}
|
||||
}
|
||||
@@ -261,13 +262,13 @@ sendMsg() {
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
getDirectMessages(){
|
||||
this.showLoader = true;
|
||||
|
||||
|
||||
this.chatService.getAllDirectMessages().subscribe((res:any)=>{
|
||||
console.log(res.ims);
|
||||
|
||||
|
||||
this.userDirectMessages = res.ims.sort((a,b)=>{
|
||||
var dateA = new Date(a._updatedAt).getTime();
|
||||
var dateB = new Date(b._updatedAt).getTime();
|
||||
@@ -288,7 +289,7 @@ sendMsg() {
|
||||
this.privateGroups = res.groups;
|
||||
this.result = this.chatService.getAllUserChannels().subscribe((res:any)=>{
|
||||
this.publicGroups = res.channels;
|
||||
let all = this.privateGroups.concat(this.publicGroups);
|
||||
let all = this.privateGroups.concat(this.publicGroups);
|
||||
this.allGroups = all.sort((a,b)=>{
|
||||
var dateA = new Date(a._updatedAt).getTime();
|
||||
var dateB = new Date(b._updatedAt).getTime();
|
||||
@@ -297,7 +298,7 @@ sendMsg() {
|
||||
console.log(this.allGroups);
|
||||
this.showLoader = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async selectContact(){
|
||||
@@ -337,7 +338,7 @@ sendMsg() {
|
||||
this.closeAllDesktopComponents();
|
||||
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'modal modal-desktop',
|
||||
@@ -352,7 +353,7 @@ sendMsg() {
|
||||
async openGroupMessagesModal(roomId:any){
|
||||
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupMessagesPage,
|
||||
cssClass: 'modal modal-desktop',
|
||||
|
||||
@@ -37,11 +37,10 @@ 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;
|
||||
@@ -95,7 +94,7 @@ export class GroupContactsPage implements OnInit {
|
||||
|
||||
|
||||
loadUsers(){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -115,7 +114,7 @@ export class GroupContactsPage implements OnInit {
|
||||
return 0;
|
||||
});
|
||||
console.log(this.users);
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
}
|
||||
@@ -143,7 +142,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();
|
||||
@@ -167,12 +166,12 @@ export class GroupContactsPage implements OnInit {
|
||||
}
|
||||
clicked(){
|
||||
console.log('clicked');
|
||||
|
||||
|
||||
}
|
||||
selectedContact(user:any){
|
||||
/* this.groupName = this.room.name; */
|
||||
user.isChecked = !user.isChecked;
|
||||
|
||||
|
||||
|
||||
}
|
||||
addContacts(room:any){
|
||||
@@ -185,11 +184,11 @@ export class GroupContactsPage implements OnInit {
|
||||
let body ={
|
||||
"roomId":room._id,
|
||||
"userId":user._id,
|
||||
|
||||
|
||||
}
|
||||
this.chatService.addUserToGroup(body).subscribe(res=>{
|
||||
console.log(res['success']);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -202,9 +201,9 @@ export class GroupContactsPage implements OnInit {
|
||||
console.log(res['group']);
|
||||
this.addContacts(res['group']);
|
||||
this.openGroupMessages(res['group']);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
this.addContacts(this.room);
|
||||
@@ -212,12 +211,12 @@ export class GroupContactsPage implements OnInit {
|
||||
/* this.openGroupMessages(this.room); */
|
||||
/* this.chatService.getGroupInfo(this.room._id).subscribe(res=>{
|
||||
console.log(res);
|
||||
|
||||
|
||||
this.addContacts(res['group']);
|
||||
this.openGroupMessages(res['group']);
|
||||
}) */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async newGroup(){
|
||||
@@ -237,7 +236,7 @@ export class GroupContactsPage implements OnInit {
|
||||
component: GroupMessagesPage,
|
||||
componentProps: {
|
||||
room: room,
|
||||
},
|
||||
},
|
||||
cssClass: 'group-messages',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<button class="btn-no-color" (click)="openOptions()">
|
||||
<ion-icon src="assets/images/icons-menu.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div (click)="addContacts()" class="header-bottom">
|
||||
<div class="header-bottom-icon">
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
<!--
|
||||
<!--
|
||||
<ion-footer>
|
||||
<ion-toolbar>
|
||||
<ion-row align-items-center class="row">
|
||||
|
||||
@@ -28,6 +28,7 @@ export class GroupMessagesPage implements OnInit {
|
||||
contacts: string[] = [" Ana M.", "Andre F.", "Bruno G.", "Catarina T", "Tiago"];
|
||||
|
||||
roomId: string;
|
||||
loggedUserChat:any;
|
||||
|
||||
constructor(
|
||||
private menu: MenuController,
|
||||
@@ -39,15 +40,14 @@ export class GroupMessagesPage implements OnInit {
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
console.log(this.roomId);
|
||||
this.loggedUser=this.loggedUserChat;
|
||||
this.getRoomInfo();
|
||||
}
|
||||
|
||||
@@ -121,17 +121,17 @@ export class GroupMessagesPage implements OnInit {
|
||||
sendMessage(){
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId, "msg": this.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
this.getRoomInfo();
|
||||
|
||||
|
||||
},(error) => {
|
||||
|
||||
|
||||
});
|
||||
this.message = "";
|
||||
}
|
||||
@@ -154,7 +154,7 @@ export class GroupMessagesPage implements OnInit {
|
||||
console.log('cancel');
|
||||
}
|
||||
console.log('OK2');
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ export class GroupMessagesPage implements OnInit {
|
||||
}
|
||||
async addContacts(){
|
||||
console.log(this.members);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: GroupContactsPage,
|
||||
componentProps: {
|
||||
@@ -180,7 +180,7 @@ export class GroupMessagesPage implements OnInit {
|
||||
room: this.room,
|
||||
members: this.members,
|
||||
name: this.room.name,
|
||||
},
|
||||
},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
@@ -211,7 +211,7 @@ export class GroupMessagesPage implements OnInit {
|
||||
handler: () => {
|
||||
console.log('Play clicked');
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
await actionSheet.present();
|
||||
|
||||
@@ -28,11 +28,10 @@ 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;
|
||||
@@ -47,7 +46,7 @@ export class ContactsPage implements OnInit {
|
||||
}
|
||||
|
||||
loadUsers(){
|
||||
this.options = {
|
||||
this.options = {
|
||||
headers: this.headers,
|
||||
};
|
||||
this.chatService.getAllUsers().subscribe((res:any)=>{
|
||||
@@ -86,7 +85,7 @@ export class ContactsPage implements OnInit {
|
||||
close(){
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
|
||||
clicked(){
|
||||
console.log('clicked');
|
||||
}
|
||||
@@ -99,17 +98,17 @@ export class ContactsPage implements OnInit {
|
||||
console.log(res);
|
||||
this.room = res['room'];
|
||||
console.log(this.room._id);
|
||||
|
||||
|
||||
this.getDirectMessage(this.room._id);
|
||||
});
|
||||
}
|
||||
getDirectMessage(roomId:any){
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
this.chatService.getAllDirectMessages().subscribe(res=>{
|
||||
let result = res['ims'].filter(data => data._id == roomId);
|
||||
console.log(result[0]);
|
||||
|
||||
|
||||
this.dm = result[0];
|
||||
console.log(this.dm);
|
||||
this.openModal(this.dm._id);
|
||||
@@ -118,7 +117,7 @@ export class ContactsPage implements OnInit {
|
||||
async openModal(roomId:any){
|
||||
this.close();
|
||||
console.log(roomId);
|
||||
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: MessagesPage,
|
||||
cssClass: 'group-messages',
|
||||
@@ -139,8 +138,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',
|
||||
|
||||
@@ -15,7 +15,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">
|
||||
@@ -35,7 +35,7 @@
|
||||
<ion-refresher-content>
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="messages" #scrollMe>
|
||||
<div id="scrollToBottom" class="messages" #scrollMe>
|
||||
<div *ngFor="let msg of messages" class='incoming-{{msg.u.username!=loggedUser.me.username}}'>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
@@ -83,7 +83,7 @@
|
||||
<ion-item class="ion-no-padding ion-no-margin 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-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
<!-- <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> -->
|
||||
</button>
|
||||
</ion-item>
|
||||
</div>
|
||||
@@ -96,4 +96,4 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ion-footer>
|
||||
</ion-footer>
|
||||
|
||||
@@ -26,8 +26,9 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
userPresence='';
|
||||
dmUsers:any;
|
||||
roomId:string;
|
||||
el:any;
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
private modalController: ModalController,
|
||||
@@ -36,7 +37,8 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
private authService: AuthService,
|
||||
private alertService: AlertService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
}
|
||||
|
||||
@@ -44,15 +46,12 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
|
||||
this.scrollToBottom();
|
||||
|
||||
this.authService.userData$.subscribe((res:any)=>{
|
||||
this.loggedUser=res;
|
||||
console.log(this.loggedUser);
|
||||
});
|
||||
|
||||
/* setInterval(()=>{ */
|
||||
this.load();
|
||||
/* }, 9000); */
|
||||
|
||||
this.el = document.getElementById("scrollToBottom");
|
||||
this.el.scrollTop = this.el.scrollHeight - this.el.scrollTop;
|
||||
|
||||
}
|
||||
|
||||
notImplemented(){
|
||||
@@ -70,34 +69,31 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
this.load();
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
scrollToBottom(): void {
|
||||
|
||||
ngAfterViewChecked() {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
scrollToBottom(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
|
||||
}
|
||||
loadMoreMessages(ev:any){
|
||||
} catch(err) { }
|
||||
|
||||
}
|
||||
|
||||
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.loadMessages();
|
||||
});
|
||||
this.message = "";
|
||||
}
|
||||
|
||||
|
||||
loadMessages(){
|
||||
this.showLoader = true;
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(res => {
|
||||
@@ -133,7 +129,7 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
async addContacts(){
|
||||
const modal = await this.modalController.create({
|
||||
component: ContactsPage,
|
||||
componentProps: {},
|
||||
componentProps: {},
|
||||
cssClass: 'contacts',
|
||||
backdropDismiss: false
|
||||
});
|
||||
@@ -153,4 +149,4 @@ async openChatOptions(ev?: any) {
|
||||
return await popover.present();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user