@extends(Theme::viewName('layout'))
@section('title', trans('admin.storage_title'))

@section('breadcrumb')
    <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
    <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
    <li class="breadcrumb-item active">@lang('navigation.breadcrumb.storage')</li>
@endsection

@section('content')
    <div class="container">
        <div class="row">
            <div class="col">
                <h1>@lang('admin.list_storages_title')</h1>
                <div class="alert alert-info" style="margin-bottom: 30px;">
                    <i class="fa fa-fw fa-info"></i> @lang('admin.list_storages_intro')
                </div>

                @if (count($storageLocations) == 0)
                    <div class="text-center">
                        <h4 class="text-danger"><b>@lang('admin.no_storages_title')</b></h4>
                        <p>@lang('admin.no_storages_text')</p>
                        <p>@lang('admin.no_storages_text2')</p>
                        <p style="margin-top: 40px;">
                            <a href="{{ route('storage.create') }}" class="btn btn-lg btn-success">@lang('admin.create_storage')</a>
                        </p>
                    </div>
                @else
                    <table class="table table-hover table-striped">
                        <tbody>
                        @foreach ($storageLocations as $storage)
                            <tr>
                                <td>
                                    <span style="font-size: 1.3em;">
                                        <a href="{{ route('storage.edit', ['id' => $storage->id]) }}">{{ $storage->name }}</a>
                                        @if ($storage->is_default) <i class="fa fa-fw fa-check text-success"></i>@endif
                                        @if (!$storage->is_active) <i class="fa fa-fw fa-minus-circle text-danger"></i>@endif
                                    </span><br/>
                                    <span style="color: #888; font-style: italic;">
                                        @if ($storage->source == 'LocalFilesystemSource'){{ $storage->location }}@endif
                                        @if ($storage->source == 'OpenStackSource'){{ $storage->container_name }} - {{ $storage->service_name }}, {{ $storage->service_region }}@endif
                                        @if ($storage->source == 'AmazonS3Source'){{ $storage->container_name }} - {{ $storage->service_region }}@endif
                                        @if ($storage->source == 'RackspaceSource'){{ $storage->container_name }} - {{ $storage->service_region }}@endif
                                    </span>
                                </td>
                                <td class="text-right">
                                    @if (!$storage->is_internal)
                                        <a href="{{ route('storage.delete', ['id' => $storage->id]) }}" class="btn btn-danger">@lang('forms.delete_action')</a>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>

                    <div class="text-center">
                        {{ $storageLocations->links() }}
                    </div>

                    <div class="pull-right" style="margin-top: 10px;">
                        <a href="{{ route('storage.create') }}" class="btn btn-success"><i class="fa fa-fw fa-plus"></i> @lang('admin.create_storage')</a>
                    </div>

                    <div class="clearfix"><!-- --></div>

                    <div class="row" style="margin-top: 15px;">
                        <div class="col-sm-6">
                            <div class="card card-outline-info">
                                <div class="card-body">
                                    <h4 class="card-title">@lang('admin.legend')</h4>
                                    <p class="card-text">
                                        <i class="fa fa-fw fa-check text-success" style="font-size: 1.3em;"></i> @lang('admin.default_storage_legend')<br/>
                                        <i class="fa fa-fw fa-minus-circle text-danger" style="font-size: 1.3em;"></i> @lang('admin.inactive_storage_legend')
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                @endif
            </div>
        </div>
    </div>
@endsection