<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">

    <kc-tabs-resource-server></kc-tabs-resource-server>

    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th class="kc-table-actions" colspan="5">
                    <div class="form-inline">
                        <div class="form-group">
                            {{:: 'filter' | translate}}:&nbsp;&nbsp;
                            <div class="input-group">
                                <input type="text" placeholder="{{:: 'name' | translate}}" data-ng-model="query.name" class="form-control search" onkeydown="if (event.keyCode == 13) document.getElementById('policySearch').click()">
                                <div class="input-group-addon">
                                    <i class="fa fa-search" id="policySearch" type="submit" data-ng-click="firstPage()"></i>
                                </div>
                            </div>
                            <div class="input-group">
                                <input type="text" placeholder="{{:: 'authz-resource' | translate}}" data-ng-model="query.resource" class="form-control search" onkeydown="if (event.keyCode == 13) document.getElementById('policySearch').click()">
                                <div class="input-group-addon">
                                    <i class="fa fa-search" type="submit" data-ng-click="firstPage()"></i>
                                </div>
                            </div>
                            <div class="input-group">
                                <select class="form-control search" data-ng-model="query.type"
                                        ng-options="p.type as p.name group by p.group for p in policyProviders track by p.type" data-ng-change="firstPage()">
                                    <option value="" selected ng-click="query.type = ''">{{:: 'authz-all-types' | translate}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="pull-right">
                            <select class="form-control" ng-model="policyType"
                                    ng-options="p.name group by p.group for p in policyProviders track by p.type"
                                    data-ng-change="addPolicy(policyType);">
                                <option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
                            </select>
                        </div>
                    </div>
                </th>
            </tr>
            <tr data-ng-hide="policies.length == 0">
                <th>{{:: 'name' | translate}}</th>
                <th>{{:: 'description' | translate}}</th>
                <th>{{:: 'type' | translate}}</th>
            </tr>
        </thead>
        <tfoot data-ng-show="policies && (policies.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="policies.length < query.max">{{:: 'next-page' | translate}}</button>
                </div>
            </td>
        </tr>
        </tfoot>
        <tbody>
            <tr ng-repeat="policy in policies | filter: {name: search.name, type: search.type} | orderBy:'name'">
                <td><a href="#/realms/{{realm.realm}}/clients/{{client.id}}/authz/resource-server/policy/{{policy.type}}/{{policy.id}}">{{policy.name}}</a></td>
                <td>{{policy.description}}</td>
                <td>{{policy.type}}</td>
            </tr>
            <tr data-ng-show="(policies | filter:search).length == 0">
                <td class="text-muted" colspan="3" data-ng-show="search.name">{{:: 'no-results' | translate}}</td>
                <td class="text-muted" colspan="3" data-ng-hide="search.name">{{:: 'authz-no-policies-available' | translate}}</td>
            </tr>
        </tbody>
    </table>
</div>

<kc-menu></kc-menu>