Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions public/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
56 changes: 56 additions & 0 deletions public/js/modal-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var confirmCallback = null;

function openAlert(message, title, type, onClose) {
var modal = $('#modal-alert');
modal.find('.modal-title').text(title || 'Pesan');
modal.find('.modal-body').text(message || '');
modal.find('.modal-content').removeClass('modal-danger modal-success modal-warning modal-info');

if (type) {
modal.find('.modal-content').addClass('modal-' + type);
}

modal.off('hidden.bs.modal.alertCallback');
if (typeof onClose === 'function') {
modal.one('hidden.bs.modal.alertCallback', onClose);
}

modal.modal('show');
}

function openConfirm(message, title, callback, btnYesText) {
var modal = $('#modal-confirm');
modal.find('.modal-title').text(title || 'Konfirmasi');
modal.find('.modal-body').text(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) {
if (form[0].requestSubmit) {
form[0].requestSubmit(btn[0]);
} else {
form.trigger('submit');
}
} else if (href) {
window.location.href = href;
}
}, btnText);
});
11 changes: 6 additions & 5 deletions resources/views/auth/2fa/verify-activation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ function updateOtpValue() {
if (expirySeconds <= 0) {
clearInterval(expiryInterval);
clearInterval(resendInterval);
alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.');
window.location.href = '{{ route('otp2fa.index') }}';
openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info', 'warning', function () {
window.location.href = '{{ route('otp2fa.index') }}';
});
}
}, 1000);

Expand Down Expand Up @@ -222,12 +223,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');
});
});
});
Expand Down
13 changes: 9 additions & 4 deletions resources/views/auth/2fa/verify-login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@
</div>
</div>

<x-modal-alert />
<x-modal-confirm />

<script src="{{ asset('/bower_components/jquery/dist/jquery.min.js') }}"></script>
<script src="{{ asset('/bower_components/bootstrap/dist/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/modal-helper.js') }}"></script>
<script>
$(document).ready(function() {
var expiryMinutes = {{ config('otp.expiry_minutes', 5) }};
Expand Down Expand Up @@ -237,8 +241,9 @@ function updateOtpValue() {
if (expirySeconds <= 0) {
clearInterval(expiryInterval);
clearInterval(resendInterval);
alert('Kode 2FA telah kadaluarsa. Silakan minta kode baru.');
window.location.href = '{{ route('login') }}';
openAlert('Kode 2FA telah kadaluarsa. Silakan minta kode baru.', 'Info', 'warning', function () {
window.location.href = '{{ route('login') }}';
});
}
}, 1000);

Expand All @@ -256,7 +261,7 @@ function updateOtpValue() {
purpose: '2fa_login'
},
success: function(response) {
alert(response.message);
openAlert(response.message, 'Info', 'success');

// Reset expiry timer
expirySeconds = expiryMinutes * 60;
Expand All @@ -282,7 +287,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(
'<i class="fa fa-refresh"></i> Kirim Ulang');
}
Expand Down
9 changes: 5 additions & 4 deletions resources/views/auth/otp/verify-activation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ function updateOtpValue() {
if (expirySeconds <= 0) {
clearInterval(expiryInterval);
clearInterval(resendInterval);
alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.');
window.location.href = '{{ route('otp2fa.index') }}';
openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info', 'warning', function () {
window.location.href = '{{ route('otp2fa.index') }}';
});
}
}, 1000);

Expand All @@ -209,7 +210,7 @@ function updateOtpValue() {
purpose: 'activation'
},
success: function(response) {
alert(response.message);
openAlert(response.message, 'Info', 'success');

// Reset timer
expirySeconds = expiryMinutes * 60;
Expand All @@ -235,7 +236,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(
'<i class="fa fa-refresh"></i> Kirim Ulang');
}
Expand Down
11 changes: 7 additions & 4 deletions resources/views/auth/otp/verify-login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
</div>
</div>
</div>
<x-modal-alert />
<x-modal-confirm />

<script src="{{ asset('/bower_components/jquery/dist/jquery.min.js') }}"></script>
<script src="{{ asset('/bower_components/bootstrap/dist/js/bootstrap.min.js') }}"></script>
Expand Down Expand Up @@ -237,8 +239,9 @@ function updateOtpValue() {
if (expirySeconds <= 0) {
clearInterval(expiryInterval);
clearInterval(resendInterval);
alert('Kode OTP telah kadaluarsa. Silakan minta kode baru.');
window.location.href = '{{ route('otp.login') }}';
openAlert('Kode OTP telah kadaluarsa. Silakan minta kode baru.', 'Info', 'warning', function () {
window.location.href = '{{ route('otp.login') }}';
});
}
}, 1000);

