mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Fix merge
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
@@ -12,18 +12,21 @@ import { SharedModule } from 'src/app/shared/shared.module';
|
||||
import { ChatPopoverPageModule } from '../../popover/chat-popover/chat-popover.module';
|
||||
import { NewEventPageModule } from '../../agenda/new-event/new-event.module';
|
||||
import { PdfViewerModule } from 'ng2-pdf-viewer';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
FontAwesomeModule,
|
||||
PdfViewerModule,
|
||||
ChatPopoverPageModule,
|
||||
GroupMessagesPageRoutingModule,
|
||||
//
|
||||
PdfViewerModule
|
||||
],
|
||||
exports: [GroupMessagesPage],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
declarations: [GroupMessagesPage]
|
||||
})
|
||||
export class GroupMessagesPageModule {}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<ion-icon src="assets/icon/icons-user.svg"></ion-icon>
|
||||
</div>
|
||||
<div class="header-bottom-contacts">
|
||||
<ion-label *ngFor="let member of members" >
|
||||
<ion-label class="contacts-list" *ngFor="let member of members" >
|
||||
{{member.name}},
|
||||
</ion-label>
|
||||
</div>
|
||||
@@ -25,7 +25,6 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
|
||||
<ion-content>
|
||||
<ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
|
||||
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
|
||||
@@ -38,6 +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 class="container-width-100" *ngFor="let msg of messages; let last = last" #scrollMe>
|
||||
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru'" class='incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
|
||||
<div class="title">
|
||||
@@ -49,15 +49,26 @@
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
|
||||
<div *ngIf="file.thumb_url">
|
||||
<div class="file d-flex">
|
||||
<ion-thumbnail slot="start">
|
||||
<img src="{{file.thumb_url}}" alt="image">
|
||||
</ion-thumbnail>
|
||||
<ion-label class="file-details">
|
||||
<h3 (click)="viewDocument(file.title_link)" class="file-title cursor-pointer">{{file.title}}</h3>
|
||||
<p *ngIf="file.text">{{file.text}}</p>
|
||||
</ion-label>
|
||||
<div>
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<ion-label class="file-details" *ngIf="msg.file">
|
||||
<span (click)="viewDocument(file.title_link)" class="file-title cursor-pointer">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
{{file.title}}
|
||||
</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -87,6 +98,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
<ion-fab-button *ngIf="scrollToBottomBtn" (click)="scrollToBottomClicked()" color="light" size="small">
|
||||
<ion-icon name="chevron-down"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<!-- <ion-fab-list side="start">
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="chevron-down"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="logo-twitter"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="logo-vimeo"></ion-icon>
|
||||
</ion-fab-button>
|
||||
</ion-fab-list> -->
|
||||
</ion-fab>
|
||||
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
@import '~src/function.scss';
|
||||
div{
|
||||
overflow: auto;
|
||||
}
|
||||
.header-toolbar{
|
||||
--background:transparent;
|
||||
--opacity: 1;
|
||||
@@ -31,7 +34,7 @@
|
||||
}
|
||||
}
|
||||
.header-bottom{
|
||||
width: 95%;
|
||||
width: 98%;
|
||||
overflow: auto;
|
||||
|
||||
.header-bottom-icon{
|
||||
@@ -42,6 +45,7 @@
|
||||
|
||||
}
|
||||
.header-bottom-contacts{
|
||||
width: calc(100% - 40px);
|
||||
font-size: 15px;
|
||||
color: #797979;
|
||||
white-space: nowrap;
|
||||
@@ -50,6 +54,12 @@
|
||||
float: left;
|
||||
padding: 5px;
|
||||
margin: 1px;
|
||||
|
||||
.contacts-list{
|
||||
white-space: nowrap;
|
||||
overflow: hidden !important;
|
||||
text-overflow: ellipsis !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,15 @@ import { SearchList } from 'src/app/models/search-document';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { FileService } from 'src/app/services/functions/file.service';
|
||||
|
||||
|
||||
/*
|
||||
import * as pdfjsLib from 'pdfjs-dist';
|
||||
if( pdfjsLib !== undefined ){
|
||||
console.log( "set worker...");
|
||||
pdfjsLib.GlobalWorkerOptions.workerSrc = "https://npmcdn.com/pdfjs-dist@2.4.456/build/pdf.worker.js";
|
||||
}
|
||||
*/
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
@@ -45,6 +54,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
private scrollChangeCallback: () => void;
|
||||
currentPosition: any;
|
||||
startPosition: number;
|
||||
scrollToBottomBtn = false;
|
||||
|
||||
@Input() roomId:string;
|
||||
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -56,6 +66,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
|
||||
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
||||
|
||||
pdfurl = "http://www.africau.edu/images/default/sample.pdf";
|
||||
|
||||
constructor(
|
||||
private menu: MenuController,
|
||||
private modalController: ModalController,
|
||||
@@ -74,6 +86,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
//this.getRoomInfo();
|
||||
@@ -87,15 +100,54 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
console.log(this.roomId);
|
||||
this.setStatus('online');
|
||||
this.getChatMembers();
|
||||
|
||||
/* pdfjs.Lib.getDocument('sample.pdf').promise.then((doc)=>{
|
||||
console.log(doc);
|
||||
|
||||
}) */
|
||||
//this.loadPDF();
|
||||
}
|
||||
|
||||
/* loadPDF() {
|
||||
const loadingTask = pdfjsLib.getDocument( this.pdfurl );
|
||||
loadingTask.promise.then((pdf) => {
|
||||
console.log( "pdf: ", pdf );
|
||||
console.log('PDF loaded');
|
||||
|
||||
// Fetch the first page
|
||||
var pageNumber = 1;
|
||||
pdf.getPage(pageNumber).then(function(page) {
|
||||
console.log('Page loaded');
|
||||
|
||||
var scale = 1.5;
|
||||
var viewport = page.getViewport({scale: scale});
|
||||
|
||||
// Prepare canvas using PDF page dimensions
|
||||
var canvas: any = document.getElementById('pdf_canvas');
|
||||
var context = canvas.getContext('2d');
|
||||
canvas.height = viewport.height;
|
||||
canvas.width = viewport.width;
|
||||
|
||||
// Render PDF page into canvas context
|
||||
var renderContext = {
|
||||
canvasContext: context,
|
||||
viewport: viewport
|
||||
};
|
||||
var renderTask = page.render(renderContext);
|
||||
renderTask.promise.then(function () {
|
||||
console.log('Page rendered');
|
||||
});
|
||||
});
|
||||
});
|
||||
} */
|
||||
|
||||
setStatus(status:string){
|
||||
let body = {
|
||||
message: '',
|
||||
status: status,
|
||||
}
|
||||
this.chatService.setUserStatus(body).subscribe(res => {
|
||||
console.log(res);
|
||||
//console.log(res);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -107,20 +159,35 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
scrollToBottomClicked(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
||||
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
||||
}
|
||||
|
||||
onContentScrolled(e) {
|
||||
onContentScrolled(e) {
|
||||
this.startPosition = e.srcElement.scrollTop;
|
||||
let scroll = e.srcElement.scrollTop;
|
||||
let windowHeight = e.srcElement.scrollHeight;
|
||||
let containerHeight = windowHeight - e.srcElement.clientHeight;
|
||||
|
||||
if (scroll > this.currentPosition) {
|
||||
//this.showButton = false;
|
||||
//alert('BOTTOM');
|
||||
} else {
|
||||
//this.showButton = true;
|
||||
//alert('UP');
|
||||
this.scrollingOnce = false;
|
||||
}
|
||||
if((containerHeight - 100) > scroll){
|
||||
this.scrollToBottomBtn = true;
|
||||
}
|
||||
else{
|
||||
this.scrollToBottomBtn = false;
|
||||
}
|
||||
this.currentPosition = scroll;
|
||||
}
|
||||
|
||||
@@ -132,10 +199,10 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
async getChatMembers(){
|
||||
//return await this.chatService.getMembers(roomId).toPromise();
|
||||
this.chatService.getAllUsers().subscribe(res=> {
|
||||
console.log(res);
|
||||
//console.log(res);
|
||||
|
||||
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
|
||||
console.log(this.allUsers);
|
||||
//console.log(this.allUsers);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -187,7 +254,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
//If group is private call getGroupMembers
|
||||
if(room.t === 'p'){
|
||||
this.chatService.getGroupMembers(this.roomId).subscribe(res=>{
|
||||
console.log(res);
|
||||
//console.log(res);
|
||||
this.members = res['members'];
|
||||
this.showLoader = false;
|
||||
});
|
||||
@@ -214,7 +281,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
console.log(res);
|
||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
||||
this.messages = msgOnly.reverse();
|
||||
console.log(res);
|
||||
//console.log(res);
|
||||
|
||||
this.showLoader = false;
|
||||
});
|
||||
@@ -438,6 +505,49 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
};
|
||||
}
|
||||
|
||||
loadDocument() {
|
||||
const input = this.fileLoaderService.createInput({
|
||||
accept: ['.doc', '.docx', '.pdf']
|
||||
})
|
||||
|
||||
input.onchange = async () => {
|
||||
const file = this.fileLoaderService.getFirstFile(input)
|
||||
|
||||
console.log(file);
|
||||
|
||||
const imageData = await this.fileToBase64Service.convert(file)
|
||||
this.capturedImage = imageData;
|
||||
this.capturedImageTitle = file.name;
|
||||
|
||||
let body = {
|
||||
"message":
|
||||
{
|
||||
"rid": this.roomId,
|
||||
"msg": "",
|
||||
"attachments": [{
|
||||
"title": this.capturedImageTitle,
|
||||
"text": "",
|
||||
"title_link": this.capturedImage,
|
||||
"title_link_download": true,
|
||||
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
||||
"message_link": this.capturedImage,
|
||||
}],
|
||||
"file":{
|
||||
"name": this.capturedImageTitle,
|
||||
"type": "application/pdf",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.chatService.sendMessage(body).subscribe(res=> {
|
||||
//console.log(res);
|
||||
},(error) => {
|
||||
|
||||
});
|
||||
//console.log(this.capturedImage)
|
||||
};
|
||||
}
|
||||
|
||||
async addDocGestaoDocumental(){
|
||||
const modal = await this.modalController.create({
|
||||
component: SearchPage,
|
||||
@@ -529,7 +639,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then((res)=>{
|
||||
console.log(res['data']);
|
||||
//console.log(res['data']);
|
||||
if(res['data'] == 'meeting'){
|
||||
//this.closeAllDesktopComponents.emit();
|
||||
let data = {
|
||||
@@ -538,54 +648,68 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
|
||||
}
|
||||
this.openNewEventPage.emit(data);
|
||||
}
|
||||
else if(res['data'] == 'picture'){
|
||||
this.loadPicture();
|
||||
else if(res['data'] == 'take-picture'){
|
||||
this.fileService.addCameraPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-picture'){
|
||||
this.fileService.addPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-document'){
|
||||
this.loadDocument();
|
||||
}
|
||||
else if(res['data'] == 'documentoGestaoDocumental'){
|
||||
this.addDocGestaoDocumental();
|
||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
||||
//this.addDocGestaoDocumental();
|
||||
}
|
||||
this.loadGroupMessages(this.roomId);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
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()
|
||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
||||
this.messages = msgOnly.reverse();
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
if(this.route.url != "/home/chat"){
|
||||
console.log("Timer message stop")
|
||||
} else {
|
||||
if(document.querySelector('app-group-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve,3000));
|
||||
await this.serverLongPull();
|
||||
this.getGroups.emit();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
if(this.route.url != "/home/chat" && document.querySelector('app-group-messages')){
|
||||
console.log("Timer message stop")
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(async res =>
|
||||
{
|
||||
if(res['success'] == true) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
//this.loadMessages()
|
||||
let msgOnly = res['messages'].filter(data => data.t != 'au');
|
||||
this.messages = msgOnly.reverse();
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
|
||||
if(document.querySelector('app-group-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve,5000));
|
||||
this.getGroups.emit();
|
||||
console.log('Timer message running')
|
||||
await this.serverLongPull();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
alert('HEY2')
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
}, (error)=>{
|
||||
console.log(error);
|
||||
this.serverLongPull();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ import { MessagesPageRoutingModule } from './messages-routing.module';
|
||||
|
||||
import { MessagesPage } from './messages.page';
|
||||
import { SharedModule } from 'src/app/shared/shared.module';
|
||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
FontAwesomeModule,
|
||||
MessagesPageRoutingModule
|
||||
],
|
||||
exports: [MessagesPage],
|
||||
|
||||
@@ -31,19 +31,70 @@
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="messages" #scrollMe>
|
||||
<div class="container-width-100" *ngFor="let msg of chatMessageStore.message[roomId]; let last = last">
|
||||
<div class='incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45'>
|
||||
<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-options d-flex justify-content-end">
|
||||
<fa-icon (click)="mesageItemDropdownOptions=true" icon="chevron-down" class="message-options-icon"></fa-icon>
|
||||
<!-- <div class="mesage-item-dropdown-options" *ngIf="mesageItemDropdownOptions">
|
||||
<ion-label>Apagar mensagem</ion-label>
|
||||
</div> -->
|
||||
<ion-select hidden class="message-options-icon" interface="popover">
|
||||
<ion-select-option value="nes">Apagar mensagem</ion-select-option>
|
||||
</ion-select>
|
||||
|
||||
</div>
|
||||
<div class="title">
|
||||
<ion-label>{{msg.u.name}}</ion-label>
|
||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||
</div>
|
||||
<div>
|
||||
<ion-label>{{msg.msg}}</ion-label>
|
||||
<div *ngIf="msg.attachments" class="message-attachments">
|
||||
<div *ngFor="let file of msg.attachments">
|
||||
<img *ngIf="file.image_url" src="{{file.image_url}}" alt="image">
|
||||
<div>
|
||||
<div class="file">
|
||||
<!-- <canvas id="pdf_canvas"></canvas> -->
|
||||
<ion-label class="file-details" *ngIf="msg.file">
|
||||
<span (click)="viewDocument(file.title_link)" class="file-title cursor-pointer">
|
||||
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
|
||||
<fa-icon *ngIf="msg.file.type == 'application/word'" icon="file-word" class="word-icon"></fa-icon>
|
||||
<ion-icon *ngIf="msg.file.type == 'application/webtrix'" src="assets/icon/webtrix.svg"></ion-icon>
|
||||
{{file.title}}
|
||||
</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
<div class="file-details-optional">
|
||||
<ion-label *ngIf="msg.file">
|
||||
<span *ngIf="file.description">{{file.description}}</span>
|
||||
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"> • </span>
|
||||
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
|
||||
</ion-label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{last ? scrollToBottom() : ''}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
|
||||
<ion-fab-button *ngIf="scrollToBottomBtn" (click)="scrollToBottomClicked()" color="light" size="small">
|
||||
<ion-icon name="chevron-down"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<!-- <ion-fab-list side="start">
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="chevron-down"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="logo-twitter"></ion-icon>
|
||||
</ion-fab-button>
|
||||
<ion-fab-button color="light">
|
||||
<ion-icon name="logo-vimeo"></ion-icon>
|
||||
</ion-fab-button>
|
||||
</ion-fab-list> -->
|
||||
</ion-fab>
|
||||
|
||||
</ion-content>
|
||||
|
||||
|
||||
@@ -151,7 +151,29 @@
|
||||
margin-left: 10px;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
.message{
|
||||
.message-attachments{
|
||||
.file{
|
||||
align-items: center;
|
||||
|
||||
.file-details{
|
||||
width: 100%;
|
||||
|
||||
.file-title{
|
||||
color: #000;
|
||||
text-decoration: underline;
|
||||
white-space: nowrap;
|
||||
overflow: hidden !important;
|
||||
text-overflow: ellipsis !important;
|
||||
}
|
||||
.file-title:hover{
|
||||
color: #0782c9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ion-footer{
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/ch
|
||||
import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
||||
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||
import { TimeService } from 'src/app/services/functions/time.service';
|
||||
import { FileService } from 'src/app/services/functions/file.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-messages',
|
||||
@@ -49,6 +50,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private scrollChangeCallback: () => void;
|
||||
currentPosition: any;
|
||||
startPosition: number;
|
||||
mesageItemDropdownOptions: boolean = false;
|
||||
scrollToBottomBtn = false;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -61,6 +64,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private toastService: ToastService,
|
||||
private route: Router,
|
||||
private timeService: TimeService,
|
||||
private fileService: FileService,
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
|
||||
@@ -120,6 +124,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
scrollToBottomClicked(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
//this.scrollingOnce = false;
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
||||
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
||||
@@ -128,14 +139,21 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
onContentScrolled(e) {
|
||||
this.startPosition = e.srcElement.scrollTop;
|
||||
let scroll = e.srcElement.scrollTop;
|
||||
let windowHeight = e.srcElement.scrollHeight;
|
||||
let containerHeight = windowHeight - e.srcElement.clientHeight;
|
||||
|
||||
if (scroll > this.currentPosition) {
|
||||
//this.showButton = false;
|
||||
//alert('BOTTOM');
|
||||
} else {
|
||||
//this.showButton = true;
|
||||
//alert('UP');
|
||||
this.scrollingOnce = false;
|
||||
}
|
||||
if((containerHeight - 100) > scroll){
|
||||
this.scrollToBottomBtn = true;
|
||||
}
|
||||
else{
|
||||
this.scrollToBottomBtn = false;
|
||||
}
|
||||
this.currentPosition = scroll;
|
||||
}
|
||||
|
||||
@@ -191,6 +209,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
})
|
||||
}
|
||||
|
||||
viewDocument(url:string){
|
||||
this.fileService.viewDocumentByUrl(url);
|
||||
}
|
||||
|
||||
getChatMembers() {
|
||||
console.log(this.roomId);
|
||||
|
||||
@@ -350,44 +372,67 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
}
|
||||
this.openNewEventPage.emit(data);
|
||||
}
|
||||
else if(res['data'] == 'take-picture'){
|
||||
this.fileService.addCameraPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-picture'){
|
||||
this.fileService.addPictureToChat(this.roomId);
|
||||
//this.loadPicture();
|
||||
}
|
||||
else if(res['data'] == 'add-document'){
|
||||
this.fileService.addDocumentToChat(this.roomId);
|
||||
//this.loadDocument();
|
||||
}
|
||||
else if(res['data'] == 'documentoGestaoDocumental'){
|
||||
|
||||
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
|
||||
this.showLoader = false;
|
||||
//this.addDocGestaoDocumental();
|
||||
}
|
||||
this.loadMessages();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
async serverLongPull() {
|
||||
|
||||
const roomId = this.roomId
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||
const roomId = this.roomId;
|
||||
|
||||
if (res == 502) {
|
||||
// Connection timeout
|
||||
// happens when the connection was pending for too long
|
||||
// let's reconnect
|
||||
await this.serverLongPull();
|
||||
} else if (res != 200) {
|
||||
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
|
||||
console.log(res['success']);
|
||||
|
||||
|
||||
if (res['success'] == true) {
|
||||
// Show Error
|
||||
//showMessage(response.statusText);
|
||||
//this.loadMessages()
|
||||
this.messages = res['messages'].reverse();
|
||||
this.chatMessageStore.add(roomId, this.messages)
|
||||
|
||||
console.log(this.messages);
|
||||
// Reconnect in one second
|
||||
if(this.route.url != "/home/chat"){
|
||||
console.log("Timer message stop")
|
||||
} else {
|
||||
if(document.querySelector('app-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
await this.serverLongPull();
|
||||
this.getDirectMessages.emit();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else{
|
||||
if(document.querySelector('app-messages')){
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
await this.serverLongPull();
|
||||
this.getDirectMessages.emit();
|
||||
console.log('Timer message running')
|
||||
}
|
||||
}
|
||||
} /* else {
|
||||
// Got message
|
||||
//let message = await response.text();
|
||||
//this.loadMessages()
|
||||
await this.serverLongPull();
|
||||
}
|
||||
} */
|
||||
}, (error)=>{
|
||||
console.log(error);
|
||||
this.serverLongPull();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
<button (click)="takePicture()" full class="btn-ok" shape="round" >Tirar Fotografia</button>
|
||||
<button hidden (click)="notImplemented()" class="btn-ok" shape="round" >Digitalizar Documento</button>
|
||||
<button (click)="anexarFoto()" full class="btn-ok" shape="round" >Anexar Fotografia</button>
|
||||
<button hidden (click)="getDoc()" class="btn-ok" shape="round" >Anexar Documento</button>
|
||||
<button (click)="addDocGestaoDocumental()" class="btn-ok" shape="round" >Anexar Documento (G.D.)</button>
|
||||
<div class="solid"></div>
|
||||
<button (click)="bookMeeting()" class="btn-ok" shape="round" >Marcar reunião</button>
|
||||
<button (click)="bookMeeting()" class="btn-ok" shape="round" >Novo Evento</button>
|
||||
<button (click)="close()" full class="btn-cancel" shape="round" >Cancelar</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -47,19 +47,28 @@ export class ChatOptionsPopoverPage implements OnInit {
|
||||
|
||||
takePicture(){
|
||||
if( window.innerWidth < 701){
|
||||
this.popoverController.dismiss('takePicture');
|
||||
this.popoverController.dismiss('take-picture');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss('takePicture');
|
||||
this.modalController.dismiss('take-picture');
|
||||
}
|
||||
}
|
||||
|
||||
anexarFoto(){
|
||||
if( window.innerWidth < 701){
|
||||
this.popoverController.dismiss('loadPicture');
|
||||
this.popoverController.dismiss('add-picture');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss('loadPicture');
|
||||
this.modalController.dismiss('add-picture');
|
||||
}
|
||||
}
|
||||
|
||||
addDocGestaoDocumental(){
|
||||
if( window.innerWidth < 701){
|
||||
this.popoverController.dismiss('documentoGestaoDocumental');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss('documentoGestaoDocumental');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +106,7 @@ export class ChatOptionsPopoverPage implements OnInit {
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
async getDoc(){
|
||||
const modal = await this.modalController.create({
|
||||
component: SearchPage,
|
||||
|
||||
@@ -111,8 +111,12 @@ export class ChatPopoverPage implements OnInit {
|
||||
}
|
||||
|
||||
async openChangeGroupName(){
|
||||
this.popoverController.dismiss('edit');
|
||||
this.modalController.dismiss('edit');
|
||||
if( window.innerWidth < 701){
|
||||
this.popoverController.dismiss('edit');
|
||||
}
|
||||
else{
|
||||
this.modalController.dismiss('edit');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user