feat: ✨ Added delete button and handler
This commit is contained in:
parent
7a10021ab1
commit
0cbae51666
|
@ -134,44 +134,42 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card-footer d-flex justify-content-between">
|
||||||
<div class="card-footer">
|
<a href="{{ env('PTERODACTYL_URL', 'http://localhost') }}/server/{{ $server->identifier }}"
|
||||||
<div class="footer btn-group d-flex justify-content-around">
|
target="__blank" class="btn btn-info mx-3 w-100">
|
||||||
<form
|
<i class="fas fa-tools mr-2"></i>
|
||||||
action="{{ env('PTERODACTYL_URL', 'http://localhost') }}/server/{{ $server->identifier }}">
|
|
||||||
@csrf
|
|
||||||
@method('DELETE')
|
|
||||||
<button class="btn btn-info w-100">
|
|
||||||
<i title="delete" class="fas fa-tools mr-2"></i>
|
|
||||||
{{ __('Manage') }}
|
{{ __('Manage') }}
|
||||||
</button>
|
</a>
|
||||||
</form>
|
<button onclick="handleServerDelete('{{ $server->id }}');" target="__blank"
|
||||||
<form method="post" onsubmit="return submitResult();"
|
class="btn btn-danger mx-3 w-100">
|
||||||
action="{{ route('servers.destroy', $server->id) }}">
|
<i class="fas fa-trash mr-2"></i>
|
||||||
@csrf
|
|
||||||
@method('DELETE')
|
|
||||||
<button class="btn btn-danger w-100">
|
|
||||||
<i title="delete" class="fas fa-trash mr-2"></i>
|
|
||||||
{{ __('Delete') }}
|
{{ __('Delete') }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
<!-- END CUSTOM CONTENT -->
|
<!-- END CUSTOM CONTENT -->
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!-- END CONTENT -->
|
<!-- END CONTENT -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function submitResult() {
|
const handleSubmit = () => {
|
||||||
return confirm("{{ __('Are you sure you wish to delete?') }}") !== false;
|
return confirm('Are you sure you want to delete this server?');
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleServerDelete = (serverId) => {
|
||||||
|
if (handleSubmit()) {
|
||||||
|
fetch("{{ route('servers.destroy', '') }}" + '/' + serverId, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
Loading…
Reference in a new issue