<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <h1>
        <span>{{:: 'admin-events' | translate}}</span>
        <kc-tooltip>{{:: 'admin-events.tooltip' | translate}}</kc-tooltip>
    </h1>
    
    <ul class="nav nav-tabs">
        <li data-ng-class="(path[2] == 'events') && 'active'"><a href="#/realms/{{realm.realm}}/events">{{:: 'login-events' | translate}}</a></li>
        <li data-ng-class="(path[2] == 'admin-events') && 'active'"><a href="#/realms/{{realm.realm}}/admin-events">{{:: 'admin-events' | translate}}</a></li>
        <li data-ng-class="(path[2] == 'events-settings') && 'active'"><a href="#/realms/{{realm.realm}}/events-settings">{{:: 'config' | translate}}</a></li>
    </ul>
    <h2></h2>

    <div id="content">
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <th class="kc-table-actions" colspan="5">
                    <div class="pull-right">
                        <select data-ng-model="query.max"
                                data-ng-click="update()"
                                data-ng-options="itemCount for itemCount in [5,10,50,100]"
                                class="btn btn-default">
                        </select>
                        <button class="btn btn-default" data-ng-click="filter = !filter">
                            <span class="glyphicon glyphicon-plus" data-ng-show="!filter"></span>
                            <span class="glyphicon glyphicon-minus" data-ng-show="filter"></span>
                            {{:: 'filter' | translate}}
                        </button>
                        <button class="btn btn-default btn-default" data-ng-click="update()">{{:: 'update' | translate}}</button>
                        <button class="btn btn-default btn-default" data-ng-click="reset()">{{:: 'reset' | translate}}</button>
                    </div>
                    <form class="form-horizontal" data-ng-show="filter">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="adminEnabledEventOperations">{{:: 'operation-types' | translate}}</label>
                            <div class="col-sm-5" onkeypress="return false;" ng-paste="disablePaste($event)">
                                <input ui-select2="adminEnabledEventOperationsOptions" id="adminEnabledEventOperations" ng-model="query.operationTypes" data-placeholder="{{:: 'select-operations.placeholder' | translate}}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="adminEnabledEventResourceTypes">{{:: 'resource-types' | translate}}</label>
                            <div class="col-sm-5" onkeypress="return false;" ng-paste="disablePaste($event)">
                                <input ui-select2="adminEnabledEventResourceTypesOptions" id="adminEnabledEventResourceTypes" ng-model="query.resourceTypes" data-placeholder="{{:: 'select-resource-types.placeholder' | translate}}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="resource">{{:: 'resource-path' | translate}}</label>
                            <kc-tooltip>{{:: 'resource-path.tooltip' | translate}}</kc-tooltip>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" id="resource" name="resource" data-ng-model="query.resourcePath">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="dateFrom">{{:: 'date-(from)' | translate}}</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" id="dateFrom" name="dateFrom" data-ng-model="query.dateFrom"  placeholder="yyyy-MM-dd">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="dateTo">{{:: 'date-(to)' | translate}}</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" id="dateTo" name="dateTo" data-ng-model="query.dateTo"  placeholder="yyyy-MM-dd">
                            </div>
                        </div>

                        <fieldset>
                            <legend><span class="text">{{:: 'authentication-details' | translate}}</span></legend>

                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="realm">{{:: 'realm' | translate}}</label>
                                <div class="col-sm-4">
                                    <input class="form-control" type="text" id="realm" name="realm" data-ng-model="query.authRealm">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="client">{{:: 'client' | translate}}</label>
                                <div class="col-sm-4">
                                    <input class="form-control" type="text" id="client" name="client" data-ng-model="query.authClient">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="user">{{:: 'user' | translate}}</label>
                                <div class="col-sm-4">
                                    <input class="form-control" type="text" id="user" name="user" data-ng-model="query.authUser">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="ipAddress">{{:: 'ip-address' | translate}}</label>
                                <div class="col-sm-4">
                                    <input class="form-control" type="text" id="ipAddress" name="ipAddress" data-ng-model="query.authIpAddress">
                                </div>
                            </div>
                        </fieldset>

                    </form>
                </th>
            </tr>
            <tr>
                <th width="100px">{{:: 'time' | translate}}</th>
                <th width="180px">{{:: 'operation-type' | translate}}</th>
                <th width="180px">{{:: 'resource-type' | translate}}</th>
                <th width="180px">{{:: 'resource-path' | translate}}</th>
                <th>{{:: 'details' | translate}}</th>
            </tr>
            </thead>
            <tfoot>
            <tr>
            	<td colspan="7">
                	<button data-ng-click="firstPage()" class="first" ng-disabled="query.first == 0"><i data-ng-class="query.first == 0 && 'text-muted'" class="fa fa-angle-double-left"></i></button>
                	<button data-ng-click="previousPage()" class="prev" ng-disabled="query.first == 0"><i data-ng-class="query.first == 0 && 'text-muted'" class="fa fa-angle-left"></i></button>
                	<button data-ng-click="nextPage()" class="next" ng-disabled="events.length < query.max"><i data-ng-class="events.length < query.max && 'text-muted'" class="fa fa-angle-right"></i></button>
            	</td>
            </tr>
            </tfoot>
            <tbody>
                <tr data-ng-repeat="event in events">
                    <td>{{event.time|date:'shortDate'}}<br>{{event.time|date:'mediumTime'}}</td>
                    <td data-ng-class="events-error">{{event.operationType}}</td>
                    <td data-ng-class="events-error">{{event.resourceType}}</td>
                    <td>{{event.resourcePath}}</td>
                    <td>
                        <button type="button" class="btn btn-default btn-xs" data-ng-click="viewAuth(event)">
                            {{:: 'auth' | translate}}
                        </button>
                        <button type="button" class="btn btn-default btn-xs" data-ng-click="viewRepresentation(event)" data-ng-show="event.representation">
                            {{:: 'representation' | translate}}
                        </button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<kc-menu></kc-menu>