Commit c39022db by Bogdan Andjelkovic

profile picture upload - solved

parent bc58a92b
......@@ -54,13 +54,11 @@ public class AppController
return("redirect:/login");
}
@GetMapping("/profile/{korisnikid}")
public String getProfile(@PathVariable("korisnikid") int korisnikid, Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
@GetMapping("/profile")
public String getProfile( Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
{
Korisnik profile = kRepo.findById(korisnikid);
System.out.println( profile.toString());
model.addAttribute("korisnik", profile);
model.addAttribute("loggedUser", loggedUser);
model.addAttribute("profileRole", kRepo.findRoleById( loggedUser.getKorisnik().getTipId()));
return("profile");
}
}
......@@ -69,4 +69,20 @@ public class KorisnikRepository
}
return( null);
}
public String findRoleById( int tipid)
{
String sql = "select * from tipkorisnika where tipId = "+tipid;
ResultSet rs = null;
try {
rs = statement.executeQuery( sql);
while( rs.next())
{
return rs.getString("naziv");
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
return( null);
}
}
......@@ -40,9 +40,9 @@
<i class="fa-solid fa-circle-user"></i><span style="padding:5px;" th:text="${loggedUser.getKorisnik().getIme()}"></span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" th:href="@{/profile/{korisnikid}(korisnikid=${loggedUser.getKorisnik().getKorisnikId()})}">Moj Profil</a>
<a class="dropdown-item" th:href="@{/mojioglasi/{korisnikid}(korisnikid=${loggedUser.getKorisnik().getKorisnikId()})}">Moji Oglasi</a>
<a class="dropdown-item" th:href="@{/mojizahtevi/{korisnikid}(korisnikid=${loggedUser.getKorisnik().getKorisnikId()})}">Moji Zahtevi</a>
<a class="dropdown-item" th:href="@{/profile}">Moj Profil</a>
<a class="dropdown-item" th:href="@{/mojioglasi}">Moji Oglasi</a>
<a class="dropdown-item" th:href="@{/mojizahtevi}">Moji Zahtevi</a>
<form th:action="@{/logout}" method="post" id="my_form" class="dropdown-item">
<a href="#" onclick="document.getElementById('my_form').submit(); return false;"><i class="fas fa-sign-in-alt"></i><span style="padding:5px;">Odjavi se</span></a>
</form>
......
......@@ -62,7 +62,7 @@
<div class="d-flex flex-column align-items-center">
<img class="photo" th:src="@{'data:image/png;charset=utf-8;base64,'+${loggedUser.getKorisnik().getSlika()}}" alt="slika korisnika">
<p class="fw-bold h4 mt-3"><span th:text="${loggedUser.getKorisnik().getIme()}"></span></p>
<p class="text-muted">Korisnik</p>
<p class="text-muted" th:object="${profileRole}" th:text="${profileRole}"></p>
<br>
<div class="d-flex ">
<div class="btn btn-outline-primary message">Poruka</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment