|
@@ -147,7 +147,7 @@
|
|
|
<i class="fas fa-tools mr-2"></i>
|
|
|
<span>{{ __('Manage') }}</span>
|
|
|
</a>
|
|
|
- <button onclick="handleServerDelete('{{ $server->id }}');" target="__blank"
|
|
|
+ <button onclick="confirmSubmit('{{ $server->id }}', handleServerDelete);" target="__blank"
|
|
|
class="btn btn-danger mx-3 w-100 align-items-center justify-content-center d-flex">
|
|
|
<i class="fas fa-trash mr-2"></i>
|
|
|
<span>{{ __('Delete') }}</span>
|
|
@@ -162,21 +162,37 @@
|
|
|
<!-- END CONTENT -->
|
|
|
|
|
|
<script>
|
|
|
- const handleSubmit = () => {
|
|
|
- return confirm('Are you sure you want to delete this server?');
|
|
|
+ const confirmSubmit = (serverId, handleServerDelete) => {
|
|
|
+ // Confirm delete submit with sweetalert
|
|
|
+ Swal.fire({
|
|
|
+ title: '{{ __('Are you sure?') }}',
|
|
|
+ text: "{{ __('This is an irreversible action, all files of this server will be removed.') }}",
|
|
|
+ icon: 'warning',
|
|
|
+ confirmButtonColor: '#d9534f',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonText: 'Yes, delete it!',
|
|
|
+ cancelButtonText: 'No, cancel!',
|
|
|
+ reverseButtons: true
|
|
|
+ }).then((result) => {
|
|
|
+ if (result.value) {
|
|
|
+ console.log('confirmed');
|
|
|
+ handleServerDelete(serverId);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ Swal.fire('Canceled ...', `Deletion has been canceled.`, 'info');
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
const handleServerDelete = (serverId) => {
|
|
|
- if (handleSubmit()) {
|
|
|
- fetch("{{ route('servers.destroy', '') }}" + '/' + serverId, {
|
|
|
- method: 'DELETE',
|
|
|
- headers: {
|
|
|
- 'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
|
- }
|
|
|
- }).then(() => {
|
|
|
- window.location.reload();
|
|
|
- });
|
|
|
- }
|
|
|
+ // Delete server
|
|
|
+ fetch("{{ route('servers.destroy', '') }}" + '/' + serverId, {
|
|
|
+ method: 'DELETE',
|
|
|
+ headers: {
|
|
|
+ 'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ window.location.reload();
|
|
|
+ });
|
|
|
}
|
|
|
</script>
|
|
|
@endsection
|