<?php $this->layout('main', ['title' => __('SFTP Users'), 'manual' => true]) ?>

<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header bg-primary-dark">
                <h2 class="card-title"><?=__('SFTP Users')?></h2>
            </div>
            <div class="card-actions">
                <a class="btn btn-outline-primary" role="button"
                   href="<?=$router->fromHere('stations:sftp_users:add')?>">
                    <i class="material-icons" aria-hidden="true">add</i>
                    <?=__('Add SFTP User')?>
                </a>
            </div>
            <table class="table table-responsive-lg table-striped mb-0">
                <colgroup>
                    <col width="25%">
                    <col width="75%">
                </colgroup>
                <thead>
                <tr>
                    <th><?=__('Actions')?></th>
                    <th><?=__('Username')?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($users as $row): ?>
                    <?php /** @var App\Entity\SftpUser $row */ ?>
                    <tr class="align-middle">
                        <td>
                            <div class="btn-group btn-group-sm">
                                <a class="btn btn-sm btn-primary" href="<?=$router->fromHere('stations:sftp_users:edit',
                                    ['id' => $row->getId()])?>"><?=__('Edit')?></a>
                                <a class="btn btn-sm btn-danger"
                                   data-confirm-title="<?=$this->e(__('Delete SFTP User "%s"?', $row->getUsername()))?>"
                                   href="<?=$router->fromHere('stations:sftp_users:delete',
                                       ['id' => $row->getId(), 'csrf' => $csrf])?>"><?=__('Delete')?></a>
                            </div>
                        </td>
                        <td><code><?=$this->e($row->getUsername())?></code></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
    <div class="col-md-4">
        <div class="card">
            <div class="card-header bg-primary-dark">
                <h2 class="card-title"><?=__('Connection Information')?></h2>
            </div>
            <div class="card-body">
                <dl>
                    <dt class="mb-1"><?=__('Server')?>:</dt>
                    <dd><code><?=$this->e($sftp_info['url'])?></code></dd>
                    <?php if ($sftp_info['ip']): ?>
                        <dd><?=__('You may need to connect directly via your IP address, which is <code>%s</code>.',
                                $sftp_info['ip'])?></dd>
                    <?php endif; ?>

                    <dt class="mb-1"><?=__('Port')?>:</dt>
                    <dd><code><?=(int)$sftp_info['port']?></code></dd>
                </dl>
            </div>
        </div>
    </div>
</div>