Expand All @@ -256,7 +259,7 @@ function updateOtpValue() {
purpose: 'login'
},
success: function(response) {
alert(response.message);
openAlert(response.message, 'Info', 'success');

// Reset expiry timer
expirySeconds = expiryMinutes * 60;
Expand All @@ -282,7 +285,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(
'<i class="fa fa-refresh"></i> Kirim Ulang');
}
Expand Down
9 changes: 5 additions & 4 deletions resources/views/auth/otp2fa/verify-settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ function updateOtpValue() {
if (expirySeconds <= 0) {
clearInterval(expiryInterval);
clearInterval(resendInterval);
alert('Kode verifikasi telah kadaluarsa. Silakan minta kode baru.');
window.location.href = '{{ route('otp2fa.index') }}';
openAlert('Kode verifikasi telah kadaluarsa. Silakan minta kode baru.', 'Info', 'warning', function () {
window.location.href = '{{ route('otp2fa.index') }}';
});
}
}, 1000);

Expand All @@ -210,7 +211,7 @@ function updateOtpValue() {
purpose: 'settings_verification'
},
success: function(response) {
alert(response.message);
openAlert(response.message, 'Info', 'success');

// Reset timer
expirySeconds = expiryMinutes * 60;
Expand All @@ -236,7 +237,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(
'<i class="fa fa-refresh"></i> Kirim Ulang');
}
Expand Down
14 changes: 14 additions & 0 deletions resources/views/components/modal-alert.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="modal fade" id="modal-alert" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="modal-alert-title">Pesan</h4>
</div>
<div class="modal-body" id="modal-alert-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
15 changes: 15 additions & 0 deletions resources/views/components/modal-confirm.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="modal fade" id="modal-confirm" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="modal-confirm-title">Konfirmasi</h4>
</div>
<div class="modal-body" id="modal-confirm-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
<button type="button" class="btn btn-primary" id="modal-confirm-yes">Ya</button>
</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion resources/views/data/data_sarana/partials/action.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<form action="{{ $deleteUrl ?? '#' }}" method="POST" style="display:inline;">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-icon btn-danger btn-sm" style="width: 40px" onclick="return confirm('Yakin ingin menghapus data ini?')">
<button type="submit" class="btn btn-icon btn-danger btn-sm" style="width: 40px" data-confirm="Yakin ingin menghapus data ini?">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
</form>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/pengurus/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function readURL(input) {
} else { //no
//warning
$("#foto").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/pengurus/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function readURL(input) {
} else { //no
//warning
$("#foto").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/pengurus/form_create_arsip.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
},
error: function(xhr, status, error) {
console.error(error);
alert("Terjadi kesalahan saat mengambil data.");
openAlert("Terjadi kesalahan saat mengambil data.", "Error", "danger");
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/data/pengurus/form_edit_arsip.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
},
error: function(xhr, status, error) {
console.error(error);
alert("Terjadi kesalahan saat mengambil data.");
openAlert("Terjadi kesalahan saat mengambil data.", "Error", "danger");
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/artikel/_form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function readURL(input) {
} else { //no
//warning
$("#file-artikel").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/media_sosial/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function readURL(input) {
} else { //no
//warning
$("#logo").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/media_sosial/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function readURL(input) {
} else { //no
//warning
$("#logo").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/prosedur/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function readURL(input) {
} else { //no
//warning
$("#file_prosedur").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/prosedur/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function readURL(input) {
} else { //no
//warning
$("#file_prosedur").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/regulasi/form_create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function readURL(input) {
} else { //no
//warning
$("#file_regulasi").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/regulasi/form_update.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function readURL(input) {
} else { //no
//warning
$("#file_regulasi").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/sinergi_program/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function readURL(input) {
} else { //no
//warning
$("#gambar").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/informasi/sinergi_program/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function readURL(input) {
} else { //no
//warning
$("#gambar").val('');
alert('File tersebut tidak diperbolehkan.');
openAlert('File tersebut tidak diperbolehkan.', 'Peringatan', 'warning');
}
}
}
Expand Down
Loading
Loading