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

    <ul class="nav nav-tabs">
        <li class="active"><a href="#/realms/{{realm.realm}}/roles">{{:: 'realm-roles' | translate}}</a></li>
        <li><a href="#/realms/{{realm.realm}}/default-roles">{{:: 'default-roles' | translate}}</a></li>
    </ul>

    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th class="kc-table-actions" colspan="5">
                    <div class="form-inline">
                        <div class="form-group">
                            <div class="input-group">
                                <input type="text" placeholder="{{:: 'search.placeholder' | translate}}" data-ng-model="query.search" ng-model-options="{debounce: 500}" class="form-control search">
                                <div class="input-group-addon">
                                    <i class="fa fa-search" type="submit" data-ng-click="firstPage()"></i>
                                </div>
                            </div>
                        </div>
                        <button id="viewAllRoles" class="btn btn-default" ng-click="query.search = null; firstPage()">{{:: 'view-all-roles' | translate}}</button>
                        <div class="pull-right" data-ng-show="access.manageRealm">
                            <a id="createRole" class="btn btn-default" href="#/create/role/{{realm.realm}}">{{:: 'add-role' | translate}}</a>
                        </div>
                    </div>
                </th>
            </tr>
            <tr data-ng-show="roles && roles.length > 0">
                <th>{{:: 'role-name' | translate}}</th>
                <th>{{:: 'composite' | translate}}</th>
                <th>{{:: 'description' | translate}}</th>
                <th colspan="2">{{:: 'actions' | translate}}</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="role in roles">
                <td><a href="#/realms/{{realm.realm}}/roles/{{role.id}}">{{role.name}}</a></td>
                <td translate="{{role.composite}}"></td>
                <td>{{role.description}}</td>
                <td class="kc-action-cell" kc-open="/realms/{{realm.realm}}/roles/{{role.id}}">{{:: 'edit' | translate}}</td>
                <td class="kc-action-cell" data-ng-click="removeRole(role)">{{:: 'delete' | translate}}</td>
            </tr>
            <tr data-ng-show="(roles | filter:{name: query.search}).length == 0">
                <td class="text-muted" colspan="4" data-ng-show="searchLoaded && roles.length == 0 && lastSearch != null">{{:: 'no-results' | translate}}</td>
                <td class="text-muted" colspan="4" data-ng-show="searchLoaded && roles.length == 0 && lastSearch == null">{{:: 'no-realm-roles-available' | translate}}</td>
            </tr>
        </tbody>
        <tfoot data-ng-show="roles && (roles.length >= query.max || query.first > 0)">
            <tr>
                <td colspan="5">
                    <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="roles.length < query.max">{{:: 'next-page' | translate}}</button>
                    </div>
                </td>
            </tr>
        </tfoot>   
    </table>
</div>

<kc-menu></kc-menu>