mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
@@ -103,7 +103,6 @@ export class ChatPage implements OnInit {
|
||||
){
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.headers = new HttpHeaders();
|
||||
this.loadMessage();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -140,16 +139,16 @@ hideRefreshButton(){
|
||||
}
|
||||
|
||||
|
||||
loadMessage(){
|
||||
/* loadMessage(){
|
||||
this.chatService.messages.subscribe(msg => {
|
||||
console.log("Response from websocket: " + msg);
|
||||
});
|
||||
}
|
||||
sendMsg() {
|
||||
} */
|
||||
/* sendMsg() {
|
||||
console.log("new message from client to websocket: ", this.message);
|
||||
this.chatService.messages.next(this.message);
|
||||
this.message.msg = "";
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
/* Fim websockets functions */
|
||||
@@ -168,9 +167,7 @@ sendMsg() {
|
||||
this.showEmptyComponent=true;
|
||||
}
|
||||
openGroupContactsPage(data){
|
||||
console.log(data);
|
||||
this.groupRoomId = data;
|
||||
console.log(this.groupRoomId);
|
||||
this.closeAllDesktopComponents();
|
||||
if(window.innerWidth <= 1024){
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<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 *ngFor="let msg of messages" class="messages">
|
||||
<div *ngFor="let msg of messages" class="messages" #scrollMe>
|
||||
<div *ngIf="msg.t != 'r'" class='incoming-{{msg.u.username!=loggedUser.me.username}}'>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
|
||||
@@ -49,8 +49,8 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
/* setInterval(()=>{ */
|
||||
this.load();
|
||||
/* }, 9000); */
|
||||
this.el = document.getElementById("scrollToBottom");
|
||||
this.el.scrollTop = this.el.scrollHeight - this.el.scrollTop;
|
||||
/* this.el = document.getElementById("scrollToBottom");
|
||||
this.el.scrollTop = this.el.scrollHeight - this.el.scrollTop; */
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ export class MessagesPage implements OnInit, AfterViewChecked {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
|
||||
}
|
||||
|
||||
sendMessage(){
|
||||
|
||||
@@ -20,8 +20,8 @@ export class ChatService {
|
||||
X_User_Id:any;
|
||||
X_Auth_Token:any;
|
||||
|
||||
SERVER_URL = 'wss://www.tabularium.pt/websocket';
|
||||
public messages: Subject<any>;
|
||||
//SERVER_URL = 'wss://www.tabularium.pt/websocket';
|
||||
//public messages: Subject<any>;
|
||||
loggedUserChat:any;
|
||||
|
||||
constructor(
|
||||
@@ -30,7 +30,7 @@ export class ChatService {
|
||||
private authService: AuthService,
|
||||
private storage: Storage,
|
||||
private storageService:StorageService,
|
||||
private wsService: WebsocketService,
|
||||
//private wsService: WebsocketService,
|
||||
)
|
||||
{
|
||||
this.loggedUserChat = authService.ValidatedUserChat;
|
||||
@@ -41,13 +41,13 @@ export class ChatService {
|
||||
headers: this.headers,
|
||||
};
|
||||
|
||||
this.messages = <Subject<any>>this.wsService.connect(this.SERVER_URL).map((response: MessageEvent): any => {
|
||||
/* this.messages = <Subject<any>>this.wsService.connect(this.SERVER_URL).map((response: MessageEvent): any => {
|
||||
let data = JSON.parse(response.data);
|
||||
console.log(data);
|
||||
return (JSON.stringify(data));
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
|
||||
getAllChannels(){
|
||||
return this.http.get(environment.apiChatUrl+'channels.list', this.options);
|
||||
}
|
||||
@@ -61,17 +61,17 @@ export class ChatService {
|
||||
getRoomInfo(roomId:any){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'rooms.info', opts);
|
||||
|
||||
|
||||
}
|
||||
customsRooms(params:any){
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'rooms.get', opts);
|
||||
}
|
||||
@@ -95,22 +95,22 @@ export class ChatService {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.history', opts);
|
||||
}
|
||||
|
||||
sendMessage(body:any){
|
||||
let opts = {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'chat.sendMessage', body, opts);
|
||||
}
|
||||
leaveRoom(body:any){
|
||||
let opts = {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'rooms.leave', body, opts);
|
||||
@@ -120,15 +120,15 @@ export class ChatService {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.members', opts);
|
||||
}
|
||||
removeChatRoom(body:any){
|
||||
let opts = {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'im.close', body, this.options);
|
||||
@@ -139,10 +139,10 @@ export class ChatService {
|
||||
getDirectMessage(roomId:string){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'im.messages', opts);
|
||||
}
|
||||
@@ -155,10 +155,10 @@ export class ChatService {
|
||||
let params = new HttpParams();
|
||||
let url=environment.apiChatUrl+'groups.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
@@ -166,10 +166,10 @@ export class ChatService {
|
||||
let params = new HttpParams();
|
||||
let url=environment.apiChatUrl+'channels.members';
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(url, opts);
|
||||
}
|
||||
@@ -178,20 +178,20 @@ export class ChatService {
|
||||
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'groups.history', opts);
|
||||
}
|
||||
getPublicGroupMessages(roomId:any){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'channels.history', opts);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ export class ChatService {
|
||||
return this.http.post(environment.apiChatUrl+'channels.leave', body, this.options);
|
||||
}
|
||||
removeChannelMember(body:any){
|
||||
let opts = {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'channels.kick', body, opts);
|
||||
@@ -225,10 +225,10 @@ export class ChatService {
|
||||
getGroupInfo(roomId:any){
|
||||
let params = new HttpParams();
|
||||
params = params.set("roomId", roomId);
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
params: params
|
||||
}
|
||||
return this.http.get(environment.apiChatUrl+'groups.info', opts);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ export class ChatService {
|
||||
return this.http.post(environment.apiChatUrl+'groups.rename', body, this.options);
|
||||
}
|
||||
removeGroupMember(body:any){
|
||||
let opts = {
|
||||
let opts = {
|
||||
headers: this.headers,
|
||||
}
|
||||
return this.http.post(environment.apiChatUrl+'groups.kick', body, opts);
|
||||
|
||||
@@ -25,7 +25,7 @@ export class WebsocketService {
|
||||
let ws = new WebSocket(url);
|
||||
|
||||
console.log(ws);
|
||||
|
||||
|
||||
|
||||
let observable = Rx.Observable.create((obs: Rx.Observer<MessageEvent>) => {
|
||||
ws.onmessage = obs.next.bind(obs);
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
<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" #scrollMe>
|
||||
<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>
|
||||
@@ -68,7 +68,7 @@
|
||||
<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()">
|
||||
<button class="btn-no-color">
|
||||
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
|
||||
</button>
|
||||
</ion-item>
|
||||
|
||||
@@ -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';
|
||||
@@ -14,7 +14,7 @@ import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
||||
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;
|
||||
@@ -34,6 +34,8 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
@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,
|
||||
@@ -49,6 +51,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
this.getRoomInfo();
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -57,8 +60,16 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
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(){
|
||||
@@ -73,6 +84,7 @@ export class GroupMessagesPage implements OnInit, OnChanges {
|
||||
this.getRoomInfo();
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
get watch(){
|
||||
this.getRoomInfo();
|
||||
console.log('here watching');
|
||||
|
||||
@@ -45,15 +45,14 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
/* this.dm = this.navParams.get('dm'); */
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
console.log(this.roomId);
|
||||
this.load();
|
||||
//this.load();
|
||||
|
||||
//throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
//this.scrollToBottom();
|
||||
this.scrollToBottom();
|
||||
|
||||
/* setInterval(()=>{ */
|
||||
this.load();
|
||||
@@ -79,20 +78,17 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
|
||||
}
|
||||
|
||||
ngAfterViewChecked() {
|
||||
//this.scrollToBottom();
|
||||
console.log(this.roomId);
|
||||
this.scrollToBottom();
|
||||
}
|
||||
/* scrollToBottom(): void {
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
scrollToBottom(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
finally {
|
||||
loader.remove()
|
||||
}
|
||||
}
|
||||
|
||||
} */
|
||||
loadMoreMessages(ev:any){
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user