<div>
    <h2>Users</h2>
    <jhi-alert></jhi-alert>
    <div class="row">
      <div class="col-md-4">
          <button class="btn btn-primary" ui-sref="user-management.new">
              <span class="glyphicon glyphicon-flash"></span> <span>Create a new User</span>
          </button>
      </div>
    </div>
    <div class="table-responsive">
        <table class="jh-table table table-striped">
            <thead>
            <tr jh-sort="vm.predicate" ascending="vm.reverse" callback="vm.transition()">
                <th jh-sort-by="id"><span>ID</span><span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="login"><span>Login</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="email"><span>Email</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th></th>
                                <th><span>Profiles</span></th>                <th jh-sort-by="createdDate"><span>Created Date</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="lastModifiedBy"><span>Last Modified By</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th jh-sort-by="lastModifiedDate"><span>Last Modified Date</span> <span class="glyphicon glyphicon-sort"></span></th>
                <th></th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="user in vm.users track by user.id">
                <td><a ui-sref="user-management-detail({login:user.login})">{{user.id}}</a></td>
                <td>{{user.login}}</td>
                <td>{{user.email}}</td>
                <td>
                    <button class="btn btn-danger btn-xs" ng-click="vm.setActive(user, true)" ng-show="!user.activated"
                           >Deactivated</button>
                    <button class="btn btn-success btn-xs" ng-click="vm.setActive(user, false)" ng-show="user.activated"
                            ng-disabled="vm.currentAccount.login==user.login">Activated</button>
                </td>
                
                <td>
                    <div ng-repeat="authority in user.authorities">
                        <span class="label label-info">{{ authority }}</span>
                    </div>
                </td>
                <td>{{user.createdDate | date:'dd/MM/yy HH:mm'}}</td>
                <td>{{user.lastModifiedBy}}</td>
                <td>{{user.lastModifiedDate | date:'dd/MM/yy HH:mm'}}</td>
                <td class="text-right">
                    <div class="btn-group flex-btn-group-container">
                        <button type="submit"
                                ui-sref="user-management-detail({login:user.login})"
                                class="btn btn-info btn-sm">
                            <span class="glyphicon glyphicon-eye-open"></span>
                            <span class="hidden-xs hidden-sm"></span>
                        </button>
                        <button type="submit"
                                ui-sref="user-management.edit({login:user.login})"
                                class="btn btn-primary btn-sm">
                            <span class="glyphicon glyphicon-pencil"></span>
                            <span class="hidden-xs hidden-sm"></span>
                        </button>
                        <button type="submit"
                                ui-sref="user-management.delete({login:user.login})"
                                class="btn btn-danger btn-sm" ng-disabled="vm.currentAccount.login==user.login">
                            <span class="glyphicon glyphicon-remove-circle"></span>
                            <span class="hidden-xs hidden-sm"></span>
                        </button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="text-center">
        <jhi-item-count page="vm.page" total="vm.queryCount" items-per-page="vm.itemsPerPage"></jhi-item-count>
        <uib-pagination class="pagination-sm" total-items="vm.totalItems" ng-model="vm.page" ng-change="vm.transition()"></uib-pagination>
    </div>
</div>
