<pagination ng-show="tokendata.count > tokensPerPage"
            total-items="tokendata.count" ng-model="params.page"
            previous-text="{{ 'Previous'|translate }}"
            next-text="{{ 'Next'|translate }}"
            last-text="{{ 'Last'|translate }}"
            first-text="{{ 'First'|translate }}"
            items-per-page="{{ tokensPerPage }}" 
            max-size="5"
            boundary-links="true" ng-change="pageChanged()"></pagination>


<span translate>total tokens:</span> {{ tokendata.count }}

<div class="table-responsive">
    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th>
                <button class="btn btn-default unsorted"
                        pi-sort-by="serial"
                        translate>serial
                </button>
                <pi-filter ng-model="serialFilter"
                           ng-change="get('livesearch')"
                           ng-keypress="($event.which==13)?get():return"
                ></pi-filter>
            </th>
            <th>
                <button class="btn btn-default unsorted"
                        pi-sort-by="tokentype"
                        translate>type
                </button>
                <pi-filter ng-model="typeFilter"
                           ng-change="get('livesearch')"
                           ng-keypress="($event.which==13)?get():return"
                ></pi-filter>
            </th>
            <th>
                <button pi-sort-by="active"
                        class="btn btn-default
                            unsorted"
                        translate>active
                </button>
            </th>
            <th>
                <button pi-sort-by="description"
                        class="btn btn-default
                       unsorted"
                        translate>description
                </button>
                <pi-filter ng-model="descriptionFilter"
                           ng-change="get('livesearch')"
                           ng-keypress="($event.which==13)?get():return"
                ></pi-filter>
            </th>
            <th>
                <button pi-sort-by="failcount"
                        class="btn btn-default
                         unsorted"
                        translate>failcounter
                </button>
            </th>
            <th ng-show="loggedInUser.role == 'admin'" translate>user</th>
            <th ng-show="loggedInUser.role == 'admin'" translate>realm</th>
            <th ng-show="loggedInUser.role == 'admin' &&
            user_details_in_tokenlist">
                <button pi-sort-by="resolver"
                        class="btn btn-default
                         unsorted"
                        translate>UserId
                </button>
                <pi-filter ng-model="userIdFilter"
                           ng-change="get('livesearch')"
                           ng-keypress="($event.which==13)?get():return"
                ></pi-filter>
            </th>
            <th ng-show="loggedInUser.role == 'admin' &&
            user_details_in_tokenlist">
                <button pi-sort-by="user_id"
                        class="btn btn-default
                         unsorted"
                        translate>User Store
                </button>
                <pi-filter ng-model="resolverFilter"
                           ng-change="get('livesearch')"
                           ng-keypress="($event.which==13)?get():return"
                ></pi-filter>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="token in tokendata.tokens">
            <td><a ui-sref="token.details({tokenSerial:token.serial,
            currentToken:token})"
                   ng-click="$rootScope.returnTo=token.list;">
                {{ token.serial }}</a></td>
            <td>{{ token.tokentype }}</td>
            <td>
                <span class="label label-success" ng-show="token.active"
                      ng-click="disable(token.serial)"
                      title="{{ 'Disable token'|translate }}"
                      translate>active
                </span>
                <span class="label label-danger" ng-hide="token.active"
                      ng-click="enable(token.serial)"
                      title="{{ 'Enable token'|translate }}"
                      translate>disabled
                </span>
            </td>
            <!--<td>{{ token.count_window }}</td>-->
            <td>{{ token.description }}</td>

            <td><span class="label"
                      title="{{ 'Reset Failcounter'|translate }}"
                      ng-click="reset(token.serial)"
                      ng-class="{'label-success': token.failcount==0,
                   'label-warning': token.failcount>0,
                   'label-danger': token.failcount>=token.maxfail}">
            {{ token.failcount }}
            </span></td>
            <!--<td>{{ token.maxfail }}</td>-->
            <!--<td>{{ token.otplen }}</td>-->
            <td ng-show="loggedInUser.role == 'admin'">
                <a ui-sref="user.details({username: token.username,
                            realmname: token.user_realm,
                            resolvername: token.resolver,
                            editable: token.user_editable})">
                {{ token.username }}</a>
            </td>
            <td ng-show="loggedInUser.role == 'admin'">
                <a ui-sref="config.realms.list">{{ token.user_realm }}</a>
            </td>

            <td ng-show="loggedInUser.role == 'admin' &&
            user_details_in_tokenlist">
                {{ token.user_id }}
            </td>
            <td ng-show="loggedInUser.role == 'admin' &&
            user_details_in_tokenlist">
                <a ui-sref="config.resolvers.list">{{ token.resolver }}</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
