From 427191ec3699188c7e530821b69de1dceee763b7 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Tue, 14 Sep 2021 15:57:24 +0100 Subject: [PATCH] add document from gestao digital --- .../chat-options-features.page.html | 2 +- .../chat-options-features.page.ts | 5 +- .../expediente-detail.page.ts | 1 - src/app/services/functions/file.service.ts | 7 +++ .../group-messages/group-messages.page.html | 17 ++++- .../group-messages/group-messages.page.scss | 34 +++++++--- .../group-messages/group-messages.page.ts | 63 +++++++++++++++++++ 7 files changed, 113 insertions(+), 16 deletions(-) diff --git a/src/app/modals/chat-options-features/chat-options-features.page.html b/src/app/modals/chat-options-features/chat-options-features.page.html index 7e630429f..d21bc3f28 100644 --- a/src/app/modals/chat-options-features/chat-options-features.page.html +++ b/src/app/modals/chat-options-features/chat-options-features.page.html @@ -8,7 +8,7 @@ - +
diff --git a/src/app/modals/chat-options-features/chat-options-features.page.ts b/src/app/modals/chat-options-features/chat-options-features.page.ts index a1ee2ec47..3951f5120 100644 --- a/src/app/modals/chat-options-features/chat-options-features.page.ts +++ b/src/app/modals/chat-options-features/chat-options-features.page.ts @@ -72,6 +72,10 @@ export class ChatOptionsFeaturesPage implements OnInit { this.modalController.dismiss('picture'); } + addDocGestaoDocumental(){ + this.modalController.dismiss('documentoGestaoDocumental'); + } + laodPicture() { const input = this.fileLoaderService.createInput({ accept: ['image/apng', 'image/jpeg', 'image/png'] @@ -171,7 +175,6 @@ export class ChatOptionsFeaturesPage implements OnInit { const data = res.data; this.documents.push(data.selected); console.log(res.data); - } }); } 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 7d7fc1a75..c986603cb 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 @@ -382,7 +382,6 @@ export class ExpedienteDetailPage implements OnInit { }); await modal.present(); modal.onDidDismiss().then( async(res)=>{ - alert('AQUI') let body = res['data']; if(res['data']) { const loader = this.toastService.loading() diff --git a/src/app/services/functions/file.service.ts b/src/app/services/functions/file.service.ts index e36efb620..172e87ba4 100644 --- a/src/app/services/functions/file.service.ts +++ b/src/app/services/functions/file.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { FileLoaderService } from '../file/file-loader.service'; import { FileToBase64Service } from '../file/file-to-base64.service'; +import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; //Cordova import { Camera, CameraOptions } from '@ionic-native/camera/ngx'; @@ -16,6 +17,7 @@ export class FileService { private camera: Camera, private fileLoaderService: FileLoaderService, private fileToBase64Service: FileToBase64Service, + private iab: InAppBrowser, ) { } takePicture() { @@ -68,4 +70,9 @@ export class FileService { return data; }; } + + viewDocumentByUrl(url) { + const browser = this.iab.create(url,"_blank"); + browser.show(); + } } diff --git a/src/app/shared/chat/group-messages/group-messages.page.html b/src/app/shared/chat/group-messages/group-messages.page.html index 5b625597b..8d6fc801b 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.html +++ b/src/app/shared/chat/group-messages/group-messages.page.html @@ -44,11 +44,22 @@ {{msg.u.name}} {{showDateDuration(msg._updatedAt)}} -
+
{{msg.msg}} -
+
- image + image +
+
+ + image + + +

{{file.title}}

+

{{file.text}}

+
+
+
{{last ? scrollToBottom() : ''}} diff --git a/src/app/shared/chat/group-messages/group-messages.page.scss b/src/app/shared/chat/group-messages/group-messages.page.scss index ca3555a51..60395f16b 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.scss +++ b/src/app/shared/chat/group-messages/group-messages.page.scss @@ -144,18 +144,32 @@ float: right; } .title{ - display: inline; - color: #0782c9; - font-weight: bold; - margin-bottom: 5px; + display: inline; + color: #0782c9; + font-weight: bold; + margin-bottom: 5px; - .time{ - color: #797979; - text-align: right; - margin-left: 10px; - float: right; + .time{ + color: #797979; + text-align: right; + margin-left: 10px; + float: right; + } + } + .messages{ + .message-attachments{ + .file{ + align-items: center; + .file-title{ + color: #000; + text-decoration: underline; + } + .file-title:hover{ + color: #0782c9; + } + } + } } - } } ion-footer{ diff --git a/src/app/shared/chat/group-messages/group-messages.page.ts b/src/app/shared/chat/group-messages/group-messages.page.ts index a830fe661..dacb387f5 100644 --- a/src/app/shared/chat/group-messages/group-messages.page.ts +++ b/src/app/shared/chat/group-messages/group-messages.page.ts @@ -13,6 +13,10 @@ import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/ch import { TimeService } from 'src/app/services/functions/time.service'; import { FileLoaderService } from 'src/app/services/file/file-loader.service'; import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service'; +import { SearchPage } from 'src/app/pages/search/search.page'; +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'; @Component({ selector: 'app-group-messages', @@ -26,6 +30,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe message:any; messages:any; allUsers:any[] = []; + documents:SearchList[] = []; room:any = new Array(); @@ -64,6 +69,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe private timeService: TimeService, private fileLoaderService: FileLoaderService, private fileToBase64Service: FileToBase64Service, + private processesService: ProcessesService, + private fileService: FileService, ) { this.loggedUserChat = authService.ValidatedUserChat['data']; this.isGroupCreated = true; @@ -435,6 +442,59 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe }; } + async addDocGestaoDocumental(){ + const modal = await this.modalController.create({ + component: SearchPage, + cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop', + componentProps: { + type: 'AccoesPresidenciais & ArquivoDespachoElect', + select: true, + showSearchInput: true, + } + }); + await modal.present(); + modal.onDidDismiss().then(async res=>{ + if(res){ + const data = res.data; + this.documents.push(data.selected); + console.log(res.data.selected); + console.log(res.data.selected.Id); + console.log(res.data.selected.ApplicationType); + + let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise(); + let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1"); + console.log(url_no_options); + console.log('Oie'); + + let body = { + "message": + { + "rid": this.roomId, + "msg": "", + "attachments": [{ + "title": res.data.selected.Assunto, + "text": res.data.selected.DocTypeDesc, + "title_link": url_no_options, + "title_link_download": true, + "thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png", + "message_link": url_no_options, + }] + } + } + this.chatService.sendMessage(body).subscribe(res=> { + console.log(res); + },(error) => { + + }); + + } + }); + } + + viewDocument(url:string){ + this.fileService.viewDocumentByUrl(url); + } + async _openChatOptions() { const enterAnimation = (baseEl: any) => { @@ -485,6 +545,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe else if(res['data'] == 'picture'){ this.loadPicture(); } + else if(res['data'] == 'documentoGestaoDocumental'){ + this.addDocGestaoDocumental(); + } }); }