Improve notification

This commit is contained in:
Peter Maquiran
2021-06-15 15:09:20 +01:00
parent bfb81fd84f
commit c856cc2927
32 changed files with 218 additions and 1447 deletions
@@ -24,6 +24,7 @@ import { AuthService } from 'src/app/services/auth.service';
import { User } from 'src/app/models/user.model';
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page';
import { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-pedido',
@@ -56,7 +57,8 @@ export class PedidoPage implements OnInit {
private alertService: AlertService,
public popoverController: PopoverController,
authService: AuthService,
private animationController: AnimationController) {
private animationController: AnimationController,
private toastService: ToastService,) {
this.loggeduser = authService.ValidatedUser;
this.activatedRoute.queryParams.subscribe(params => {
if(params["serialNumber"]) {
@@ -199,10 +201,10 @@ export class PedidoPage implements OnInit {
try {
await this.processes.CompleteTask(body).toPromise()
this.successMessage()
this.toastService.successMessage()
this.close();
} catch (error) {
this.badRequest()
this.toastService.badRequest()
}
@@ -221,10 +223,10 @@ export class PedidoPage implements OnInit {
try {
await this.processes.CompleteTask(body).toPromise()
this.successMessage('Processo arquivado')
this.toastService.successMessage('Processo arquivado')
this.close();
} catch (error) {
this.badRequest()
this.toastService.badRequest()
}
@@ -418,52 +420,7 @@ export class PedidoPage implements OnInit {
}
async successMessage(message?: any, callback?) {
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
.addElement(baseEl.querySelector('ion-backdrop')!)
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
const wrapperAnimation = this.animationController.create()
.addElement(baseEl.querySelector('.modal-wrapper')!)
.keyframes([
{ offset: 0, opacity: '1', right: '-100%' },
{ offset: 1, opacity: '1', right: '0px' }
]);
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
}
const leaveAnimation = (baseEl: any) => {
return enterAnimation(baseEl).direction('reverse');
}
const modal = await this.modalController.create({
enterAnimation,
leaveAnimation,
component: SuccessMessagePage,
componentProps: {
message: message || 'Processo efetuado' ,
},
cssClass: 'notification-modal'
});
modal.present()
setTimeout(()=>{
if (callback) {
callback()
}
modal.dismiss()
},7000)
}
async badRequest(message?: string, callback?) {
const enterAnimation = (baseEl: any) => {