-
@@ -21,7 +21,7 @@
- +
diff --git a/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts b/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts index 4af06ce11..dea2b1782 100644 --- a/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts +++ b/src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { ModalController, PopoverController } from '@ionic/angular'; +import { ModalController, PopoverController, ToastController } from '@ionic/angular'; import { ProcessesService } from 'src/app/services/processes.service'; import { momentG } from 'src/plugin/momentG'; @@ -17,6 +17,7 @@ import { CreateProcessPage } from 'src/app/modals/create-process/create-process. import { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page'; import { TaskService } from 'src/app/services/task.service' import { TinyMCEPage } from 'src/app/tiny-mce/tiny-mce.page'; +import { PopupQuestionPage } from 'src/app/modals/popup-question/popup-question.page'; @Component({ selector: 'app-diploma-assinar', @@ -50,7 +51,8 @@ export class DiplomaAssinarPage implements OnInit { public ThemeService: ThemeService, private httpErroHandle: HttpErrorHandle, private despachoService: DespachoService, - public TaskService: TaskService + public TaskService: TaskService, + private toastController: ToastController ) { this.activatedRoute.paramMap.subscribe(params => { if(params["params"].SerialNumber) { @@ -103,7 +105,7 @@ export class DiplomaAssinarPage implements OnInit { this.processes.GetTask(serial).subscribe(res => { this.TaskService.loadDiplomas(); - + this.task = { "SerialNumber": res.serialNumber, "Folio": res.workflowInstanceDataFields.Subject, @@ -149,7 +151,7 @@ export class DiplomaAssinarPage implements OnInit { this.cc = users.filter(user=>{ return user.Type == 'CC'; }); - + }); this.getDocumentDetails(this.task.FolderId, '361'); @@ -207,8 +209,8 @@ export class DiplomaAssinarPage implements OnInit { getDocumentDetails(forlderId:string, applicationId:string) { this.processes.GetDocumentDetails(forlderId,applicationId).subscribe(res=>{ this.attachments = res.Documents; - - + + }) } @@ -242,32 +244,53 @@ export class DiplomaAssinarPage implements OnInit { } async AssinarDraft() { - let body = { - "InstanceId": this.task.InstanceID, - "FolderId": this.task.FolderID, - "DraftIds": this.DraftIds, - "OriginalFileName": this.DraftNames - } - - const loader = this.toastService.loading() - try { - await this.processes.presidentialActionsSignature(body).toPromise() + const modal = await this.modalController.create({ + component: PopupQuestionPage, + componentProps: { + title: 'Deseja assinar este Diploma?', + message: 'Nota: Ao Efetuar esta operação, o tratamento deste diploma não poderá ser realizado a partir da caixa de correspondência' + }, + cssClass: "popup-question discart-expedient-modal", + backdropDismiss: true + }); - await this.Assinar(); - this.TaskService.loadDiplomas(); - this.goBack(); - } catch (error) { - this.httpErroHandle.httpStatusHandle(error) - } - finally { - loader.remove() - } + modal.onDidDismiss().then(async (res) => { + const data = res.data + if(data == "Yes") { + let body = { + "InstanceId": this.task.InstanceID, + "FolderId": this.task.FolderID, + "DraftIds": this.DraftIds, + "OriginalFileName": this.DraftNames + } + + const loader = this.toastService.loading() + + + try { + await this.processes.presidentialActionsSignature(body).toPromise() + + await this.Assinar(); + this.TaskService.loadDiplomas(); + this.goBack(); + } catch (error) { + this.httpErroHandle.httpStatusHandle(error) + } + finally { + loader.remove() + } + } + + }, (error) => { + console.log(error) + }); + + await modal.present(); } async openAddNoteModal(actionName: string) { - let classs; if (window.innerWidth <= 800) { classs = 'modal modal-desktop' @@ -363,7 +386,7 @@ export class DiplomaAssinarPage implements OnInit { }); await modal.present(); modal.onDidDismiss().then(async (res) => { - + if (res['data'] == 'openDiscart') { await this.distartExpedientModal(); @@ -376,7 +399,7 @@ export class DiplomaAssinarPage implements OnInit { } async distartExpedientModal() { - + const modal = await this.modalController.create({ component: DiscartExpedientModalPage, componentProps: { @@ -392,7 +415,7 @@ export class DiplomaAssinarPage implements OnInit { modal.onDidDismiss().then(res => { if (res['data'] == 'close') { this.close(); - /* + /* this.close(); this.openMenu(); */ } diff --git a/src/app/services/chat/chat-system.service.ts b/src/app/services/chat/chat-system.service.ts index af29c2a40..a40152776 100644 --- a/src/app/services/chat/chat-system.service.ts +++ b/src/app/services/chat/chat-system.service.ts @@ -74,13 +74,14 @@ export class ChatSystemService { * when the connection is lost the subscribe is also lost, so we have to subscribe again when reconnection is establish. */ - await this.chatService.refreshtoken(); - await this.getUser(); - this.RochetChatConnectorService.setStatus('online') - await this.getAllRooms(); - this.subscribeToRoom(); - // - this.getUserStatus(); + this.RochetChatConnectorService.setStatus('online') + this.getUserStatus(); + await this.chatService.refreshtoken(); + this.getUser(); + this.getAllRooms(); + this.subscribeToRoom(); + // + if(this.currentRoom) { this.currentRoom.loadHistory({forceUpdate: true}) diff --git a/src/app/services/chat/rochet-chat-connector.service.ts b/src/app/services/chat/rochet-chat-connector.service.ts index 8547d3809..5aa3546fe 100644 --- a/src/app/services/chat/rochet-chat-connector.service.ts +++ b/src/app/services/chat/rochet-chat-connector.service.ts @@ -19,7 +19,7 @@ export class RochetChatConnectorService { } reConnect() { - + } connect() { @@ -67,7 +67,7 @@ export class RochetChatConnectorService { } const requestId = uuidv4() - // + // const message = { msg: "method", method: "login", @@ -83,12 +83,12 @@ export class RochetChatConnectorService { return new Promise((resolve, reject) => { - // + // this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ - // + // if(message.id == requestId ) { // same request send - // - // + // + // if(message.result) { if(message.result.token) { this.isLogin = true @@ -99,11 +99,11 @@ export class RochetChatConnectorService { }, 10) resolve(message) - // + // } } else { this.isLogin = false - // + // reject(message) } @@ -118,7 +118,7 @@ export class RochetChatConnectorService { getRooms(roomOlder = 1480377601) { - + //const requestId = uuidv4() const requestId = uuidv4() const message = { @@ -219,7 +219,7 @@ export class RochetChatConnectorService { }] } - // + // this.ws.send({message, requestId}); @@ -325,7 +325,7 @@ export class RochetChatConnectorService { this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ if(message.id == requestId ) { // same request send resolve(message) - // + // return true } @@ -548,7 +548,7 @@ export class RochetChatConnectorService { return new Promise((resolve, reject) => { this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ - // + // if(message.id == requestId ) { // same request send resolve(message) return true @@ -746,7 +746,7 @@ export class RochetChatConnectorService { registerCallback:(params: wsCallbacksParams) => { let id = params.requestId || params.key || uuidv4() - // + // this.wsCallbacks[id] = params this.n++ return id @@ -758,8 +758,13 @@ export class RochetChatConnectorService { this.socket.onmessage = this.ws.onmessage; this.socket.onclose = this.ws.onclose; this.socket.onerror = this.ws.onerror; + + console.log(' === on open connection ===') }, onopen: async ()=> { + + console.log('===socket on connection open===') + this.ws.connected = true this.backgroundservice.online(); @@ -802,7 +807,7 @@ export class RochetChatConnectorService { send: ({message, requestId = uuidv4(), loginRequired = true}:send) => { if (this.ws.connected == false || loginRequired == true && this.isLogin == false) { // save data to send when back online - // + // // this.wsMsgQueue[requestId] = {message, requestId, loginRequired} @@ -814,7 +819,7 @@ export class RochetChatConnectorService { }, onmessage: async (event: any)=> { - + this.backgroundservice.online(); const data = JSON.parse(event.data) @@ -837,6 +842,7 @@ export class RochetChatConnectorService { onclose: async (event: any)=> { this.ws.connected = false this.isLogin = false + console.error('===close socket connection===') this.connect() this.login() @@ -854,13 +860,14 @@ export class RochetChatConnectorService { } - + }, onerror: (event: any) => { - + console.log(' ==== error ====') }, disconnect:() => { + console.log('==== desconnect ====') if(this.socket) { this.socket.onopen = (event: any) => {} this.socket.onmessage = (event: any) => {} diff --git a/src/app/services/network-service.service.ts b/src/app/services/network-service.service.ts index b171aa5c6..da617d7c6 100644 --- a/src/app/services/network-service.service.ts +++ b/src/app/services/network-service.service.ts @@ -15,38 +15,40 @@ export enum ConnectionStatus { }) export class NetworkServiceService { private status: BehaviorSubject = new BehaviorSubject(ConnectionStatus.Offline); - + + private wsCallbacks: {[key: string]: { + function: Function, + event: ConnectionStatus + }} = {} + constructor(private network: Network, private toastController: ToastController, private plt: Platform) { this.plt.ready().then(() => { this.initializeNetworkEvents(); let status = this.network.type !== 'none' ? ConnectionStatus.Online : ConnectionStatus.Offline; this.status.next(status); - }); - + }); + this.onNetworkChange().subscribe((status) => { }) } - public initializeNetworkEvents() { - this.network.onDisconnect().subscribe(() => { if (this.status.getValue() === ConnectionStatus.Online) { this.updateNetworkStatus(ConnectionStatus.Offline); } }); - this.network.onConnect().subscribe(() => { if (this.status.getValue() === ConnectionStatus.Offline) { this.updateNetworkStatus(ConnectionStatus.Online); } }); } - + private async updateNetworkStatus(status: ConnectionStatus) { this.status.next(status); - + let connection = status == ConnectionStatus.Offline ? 'Offline' : 'Online'; let toast = this.toastController.create({ message: `You are now ${connection}`, @@ -55,11 +57,9 @@ export class NetworkServiceService { }); toast.then(toast => toast.present()); } - public onNetworkChange(): Observable { return this.status.asObservable(); } - public getCurrentNetworkStatus(): ConnectionStatus { return this.status.getValue(); } diff --git a/src/app/services/toast.service.ts b/src/app/services/toast.service.ts index acd713a2e..8c5ad408a 100644 --- a/src/app/services/toast.service.ts +++ b/src/app/services/toast.service.ts @@ -264,7 +264,7 @@ export class ToastService {
`; - // + // document.body.append(loader) loader.addEventListener('click', ()=>{ @@ -278,3 +278,4 @@ export class ToastService { export const ToastsService = new ToastService(new ToastController(), new ThemeService()) + diff --git a/src/app/shared/popover/deploma-options/deploma-options.page.html b/src/app/shared/popover/deploma-options/deploma-options.page.html index faae9cef3..748de32ee 100644 --- a/src/app/shared/popover/deploma-options/deploma-options.page.html +++ b/src/app/shared/popover/deploma-options/deploma-options.page.html @@ -14,15 +14,15 @@ - - + +