diff --git a/.gitignore b/.gitignore index 4126c5c2d8..ececb89ee2 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,9 @@ public/error_log /.vscode # Themes -# /themes/* +/themes/* +!/themes/opendk/ +/themes/opendk/* !/themes/opendk/default/ /storage/komplain diff --git a/public/js/admin.js b/public/js/admin.js index 31480f3533..445a5c445a 100644 --- a/public/js/admin.js +++ b/public/js/admin.js @@ -11,13 +11,7 @@ function errorValidation(response) { var errors = response.responseJSON?.errors; if (!errors) { - Swal.fire({ - title: 'Gagal!', - text: response, - icon: 'error', - confirmButtonText: 'OK', - timer: 1500 - }); + openAlert(response, 'Gagal!', 'danger'); } else { $.each(errors, function(key, value) { $('#' + key) diff --git a/public/js/modal-helper.js b/public/js/modal-helper.js new file mode 100644 index 0000000000..8ef1a02d4f --- /dev/null +++ b/public/js/modal-helper.js @@ -0,0 +1,45 @@ +var confirmCallback = null; + +function openAlert(message, title, type) { + var modal = $('#modal-alert'); + modal.find('.modal-title').text(title || 'Pesan'); + modal.find('.modal-body').html(message || ''); + modal.find('.modal-content').removeClass('modal-danger modal-success modal-warning modal-info'); + if (type) { + modal.find('.modal-content').addClass('modal-' + type); + } + modal.modal('show'); +} + +function openConfirm(message, title, callback, btnYesText) { + var modal = $('#modal-confirm'); + modal.find('.modal-title').text(title || 'Konfirmasi'); + modal.find('.modal-body').html(message || ''); + confirmCallback = callback; + modal.find('#modal-confirm-yes').text(btnYesText || 'Ya'); + modal.modal('show'); +} + +$(document).on('click', '#modal-confirm-yes', function () { + $('#modal-confirm').modal('hide'); + if (typeof confirmCallback === 'function') { + confirmCallback(); + } +}); + +$(document).on('click', '[data-confirm]', function (e) { + e.preventDefault(); + var btn = $(this); + var message = btn.data('confirm'); + var title = btn.data('confirm-title') || 'Konfirmasi'; + var btnText = btn.data('confirm-btn') || 'Ya'; + var form = btn.closest('form'); + var href = btn.attr('href'); + openConfirm(message, title, function () { + if (form.length) { + form[0].submit(); + } else if (href) { + window.location.href = href; + } + }, btnText); +}); diff --git a/resources/views/auth/2fa/verify-activation.blade.php b/resources/views/auth/2fa/verify-activation.blade.php index ef9c210f40..3cd2c084c9 100644 --- a/resources/views/auth/2fa/verify-activation.blade.php +++ b/resources/views/auth/2fa/verify-activation.blade.php @@ -189,7 +189,7 @@ function updateOtpValue() { if (expirySeconds <= 0) { clearInterval(expiryInterval); clearInterval(resendInterval); - alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.'); + openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info'); window.location.href = '{{ route('otp2fa.index') }}'; } }, 1000); @@ -222,12 +222,12 @@ function updateOtpValue() { } }, 1000); - alert('Kode OTP baru telah dikirim.'); + openAlert('Kode OTP baru telah dikirim.', 'Info', 'success'); } else { - alert(response.message || 'Gagal mengirim ulang kode OTP.'); + openAlert(response.message || 'Gagal mengirim ulang kode OTP.', 'Info', 'warning'); } }).fail(function() { - alert('Gagal mengirim ulang kode OTP.'); + openAlert('Gagal mengirim ulang kode OTP.', 'Error', 'danger'); }); }); }); diff --git a/resources/views/auth/2fa/verify-login.blade.php b/resources/views/auth/2fa/verify-login.blade.php index 022c7290b5..1d925e7744 100644 --- a/resources/views/auth/2fa/verify-login.blade.php +++ b/resources/views/auth/2fa/verify-login.blade.php @@ -237,7 +237,7 @@ function updateOtpValue() { if (expirySeconds <= 0) { clearInterval(expiryInterval); clearInterval(resendInterval); - alert('Kode 2FA telah kadaluarsa. Silakan minta kode baru.'); + openAlert('Kode 2FA telah kadaluarsa. Silakan minta kode baru.', 'Info'); window.location.href = '{{ route('login') }}'; } }, 1000); @@ -256,7 +256,7 @@ function updateOtpValue() { purpose: '2fa_login' }, success: function(response) { - alert(response.message); + openAlert(response.message, 'Info', 'success'); // Reset expiry timer expirySeconds = expiryMinutes * 60; @@ -282,7 +282,7 @@ function updateOtpValue() { }, 1000); }, error: function(xhr) { - alert('Gagal mengirim ulang kode 2FA'); + openAlert('Gagal mengirim ulang kode 2FA', 'Error', 'danger'); $('#resend-btn').prop('disabled', false).html( ' Kirim Ulang'); } diff --git a/resources/views/auth/otp/verify-activation.blade.php b/resources/views/auth/otp/verify-activation.blade.php index 62543f628f..0b24ae8123 100644 --- a/resources/views/auth/otp/verify-activation.blade.php +++ b/resources/views/auth/otp/verify-activation.blade.php @@ -190,7 +190,7 @@ function updateOtpValue() { if (expirySeconds <= 0) { clearInterval(expiryInterval); clearInterval(resendInterval); - alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.'); + openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info'); window.location.href = '{{ route('otp2fa.index') }}'; } }, 1000); @@ -209,7 +209,7 @@ function updateOtpValue() { purpose: 'activation' }, success: function(response) { - alert(response.message); + openAlert(response.message, 'Info', 'success'); // Reset timer expirySeconds = expiryMinutes * 60; @@ -235,7 +235,7 @@ function updateOtpValue() { }, 1000); }, error: function(xhr) { - alert('Gagal mengirim ulang kode OTP'); + openAlert('Gagal mengirim ulang kode OTP', 'Error', 'danger'); $('#resend-btn').prop('disabled', false).html( ' Kirim Ulang'); } diff --git a/resources/views/auth/otp/verify-login.blade.php b/resources/views/auth/otp/verify-login.blade.php index 692fb4b4b0..9016903643 100644 --- a/resources/views/auth/otp/verify-login.blade.php +++ b/resources/views/auth/otp/verify-login.blade.php @@ -237,7 +237,7 @@ function updateOtpValue() { if (expirySeconds <= 0) { clearInterval(expiryInterval); clearInterval(resendInterval); - alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.'); + openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info'); window.location.href = '{{ route('otp.login') }}'; } }, 1000); @@ -256,7 +256,7 @@ function updateOtpValue() { purpose: 'login' }, success: function(response) { - alert(response.message); + openAlert(response.message, 'Info', 'success'); // Reset expiry timer expirySeconds = expiryMinutes * 60; @@ -282,7 +282,7 @@ function updateOtpValue() { }, 1000); }, error: function(xhr) { - alert('Gagal mengirim ulang kode OTP'); + openAlert('Gagal mengirim ulang kode OTP', 'Error', 'danger'); $('#resend-btn').prop('disabled', false).html( ' Kirim Ulang'); } diff --git a/resources/views/auth/otp2fa/verify-settings.blade.php b/resources/views/auth/otp2fa/verify-settings.blade.php index ff6e10c5f0..9eee720613 100644 --- a/resources/views/auth/otp2fa/verify-settings.blade.php +++ b/resources/views/auth/otp2fa/verify-settings.blade.php @@ -191,7 +191,7 @@ function updateOtpValue() { if (expirySeconds <= 0) { clearInterval(expiryInterval); clearInterval(resendInterval); - alert('Kode verifikasi telah kadaluarsa. Silakan minta kode baru.'); + openAlert('Kode verifikasi telah kadaluarsa. Silakan minta kode baru.', 'Info'); window.location.href = '{{ route('otp2fa.index') }}'; } }, 1000); @@ -210,7 +210,7 @@ function updateOtpValue() { purpose: 'settings_verification' }, success: function(response) { - alert(response.message); + openAlert(response.message, 'Info', 'success'); // Reset timer expirySeconds = expiryMinutes * 60; @@ -236,7 +236,7 @@ function updateOtpValue() { }, 1000); }, error: function(xhr) { - alert('Gagal mengirim ulang kode verifikasi'); + openAlert('Gagal mengirim ulang kode verifikasi', 'Error', 'danger'); $('#resend-btn').prop('disabled', false).html( ' Kirim Ulang'); } diff --git a/resources/views/components/modal-alert.blade.php b/resources/views/components/modal-alert.blade.php new file mode 100644 index 0000000000..0140e30d88 --- /dev/null +++ b/resources/views/components/modal-alert.blade.php @@ -0,0 +1,14 @@ +