Improve loader

This commit is contained in:
Peter Maquiran
2021-07-12 11:13:29 +01:00
parent c526426aec
commit 507ebd691a
34 changed files with 400 additions and 32 deletions
@@ -190,6 +190,8 @@ export class DespachoPrPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.close();
@@ -197,6 +199,10 @@ export class DespachoPrPage implements OnInit {
} catch(error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
async arquivar(note:string, documents:any){
@@ -209,6 +215,9 @@ export class DespachoPrPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage('Processo arquivado')
@@ -216,6 +225,10 @@ export class DespachoPrPage implements OnInit {
} catch (error) {
this.toastService.badRequest('Processo não arquivado')
}
finally {
loader.remove()
}
}
@@ -230,6 +243,8 @@ export class DespachoPrPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage('Processo criado')
@@ -237,6 +252,9 @@ export class DespachoPrPage implements OnInit {
} catch (error) {
this.toastService.badRequest('Processo não criado')
}
finally {
loader.remove()
}
}
@@ -187,6 +187,8 @@ export class DespachoPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.close();
@@ -194,6 +196,9 @@ export class DespachoPage implements OnInit {
} catch(error) {
this.toastService.badRequest("Processo não criado")
}
finally {
loader.remove()
}
}
async arquivar(note:string, documents:any){
@@ -206,6 +211,8 @@ export class DespachoPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage('Processo descartado')
@@ -213,6 +220,9 @@ export class DespachoPage implements OnInit {
} catch (error) {
this.toastService.badRequest("Processo não descartado")
}
finally {
loader.remove()
}
}
@@ -226,6 +236,9 @@ export class DespachoPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
@@ -233,6 +246,10 @@ export class DespachoPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
async reexecute(note:string, documents:any) {
@@ -246,6 +263,8 @@ export class DespachoPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
@@ -254,6 +273,9 @@ export class DespachoPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
@@ -154,6 +154,9 @@ export class DiplomaAssinarPage implements OnInit {
},
"AttachmentList": [],
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
@@ -163,6 +166,10 @@ export class DiplomaAssinarPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
close() {
@@ -168,6 +168,9 @@ export class DiplomaPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
@@ -178,6 +181,9 @@ export class DiplomaPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
async askToChange(note:string, documents:any){
@@ -191,12 +197,17 @@ export class DiplomaPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
async finish(note:string, documents:any){
@@ -210,12 +221,18 @@ export class DiplomaPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
this.toastService.successMessage('Processo concluído')
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
@@ -102,6 +102,9 @@ export class ApproveEventModalPage implements OnInit {
console.log('approveTask SERIALNUMBER: ', serialNumber)
let body = { "serialNumber": serialNumber, "action": "Aprovar" }
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
@@ -112,6 +115,9 @@ export class ApproveEventModalPage implements OnInit {
} catch (error) {
this.toastService.badRequest('Evento não aprovado')
}
finally {
loader.remove()
}
}
@@ -128,6 +134,8 @@ export class ApproveEventModalPage implements OnInit {
let body = { "serialNumber": serialNumber, "action": "Rejeitar" }
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
@@ -136,6 +144,9 @@ export class ApproveEventModalPage implements OnInit {
})
} catch (error) {
this.toastService.badRequest('Evento não rejeitado')
}
finally {
loader.remove()
}
this.modalController.dismiss(null);
@@ -183,7 +194,8 @@ export class ApproveEventModalPage implements OnInit {
}
//console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
this.router.navigate(['/home/gabinete-digital/event-list']);
@@ -191,6 +203,9 @@ export class ApproveEventModalPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
this.router.navigate(['/home/gabinete-digital/event-list']);
}
finally {
loader.remove()
}
}
@@ -97,6 +97,8 @@ export class ApproveEventPage implements OnInit {
let body = { "serialNumber": serialNumber, "action": "Aprovar" }
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
this.toastService.successMessage();
@@ -105,6 +107,9 @@ export class ApproveEventPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
/* this.approveEventDismiss.emit({
@@ -144,13 +149,18 @@ export class ApproveEventPage implements OnInit {
}
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise();
this.toastService.successMessage('Pedido enviado');
this.goBack();
} catch (error) {
this.toastService.badRequest();
} finally {
loader.remove()
}
}
else{
//this.alertService.presentAlert('Operação cancelada!');
@@ -164,6 +174,7 @@ export class ApproveEventPage implements OnInit {
async rejeitar(serialNumber:string){
let body = { "serialNumber": serialNumber, "action": "Rejeitar" }
console.log(body);
const loader = this.toastService.loading()
try {
this.processes.PostTaskAction(body).toPromise();
await this.toastService.successMessage('Processo rejeitado');
@@ -171,9 +182,14 @@ export class ApproveEventPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
}
finally {
loader.remove()
}
}
async getAttachments(instanceId:string){
const loader = this.toastService.loading()
try {
this.loadedAttachments = await this.attachmentsService.getAttachmentsById(instanceId).toPromise();
@@ -233,13 +249,18 @@ export class ApproveEventPage implements OnInit {
}
console.log(body);
try {
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise();
this.toastService.successMessage();
this.goBack();
} catch (error) {
this.toastService.badRequest();
} finally {
loader.remove()
}
}
else{
//this.alertService.presentAlert('Operação cancelada!');
@@ -252,7 +252,7 @@ export class BookMeetingModalPage implements OnInit {
console.log(this.postData);
if(this.task.FsId == '8') {
const loader = this.toastService.loading()
try {
switch (this.loggeduser.Profile) {
case 'MDGPR':
@@ -271,10 +271,14 @@ export class BookMeetingModalPage implements OnInit {
} catch (error) {
this.toastService.badRequest('Reunião não criada')
}
finally {
loader.remove()
}
}
else if(this.task.FsId == '361') {
const loader = this.toastService.loading()
try {
switch (this.loggeduser.Profile) {
case 'MDGPR':
@@ -290,7 +294,10 @@ export class BookMeetingModalPage implements OnInit {
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
}
@@ -271,6 +271,8 @@ export class ExpedientTaskModalPage implements OnInit {
DispatchFolder: this.dispatchFolder,
AttachmentList: docs,
}
const loader = this.toastService.loading()
try {
let action_despacho = {
"serialNumber": this.task.serialNumber,
@@ -291,6 +293,8 @@ export class ExpedientTaskModalPage implements OnInit {
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
console.log('this.taskResult', this.taskResult);
break;
@@ -336,6 +340,8 @@ export class ExpedientTaskModalPage implements OnInit {
AttachmentList: docs
}
//console.log(this.postData);
const loader1 = this.toastService.loading()
try {
let action_deferimento = {
"serialNumber": this.task.serialNumber,
@@ -346,14 +352,15 @@ export class ExpedientTaskModalPage implements OnInit {
}
}
this.taskResult = await this.processes.postDeferimento(this.postData).toPromise();
loader.remove()
await this.toastService.successMessage('Processo efetuado');
this.modalController.dismiss(action_deferimento);
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader1.remove()
}
console.log('this.taskResult', this.taskResult);
break;
}
@@ -375,6 +382,8 @@ export class ExpedientTaskModalPage implements OnInit {
AttachmentList: docs,
}
console.log(this.postData);
const loader = this.toastService.loading()
try {
let action_despacho_pr = {
"serialNumber": this.task.serialNumber,
@@ -394,7 +403,10 @@ export class ExpedientTaskModalPage implements OnInit {
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader.remove()
}
console.log('this.taskResult', this.taskResult);
break;
@@ -408,7 +420,9 @@ export class ExpedientTaskModalPage implements OnInit {
DispatchFolder: this.dispatchFolder,
AttachmentList: docs
}
const loader2 = this.toastService.loading()
try {
let action_parecer_pr = {
"serialNumber": this.task.serialNumber,
@@ -418,15 +432,17 @@ export class ExpedientTaskModalPage implements OnInit {
"Note": "",
}
}
loader.remove()
this.taskResult = await this.processes.postParecerPr(this.postData).toPromise();
await this.toastService.badRequest('Processo não efetuado');
this.modalController.dismiss(action_parecer_pr);
} catch (error) {
loader.remove()
await this.toastService.badRequest('Processo não efetuado')
} finally {
loader2.remove()
}
break;
}
@@ -246,12 +246,16 @@ export class ExpedienteDetailPage implements OnInit {
}
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(otherbody).toPromise()
this.toastService.successMessage('Processo descartado');
this.goBack();
} catch (error) {
this.toastService.badRequest('Processo não descartado')
} finally {
loader.remove()
}
}
@@ -261,23 +265,30 @@ export class ExpedienteDetailPage implements OnInit {
}
else{
if(res['data']== 'Yes'){
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
this.toastService.successMessage('Processo descartado');
this.goBack();
} catch (error) {
this.toastService.badRequest('Processo não descartado')
} finally {
loader.remove()
}
this.goBack();
}
else if(res['data'] == 'No'){
console.log('Update');
const loader = this.toastService.loading()
try {
await this.processes.UpdateTaskStatus(this.task.FolderId).toPromise();
this.toastService.successMessage();
this.goBack();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
}
@@ -231,13 +231,18 @@ export class ExpedientePrPage implements OnInit {
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
this.close();
this.toastService.successMessage('Processo aprovado')
} catch(error) {
this.toastService.badRequest('Processo não aprovado')
} finally {
loader.remove()
}
}
async sendToReview(note:string, documents:any){
@@ -251,12 +256,16 @@ export class ExpedientePrPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.close();
this.toastService.successMessage()
} catch(error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -360,12 +369,16 @@ export class ExpedientePrPage implements OnInit {
}
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(otherbody).toPromise()
this.toastService.successMessage('Processo descartado');
this.goBack();
} catch (error) {
this.toastService.badRequest('Processo não descartado')
} finally {
loader.remove()
}
}
@@ -375,23 +388,34 @@ export class ExpedientePrPage implements OnInit {
}
else{
if(res['data']== 'Yes'){
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise();
this.toastService.successMessage('Processo descartado');
this.goBack();
} catch (error) {
this.toastService.badRequest('Processo não descartado')
} finally {
loader.remove()
}
this.goBack();
}
else if(res['data'] == 'No'){
console.log('Update');
const loader = this.toastService.loading()
try {
await this.processes.UpdateTaskStatus(this.task.FolderId).toPromise();
this.toastService.successMessage();
this.goBack();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
}
@@ -199,6 +199,9 @@ export class PedidoPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
@@ -206,6 +209,8 @@ export class PedidoPage implements OnInit {
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -220,13 +225,18 @@ export class PedidoPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage('Processo arquivado')
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
async assignar(note:string, documents:any) {
@@ -240,13 +250,18 @@ export class PedidoPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage('Processo arquivado')
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
sendExpedienteToPending() {