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
+4 -3
View File
@@ -12,13 +12,14 @@ export class AuthGuard implements CanActivate {
private router:Router,
private localstoreService: LocalstoreService
){}
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
if(!SessionStore.user.Inactivity) {
this.router.navigate(['/']);
return false
}
else if(!SessionStore.exist) {
this.router.navigate(['/']);
@@ -27,5 +28,5 @@ export class AuthGuard implements CanActivate {
return true
}
}
}
@@ -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';
+30 -7
View File
@@ -7,7 +7,9 @@ import {
ComponentFactoryResolver,
ComponentRef,
ComponentFactory,
Output
Output,
AfterViewChecked,
AfterViewInit
} from '@angular/core';
import { ModalController, Platform } from '@ionic/angular';
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 { 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';
@@ -39,7 +40,7 @@ import { SqliteService } from 'src/app/services/sqlite.service';
templateUrl: './chat.page.html',
styleUrls: ['./chat.page.scss'],
})
export class ChatPage implements OnInit {
export class ChatPage implements OnInit, AfterViewInit {
showLoader: boolean;
@@ -136,6 +137,7 @@ export class ChatPage implements OnInit {
}
ngOnInit() {
console.log(this.loggedUserChat);
this.segment = "Contactos";
@@ -162,17 +164,38 @@ export class ChatPage implements OnInit {
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 {
alert('Aqui' + this.dataService.get("newGroup"))
if (this.dataService.get("newGroup")) {
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")) {
this.openNewGroupPage();
}
}
ngAfterViewInit() {
alert(this.dataService.get("newGroup"))
}
ngAfterViewChecked(){
//alert(this.dataService.get("newGroup"))
}
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 { 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;
@@ -73,6 +78,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();
});
}
});
}
@@ -634,6 +634,9 @@ export class ExpedienteDetailPage implements OnInit {
}
openNewGroupPage() {
console.log(this.fulltask);
this.dataService.set("newGroup", true);
this.router.navigate(['/home/chat']);
this.dataService.set("newGroup", true);
@@ -644,6 +647,7 @@ export class ExpedienteDetailPage implements OnInit {
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);
}
}
@@ -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) {
@@ -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) {
@@ -3,6 +3,7 @@ import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu
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 +23,7 @@ export class NewGroupPage implements OnInit{
countDownTime:any;
//groupName:string;
task:any;
documents: any;
@Input() groupName:string;
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
@@ -32,31 +34,37 @@ export class NewGroupPage implements OnInit{
private modalController: ModalController,
private chatService: ChatService,
private dataService:DataService,
private processesService: ProcessesService,
)
{
this.isGroupCreated = false;
//this.groupName = this.navParams.get('name');
}
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.groupName = this.task.Folio;
this.documents = this.dataService.get("documents");
}
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();
@@ -90,6 +98,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();
});
}
});
}
@@ -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() {