@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    {{ __('Available Servers') }}
                </div>
                <div class="card-body">
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">Name</th>
                            <th scope="col">IP</th>
                            <th scope="col">Type</th>
                          </tr>
                        </thead>
                        <tbody>
                        @forelse ($servers as $server)
                            <tr>
                                <td>{{ $server->name }}</td>
                                <td>{{ $server->ip }}</td>
                                <td>{{ $server->type }}</td>
                                <td>
                                        @can('manage-users')                        
                                            <a href="{{ route('servers.edit', $server->id) }}"><button type="button" class="btn btn-primary float-left">Edit</button></a>

                                            <form action="{{ route('servers.destroy', $server) }}" method="POST" class="float-left">
                                                @csrf
                                                {{ method_field('DELETE') }}
                                                <button type="submit" class="btn btn-warning">Delete</button>
                                            </form>
                                        @endcan
                                </td>
                                <td>
                                  
                                </td>
                            </tr>
                        @empty
                        <tr>
                            <td>No Servers</td>                                
                        </tr>
                        @endforelse
                        </tbody>
                    </table>
                </div>

            </div>
            <br>


            @can('manage-users')                        
                <div class="card">
                    <div class="card-header">
                        {{ __('Add new server') }}
                    </div>               
                    <div class="card-body">
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td>ESXi</td>
                                    <td>
                                        <a href="/servers/createESXi"><button type="button" class="btn btn-primary float-left">Add new</button></a>                                  
                                    </td>
                                </tr>
                                <tr>
                                    <td>Windows Server</td>
                                    <td>
                                        <a href="/servers/createHyperV"><button type="button" class="btn btn-primary float-left">Add new</button></a>                                  
                                    </td>
                                </tr>                         
                            </tbody>
                        </table>
                    </div>
                </div>
            @endcan

        </div>
    </div>
</div>
@endsection
