|
18 | 18 | <th>Description</th> |
19 | 19 | <th class="text-center">Nodes</th> |
20 | 20 | <th class="text-center">Servers</th> |
| 21 | + <th class="text-center"></th> |
| 22 | + <th class="text-center"></th> |
21 | 23 | </tr> |
22 | 24 | </thead> |
23 | 25 | <tbody> |
24 | 26 | @foreach ($locations as $location) |
25 | 27 | <tr> |
26 | | - <td><a href="#/edit/{{ $location->id }}" data-action="edit" data-location="{{ $location->id }}"><code>{{ $location->short }}</code></td> |
| 28 | + <td><code>{{ $location->short }}</code></td> |
27 | 29 | <td>{{ $location->long }}</td> |
28 | 30 | <td class="text-center">{{ $location->a_nodeCount }}</td> |
29 | 31 | <td class="text-center">{{ $location->a_serverCount }}</td> |
| 32 | + <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> |
| 33 | + <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> |
30 | 34 | </tr> |
31 | 35 | @endforeach |
32 | 36 | </tbody> |
33 | 37 | </table> |
34 | 38 | <div class="row"> |
35 | 39 | <div class="col-md-12 text-center">{!! $locations->render() !!}</div> |
36 | 40 | </div> |
| 41 | + <div class="well"> |
| 42 | + <div class="row"> |
| 43 | + <div class="col-md-12"> |
| 44 | + <button class="btn btn-sm btn-success" id="addNewLocation">Add New Location</button> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + </div> |
37 | 48 | </div> |
38 | 49 | <script> |
39 | 50 | $(document).ready(function () { |
40 | 51 | $('#sidebar_links').find("a[href='/admin/locations']").addClass('active'); |
| 52 | + $('[data-action="delete"]').click(function (event) { |
| 53 | + event.preventDefault(); |
| 54 | + var self = $(this); |
| 55 | + swal({ |
| 56 | + type: 'warning', |
| 57 | + title: '', |
| 58 | + text: 'Do you really want to delete this location?', |
| 59 | + showCancelButton: true, |
| 60 | + closeOnConfirm: false, |
| 61 | + showLoaderOnConfirm: true |
| 62 | + }, function () { |
| 63 | + $.ajax({ |
| 64 | + method: 'DELETE', |
| 65 | + url: '{{ route('admin.locations') }}/' + self.data('id'), |
| 66 | + headers: { |
| 67 | + 'X-CSRF-TOKEN': '{{ csrf_token() }}' |
| 68 | + } |
| 69 | + }).done(function () { |
| 70 | + swal({ |
| 71 | + type: 'success', |
| 72 | + title: '', |
| 73 | + text: 'Location was successfully deleted.' |
| 74 | + }); |
| 75 | + self.parent().parent().slideUp(); |
| 76 | + }).fail(function (jqXHR) { |
| 77 | + console.error(jqXHR); |
| 78 | + swal({ |
| 79 | + type: 'error', |
| 80 | + title: 'Whoops!', |
| 81 | + text: (typeof jqXHR.responseJSON !== 'undefined') ? jqXHR.responseJSON.error : 'An error occured while processing this request.' |
| 82 | + }); |
| 83 | + }); |
| 84 | + }); |
| 85 | + }); |
41 | 86 | }); |
42 | 87 | </script> |
43 | 88 | @endsection |
0 commit comments