<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org" xmlns:custom="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Svi korisnici</title>
    <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>
</head>
<body>

<script>
    function post(url, data) {
    return fetch(url, { method: "POST", body: data });
}

function izbrisi(idkorisnika){
    var odgovor = post("http://localhost:8080/izbrisi", idkorisnika);
}
</script>

<div class="container text-center">


    <div>
        <form th:action="@{/logout}" method="post">
            <p>
                Dobrodosli <b>[[${#request.userPrincipal.principal.fullName}]]</b>
            </p>
            <input type="submit" value="Izloguj Se" />
        </form>




    </div>

    <h1>Lista svih korisnika </h1>


    <div>
        <table class="table-striped table-bordered">
            <thead class="thead-dark">
            <th>ID</th>
            <th>Ime</th>
            <th>Email</th>
            <th>Lozinka</th>
            <th>Telefon</th>
            <th>ID tipa</th>
            <th>Prezime</th>
            <th>Korisnicko ime</th>
            <th>Obrisi</th>
            </thead>

            <tbody>
            <tr th:each="korisnik: ${listaKorisnika}">
                <td th:text="${korisnik.idKorisnika}">ID</td>
                <td th:text="${korisnik.ime}">Ime</td>
                <td th:text="${korisnik.email}">Email</td>
                <td th:text="${korisnik.lozinka}">Lozinka</td>
                <td th:text="${korisnik.telefon}">Telefon</td>
                <td th:text="${korisnik.idTipaKorisnika}">ID tipa</td>
                <td th:text="${korisnik.prezime}">Prezime</td>
                <td th:text="${korisnik.username}">Korisnicko ime</td>
                <td><a th:href="@{/izbrisi(idKorisnika=${korisnik.idKorisnika})}" custom:linkMethod="post">Obrisi korisnika</a></td>
            </tr>

            </tbody>

        </table>
    </div>

    <a th:href="@{/lista_oglasa}">Lista Oglasa</a>
    <a th:href="@{/admin_zahtevi}">Zahtevi za administrativne naloge</a>
    <a th:href="@{/}">Pocetna stranica</a>

</div>
</body>
</html>