<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <kc-tabs-realm></kc-tabs-realm>

    <div class="form-group">
        <legend>{{:: 'trusted-hosts-legend' | translate}}</legend>
        <kc-tooltip>{{:: 'trusted-hosts-legend.tooltip' | translate}}</kc-tooltip>
    </div>

    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th class="kc-table-actions" colspan="6">
                <div class="form-inline">

                    <div class="form-group">
                        <div class="input-group">
                            <input type="text" placeholder="{{:: 'search.placeholder' | translate}}" data-ng-model="search1.host" class="form-control search" onkeyup="if(event.keyCode == 13){$(this).next('I').click();}">
                            <div class="input-group-addon">
                                <i class="fa fa-search" type="submit"></i>
                            </div>
                        </div>
                    </div>

                    <div class="pull-right" data-ng-show="access.manageClients">
                        <a id="createClientTrustedHost" class="btn btn-default" href="#/realms/{{realm.realm}}/client-reg-trusted-hosts/create">{{:: 'create' | translate}}</a>
                    </div>
                </div>
            </th>
        </tr>
        <tr data-ng-hide="clientRegTrustedHosts.length == 0">
            <th>{{:: 'hostname' | translate}}</th>
            <th>{{:: 'count' | translate}}</th>
            <th>{{:: 'remainingCount' | translate}}</th>
            <th colspan="2">{{:: 'actions' | translate}}</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="host in clientRegTrustedHosts | filter:search1 | orderBy:'timestamp'">
            <td>{{host.hostName}}</td>
            <td>{{host.count}}</td>
            <td>{{host.remainingCount}}</td>
            <td class="kc-action-cell" data-ng-click="updateHost(host.hostName)">{{:: 'update' | translate}}</td>
            <td class="kc-action-cell" data-ng-click="removeHost(host.hostName)">{{:: 'delete' | translate}}</td>
        </tr>
        <tr data-ng-show="(clientRegTrustedHosts | filter:search1).length == 0">
            <td class="text-muted" colspan="3" data-ng-show="search1.host">{{:: 'no-results' | translate}}</td>
            <td class="text-muted" colspan="3" data-ng-hide="search1.host">{{:: 'no-client-trusted-hosts-available' | translate}}</td>
        </tr>
        </tbody>
    </table>


    <div class="form-group">
        <legend>{{:: 'initial-access-tokens' | translate}}</legend>
        <kc-tooltip>{{:: 'initial-access-tokens.tooltip' | translate}}</kc-tooltip>
    </div>
    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th class="kc-table-actions" colspan="6">
                <div class="form-inline">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="text" placeholder="{{:: 'search.placeholder' | translate}}" data-ng-model="search2.id" class="form-control search" onkeyup="if(event.keyCode == 13){$(this).next('I').click();}">
                            <div class="input-group-addon">
                                <i class="fa fa-search" type="submit"></i>
                            </div>
                        </div>
                    </div>

                    <div class="pull-right" data-ng-show="access.manageClients">
                        <a id="createClient" class="btn btn-default" href="#/realms/{{realm.realm}}/client-initial-access/create">{{:: 'create' | translate}}</a>
                    </div>
                </div>
            </th>
        </tr>
        <tr data-ng-hide="clientInitialAccess.length == 0">
            <th>{{:: 'id' | translate}}</th>
            <th>{{:: 'created' | translate}}</th>
            <th>{{:: 'expires' | translate}}</th>
            <th>{{:: 'count' | translate}}</th>
            <th>{{:: 'remainingCount' | translate}}</th>
            <th>{{:: 'actions' | translate}}</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="ia in clientInitialAccess | filter:search2 | orderBy:'timestamp'">
            <td>{{ia.id}}</td>
            <td>{{(ia.timestamp * 1000)|date:'shortDate'}}&nbsp;{{(ia.timestamp * 1000)|date:'mediumTime'}}</td>
            <td><span data-ng-show="ia.expiration > 0">{{((ia.timestamp + ia.expiration) * 1000)|date:'shortDate'}}&nbsp;{{((ia.timestamp + ia.expiration) * 1000)|date:'mediumTime'}}</span></td>
            <td>{{ia.count}}</td>
            <td>{{ia.remainingCount}}</td>
            <td class="kc-action-cell" data-ng-click="remove(ia.id)">{{:: 'delete' | translate}}</td>
        </tr>
        <tr data-ng-show="(clientInitialAccess | filter:search2).length == 0">
            <td class="text-muted" colspan="3" data-ng-show="search2.id">{{:: 'no-results' | translate}}</td>
            <td class="text-muted" colspan="3" data-ng-hide="search2.id">{{:: 'no-initial-access-available' | translate}}</td>
        </tr>
        </tbody>
    </table>
</div>

<kc-menu></kc-menu>