1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import {Injectable} from '@angular/core';
import Swal from 'sweetalert2';
import {TranslateService} from '@ngx-translate/core';
@Injectable({
providedIn: 'root'
})
export class OgSweetAlertService {
constructor(private translate: TranslateService) {}
swal(options): Promise<any> {
return Swal.fire(options);
}
success(title, message) {
Swal.fire( title, message, 'success' );
}
error(title, message) {
Swal.fire( title, message, 'error' );
}
warning(title, message) {
Swal.fire( title, message, 'warning' );
}
info(title, message) {
Swal.fire( title, message, 'info' );
}
question(title, message, okcallback?, cancelcallback?) {
Swal.fire({
title: title,
text: message,
type: 'info',
showCancelButton: true,
cancelButtonText: this.translate.instant('no'),
cancelButtonClass: 'default',
confirmButtonClass: 'primary',
confirmButtonText: this.translate.instant('yes')
}).then((response) => {
if (response.dismiss) {
if (typeof cancelcallback === 'function') {
cancelcallback(response);
}
} else {
okcallback(response);
}
});
}
}
|