<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">
    <h1>
        <span>Admin Events</span>
        <kc-tooltip>Displays saved admin events for the realm. Events are related to admin account, for example a realm creation. To enable persisted events go to config.</kc-tooltip>
    </h1>
    
    <ul class="nav nav-tabs">
        <li data-ng-class="(path[2] == 'events') && 'active'"><a href="#/realms/{{realm.realm}}/events">Login Events</a></li>
        <li data-ng-class="(path[2] == 'admin-events') && 'active'"><a href="#/realms/{{realm.realm}}/admin-events">Admin Events</a></li>
        <li data-ng-class="(path[2] == 'events-settings') && 'active'"><a href="#/realms/{{realm.realm}}/events-settings">Config</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()" class="btn btn-default">
                            <option>5</option>
                            <option>10</option>
                            <option>50</option>
                            <option>100</option>
                        </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
                        </button>
                        <button class="btn btn-default btn-primary" data-ng-click="update()">Update</button>
                        <button class="btn btn-default btn-primary" data-ng-click="reset()">Reset</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</label>
                    	    <div class="col-sm-5">
                                <input ui-select2="adminEnabledEventOperationsOptions" id="adminEnabledEventOperations" ng-model="query.operationTypes" data-placeholder="Select operations..."/>
			                </div>
			            </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="resource">Resource Path</label>
                            <div class="col-sm-4">
                                <input class="form-control" type="text" id="resource" name="resource" data-ng-model="query.resourcePath">
                            </div>
                            <span tooltip-placement="right" tooltip="Filter by resource path. Supports wildcards '*' to match a single part of the path and '**' matches multiple parts. For example 'realms/*/clients/asbc' matches client with id asbc in any realm, while or 'realms/master/**' matches anything in the master realm." class="fa fa-info-circle"></span>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="dateFrom">Date (From)</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)</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</span></legend>

                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="realm">Realm</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</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</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</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</th>
                <th width="180px">Operation Type</th>
                <th width="180px">Resource Path</th>
                <th>Details</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>{{event.resourcePath}}</td>
                    <td>
                        <button type="button" class="btn btn-default btn-xs" data-ng-click="viewAuth(event)">
                            Auth
                        </button>
                        <button type="button" class="btn btn-default btn-xs" data-ng-click="viewRepresentation(event)" data-ng-show="event.representation">
                            Representation
                        </button>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<kc-menu></kc-menu>