continue work on opening chat from expediente

This commit is contained in:
tiago.kayaya
2021-12-10 10:32:49 +01:00
parent 89c3db663b
commit 3b34057559
10 changed files with 144 additions and 37 deletions
+1
View File
@@ -19,6 +19,7 @@ export class AuthGuard implements CanActivate {
if(!SessionStore.user.Inactivity) { if(!SessionStore.user.Inactivity) {
this.router.navigate(['/']); this.router.navigate(['/']);
return false
} }
else if(!SessionStore.exist) { else if(!SessionStore.exist) {
this.router.navigate(['/']); this.router.navigate(['/']);
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { ModalController, NavParams } from '@ionic/angular'; import { ModalController, NavParams } from '@ionic/angular';
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage'; 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 { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { EventDetailsDocumentsOptionsPage } from 'src/app/shared/popover/event-details-documents-options/event-details-documents-options.page'; import { EventDetailsDocumentsOptionsPage } from 'src/app/shared/popover/event-details-documents-options/event-details-documents-options.page';
+30 -7
View File
@@ -7,7 +7,9 @@ import {
ComponentFactoryResolver, ComponentFactoryResolver,
ComponentRef, ComponentRef,
ComponentFactory, ComponentFactory,
Output Output,
AfterViewChecked,
AfterViewInit
} from '@angular/core'; } from '@angular/core';
import { ModalController, Platform } from '@ionic/angular'; import { ModalController, Platform } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service'; import { AuthService } from 'src/app/services/auth.service';
@@ -17,7 +19,6 @@ import { ContactsPage } from './messages/contacts/contacts.page';
import { MessagesPage } from './messages/messages.page'; import { MessagesPage } from './messages/messages.page';
import { NewGroupPage } from './new-group/new-group.page'; import { NewGroupPage } from './new-group/new-group.page';
import { Storage } from '@ionic/storage'; 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 { EditGroupPage } from 'src/app/shared/chat/edit-group/edit-group.page';
import * as Rx from "rxjs/Rx"; import * as Rx from "rxjs/Rx";
import { Message } from 'src/app/models/message.model'; import { Message } from 'src/app/models/message.model';
@@ -39,7 +40,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
templateUrl: './chat.page.html', templateUrl: './chat.page.html',
styleUrls: ['./chat.page.scss'], styleUrls: ['./chat.page.scss'],
}) })
export class ChatPage implements OnInit { export class ChatPage implements OnInit, AfterViewInit {
showLoader: boolean; showLoader: boolean;
@@ -136,6 +137,7 @@ export class ChatPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log(this.loggedUserChat); console.log(this.loggedUserChat);
this.segment = "Contactos"; this.segment = "Contactos";
@@ -162,17 +164,38 @@ export class ChatPage implements OnInit {
this.openNewGroupPage(); this.openNewGroupPage();
} */ } */
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) { if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) { alert('Aqui' + this.dataService.get("newGroup"))
//alert('OIII') if (this.dataService.get("newGroup")) {
} else { this.openNewGroupPage();
}
/* if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/chat')) {
alert(this.dataService.get("newGroup"))
}
else {
if (this.dataService.get("newGroup")) {
this.openNewGroupPage();
}
} */
}
else{
this.dataService.set("newGroup", false);
}
});
if (this.dataService.get("newGroup")) { if (this.dataService.get("newGroup")) {
this.openNewGroupPage(); this.openNewGroupPage();
} }
} }
ngAfterViewInit() {
alert(this.dataService.get("newGroup"))
} }
});
ngAfterViewChecked(){
//alert(this.dataService.get("newGroup"))
} }
ngOnDestroy() { ngOnDestroy() {
+39 -1
View File
@@ -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 { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { ProcessesService } from 'src/app/services/processes.service';
@Component({ @Component({
selector: 'app-new-group', selector: 'app-new-group',
@@ -19,6 +20,7 @@ export class NewGroupPage implements OnInit {
selectedDuration = ['','','']; selectedDuration = ['','',''];
thedate:any; thedate:any;
groupName:string; groupName:string;
documents:any;
constructor( constructor(
private pickerController: PickerController, private pickerController: PickerController,
@@ -27,15 +29,18 @@ export class NewGroupPage implements OnInit {
private navParams: NavParams, private navParams: NavParams,
public ThemeService: ThemeService, public ThemeService: ThemeService,
private chatService: ChatService, private chatService: ChatService,
private processesService: ProcessesService,
) )
{ {
this.isGroupCreated = false; this.isGroupCreated = false;
this.groupName = this.navParams.get('name'); this.groupName = this.navParams.get('name');
this.documents = this.navParams.get('documents');
} }
ngOnInit() { ngOnInit() {
console.log(this.documents);
} }
_ionChange(event){ _ionChange(event){
this.showDuration = event.detail.checked; this.showDuration = event.detail.checked;
@@ -73,6 +78,39 @@ export class NewGroupPage implements OnInit {
this.isGroupCreated = true; this.isGroupCreated = true;
this.addContacts(res['group']); 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();
});
}
}); });
} }
@@ -634,6 +634,9 @@ export class ExpedienteDetailPage implements OnInit {
} }
openNewGroupPage() { openNewGroupPage() {
console.log(this.fulltask);
this.dataService.set("newGroup", true);
this.router.navigate(['/home/chat']); this.router.navigate(['/home/chat']);
this.dataService.set("newGroup", true); this.dataService.set("newGroup", true);
@@ -644,6 +647,7 @@ export class ExpedienteDetailPage implements OnInit {
this.dataService.set("newGroup", true); this.dataService.set("newGroup", true);
this.dataService.set("task", this.task); this.dataService.set("task", this.task);
this.dataService.set("newGroupName", this.task.Folio); this.dataService.set("newGroupName", this.task.Folio);
this.dataService.set("documents", this.fulltask.Documents);
} }
} }
@@ -30,6 +30,7 @@ import { SqliteService } from '../../services/sqlite.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { BackgroundService } from 'src/app/services/background.service'; import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service'; import { SortService } from 'src/app/services/functions/sort.service';
import { DataService } from 'src/app/services/data.service';
@Component({ @Component({
selector: 'app-gabinete-digital', selector: 'app-gabinete-digital',
@@ -133,6 +134,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
private backgroundservice: BackgroundService, private backgroundservice: BackgroundService,
public ThemeService: ThemeService, public ThemeService: ThemeService,
private sortService: SortService, private sortService: SortService,
private dataService: DataService,
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
@@ -315,24 +315,6 @@ export class FileService {
//loader.remove(); //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) { addPictureToChat(roomId) {
@@ -3,6 +3,7 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular'; import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { DataService } from 'src/app/services/data.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 { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page'; import { GroupContactsPage } from '../group-messages/group-contacts/group-contacts.page';
@@ -22,6 +23,7 @@ export class NewGroupPage implements OnInit{
countDownTime:any; countDownTime:any;
//groupName:string; //groupName:string;
task:any; task:any;
documents: any;
@Input() groupName:string; @Input() groupName:string;
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>(); @Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
@@ -32,27 +34,33 @@ export class NewGroupPage implements OnInit{
private modalController: ModalController, private modalController: ModalController,
private chatService: ChatService, private chatService: ChatService,
private dataService:DataService, private dataService:DataService,
private processesService: ProcessesService,
) )
{ {
this.isGroupCreated = false; this.isGroupCreated = false;
//this.groupName = this.navParams.get('name'); //this.groupName = this.navParams.get('name');
} }
ngOnInit() { ngOnInit() {
if(this.dataService.get("newGroup")){ //alert(this.dataService.get("newGroup"))
setTimeout(() => {
//alert(this.dataService.get("newGroup"))
}, 100)
if(this.dataService.get("newGroup") == true){
this.task = this.dataService.get("task"); this.task = this.dataService.get("task");
this.groupName = this.task.Folio; this.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
} }
console.log(this.task); console.log(this.task);
} }
/* ngOnDestroy(){ /* ngOnDestroy(){
alert('Destroy') alert('Destroy')
this.dataService.set("newGroup", false); this.dataService.set("newGroup", false);
this.dataService.set("task", null); this.dataService.set("task", null);
this.dataService.set("newGroupName", ''); this.dataService.set("newGroupName", '');
} */ } */
_ionChange(event){ _ionChange(event){
console.log(event); console.log(event);
console.log(event.detail.checked); console.log(event.detail.checked);
@@ -90,6 +98,43 @@ export class NewGroupPage implements OnInit{
console.log(res); 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();
});
}
}); });
} }
@@ -17,6 +17,7 @@ import { TaskService } from 'src/app/Rules/task.service'
import { ExpedienteService } from 'src/app/Rules/expediente.service'; import { ExpedienteService } from 'src/app/Rules/expediente.service';
import { PermissionService } from 'src/app/services/worker/permission.service'; import { PermissionService } from 'src/app/services/worker/permission.service';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
import { NewGroupPage } from 'src/app/pages/chat/new-group/new-group.page';
@Component({ @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() { close() {