<!---
* Edited by:     Nermin Jukan, 63150367
* Date:          16. 05. 2018
* Modifications: Added a new table header in line 33, inserted a delete-'izbrisi' link, that deletes a user.

--->

<div class="container">
    <div class="row">
        <div class="col-xs-12">
            <div class="toolbar" style="left:0px;">
                <button type="button" ng-click="$ctrl.go('/')" class="btn btn-default">Nazaj</button>
                <button type="button" ng-click="$ctrl.go('/login')" class="btn btn-warning">Odjava</button>
            </div>
            <h1>Uporabniški računi</h1>
            <div class="toolbar">
                <button type="button" ng-if="$ctrl.user.admin == 1" ng-click="$ctrl.go('/user')" class="btn btn-primary save">Dodaj uporabnika</button>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        <table class="table table-striped">
            <thead>
                <tr bgcolor='#CCCCCC'>
                    <th>#</th>
                    <th>Ime in priimek</th>
                    <th>Uporabniško ime</th>
                    <th title="Lahko dodaja in briše uporabnike">Skrbnik</th>
                    <th ng-if="$ctrl.user.admin == 1">Upravljanje</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="user in $ctrl.users">
                    <td>{{ $index + 1 }}</td>
                    <td>{{user.name}}</td>
                    <td>{{user.username}}</td>
                    <td>{{(user.is_admin == 1) ? 'da' : 'ne'}}</td>
                    <td ng-if="$ctrl.user.admin == 1"><a href="" ng-if="user.username !== $ctrl.user.username && $ctrl.user.admin == 1" ng-click="$ctrl.delete(user.id, user.name)">Izbriši</a></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>