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
@@ -81,12 +81,16 @@ export class ApproveEventPage implements OnInit {
async approveTask(serialNumber:string) {
let body = { "serialNumber": serialNumber, "action": "Aprovar" }
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
this.modalController.dismiss(serialNumber);
this.toastService.successMessage()
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
/* this.approveEventDismiss.emit({
@@ -105,12 +109,16 @@ export class ApproveEventPage implements OnInit {
let body = { "serialNumber": serialNumber, "action": "Rejeitar" }
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise()
this.router.navigate(['/home/gabinete-digital/event-list']);
this.toastService.successMessage('Evento rejeitado')
} catch (error) {
this.toastService.badRequest('Processo não efectuado')
} finally {
loader.remove()
}
}
@@ -165,6 +173,7 @@ export class ApproveEventPage implements OnInit {
}
}
console.log(body);
const loader = this.toastService.loading()
try {
await this.processes.PostTaskAction(body).toPromise();
@@ -172,6 +181,8 @@ export class ApproveEventPage implements OnInit {
this.close();
} catch (error) {
this.toastService.badRequest();
} finally {
loader.remove()
}
}
else{
+10 -2
View File
@@ -4,6 +4,7 @@ import { Status } from 'src/app/models/chat/status.model';
import { AlertService } from 'src/app/services/alert.service';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { ToastService } from 'src/app/services/toast.service';
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
import { ProfileComponent } from '../../headers/header-no-search/profile/profile.page';
@@ -37,6 +38,7 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
private authService: AuthService,
private animationController: AnimationController,
private alertService: AlertService,
private toastService: ToastService,
) {
/* this.dm = this.navParams.get('dm'); */
}
@@ -84,9 +86,15 @@ export class MessagesPage implements OnInit, AfterViewChecked, OnChanges {
console.log(this.roomId);
}
scrollToBottom(): void {
const loader = this.toastService.loading()
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
finally {
loader.remove()
}
}
loadMoreMessages(ev:any){
@@ -95,13 +95,18 @@ export class DeplomaOptionsPage 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()
}
}
@@ -135,13 +140,19 @@ export class DeplomaOptionsPage 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()
}
}
@@ -146,12 +146,16 @@ export class DespachosOptionsPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -220,13 +224,19 @@ export class DespachosOptionsPage 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('Processo não arquivado')
} finally {
loader.remove()
}
}
@@ -242,13 +252,18 @@ export class DespachosOptionsPage 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()
}
}
@@ -263,12 +278,17 @@ export class DespachosOptionsPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -179,12 +179,16 @@ export class DespachosPrOptionsPage implements OnInit {
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -255,12 +259,17 @@ export class DespachosPrOptionsPage 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('Processo não arquivado')
} finally {
loader.remove()
}
}
@@ -277,13 +286,18 @@ export class DespachosPrOptionsPage 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()
}
}
@@ -297,12 +311,17 @@ export class DespachosPrOptionsPage implements OnInit {
},
"AttachmentList" :documents,
}
const loader = this.toastService.loading()
try {
await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage()
this.close();
} catch (error) {
this.toastService.badRequest()
} finally {
loader.remove()
}
}
@@ -128,12 +128,16 @@ export class OptsExpedientePrPage 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()
}
}
@@ -162,12 +166,16 @@ export class OptsExpedientePrPage 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()
}
}
@@ -177,23 +185,31 @@ export class OptsExpedientePrPage 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()
}
}
}
@@ -212,13 +228,18 @@ export class OptsExpedientePrPage 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()
}
}
sendExpedienteToPending(){
@@ -187,13 +187,18 @@ export class OptsExpedientePage 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()
}
}
else if(res['data'] == 'No'){
@@ -202,23 +207,31 @@ export class OptsExpedientePage 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()
}
}
}
@@ -166,12 +166,17 @@ export class RequestOptionsPage 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()
}
}
@@ -96,6 +96,8 @@ export class EditActionPage implements OnInit {
}
console.log(body);
const loader = this.toastService.loading()
try {
await this.publicationsService.UpdatePresidentialAction(body).toPromise()
this.close();
@@ -103,6 +105,9 @@ export class EditActionPage implements OnInit {
this.toastService.successMessage('Acção presidencial atualizada')
} catch (error) {
this.toastService.badRequest('Não foi possivel atualizar a acção presidencial')
} finally {
loader.remove()
}
}
}
@@ -110,13 +110,18 @@ export class NewActionPage implements OnInit {
}
console.log(this.folder);
const loader = this.toastService.loading()
try {
await this.publication.CreatePublicationFolder(this.folder).toPromise()
this.close();
this.toastService.successMessage('Acção presidencial criada')
} catch (error) {
this.toastService.badRequest('Não foi possivel criar a acção presidencial')
} finally {
loader.remove()
}
}
close(){
@@ -1,17 +1,10 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { AlertController, AnimationController, ModalController, NavParams } from '@ionic/angular';
/* import {Plugins, CameraResultType, CameraSource} from '@capacitor/core'; */
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { AnimationController, ModalController } from '@ionic/angular';
import { SafeResourceUrl } from '@angular/platform-browser';
import { PublicationsService } from 'src/app/services/publications.service';
import { Publication } from 'src/app/models/publication';
import { Image } from 'src/app/models/image';
import { ThrowStmt } from '@angular/compiler';
import { PhotoService } from 'src/app/services/photo.service';
//Capacitor
/* const { Camera } = Plugins; */
//Cordova
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@@ -71,7 +64,7 @@ export class NewPublicationPage implements OnInit {
this.takePicture();
}
getPublicationDetail(){
getPublicationDetail() {
this.showLoader = true;
//console.log(this.publicationId);
/* console.log(this.folderId); */
@@ -177,6 +170,7 @@ export class NewPublicationPage implements OnInit {
}
console.log('Edit change image');
console.log(this.publication);
const loader = this.toastService.loading()
try {
console.log(this.publication);
@@ -187,6 +181,8 @@ export class NewPublicationPage implements OnInit {
this.goBack();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
} finally {
loader.remove()
}
}
@@ -202,6 +198,7 @@ export class NewPublicationPage implements OnInit {
FileBase64: this.publication.FileBase64,
FileExtension: 'jpeg',
}
const loader = this.toastService.loading()
try {
console.log(this.publication);
@@ -211,11 +208,13 @@ export class NewPublicationPage implements OnInit {
this.goBack();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
} finally {
loader.remove()
}
}
}
else{
else {
this.publication = {
DateIndex: new Date(),
@@ -229,6 +228,8 @@ export class NewPublicationPage implements OnInit {
FileExtension: 'jpeg',
}
const loader = this.toastService.loading()
try {
console.log(this.publication);
await this.publications.CreatePublication(this.folderId, this.publication).toPromise()
@@ -237,6 +238,8 @@ export class NewPublicationPage implements OnInit {
this.goBackToViewPublications.emit();
} catch (error) {
this.toastService.badRequest("Publicação não criado")
} finally {
loader.remove()
}
}