@extends('admin')
@section('contentData')
    @if (session()->has('message'))
        <div class="alert alert-success">
            {{ session('message') }}
        </div>
    @endif
    <h2 style="color: #0095fe; font-family: Calibri,serif;">Nastavení přístupů přes API</h2>
    <div class="alert-info p-2 mb-3" style="width: 730px; border-radius: 5px; border: 1px rgba(142,194,236,0.65) solid; font-family: Calibri,serif; color: #1b1e21; font-size: 17px;">
       Pro přijetí dat pomocí API je nutné vytvořit uživatelské přístupy (Basic Auth). <br>Adresa pro příjem dat je: {{\Request::root()}}/api/addData/XXX, kde XXX je externí id stanice
    </div>
    <div style=' width: 730px; padding: 40px;background-image: url("{{URL::asset('/resources/images/bg-top1.png')}}"); background-repeat:no-repeat; background-size: 10px 100%; border-radius: 10px; background-color: whitesmoke;'>
        <a href="{{ route('apiAuth-add') }}">
            <input type="button" style="width: 150px; height: 37px; background-color: darkorange; border: 0 darkorange; font-size: 20px; font-family: Calibri,serif; margin-bottom: 15px; color: whitesmoke; border-radius: 5px;" value="Přidat veličinu"/>
        </a>
        <table width="100%" id="table">
            <thead style='background-image: url("{{URL::asset('/resources/images/bg-top1.png')}}"); background-repeat:no-repeat; background-size: 100%; color: white;'>
            <tr>
                <th scope="col" style="padding-left: 10px; width: 30px;">ID</th>
                <th scope="col">Název</th>
                <th scope="col">User</th>
                <th scope="col">Heslo</th>
                <th scope="col" style="width: 20px;" class="nosort"> </th>
                <th scope="col" style="width: 20px;" class="nosort"> </th>
            </tr>
            </thead>
            @foreach(\App\ApiAuth::all() as $id => $data)
                @php
                    if ($id%2 == 1)
                    {
                      $rowColor = "#e5e5e5";
                    }
                    else
                    {
                        $rowColor = "whitesmoke";
                    }
                @endphp
                <tr style="background-color: {{$rowColor}};">
                    <th scope="row" style="padding-left: 10px;">{{$data->idapi_auth}}</th>
                    <td>{{$data->nazev}}</td>
                    <td>{{$data->user}}</td>
                    <td>{{$data->password}}</td>
                    <td style="width: 20px;"> <a href="{{ route('apiAuth-edit',$data->idapi_auth) }}"> <img src="{{URL::asset('/resources/images/btn-edit.png')}}" alt="Edit"/></a></td>
                    <td style="width: 20px;"> <a href="{{ route('apiAuth-delete',$data->idapi_auth) }}"> <img src="{{URL::asset('/resources/images/btn-delete.png')}}" alt="Smazat"/></a></td>
                </tr>
            @endforeach
        </table>
    </div>
@endsection
