Add location delete support
This commit is contained in:
parent
861af87e93
commit
21a95a5d0e
3 changed files with 70 additions and 3 deletions
|
@ -18,15 +18,19 @@
|
|||
<th>Description</th>
|
||||
<th class="text-center">Nodes</th>
|
||||
<th class="text-center">Servers</th>
|
||||
<th class="text-center"></th>
|
||||
<th class="text-center"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($locations as $location)
|
||||
<tr>
|
||||
<td><a href="#/edit/{{ $location->id }}" data-action="edit" data-location="{{ $location->id }}"><code>{{ $location->short }}</code></td>
|
||||
<td><code>{{ $location->short }}</code></td>
|
||||
<td>{{ $location->long }}</td>
|
||||
<td class="text-center">{{ $location->a_nodeCount }}</td>
|
||||
<td class="text-center">{{ $location->a_serverCount }}</td>
|
||||
<td class="text-center"><a href="#edit"><i class="fa fa-wrench" data-action="edit" data-id="{{ $location->id }}" data-short="{{ $location->short }}" data-long="{{ $location->long }}"></i></a></td>
|
||||
<td class="text-center"><a href="#delete" class="text-danger" data-action="delete" data-id="{{ $location->id }}"><i class="fa fa-trash-o"></i></a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@ -34,10 +38,51 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12 text-center">{!! $locations->render() !!}</div>
|
||||
</div>
|
||||
<div class="well">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-sm btn-success" id="addNewLocation">Add New Location</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sidebar_links').find("a[href='/admin/locations']").addClass('active');
|
||||
$('[data-action="delete"]').click(function (event) {
|
||||
event.preventDefault();
|
||||
var self = $(this);
|
||||
swal({
|
||||
type: 'warning',
|
||||
title: '',
|
||||
text: 'Do you really want to delete this location?',
|
||||
showCancelButton: true,
|
||||
closeOnConfirm: false,
|
||||
showLoaderOnConfirm: true
|
||||
}, function () {
|
||||
$.ajax({
|
||||
method: 'DELETE',
|
||||
url: '{{ route('admin.locations') }}/' + self.data('id'),
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
}).done(function () {
|
||||
swal({
|
||||
type: 'success',
|
||||
title: '',
|
||||
text: 'Location was successfully deleted.'
|
||||
});
|
||||
self.parent().parent().slideUp();
|
||||
}).fail(function (jqXHR) {
|
||||
console.error(jqXHR);
|
||||
swal({
|
||||
type: 'error',
|
||||
title: 'Whoops!',
|
||||
text: (typeof jqXHR.responseJSON !== 'undefined') ? jqXHR.responseJSON.error : 'An error occured while processing this request.'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue