<section class="content-header">
    <h1>
        People
        <small>users for your organization</small>
    </h1>
</section>
<section class="content">
    <div class="box">
        <div class="box-header with-border">
            &nbsp;
            <div class="box-filters hidden-xs">
                <div class="form-group form-group-sm has-feedback has-feedback-left">
                    <input type="text" id="filterSearch" class="form-control" placeholder="Search people..."
                           style="width: 200px;" ng-model="filterSearch">
                    <span class="fa fa-search form-control-feedback text-muted" aria-hidden="true"></span>
                </div>
            </div>
            <div class="box-tools">
                <button type="button" class="btn btn-primary btn-sm btn-flat" ng-click="invite()">
                    <i class="fa fa-fw fa-plus-circle"></i> Invite User
                </button>
            </div>
        </div>
        <div class="box-body" ng-class="{'no-padding': filteredUsers.length}">
            <div ng-show="!filteredUsers.length && !filterSearch">
                Loading...
            </div>
            <div class="table-responsive" ng-show="filteredUsers.length">
                <table class="table table-striped table-hover table-vmiddle">
                    <tbody>
                        <tr ng-repeat="user in filteredUsers = (users | filter: (filterSearch || '') |
                            orderBy: ['type', 'name', 'email']) track by user.id">
                            <td style="width: 70px;">
                                <div class="btn-group" data-append-to="body">
                                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                        <i class="fa fa-cog"></i> <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu">
                                        <li>
                                            <a href="#" stop-click ng-click="edit(user)">
                                                <i class="fa fa-fw fa-pencil"></i> Edit
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#" stop-click ng-click="groups(user)" ng-if="useGroups">
                                                <i class="fa fa-fw fa-sitemap"></i> Groups
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#" stop-click ng-click="events(user)"
                                               ng-if="useEvents && user.status === 2">
                                                <i class="fa fa-fw fa-file-text-o"></i> Event Logs
                                            </a>
                                        </li>
                                        <li ng-show="user.status === 1">
                                            <a href="#" stop-click ng-click="confirm(user)">
                                                <i class="fa fa-fw fa-check"></i> Confirm
                                            </a>
                                        </li>
                                        <li ng-show="user.status === 0">
                                            <a href="#" stop-click ng-click="reinvite(user)">
                                                <i class="fa fa-fw fa-envelope-o"></i> Re-send Invitation
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#" stop-click ng-click="delete(user)" class="text-red">
                                                <i class="fa fa-fw fa-remove"></i> Remove
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                            <td style="width: 45px;">
                                <letter-avatar data="{{user.name || user.email}}"></letter-avatar>
                            </td>
                            <td>
                                <a href="#" stop-click ng-click="edit(user)">{{user.email}}</a>
                                <i class="fa fa-unlock text-muted" ng-show="user.accessAll"
                                   title="Can Access All Items"></i>
                                <div ng-if="user.name"><small class="text-muted">{{user.name}}</small></div>
                            </td>
                            <td style="width: 100px;">
                                {{user.type | enumName: 'OrgUserType'}}
                            </td>
                            <td style="width: 120px;">
                                <span class="label {{user.status | enumLabelClass: 'OrgUserStatus'}}">
                                    {{user.status | enumName: 'OrgUserStatus'}}
                                </span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>
