diff --git a/src/app/guards/auth.guard.ts b/src/app/guards/auth.guard.ts index 6d859eafe..74a8e799d 100644 --- a/src/app/guards/auth.guard.ts +++ b/src/app/guards/auth.guard.ts @@ -12,11 +12,11 @@ export class AuthGuard implements CanActivate { private router:Router, private localstoreService: LocalstoreService ){} - + canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { - + if(!SessionStore.user.Inactivity) { this.router.navigate(['/']); return false @@ -28,5 +28,5 @@ export class AuthGuard implements CanActivate { return true } } - + } diff --git a/src/app/modals/view-document/view-document.page.ts b/src/app/modals/view-document/view-document.page.ts index cb5b52480..ff385dd90 100644 --- a/src/app/modals/view-document/view-document.page.ts +++ b/src/app/modals/view-document/view-document.page.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { ModalController, NavParams } from '@ionic/angular'; import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage'; -import { SearchDocumentDetails, SearchFolderDetails } from 'src/app/models/search-document'; import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page'; import { ProcessesService } from 'src/app/services/processes.service'; import { EventDetailsDocumentsOptionsPage } from 'src/app/shared/popover/event-details-documents-options/event-details-documents-options.page'; diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts index 4921e409b..074c036e7 100644 --- a/src/app/pages/chat/chat.page.ts +++ b/src/app/pages/chat/chat.page.ts @@ -7,7 +7,7 @@ import { ComponentFactoryResolver, ComponentRef, ComponentFactory, - Output + Output, } from '@angular/core'; import { ModalController, Platform } from '@ionic/angular'; import { AuthService } from 'src/app/services/auth.service'; @@ -17,7 +17,6 @@ import { ContactsPage } from './messages/contacts/contacts.page'; import { MessagesPage } from './messages/messages.page'; import { NewGroupPage } from './new-group/new-group.page'; import { Storage } from '@ionic/storage'; -import { AlertService } from 'src/app/services/alert.service'; import { EditGroupPage } from 'src/app/shared/chat/edit-group/edit-group.page'; import * as Rx from "rxjs/Rx"; import { Message } from 'src/app/models/message.model'; @@ -136,6 +135,7 @@ export class ChatPage implements OnInit { } ngOnInit() { + console.log(this.loggedUserChat); this.segment = "Contactos"; @@ -164,19 +164,23 @@ export class ChatPage implements OnInit { 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(); - } + if (this.dataService.get("newGroup")) { + this.openNewGroupPage(); } + else{ + this.closeAllDesktopComponents(); + this.showEmptyComponent = true; + } + } + else{ + this.dataService.set("newGroup", false); } }); } ngOnDestroy() { this.setStatus('offline'); + this.dataService.set("newGroup", false); console.log('On Destroy') } @@ -490,6 +494,13 @@ export class ChatPage implements OnInit { console.log('Chat list', res); if (res != 200) { + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.userDirectMessages = res.ims.sort((a, b) => { + var dateA = new Date(a._updatedAt).getTime(); + var dateB = new Date(b._updatedAt).getTime(); + return dateB - dateA; + }); + } //console.log(res.ims); /* this.userDirectMessages = res.ims.sort((a, b) => { var dateA = new Date(a._updatedAt).getTime(); @@ -534,9 +545,10 @@ export class ChatPage implements OnInit { this.chatService.getAllUsers().subscribe(res => { console.log('chatusers', res); this.transformDataUserList(res['users']) - - //this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username); - //console.log(this.dmUsers); + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + this.dmUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username); + console.log(this.dmUsers); + } }); } diff --git a/src/app/pages/chat/new-group/new-group.page.ts b/src/app/pages/chat/new-group/new-group.page.ts index 9b5d33136..d1006c0e2 100644 --- a/src/app/pages/chat/new-group/new-group.page.ts +++ b/src/app/pages/chat/new-group/new-group.page.ts @@ -5,6 +5,7 @@ import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-d import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page'; import { ThemeService } from 'src/app/services/theme.service' import { ChatService } from 'src/app/services/chat.service'; +import { ProcessesService } from 'src/app/services/processes.service'; @Component({ selector: 'app-new-group', @@ -19,6 +20,7 @@ export class NewGroupPage implements OnInit { selectedDuration = ['','','']; thedate:any; groupName:string; + documents:any; constructor( private pickerController: PickerController, @@ -27,15 +29,18 @@ export class NewGroupPage implements OnInit { private navParams: NavParams, public ThemeService: ThemeService, private chatService: ChatService, + private processesService: ProcessesService, ) { this.isGroupCreated = false; this.groupName = this.navParams.get('name'); + this.documents = this.navParams.get('documents'); } ngOnInit() { - + console.log(this.documents); } + _ionChange(event){ this.showDuration = event.detail.checked; @@ -52,6 +57,7 @@ export class NewGroupPage implements OnInit { createGroup(){ let name = this.groupName.split(' ').join('-'); + //Take out all special characters in string name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); let body = { "name":name, } this.chatService.addGroup(body).subscribe(res=>{ @@ -73,6 +79,39 @@ export class NewGroupPage implements OnInit { this.isGroupCreated = true; this.addContacts(res['group']); + if(this.documents.length > 0){ + //If there is documents add + this.documents.forEach(async document => { + + let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise(); + let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); + + let body = { + "message": + { + "rid": res['group']._id, + "msg": "", + "attachments": [{ + "title": document.Assunto, + "description": document.DocTypeDesc, + "title_link": url_no_options, + "title_link_download": true, + //"thumb_url": "assets/images/webtrix-logo.png", + "message_link": url_no_options, + "type": "webtrix" + }], + "file":{ + "name": document.Assunto, + "type": "application/webtrix", + "ApplicationId": document.ApplicationType, + "DocId": document.Id, + "Assunto": document.Assunto, + } + } + } + this.chatService.sendMessage(body).toPromise(); + }); + } }); } diff --git a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts index e5ea396b7..1a60e2b39 100644 --- a/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts @@ -634,16 +634,16 @@ export class ExpedienteDetailPage implements OnInit { } openNewGroupPage() { - this.router.navigate(['/home/chat']); - this.dataService.set("newGroup", true); - if (window.innerWidth < 801) { + this.router.navigate(['/home/chat']); this.newGroup(); } else { this.dataService.set("newGroup", true); this.dataService.set("task", this.task); this.dataService.set("newGroupName", this.task.Folio); + this.dataService.set("documents", this.fulltask.Documents); + this.router.navigate(['/home/chat']); } } diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index 2d701a46d..c3c98059d 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -30,6 +30,7 @@ import { SqliteService } from '../../services/sqlite.service'; import { Platform } from '@ionic/angular'; import { BackgroundService } from 'src/app/services/background.service'; import { SortService } from 'src/app/services/functions/sort.service'; +import { DataService } from 'src/app/services/data.service'; @Component({ selector: 'app-gabinete-digital', @@ -133,6 +134,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { private backgroundservice: BackgroundService, public ThemeService: ThemeService, private sortService: SortService, + private dataService: DataService, ) { this.loggeduser = authService.ValidatedUser; @@ -616,7 +618,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck { doRefresh(event) { console.log(event); - + this.LoadCounts(); if (event) { diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html index 65578e163..ed64311d0 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.html @@ -130,8 +130,8 @@ -
- +
+
diff --git a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts index 5a7c2a1eb..a06ecb331 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts @@ -480,17 +480,17 @@ export class PedidoPage implements OnInit { modal.onDidDismiss(); } - openNewGroupPage(task?:any){ - this.router.navigate(['/home/chat']); - this.dataService.set("newGroup", true); - - if( window.innerWidth < 801){ + openNewGroupPage() { + if (window.innerWidth < 801) { + this.router.navigate(['/home/chat']); this.newGroup(); } - else{ + else { this.dataService.set("newGroup", true); this.dataService.set("task", this.task); this.dataService.set("newGroupName", this.task.Folio); + this.dataService.set("documents", this.fulltask.Documents); + this.router.navigate(['/home/chat']); } } diff --git a/src/app/services/functions/file.service.ts b/src/app/services/functions/file.service.ts index 5973e67df..00883b376 100644 --- a/src/app/services/functions/file.service.ts +++ b/src/app/services/functions/file.service.ts @@ -315,24 +315,6 @@ export class FileService { //loader.remove(); }); */ } - async shareLocalFile(){ - this.http.get('./assets/any.svg', {responseType: 'blob'}).subscribe(res=>{ - const reader = new FileReader() - reader.onloadend=()=>{ - const result = reader.result as string - const base64Data = result.split(',')[1] - - /* FileSharer.share({ - filename:'any.pdf', - base64Data, - contentType: "application/pdf", - }) */ - reader.readAsDataURL(res) - } - - }) - -} addPictureToChat(roomId) { diff --git a/src/app/shared/chat/new-group/new-group.page.ts b/src/app/shared/chat/new-group/new-group.page.ts index afcdba940..a8fb7a4c5 100644 --- a/src/app/shared/chat/new-group/new-group.page.ts +++ b/src/app/shared/chat/new-group/new-group.page.ts @@ -1,8 +1,10 @@ import { analyzeAndValidateNgModules } from '@angular/compiler'; import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; +import { NavigationStart, Router } from '@angular/router'; import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular'; import { ChatService } from 'src/app/services/chat.service'; import { DataService } from 'src/app/services/data.service'; +import { ProcessesService } from 'src/app/services/processes.service'; import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page'; import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page'; @@ -22,6 +24,7 @@ export class NewGroupPage implements OnInit{ countDownTime:any; //groupName:string; task:any; + documents: any; @Input() groupName:string; @Output() addGroupMessage:EventEmitter = new EventEmitter(); @@ -32,31 +35,42 @@ export class NewGroupPage implements OnInit{ private modalController: ModalController, private chatService: ChatService, private dataService:DataService, + private processesService: ProcessesService, + private router: Router, ) { this.isGroupCreated = false; //this.groupName = this.navParams.get('name'); - } ngOnInit() { - if(this.dataService.get("newGroup")){ - this.task = this.dataService.get("task"); - this.groupName = this.task.Folio; - } - console.log(this.task); + this.router.events.forEach((event) => { + if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) { + if (this.dataService.get("newGroup")) { + this.task = this.dataService.get("task"); + this.groupName = this.task.Folio; + this.documents = this.dataService.get("documents"); + } + } + else{ + this.dataService.set("newGroup", false); + } + }); + console.log(this.task); } + /* ngOnDestroy(){ alert('Destroy') this.dataService.set("newGroup", false); this.dataService.set("task", null); this.dataService.set("newGroupName", ''); } */ + _ionChange(event){ console.log(event); console.log(event.detail.checked); - this.showDuration = event.detail.checked; + this.showDuration = event.detail.checked; if(event.detail.checked){ this.thedate = new Date(); @@ -74,6 +88,8 @@ export class NewGroupPage implements OnInit{ createGroup(){ let name = this.groupName.split(' ').join('-'); + //Take out all special characters in string + name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); let body = { "name":name, } this.chatService.addGroup(body).subscribe(res=>{ console.log('group created'); @@ -90,6 +106,43 @@ export class NewGroupPage implements OnInit{ console.log(res); }); } + + if(this.documents.length > 0){ + //If there is documents add + this.documents.forEach(async document => { + + let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise(); + let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); + + let body = { + "message": + { + "rid": res['group']._id, + "msg": "", + "attachments": [{ + "title": document.Assunto, + "description": document.DocTypeDesc, + "title_link": url_no_options, + "title_link_download": true, + //"thumb_url": "assets/images/webtrix-logo.png", + "message_link": url_no_options, + "type": "webtrix" + }], + "file":{ + "name": document.Assunto, + "type": "application/webtrix", + "ApplicationId": document.ApplicationType, + "DocId": document.Id, + "Assunto": document.Assunto, + } + } + } + this.chatService.sendMessage(body).toPromise(); + }); + } + + + }); } diff --git a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts index f874a9f4d..da24ec370 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts @@ -17,6 +17,7 @@ import { TaskService } from 'src/app/Rules/task.service' import { ExpedienteService } from 'src/app/Rules/expediente.service'; import { PermissionService } from 'src/app/services/worker/permission.service'; import { ThemeService } from 'src/app/services/theme.service' +import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page'; @Component({ @@ -66,8 +67,20 @@ export class OptsExpedientePage implements OnInit { }; } - openNewGroupPage(){ + async openNewGroupPage(){ + console.log(this.fulltask); + const modal = await this.modalController.create({ + component: NewGroupPage, + cssClass: 'modal modal-desktop', + componentProps: { + name: this.task.Folio, + task: this.task, + documents: this.fulltask.Documents, + }, + }); + await modal.present(); + modal.onDidDismiss(); } close() { diff --git a/src/app/shared/popover/request-options/request-options.page.html b/src/app/shared/popover/request-options/request-options.page.html index 7105f2577..d76118df8 100644 --- a/src/app/shared/popover/request-options/request-options.page.html +++ b/src/app/shared/popover/request-options/request-options.page.html @@ -42,6 +42,7 @@ +
@@ -54,8 +55,8 @@
-
- -
+ diff --git a/src/app/shared/popover/request-options/request-options.page.ts b/src/app/shared/popover/request-options/request-options.page.ts index b8616959b..f59911563 100644 --- a/src/app/shared/popover/request-options/request-options.page.ts +++ b/src/app/shared/popover/request-options/request-options.page.ts @@ -112,18 +112,20 @@ export class RequestOptionsPage implements OnInit { modal.onDidDismiss(); } - 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 openNewGroupPage(){ + const modal = await this.modalController.create({ + component: NewGroupPage, + cssClass: 'modal modal-desktop', + componentProps: { + name: this.task.Folio, + task: this.task, + documents: this.fulltask.Documents, + }, + }); + await modal.present(); + modal.onDidDismiss().then( () => { + this.popoverController.dismiss('close'); + }); } async newGroup(){ diff --git a/src/polyfills.ts b/src/polyfills.ts index 4f7af3834..f75239d4f 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -68,4 +68,4 @@ import 'zone.js'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS */ -(window as any).global = window; \ No newline at end of file +(window as any).global = window;