@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">Virtual details</div>
                
                <div class="card-body">
                    <form action="{{ route('virtuals.edit', $virtual) }}" method="GET">
                        @csrf
                        {{ method_field('GET') }}
                        <div class="form-group row">
                            <label for="System" class="col-md-4 col-form-label text-md-right">State</label>
                            <div class="col-md-6">
                                <table>
                                    <tr>
                                        <td>
                                            @switch($virtual->ready)
                                            @case(0)
                                                <label class="col-form-label text-md-right">Requested</label>                                                       
                                                @break;
                                            @case(1)
                                                <label class="col-form-label text-md-right">Waiting to deploy</label>
                                                @break;
                                            @case(2)
                                                <label class="col-form-label text-md-right">Deployed</label>
                                                @break;
                                            @case(3)
                                                <label class="col-form-label text-md-right">Waiting to be deleted</label>
                                                @break;
                                            @default
                                                Undefined
                                            @endswitch                                    
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <label for="System" class="col-md-4 col-form-label text-md-right">System</label>
                            <div class="col-md-6">                            
                                <tr>
                                    <td>
                                        <input readonly style="color: grey" value="{{$virtual->system}}" name="memory" id="memory"/>
                                    </td>
                                    </tr>
                                </table>
                            </div>

                            <label for="System" class="col-md-4 col-form-label text-md-right">Mem size</label>
                            <div class="col-md-6">
                                <table>
                                    <tr>
                                    <td>
                                        <input readonly style="color: grey" value="{{$virtual->memory}}" name="memory" id="memory" type="number" size="3" min="1" max="100"/>
                                    </td>
                                    <td>GB</td>
                                    </tr>
                                </table>
                                <p style="color: red">@error('memory') {{ $message }} @enderror</p>
                            </div>

                            <label for="System" class="col-md-4 col-form-label text-md-right">Disk size</label>
                            <div class="col-md-6">
                                <table>
                                    <tr>
                                    <td>
                                        <input readonly style="color: grey" value="{{$virtual->disk}}" name="disk" id="disk" type="number" size="3" min="1" max="100"/>
                                    </td>
                                    <td>GB</td>
                                    </tr>
                                </table>
                                <p style="color: red">@error('disk') {{ $message }} @enderror</p>
                            </div>

                            <label for="System" class="col-md-4 col-form-label text-md-right">Number of CPU</label>
                            <div class="col-md-6">
                                    <table>
                                        <tr>
                                        <td>
                                            <input readonly style="color: grey" value="{{$virtual->cpu}}" name="cpu" id="cpu" type="number" size="3" min="1" max="100"/>
                                        </td>
                                        <td>CPU</td>
                                        </tr>
                                    </table>
                                    <p style="color: red">@error('cpu') {{ $message }} @enderror</p>
                            </div>
                            @can('manage-virtuals')

                            <label for="Server" class="col-md-4 col-form-label text-md-right">Server</label>
                            <div class="col-md-6">
                                <table>
                                    <tr>
                                        <td>
                                            <input style="color: grey" readonly value="{{$servers}}" name="Server" id="Server" />
                                        </td>
                                    </tr>
                                </table>
                            </div>

                            <label for="Server" class="col-md-4 col-form-label text-md-right">Network</label>
                            <div class="col-md-6">
                                <table>
                                    <tr>
                                        <td>
                                            <input style="color: grey" readonly value="{{$virtual->switch}}" name="Server" id="Server" />
                                        </td>
                                        
                                        <td> 
                                            <a href="/virtuals/{{$virtual->id}}/editserver">
                                                <button type="button" class="btn btn-primary float-left">Change</button>
                                            </a>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            @endcan
                        </div>
                        <button formaction="/virtuals/" method="get" type="submit" class="btn btn-secondary">
                            Back
                        </button>
                        <button style="float: left;" type="submit" class="btn btn-primary">
                            Edit
                        </button> 
                        @if ($virtual->ready==0)
                            <button formaction="/virtuals/{{ $virtual->id }}/allow" method="get" type="submit" class="btn btn-secondary float-right">
                                Allow
                            </button>
                        @endif
                        @if ($virtual->ready==1)
                            <button formaction="/virtuals/{{ $virtual->id }}/cancel" method="get" type="submit" class="btn btn-secondary float-right">
                                Cancel
                            </button>
                        @endif                      
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
