<div>
    <h2>
        <span jhiTranslate="userManagement.home.title">Users</span>
        <button class="btn btn-primary float-right" [routerLink]="['/', { outlets: { popup: ['user-management-new'] } }]">
            <span class="fa fa-plus"></span> <span jhiTranslate="userManagement.home.createLabel">Create a new User</span>
        </button>
    </h2>
    <jhi-alert></jhi-alert>
    <div class="table-responsive" *ngIf="users">
        <table class="table table-striped">
            <thead>
            <tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="transition.bind(this)">
            <th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span><span class="fa fa-sort"></span></th>
                <th jhiSortBy="login"><span jhiTranslate="userManagement.login">Login</span> <span class="fa fa-sort"></span></th>
                <th jhiSortBy="email"><span jhiTranslate="userManagement.email">Email</span> <span class="fa fa-sort"></span></th>
                <th></th>
                <th  jhiSortBy="langKey"> <span jhiTranslate="userManagement.langKey">Lang Key</span> <span class="fa fa-sort"></span></th>
                <th><span jhiTranslate="userManagement.profiles">Profiles</span></th>
                <th jhiSortBy="createdDate"><span jhiTranslate="userManagement.createdDate">Created Date</span> <span class="fa fa-sort"></span></th>
                <th jhiSortBy="lastModifiedBy"><span jhiTranslate="userManagement.lastModifiedBy">Last Modified By</span> <span class="fa fa-sort"></span></th>
                <th jhiSortBy="lastModifiedDate"><span jhiTranslate="userManagement.lastModifiedDate">Last Modified Date</span> <span class="fa fa-sort"></span></th>
                <th></th>
            </tr>
            </thead>
            <tbody *ngIf ="users">
            <tr *ngFor="let user of users; trackBy: trackIdentity">
                <td><a [routerLink]="['../user-management', user.login]">{{user.id}}</a></td>
                <td>{{user.login}}</td>
                <td>{{user.email}}</td>
                <td>
                    <span class="badge badge-danger hand" (click)="setActive(user, true)" *ngIf="!user.activated"
                          jhiTranslate="userManagement.deactivated">Deactivated</span>
                    <span class="badge badge-success hand" (click)="setActive(user, false)" *ngIf="user.activated"
                          jhiTranslate="userManagement.activated">Activated</span>
                </td>
                <td>{{user.langKey}}</td>
                <td>
                    <div *ngFor="let authority of user.authorities">
                        <span class="tag tag-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"
                                [routerLink]="['../user-management', user.login]"
                                class="btn btn-info btn-sm">
                            <span class="fa fa-eye"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.view">View</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'user-management/'+ user.login + '/edit'} }]"
                                replaceUrl="true"
                                class="btn btn-primary btn-sm">
                            <span class="fa fa-pencil"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.edit">Edit</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'user-management/'+ user.login + '/delete'} }]"
                                replaceUrl="true"
                                class="btn btn-danger btn-sm" [disabled]="currentAccount.login==user.login">
                            <span class="fa fa-remove"></span>
                            <span class="hidden-md-down" jhiTranslate="entity.action.delete">Delete</span>
                        </button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div *ngIf="users">
        <div class="row justify-content-center">
            <jhi-item-count [page]="page" [total]="queryCount" [itemsPerPage]="itemsPerPage"></jhi-item-count>
        </div>
        <div class="row justify-content-center">
            <ngb-pagination [collectionSize]="totalItems" [(page)]="page" (pageChange)="loadPage(page)"></ngb-pagination>
        </div>
    </div>
</div>
