From ecd19c46bbbb27aa7d5fd7be292827c057f7bde6 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 2 Feb 2023 12:01:18 +0100 Subject: [PATCH] add notification message --- .../create-process/create-process.page.ts | 49 ++++++++++++--- .../modals/dar-parecer/dar-parecer.page.ts | 6 +- src/app/modals/delegar/delegar.page.ts | 4 ++ .../document-set-up-meeting.page.ts | 7 ++- src/app/modals/forward/forward.page.ts | 7 ++- .../agenda/edit-event/edit-event.page.ts | 16 +++-- .../pages/agenda/new-event/new-event.page.ts | 7 ++- .../despacho-pr/despacho-pr.page.ts | 44 ++++++++++--- .../despachos/despacho/despacho.page.ts | 28 +++++++-- .../diploma-assinar/diploma-assinar.page.ts | 14 ++++- .../diplomas-gerar/diplomas-gerar.page.ts | 14 ++++- .../diplomas/diploma/diploma.page.ts | 28 +++++++-- .../approve-event-modal.page.ts | 19 +++++- .../approve-event/approve-event.page.ts | 26 +++++++- .../book-meeting-modal.page.ts | 14 ++++- .../expedient-task-modal.page.ts | 37 ++++++++--- .../expediente-detail.page.ts | 63 ++++++++++++++++--- .../expediente-pr/expediente-pr.page.ts | 35 +++++++++-- .../pedidos/pedido/pedido.page.ts | 37 +++++++++-- .../edit-action/edit-action.page.ts | 7 ++- .../pages/publications/publications.page.ts | 9 ++- .../server-connection.service.spec.ts | 16 +++++ src/app/services/server-connection.service.ts | 20 ++++++ .../approve-event/approve-event.page.ts | 7 ++- .../edit-event-to-approve.page.ts | 7 ++- .../agenda/new-event/new-event.page.html | 2 +- .../shared/agenda/new-event/new-event.page.ts | 32 ++++++++-- .../edit-event-to-approve/edit-event.page.ts | 21 ++++++- .../deploma-options/deploma-options.page.ts | 25 +++++++- .../despachos-options.page.ts | 35 +++++++++-- .../despachos-pr-options.page.ts | 24 +++++-- .../diplomas-gerar-options.page.ts | 7 ++- .../opts-expediente-pr.page.ts | 51 ++++++++++++--- .../opts-expediente/opts-expediente.page.ts | 56 ++++++++++++++--- .../request-options/request-options.page.ts | 14 ++++- .../edit-action/edit-action.page.ts | 6 +- .../publication/new-action/new-action.page.ts | 5 ++ .../new-publication/new-publication.page.ts | 24 +++++-- .../publication-detail.page.ts | 6 +- .../view-publications.page.ts | 9 ++- version/git-version.ts | 14 ++--- 41 files changed, 721 insertions(+), 131 deletions(-) create mode 100644 src/app/services/server-connection.service.spec.ts create mode 100644 src/app/services/server-connection.service.ts diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts index 5a6b5f37e..fa42bc404 100644 --- a/src/app/modals/create-process/create-process.page.ts +++ b/src/app/modals/create-process/create-process.page.ts @@ -292,7 +292,12 @@ export class CreateProcessPage implements OnInit { this.modalController.dismiss(); this.toastService._successMessage('Despacho criado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error?.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() @@ -324,7 +329,12 @@ export class CreateProcessPage implements OnInit { this.toastService._successMessage('Pedido de Parecer enviado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error?.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() } @@ -349,7 +359,12 @@ export class CreateProcessPage implements OnInit { this.toastService._successMessage('Pedido de Deferimento criado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error?.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() @@ -377,7 +392,12 @@ export class CreateProcessPage implements OnInit { this.modalController.dismiss(); this.toastService._successMessage('Despacho criado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error?.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove(); } @@ -413,7 +433,12 @@ export class CreateProcessPage implements OnInit { this.toastService._successMessage('Pedido de Parecer criado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() } @@ -438,7 +463,12 @@ export class CreateProcessPage implements OnInit { this.toastService._successMessage('Pedido de Deferimento criado'); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() } @@ -493,7 +523,12 @@ export class CreateProcessPage implements OnInit { await this.processes.CompleteTask(body).toPromise(); this.toastService._successMessage(message); } catch (error) { - this.toastService._badRequest('Processo não efectuado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não efectuado'); + } } finally { loader.remove() } diff --git a/src/app/modals/dar-parecer/dar-parecer.page.ts b/src/app/modals/dar-parecer/dar-parecer.page.ts index 7846b1595..4ecc60a01 100644 --- a/src/app/modals/dar-parecer/dar-parecer.page.ts +++ b/src/app/modals/dar-parecer/dar-parecer.page.ts @@ -68,7 +68,11 @@ export class DarParecerPage implements OnInit { this.modalController.dismiss('sucess'); this.toastService._successMessage('Parecer enviado'); } catch (error) { - this.toastService._badRequest("Parecer não solicitado"); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest("Parecer não solicitado"); + } } finally { loader.remove() } diff --git a/src/app/modals/delegar/delegar.page.ts b/src/app/modals/delegar/delegar.page.ts index 2f05f8bfb..81b1fa971 100644 --- a/src/app/modals/delegar/delegar.page.ts +++ b/src/app/modals/delegar/delegar.page.ts @@ -107,7 +107,11 @@ export class DelegarPage implements OnInit { this.close(); }, (error)=>{ + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { this.toastService._badRequest("Processo não delegado") + } }, ()=>{ loader.remove() diff --git a/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts b/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts index 32a3fb7c5..d30e733e5 100644 --- a/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts +++ b/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts @@ -277,7 +277,12 @@ export class DocumentSetUpMeetingPage implements OnInit { this.modalController.dismiss() }, (error) => { laoder.remove() - this.toastService._badRequest('Não foi possível marcar a reunião'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Não foi possível marcar a reunião'); + } }, ()=>{ laoder.remove() }); diff --git a/src/app/modals/forward/forward.page.ts b/src/app/modals/forward/forward.page.ts index 1b70c6832..1b066f996 100644 --- a/src/app/modals/forward/forward.page.ts +++ b/src/app/modals/forward/forward.page.ts @@ -151,7 +151,12 @@ export class ForwardPage implements OnInit { this.goBack(); }, (error)=>{ - this.toastService._badRequest("Processo não delegado") + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest("Processo não delegado") + } }); } } diff --git a/src/app/pages/agenda/edit-event/edit-event.page.ts b/src/app/pages/agenda/edit-event/edit-event.page.ts index c129da113..e4c290803 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.ts +++ b/src/app/pages/agenda/edit-event/edit-event.page.ts @@ -352,8 +352,12 @@ export class EditEventPage implements OnInit { this.toastService._successMessage(); }, error => { - if(error.status != 0) - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } }); } else { this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => { @@ -376,8 +380,12 @@ export class EditEventPage implements OnInit { this.toastService._successMessage(); }, error => { - if(error.status != 0) - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } }); } diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts index 75ec9c57b..cddcf6bf2 100644 --- a/src/app/pages/agenda/new-event/new-event.page.ts +++ b/src/app/pages/agenda/new-event/new-event.page.ts @@ -446,7 +446,12 @@ export class NewEventPage implements OnInit { this.modalController.dismiss(data); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } diff --git a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts index 81d4ab200..ed0a9b265 100644 --- a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts +++ b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts @@ -274,7 +274,12 @@ export class DespachoPrPage implements OnInit { await this.processes.CompleteTask(body).toPromise() this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -299,7 +304,12 @@ export class DespachoPrPage implements OnInit { await this.processes.CompleteTask(body).toPromise() this.toastService._successMessage('Processo arquivado') } catch (error) { - this.toastService._badRequest('Processo não arquivado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não arquivado') + } } finally { loader.remove() @@ -321,7 +331,12 @@ export class DespachoPrPage implements OnInit { this.toastService._successMessage('Processo criado') } catch (error) { - this.toastService._badRequest('Processo não criado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não criado') + } } finally { loader.remove() @@ -346,7 +361,12 @@ export class DespachoPrPage implements OnInit { await this.processes.CompleteTask(body).toPromise() this.toastService._successMessage('') } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -371,7 +391,12 @@ export class DespachoPrPage implements OnInit { await this.processes.CompleteTask(body).toPromise() this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -390,9 +415,14 @@ export class DespachoPrPage implements OnInit { this.toastService._successMessage('Processo enviado para pendentes') this.goBack() loader.remove() - }, () => { + }, (error) => { loader.remove() - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } }); } diff --git a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts index 379cebf6f..c1146c3f5 100644 --- a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts +++ b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts @@ -279,7 +279,12 @@ export class DespachoPage implements OnInit { this.toastService._successMessage('Processo criado') this.close(); } catch (error) { - this.toastService._badRequest("Processo não criado") + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest("Processo não criado") + } } finally { loader.remove() @@ -295,7 +300,12 @@ export class DespachoPage implements OnInit { this.toastService._successMessage('Processo descartado') this.close(); } catch (error) { - this.toastService._badRequest("Processo não descartado") + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest("Processo não descartado") + } } finally { loader.remove() @@ -322,7 +332,12 @@ export class DespachoPage implements OnInit { this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -348,7 +363,12 @@ export class DespachoPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } 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 a6b77c933..8ed5f4370 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 @@ -110,7 +110,12 @@ export class DiplomaAssinarPage implements OnInit { }, (error)=>{ try { - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } this.goBack() } catch (e) { window.history.back(); @@ -176,7 +181,12 @@ export class DiplomaAssinarPage implements OnInit { this.goBack(); }) } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.ts b/src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.ts index 04e91a389..561c3f700 100644 --- a/src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.ts +++ b/src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.ts @@ -252,7 +252,12 @@ export class DiplomasGerarPage implements OnInit { this.toastService._successMessage(); this.goBack() } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } @@ -314,7 +319,12 @@ export class DiplomasGerarPage implements OnInit { this.goBack(); }) } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts index e1769d53a..06d76e294 100644 --- a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts +++ b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts @@ -162,7 +162,12 @@ export class DiplomaPage implements OnInit { } catch (e) { window.history.back(); } - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } } }); @@ -286,7 +291,12 @@ export class DiplomaPage implements OnInit { }) } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -309,7 +319,12 @@ export class DiplomaPage implements OnInit { await this.processes.CompleteTask(body).toPromise() this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -335,7 +350,12 @@ export class DiplomaPage implements OnInit { await this.processes.CompleteTask(body).toPromise(); this.toastService._successMessage('Processo concluído') } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts index 6e6ea1234..e683df373 100644 --- a/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts +++ b/src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts @@ -107,7 +107,12 @@ export class ApproveEventModalPage implements OnInit { }) } catch (error) { - this.toastService._badRequest('Evento não aprovado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Evento não aprovado') + } } finally { loader.remove() @@ -134,7 +139,12 @@ export class ApproveEventModalPage implements OnInit { this.router.navigate(['/home/gabinete-digital/event-list']); }) } catch (error) { - this.toastService._badRequest('Evento não rejeitado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Evento não rejeitado') + } } finally { loader.remove() @@ -198,7 +208,12 @@ export class ApproveEventModalPage implements OnInit { this.router.navigate(['/home/gabinete-digital/event-list']); this.toastService._successMessage() } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } this.router.navigate(['/home/gabinete-digital/event-list']); } finally { diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts index f5acecbc1..2d596fdfe 100644 --- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts +++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts @@ -218,7 +218,12 @@ export class ApproveEventPage implements OnInit { this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -264,7 +269,12 @@ export class ApproveEventPage implements OnInit { this.toastService._successMessage('Pedido enviado'); this.goBack(); } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } @@ -285,7 +295,12 @@ export class ApproveEventPage implements OnInit { await this.toastService._successMessage('Processo rejeitado'); this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -365,7 +380,12 @@ export class ApproveEventPage implements OnInit { this.toastService._successMessage(); this.goBack(); } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest(); + } } finally { loader.remove() } diff --git a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts index 174cfcd3e..076d83b9b 100644 --- a/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts @@ -318,7 +318,12 @@ export class BookMeetingModalPage implements OnInit { this.toastService._successMessage('Reunião criada'); } catch (error) { - this.toastService._badRequest('Reunião não criada') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Reunião não criada') + } } finally { loader.remove() @@ -338,7 +343,12 @@ export class BookMeetingModalPage implements OnInit { this.toastService._successMessage('Reunião criada'); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts index bf2445956..a1375f620 100644 --- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts +++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts @@ -320,7 +320,12 @@ export class ExpedientTaskModalPage implements OnInit { this.modalController.dismiss(action_despacho); } catch (error) { - await this.toastService._badRequest('Processo não efetuado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + await this.toastService._badRequest('Processo não efetuado') + } } finally { loader.remove() } @@ -354,7 +359,12 @@ export class ExpedientTaskModalPage implements OnInit { this.modalController.dismiss(action_parecer); } catch (error) { - await this.toastService._badRequest('Processo não efetuado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + await this.toastService._badRequest('Processo não efetuado') + } } finally { loader.remove() } @@ -385,7 +395,12 @@ export class ExpedientTaskModalPage implements OnInit { this.toastService._successMessage('Processo efetuado'); this.modalController.dismiss(action_deferimento); } catch (error) { - await this.toastService._badRequest('Processo não efetuado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + await this.toastService._badRequest('Processo não efetuado') + } } finally { loader.remove() } @@ -423,8 +438,12 @@ export class ExpedientTaskModalPage implements OnInit { await this.toastService._successMessage('Processo efetuado'); this.modalController.dismiss(action_despacho_pr); } catch (error) { - - await this.toastService._badRequest('Processo não efetuado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + await this.toastService._badRequest('Processo não efetuado') + } } finally { //loader.remove() } @@ -461,8 +480,12 @@ export class ExpedientTaskModalPage implements OnInit { await this.toastService._successMessage('Pedido enviado'); this.modalController.dismiss(action_parecer_pr); } catch (error) { - - await this.toastService._badRequest('Processo não efetuado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + await this.toastService._badRequest('Processo não efetuado') + } } finally { loader.remove() } 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 7793b028d..2029b97f8 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 @@ -242,7 +242,12 @@ export class ExpedienteDetailPage implements OnInit { this.close(); this.toastService._successMessage('Processo aprovado') } catch (error) { - this.toastService._badRequest('Processo não aprovado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não aprovado') + } } finally { loader.remove() } @@ -267,7 +272,12 @@ export class ExpedienteDetailPage implements OnInit { this.close(); this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -334,7 +344,12 @@ export class ExpedienteDetailPage implements OnInit { }, (error) => { loader.remove() - this.toastService._badRequest('Processo não enviado para pendentes') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não enviado para pendentes') + } }); } @@ -391,7 +406,12 @@ export class ExpedienteDetailPage implements OnInit { } catch (e) { window.history.back(); } - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } } }); @@ -482,8 +502,13 @@ export class ExpedienteDetailPage implements OnInit { loader.remove() await this.attachmentsService.AddAttachment(body).toPromise() this.toastService._successMessage() - } catch(e) { + } catch(error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } }); } @@ -519,7 +544,12 @@ export class ExpedienteDetailPage implements OnInit { await this.processes.CompleteTask(body).toPromise(); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -553,7 +583,12 @@ export class ExpedienteDetailPage implements OnInit { this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -572,7 +607,12 @@ export class ExpedienteDetailPage implements OnInit { //this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -586,7 +626,12 @@ export class ExpedienteDetailPage implements OnInit { this.toastService._successMessage(); this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } diff --git a/src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts b/src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts index 00f1bb75b..e288fd779 100644 --- a/src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts +++ b/src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts @@ -143,7 +143,12 @@ export class ExpedientePrPage implements OnInit { }, (error)=>{ loader.remove() - this.toastService._badRequest('Processo não enviado para pendentes') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não enviado para pendentes') + } }); } @@ -309,7 +314,12 @@ export class ExpedientePrPage implements OnInit { this.close(); this.toastService._successMessage('Processo aprovado') } catch(error) { - this.toastService._badRequest('Processo não aprovado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não aprovado') + } } finally { loader.remove() } @@ -334,7 +344,12 @@ export class ExpedientePrPage implements OnInit { this.close(); this.toastService._successMessage() } catch(error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -455,7 +470,12 @@ export class ExpedientePrPage implements OnInit { this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -492,7 +512,12 @@ export class ExpedientePrPage implements OnInit { this.toastService._successMessage(); this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } 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 bdb0b2857..1e34d6a94 100644 --- a/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts +++ b/src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts @@ -183,7 +183,12 @@ export class PedidoPage implements OnInit { } catch (e) { window.history.back(); } - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } } }); @@ -374,7 +379,12 @@ export class PedidoPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -394,7 +404,12 @@ export class PedidoPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -419,7 +434,12 @@ export class PedidoPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -431,9 +451,14 @@ export class PedidoPage implements OnInit { this.processes.SetTaskToPending(this.serialnumber).subscribe(res => { this.goBack(); loader.remove() - }, () => { + }, (error) => { loader.remove() - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } }); } diff --git a/src/app/pages/publications/edit-action/edit-action.page.ts b/src/app/pages/publications/edit-action/edit-action.page.ts index 714f77c3c..e11b7f609 100644 --- a/src/app/pages/publications/edit-action/edit-action.page.ts +++ b/src/app/pages/publications/edit-action/edit-action.page.ts @@ -119,7 +119,12 @@ export class EditActionPage implements OnInit { this.updateDesktopComponent.emit(); this.toastService._successMessage('Acção presidencial atualizada') } catch (error) { - this.toastService._badRequest('Não foi possivel atualizar a acção presidencial') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Não foi possivel atualizar a acção presidencial') + } } finally { loader.remove() } diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index a8ffc6082..7f55a5a35 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -255,8 +255,13 @@ export class PublicationsPage implements OnInit { try { await this.publications.DeletePresidentialAction(id).toPromise(); this.toastService._successMessage() - } catch (e) { - this.toastService._badRequest() + } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/services/server-connection.service.spec.ts b/src/app/services/server-connection.service.spec.ts new file mode 100644 index 000000000..5c6082292 --- /dev/null +++ b/src/app/services/server-connection.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ServerConnectionService } from './server-connection.service'; + +describe('ServerConnectionService', () => { + let service: ServerConnectionService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ServerConnectionService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/server-connection.service.ts b/src/app/services/server-connection.service.ts new file mode 100644 index 000000000..a54c3d54e --- /dev/null +++ b/src/app/services/server-connection.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class ServerConnectionService { + + constructor(private http: HttpClient,) { } + + async BaseAPI(): Promise { + try { + await this.http.get(environment.apiURL) + return true + } catch { + return false + } + } +} diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts index bc3154af7..aa39cf75d 100644 --- a/src/app/shared/agenda/approve-event/approve-event.page.ts +++ b/src/app/shared/agenda/approve-event/approve-event.page.ts @@ -192,7 +192,12 @@ export class ApproveEventPage implements OnInit { this.toastService._successMessage('Evento enviado para revisão'); this.close(); } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } diff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts index 9aa8aff42..847390a20 100644 --- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts +++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts @@ -415,7 +415,12 @@ export class EditEventToApprovePage implements OnInit { this.toastService._successMessage(); this.goToApproveEventList(); } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } diff --git a/src/app/shared/agenda/new-event/new-event.page.html b/src/app/shared/agenda/new-event/new-event.page.html index 0be3e0bc3..d5dcc52c8 100644 --- a/src/app/shared/agenda/new-event/new-event.page.html +++ b/src/app/shared/agenda/new-event/new-event.page.html @@ -3,7 +3,7 @@
- Novo Evento + Novo Evento"
diff --git a/src/app/shared/agenda/new-event/new-event.page.ts b/src/app/shared/agenda/new-event/new-event.page.ts index 3fd33a44e..5a2218e90 100644 --- a/src/app/shared/agenda/new-event/new-event.page.ts +++ b/src/app/shared/agenda/new-event/new-event.page.ts @@ -25,6 +25,7 @@ import { FormGroup, Validators } from '@angular/forms'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; import { ThemeService } from 'src/app/services/theme.service' import { ChatMethodsService } from 'src/app/services/chat/chat-methods.service'; +import { ServerConnectionService } from 'src/app/services/server-connection.service'; import { SessionStore } from 'src/app/store/session.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { @@ -129,6 +130,7 @@ export class NewEventPage implements OnInit { private dateAdapter: DateAdapter, public ThemeService: ThemeService, private chatMethodService: ChatMethodsService, + private ServerConnectionService: ServerConnectionService // private translate: TranslateService ) { this.dateAdapter.setLocale('pt'); @@ -529,9 +531,15 @@ export class NewEventPage implements OnInit { }, error => { + console.log(error, 'error') loader.remove() this.showLoader = false - this.toastService._badRequest('Evento não criado') + + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Evento não criado') + } }); } @@ -585,10 +593,19 @@ export class NewEventPage implements OnInit { } this.toastService._successMessage('Evento criado') - },()=>{ + },(error) => { + + //const connectionToServer = this.ServerConnectionService.BaseAPI() + + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Evento não criado') + } + loader.remove() this.showLoader = false - this.toastService._badRequest('Evento não criado') + }); } else { @@ -641,10 +658,15 @@ export class NewEventPage implements OnInit { this.chatMethodService.sendMessage(this.roomId,data); } this.toastService._successMessage('Evento criado') - },()=>{ + },(error)=>{ + loader.remove() this.showLoader = false - this.toastService._badRequest('Evento não criado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Evento não criado') + } }); } diff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts index d023e5b6a..e25922581 100644 --- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts +++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts @@ -312,7 +312,12 @@ export class EditEventToApproveComponent implements OnInit { this.eventsService.postEventToApproveEdit(event).subscribe(()=>{ this.toastService._successMessage('Evento editado'); }, error =>{ - this.toastService._badRequest('Evento não editado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Evento não editado'); + } }) @@ -322,14 +327,24 @@ export class EditEventToApproveComponent implements OnInit { this.attachmentsService.setEventAttachmentById(document).subscribe(()=>{ this.toastService._successMessage(); }, error =>{ - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } }); } else if(document['action'] == 'delete') { delete document.action this.attachmentsService.deleteEventAttachmentById(document.Id).subscribe( res=>{ this.toastService._successMessage() }, error =>{ - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } }) } diff --git a/src/app/shared/popover/deploma-options/deploma-options.page.ts b/src/app/shared/popover/deploma-options/deploma-options.page.ts index 7ae04b5c7..2741bc0f8 100644 --- a/src/app/shared/popover/deploma-options/deploma-options.page.ts +++ b/src/app/shared/popover/deploma-options/deploma-options.page.ts @@ -107,7 +107,12 @@ export class DeplomaOptionsPage implements OnInit { this.close(); this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -154,7 +159,12 @@ export class DeplomaOptionsPage implements OnInit { this.close(); this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -180,7 +190,11 @@ export class DeplomaOptionsPage implements OnInit { this.close(); this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() } @@ -205,7 +219,12 @@ export class DeplomaOptionsPage implements OnInit { await this.processes.CompleteTask(body).toPromise(); this.toastService._successMessage('Processo concluído') } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/shared/popover/despachos-options/despachos-options.page.ts b/src/app/shared/popover/despachos-options/despachos-options.page.ts index 677f6a6f7..f1ef1e8e0 100644 --- a/src/app/shared/popover/despachos-options/despachos-options.page.ts +++ b/src/app/shared/popover/despachos-options/despachos-options.page.ts @@ -78,9 +78,14 @@ export class DespachosOptionsPage implements OnInit { loader.remove() this.close(); - },()=>{ + },(error)=>{ loader.remove() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Processo não encontrado') + } }); } @@ -173,7 +178,12 @@ export class DespachosOptionsPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -254,7 +264,12 @@ export class DespachosOptionsPage implements OnInit { this.toastService._successMessage('Processo arquivado') this.close(); } catch (error) { - this.toastService._badRequest('Processo não arquivado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não arquivado') + } } finally { loader.remove() } @@ -281,7 +296,12 @@ export class DespachosOptionsPage implements OnInit { this.close(); this.toastService._successMessage() } catch(error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -308,7 +328,12 @@ export class DespachosOptionsPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } diff --git a/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts b/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts index 17f217a5c..336252cfa 100644 --- a/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts +++ b/src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts @@ -104,10 +104,14 @@ export class DespachosPrOptionsPage implements OnInit { this.toastService._successMessage() this.popoverController.dismiss('close') loader.remove() - },()=>{ + },(error)=>{ loader.remove() - - this.toastService._badRequest('Processo não encontrado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } }); } @@ -206,7 +210,12 @@ export class DespachosPrOptionsPage implements OnInit { this.toastService._successMessage() this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -290,7 +299,12 @@ export class DespachosPrOptionsPage implements OnInit { this.toastService._successMessage('') this.close(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts b/src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts index 4a30c6333..e6266ad86 100644 --- a/src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts +++ b/src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts @@ -92,7 +92,12 @@ export class DiplomasGerarOptionsPage implements OnInit { this.toastService._successMessage(); this.goBack() } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } diff --git a/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts b/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts index 0516d8a92..d50f0d403 100644 --- a/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts +++ b/src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts @@ -142,7 +142,12 @@ export class OptsExpedientePrPage implements OnInit { this.close(); this.toastService._successMessage() } catch(error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -180,7 +185,12 @@ export class OptsExpedientePrPage implements OnInit { this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -199,7 +209,12 @@ export class OptsExpedientePrPage implements OnInit { // this.toastService.successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado'); + } } finally { loader.remove() } @@ -214,7 +229,12 @@ export class OptsExpedientePrPage implements OnInit { this.toastService._successMessage(); this.goBack(); } catch (error) { - this.toastService._badRequest(); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest(); + } } finally { loader.remove() } @@ -242,7 +262,12 @@ export class OptsExpedientePrPage implements OnInit { this.close(); this.toastService._successMessage() } catch(error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -255,9 +280,13 @@ export class OptsExpedientePrPage implements OnInit { this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{ loader.remove() this.close(); - },()=>{ - - this.toastService._badRequest('Processo não encontrado') + }, (error) => { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } loader.remove() }); } @@ -295,7 +324,11 @@ export class OptsExpedientePrPage implements OnInit { // this.toastService.successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado'); + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Processo não descartado'); + } } finally { loader.remove() } 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 5a2262643..7f27a3576 100644 --- a/src/app/shared/popover/opts-expediente/opts-expediente.page.ts +++ b/src/app/shared/popover/opts-expediente/opts-expediente.page.ts @@ -170,8 +170,13 @@ export class OptsExpedientePage implements OnInit { this.attachmentsService.AddAttachment(body).subscribe((res)=> { this.toastService._successMessage() - },()=> { + },(error)=> { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } },()=> { loader.remove() }); @@ -248,7 +253,12 @@ export class OptsExpedientePage implements OnInit { this.close(); this.toastService._successMessage() } catch(error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() } @@ -258,9 +268,13 @@ export class OptsExpedientePage implements OnInit { this.close(); this.processes.SetTaskToPending(this.task.SerialNumber).subscribe(res=>{ this.goBack(); - },()=>{ - - this.toastService._badRequest('Processo não encontrado') + },(error)=>{ + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não encontrado') + } }); } @@ -284,7 +298,12 @@ export class OptsExpedientePage implements OnInit { this.close(); this.toastService._successMessage('Processo aprovado') } catch(error) { - this.toastService._badRequest('Processo não aprovado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não aprovado') + } } finally { loader.remove() } @@ -340,7 +359,12 @@ export class OptsExpedientePage implements OnInit { await this.processes.CompleteTask(body).toPromise(); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -375,7 +399,12 @@ export class OptsExpedientePage implements OnInit { this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { - this.toastService._badRequest('Processo não descartado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -395,7 +424,12 @@ export class OptsExpedientePage implements OnInit { this.toastService._successMessage('Processo descartado'); this.goBack(); } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Processo não descartado') + } } finally { loader.remove() } @@ -409,8 +443,12 @@ export class OptsExpedientePage implements OnInit { await this.processes.UpdateTaskStatus(this.task.FolderId).toPromise(); this.toastService._successMessage(); this.goBack(); - } catch (error) { + } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { this.toastService._badRequest() + } } finally { loader.remove() } 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 a7590a2dc..409c39eb5 100644 --- a/src/app/shared/popover/request-options/request-options.page.ts +++ b/src/app/shared/popover/request-options/request-options.page.ts @@ -191,7 +191,12 @@ export class RequestOptionsPage implements OnInit { this.close(); this.toastService._successMessage() } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest() + } } finally { loader.remove() @@ -260,7 +265,12 @@ export class RequestOptionsPage implements OnInit { this.toastService._successMessage('Processo arquivado') } catch (error) { - this.toastService._badRequest('Processo não arquivado') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + + this.toastService._badRequest('Processo não arquivado') + } } finally { loader.remove() } diff --git a/src/app/shared/publication/edit-action/edit-action.page.ts b/src/app/shared/publication/edit-action/edit-action.page.ts index 148a679fa..db88afe63 100644 --- a/src/app/shared/publication/edit-action/edit-action.page.ts +++ b/src/app/shared/publication/edit-action/edit-action.page.ts @@ -111,7 +111,11 @@ export class EditActionPage implements OnInit { this.getActions.emit() } catch (error) { - this.toastService._badRequest('Não foi possivel atualizar a acção presidencial') + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Não foi possivel atualizar a acção presidencial') + } } finally { loader.remove() } diff --git a/src/app/shared/publication/new-action/new-action.page.ts b/src/app/shared/publication/new-action/new-action.page.ts index c34bf48ff..2f2b524d3 100644 --- a/src/app/shared/publication/new-action/new-action.page.ts +++ b/src/app/shared/publication/new-action/new-action.page.ts @@ -133,7 +133,12 @@ export class NewActionPage implements OnInit { this.getActions.emit() } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest('Não foi possivel criar a acção presidencial') + } } finally { loader.remove() } diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index cbdedb65b..c7f2a7c9a 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -159,7 +159,11 @@ export class NewPublicationPage implements OnInit { this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() } @@ -188,7 +192,11 @@ export class NewPublicationPage implements OnInit { this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() } @@ -216,7 +224,11 @@ export class NewPublicationPage implements OnInit { this.goBack(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() } @@ -247,7 +259,11 @@ export class NewPublicationPage implements OnInit { this.goBackToViewPublications.emit(); } catch (error) { - this.toastService._badRequest() + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() } diff --git a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts index 5570b5f44..09743b745 100644 --- a/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts +++ b/src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts @@ -90,7 +90,11 @@ export class PublicationDetailPage implements OnInit { this.toastService._successMessage("Publicação eliminado") this.goBackToViewPublications.emit(); } catch (error) { - this.toastService._badRequest("Publicação não eliminado") + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest("Publicação não eliminado") + } } finally { laoder.remove() } diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 817ec8e34..b0c53cea7 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -26,7 +26,7 @@ export class ViewPublicationsPage implements OnInit { getpublication = []; error: any; - @Input() folderId: string; + @Input() folderId: any; @Output() addNewPublication = new EventEmitter(); @Output() editPublication = new EventEmitter(); @Output() openPublicationDetails= new EventEmitter(); @@ -221,8 +221,13 @@ export class ViewPublicationsPage implements OnInit { try { await this.publications.DeletePresidentialAction(folderId).toPromise(); this.toastService._successMessage() - } catch (e) { + } catch (error) { + if(error.status == 0) { + this.toastService._badRequest('sem conexão ao servidor') + } else { + this.toastService._badRequest() + } } finally { loader.remove() diff --git a/version/git-version.ts b/version/git-version.ts index 486635cd0..4ffe4bdbf 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "ac23c085f", - "SHA": "ac23c085fb436db5698015e7627ec7c098cae72c", - "branch": "no_bug_movemente", + "shortSHA": "0036ce6ab", + "SHA": "0036ce6ab20cb98b60cd6f86af434a2bffa15d13", + "branch": "feature/notificationMessage", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Wed Feb 1 18:04:01 2023 +0100'", - "lastCommitMessage": "merge", - "lastCommitNumber": "4708", + "lastCommitTime": "'Thu Feb 2 10:37:17 2023 +0100'", + "lastCommitMessage": "fix loader", + "lastCommitNumber": "4709", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/view-event/view-event.page.ts\n\tmodified: src/app/pages/events/events.page.html\n\tmodified: src/app/pages/events/events.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.html\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/shared/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.html\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.ts\n\tmodified: src/app/shared/gabinete-digital/diplomas-assinar/diplomas-assinar.page.html\n\tmodified: src/app/shared/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts\n\tmodified: src/app/shared/gabinete-digital/diplomas-gerar/diplomas-gerar.page.html\n\tmodified: src/app/shared/gabinete-digital/diplomas-gerar/diplomas-gerar.page.ts\n\tmodified: src/app/shared/gabinete-digital/diplomas-gerar/expedients/expedients.page.html\n\tmodified: src/app/shared/gabinete-digital/diplomas-gerar/expedients/expedients.page.ts\n\tmodified: src/app/shared/gabinete-digital/diplomas/diplomas.page.html\n\tmodified: src/app/shared/gabinete-digital/diplomas/diplomas.page.ts\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/app/shared/gabinete-digital/expedients/expedients.page.html\n\tmodified: src/app/shared/gabinete-digital/expedients/expedients.page.ts\n\tmodified: src/app/shared/gabinete-digital/pedidos/pedidos.page.html\n\tmodified: src/app/shared/gabinete-digital/pedidos/pedidos.page.ts\n\tmodified: src/app/shared/gabinete-digital/pendentes/pendentes.page.html\n\tmodified: src/app/shared/gabinete-digital/pendentes/pendentes.page.ts", + "changeStatus": "On branch feature/notificationMessage\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/create-process/create-process.page.ts\n\tmodified: src/app/modals/dar-parecer/dar-parecer.page.ts\n\tmodified: src/app/modals/delegar/delegar.page.ts\n\tmodified: src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n\tmodified: src/app/modals/forward/forward.page.ts\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts\n\tmodified: src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.ts\n\tmodified: src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts\n\tmodified: src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedido/pedido.page.ts\n\tmodified: src/app/pages/publications/edit-action/edit-action.page.ts\n\tmodified: src/app/pages/publications/publications.page.ts\n\tnew file: src/app/services/server-connection.service.spec.ts\n\tnew file: src/app/services/server-connection.service.ts\n\tmodified: src/app/shared/agenda/approve-event/approve-event.page.ts\n\tmodified: src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.html\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts\n\tmodified: src/app/shared/popover/deploma-options/deploma-options.page.ts\n\tmodified: src/app/shared/popover/despachos-options/despachos-options.page.ts\n\tmodified: src/app/shared/popover/despachos-pr-options/despachos-pr-options.page.ts\n\tmodified: src/app/shared/popover/diplomas-gerar-options/diplomas-gerar-options.page.ts\n\tmodified: src/app/shared/popover/opts-expediente-pr/opts-expediente-pr.page.ts\n\tmodified: src/app/shared/popover/opts-expediente/opts-expediente.page.ts\n\tmodified: src/app/shared/popover/request-options/request-options.page.ts\n\tmodified: src/app/shared/publication/edit-action/edit-action.page.ts\n\tmodified: src/app/shared/publication/new-action/new-action.page.ts\n\tmodified: src/app/shared/publication/new-publication/new-publication.page.ts\n\tmodified: src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file