This commit is contained in:
tiago.kayaya
2021-11-03 15:35:01 +01:00
parent adc80aaff3
commit 3f6b053660
11 changed files with 120 additions and 76 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ ion-content{
margin-top: 10px;
}
.item-title{
width: calc(100% - 80px);
width: calc(100% - 90px);
float: left;
font-size: 15px;
color: var(--title-text-color);
@@ -105,7 +105,7 @@ ion-content{
color: #fff;
}
.item-date{
width: 80px;
width: 90px;
float: right;
font-size: 13px;
color: #797979;
+21 -3
View File
@@ -29,6 +29,7 @@ import { environment } from 'src/environments/environment';
import { NotificationsService } from 'src/app/services/notifications.service';
import { TimeService } from 'src/app/services/functions/time.service';
import { ThemeService } from 'src/app/services/theme.service'
import { DataService } from 'src/app/services/data.service';
@Component({
@@ -115,7 +116,9 @@ export class ChatPage implements OnInit {
private resolver: ComponentFactoryResolver,
private route: Router,
private timeService: TimeService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private dataService:DataService,
private router: Router,
){
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.headers = new HttpHeaders();
@@ -150,6 +153,21 @@ export class ChatPage implements OnInit {
console.log(t);
this.setStatus('away');
if(this.dataService.get("newGroup")){
this.openNewGroupPage();
}
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) {
alert('OIII')
} else {
if(this.dataService.get("newGroup")){
this.openNewGroupPage();
}
}
}
});
}
ngOnDestroy(){
@@ -397,7 +415,7 @@ hideRefreshButton(){
//console.log('TIMER');
//Check if modal is opened
if(this.segment == "Contactos" && this.showMessages != true){
await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getDirectMessages();
//console.log('Timer contactos list running')
}
@@ -453,7 +471,7 @@ hideRefreshButton(){
else {
//Check if modal is opened
if(this.segment == "Grupos" && this.showGroupMessages != true){
await new Promise(resolve => setTimeout(resolve, 2000));
await new Promise(resolve => setTimeout(resolve, 1000));
await this.getGroups();
//console.log('Timer groups list running')
}
@@ -126,6 +126,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
ngAfterViewInit() {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
}
handlePress(id?:string){
@@ -184,7 +185,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.room = room['room'];
this.roomName = this.room.name.split('-').join(' ');
if(this.room.customFields.countDownDate){
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
this.roomCountDownDate = this.timeService.countDownDateTimer(this.room.customFields.countDownDate, this.room._id);
}
this.getGroupContacts(this.room);
this.loadGroupMessages(this.room);
@@ -260,7 +261,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
return this.timeService.showDateDuration(start);
}
countDownDate(date:any, roomId:string){
return this.timeService.countDownDate(date, roomId);
this.roomCountDownDate = this.timeService.countDownDate(date, roomId);
return this.timeService.countDownDateTimer(date, roomId);
}
addZero(i) {
@@ -32,7 +32,7 @@
</div>
<div *ngIf="showDuration" class="container-div">
<div class="ion-item-class-2">
<div class="ion-item-class-2 width-100">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-duration.svg"></ion-icon>
</div>
@@ -61,7 +61,7 @@ ion-content{
.middle{
padding: 0!important;
float: left;
width: 221px;
width:fit-content;
margin: 2.5px 0 0 5px;
}
.btn-criar{
@@ -115,7 +115,6 @@ ion-content{
.item-container-no-border{
display: flex;
width: 360px;
margin: 25px auto;
border-radius: 5px;
align-items: center;
@@ -133,8 +132,8 @@ ion-content{
overflow: auto;
.ion-item-class-2{
width: 360px;
margin: 0px auto;
overflow: auto;
.ion-icon-class{
width: 45px;
@@ -145,7 +144,7 @@ ion-content{
}
}
.ion-input-class{
width: 315px;
width: calc(100% - 45px) !important;
height: 45px;
border: 1px solid #ebebeb;
border-radius: 5px;
@@ -52,6 +52,7 @@ export class NewGroupPage implements OnInit {
createGroup(){
let name = this.groupName.split(' ').join('-');
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
@@ -104,6 +104,7 @@
<button *ngIf="!p.userRole(['PR'])" (click)="attachDocument()" class="btn-cancel" shape="round" >Anexar Documentos</button>
<button (click)="distartExpedientModal('descartar')" class="btn-cancel" shape="round" >Descartar</button>
<button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" full class="btn-cancel" shape="round" >Enviar para pendentes</button>
<button (click)="openNewGroupPage()" class="btn-cancel" shape="round" >Inicair Conversa</button>
<div class="solid"></div>
</div>
</div>
@@ -30,6 +30,8 @@ import { ThemeService } from 'src/app/services/theme.service'
import { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular';
import { BackgroundService } from 'src/app/services/background.service';
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
import { DataService } from 'src/app/services/data.service';
@Component({
selector: 'app-expediente-detail',
@@ -77,7 +79,8 @@ export class ExpedienteDetailPage implements OnInit {
public platform: Platform,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private dataService: DataService,
) {
this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) {
@@ -606,4 +609,30 @@ export class ExpedienteDetailPage implements OnInit {
return await popover.present();
}
openNewGroupPage(){
this.router.navigate(['/home/chat']);
this.dataService.set("newGroup", true);
if( window.innerWidth < 801){
this.newGroup();
}
else{
this.dataService.set("newGroup", true);
/* this.closeAllDesktopComponents();
this.showNewGroup=true; */
}
}
async newGroup(){
const modal = await this.modalController.create({
component: NewGroupPage,
cssClass: 'modal modal-desktop',
componentProps: {
name: this.task.Folio,
},
});
await modal.present();
modal.onDidDismiss();
}
}
+34 -1
View File
@@ -49,7 +49,7 @@ export class TimeService {
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = c_day + " : " + c_hours + " : " + c_minutes + " : " + c_seconds ;
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0){
//clearInterval(timer);
@@ -74,6 +74,39 @@ export class TimeService {
return this.countDownTime;
}
countDownDateTimer(date:any, roomId:string){
let timer = setInterval(() =>{
let difference = new Date(date).getTime() - new Date().getTime();
let c_day = Math.floor(difference/(1000*60*60*24));
let c_hours = Math.floor((difference % (1000*60*60*24)) / (1000*60*60));
let c_minutes = Math.floor((difference % (1000*60*60)) / (1000*60));
let c_seconds = Math.floor((difference % (1000*60)) / 1000);
this.countDownTime = this.addZero(c_day) + " : " + this.addZero(c_hours) + " : " + this.addZero(c_minutes) + " : " + this.addZero(c_seconds) ;
if(difference < 0){
clearInterval(timer);
this.countDownTime = "Expired";
let body = { "roomId":roomId, }
this.chatService.getRoomInfo(roomId).subscribe(room=>{
this.room = room['room'];
if(this.room.t === 'p'){
this.chatService.deleteGroup(body).subscribe(res=>{
console.log(res);
});
}
else{
this.chatService.deleteChannel(body).subscribe(res=>{
console.log(res);
});
}
});
}
})
return this.countDownTime;
}
addZero(i) {
if (i < 10) {
i = "0" + i;
@@ -23,9 +23,9 @@
</ion-label>
</div>
</div>
<div *ngIf="roomCountDownDate" class="d-flex align-items-center yellow-orange pl-10">
<div *ngIf="room.customFields.countDownDate" class="d-flex align-items-center yellow-orange pl-10">
<i class="far fa-clock font-15" ></i>
<ion-label class="font-15 pl-10" color="warning">{{roomCountDownDate}}</ion-label>
<ion-label class="font-15 pl-10" color="warning">{{countDownDate()}}</ion-label>
</div>
</div>
</ion-toolbar>
@@ -56,7 +56,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
currentPosition: any;
startPosition: number;
scrollToBottomBtn = false;
roomCountDownDate:any;
roomCountDownDate:string;
roomCountDownTime:string;
@Input() roomId:string;
@Output() closeAllDesktopComponents:EventEmitter<any> = new EventEmitter<any>();
@@ -89,6 +90,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
this.roomCountDownDate = "";
this.roomCountDownTime = "";
}
ngOnChanges(changes: SimpleChanges): void {
@@ -100,49 +103,18 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.loggedUser=this.loggedUserChat;
this.getRoomInfo();
this.serverLongPull();
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');
showDateDuration(start:any){
return this.timeService.showDateDuration(start);
}
// 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');
});
});
});
} */
countDownDate(){
//this.roomCountDownTime = this.timeService.countDownDateTimer(this.roomCountDownDate, this.room._id);
return this.timeService.countDownDateTimer(this.roomCountDownDate, this.roomId);
}
setStatus(status:string){
let body = {
@@ -235,30 +207,19 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
console.log('here watching');
return this.roomId;
}
showDateDuration(start:any){
return this.timeService.showDateDuration(start);
}
countDownDate(date:any, roomId:string){
return this.timeService.countDownDate(date, roomId);
}
async getRoomInfo(){
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
this.room=room['room'];
if(this.room.name){
this.roomName = this.room.name.split('-').join(' ');
}
getRoomInfo(){
this.showLoader = true;
this.chatService.getRoomInfo(this.roomId).subscribe(room=>{
console.log(room);
if(this.room.customFields.countDownDate){
this.roomCountDownDate = this.room.customFields.countDownDate;
}
this.room = room['room'];
if(this.room.name){
this.roomName = this.room.name.split('-').join(' ');
}
if(this.room.customFields.countDownDate){
this.roomCountDownDate = this.timeService.countDownDate(this.room.customFields.countDownDate, this.room._id);
}
this.getGroupContacts(this.room);
//this.loadGroupMessages(this.room);
this.showLoader = false;
});
this.getGroupContacts(this.room);
}
getGroupContacts(room:any){