<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2" ng-init="init()">

    <kc-tabs-users></kc-tabs-users>

    <table class="table table-striped table-bordered" id="user-table">
        <caption data-ng-show="users" class="hidden">{{:: 'table-of-realm-users' | translate}}</caption>
        <thead>
        <tr>
            <th colspan="{{access.impersonation == true ? '8' : '7'}}">
                <div class="form-inline">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="text" placeholder="{{:: 'search.placeholder' | translate}}" data-ng-model="query.search" class="form-control search" onkeydown="if (event.keyCode == 13) document.getElementById('userSearch').click()">
                            <div class="input-group-addon">
                                    <i class="fa fa-search" id="userSearch" data-ng-click="firstPage()"></i>
                            </div>
                        </div>
                    </div>
                    <button id="viewAllUsers" class="btn btn-default" ng-click="query.search = null; firstPage()">{{:: 'view-all-users' | translate}}</button>

                    <div class="pull-right" data-ng-show="access.manageUsers">
                        <button data-ng-click="unlockUsers()" class="btn btn-default">{{:: 'unlock-users' | translate}}</button>
                        <a id="createUser" class="btn btn-default" href="#/create/user/{{realm.realm}}">{{:: 'add-user' | translate}}</a>
                    </div>
                </div>
            </th>
        </tr>
        <tr>
        <tr data-ng-show="searchLoaded && users.length > 0">
            <th class="w-15">{{:: 'id' | translate}}</th>
            <th class="w-15">{{:: 'username' | translate}}</th>
            <th class="w-15">{{:: 'email' | translate}}</th>
            <th class="w-15">{{:: 'last-name' | translate}}</th>
            <th class="w-15">{{:: 'first-name' | translate}}</th>
            <th colspan="{{serverInfo.featureEnabled('IMPERSONATION') && access.impersonation == true ? '3' : '2'}}">{{:: 'actions' | translate}}</th>
        </tr>
        </thead>
        <tfoot data-ng-show="users && (users.length >= query.max || query.first > 0)">
        <tr>
            <td colspan="7">
                <div class="table-nav">
                    <button data-ng-click="firstPage()" class="first" ng-disabled="query.first == 0">{{:: 'first-page' | translate}}</button>
                    <button data-ng-click="previousPage()" class="prev" ng-disabled="query.first == 0">{{:: 'previous-page' | translate}}</button>
                    <button data-ng-click="nextPage()" class="next" ng-disabled="users.length < query.max">{{:: 'next-page' | translate}}</button>
                </div>
            </td>
        </tr>
        </tfoot>
        <tbody>
        <tr ng-repeat="user in users">
            <td class="clip"><a href="#/realms/{{realm.realm}}/users/{{user.id}}">{{user.id}}</a></td>
            <td class="clip">{{user.username}}</td>
            <td class="clip">{{user.email}}</td>
            <td class="clip">{{user.lastName}}</td>
            <td class="clip">{{user.firstName}}</td>
            <td class="kc-action-cell" kc-open="/realms/{{realm.realm}}/users/{{user.id}}">{{:: 'edit' | translate}}</td>
            <td data-ng-show="serverInfo.featureEnabled('IMPERSONATION') && access.impersonation" class="kc-action-cell" data-ng-click="impersonate(user.id)">{{:: 'impersonate' | translate}}</td>
            <td data-ng-show="user.access.manage" class="kc-action-cell" data-ng-click="removeUser(user)">{{:: 'delete' | translate}}</td>
        </tr>
        <tr data-ng-show="!users || users.length == 0">
            <td class="text-muted" data-ng-show="!users">{{:: 'users.instruction' | translate}}</td>
            <td class="text-muted" data-ng-show="searchLoaded && users.length == 0 && lastSearch != null">{{:: 'no-results' | translate}}</td>
            <td class="text-muted" data-ng-show="searchLoaded && users.length == 0 && lastSearch == null">{{:: 'no-users-available' | translate}}</td>
        </tr>
        </tbody>
    </table>
</div>

<kc-menu></kc-menu>
