mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { AlertController, AnimationController } from '@ionic/angular';
|
|
import { ChatService } from './chat.service';
|
|
import { ToastService } from './toast.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class AlertService {
|
|
|
|
constructor(
|
|
public alertController: AlertController,
|
|
private animationController: AnimationController,
|
|
private chatService: ChatService,
|
|
private toastService: ToastService,
|
|
) { }
|
|
|
|
async presentAlert(message:string) {
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Mensagem do sistema',
|
|
message: message,
|
|
buttons: ['OK']
|
|
});
|
|
|
|
await alert.present();
|
|
}
|
|
|
|
async presentErrorMessage(message:string) {
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Mensagem de erro',
|
|
message: message,
|
|
});
|
|
|
|
await alert.present();
|
|
|
|
setTimeout(()=>{
|
|
alert.dismiss();
|
|
}, 2500);
|
|
}
|
|
|
|
async confirmDeleteMessage(body:any) {
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Apagar a mensagem?',
|
|
buttons: [
|
|
{
|
|
text: 'Cancelar',
|
|
role: 'cancel',
|
|
cssClass: 'secondary',
|
|
handler: () => {
|
|
//console.log('Confirm Cancel');
|
|
}
|
|
}, {
|
|
text: 'Apagar',
|
|
handler: () => {
|
|
const loader = this.toastService.loading();
|
|
this.chatService.deleteMessage(body).subscribe(res=>{
|
|
loader.remove();
|
|
});
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
await alert.present();
|
|
}
|
|
|
|
}
|