Commit f52f760c by Milovan Samardzic

frontIzmenaResponzivnost

parent baac01a4
......@@ -156,7 +156,7 @@ public class OglasController
@PostMapping("/obrisi-oglas/{oglasId}")
public String postObrisiOglas(@AuthenticationPrincipal KorisnikDetails loggedUser, @PathVariable("oglasId") int oglasId)
{
if (loggedUser!=null && (loggedUser.getKorisnik().getTipId()==1 || oRepo.findById(oglasId).getKorisnikId()==loggedUser.getKorisnik().getKorisnikId())) {
if (loggedUser!=null && (loggedUser.getKorisnik().getTipId()==2 || oRepo.findById(oglasId).getKorisnikId()==loggedUser.getKorisnik().getKorisnikId())) {
oRepo.deleteOglas(oglasId);
}
return "redirect:/lista-oglasa";
......
......@@ -14,13 +14,18 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@Controller
public class ProfileController
{
public static float round(double d, int decimalPlace) {
return BigDecimal.valueOf(d).setScale(decimalPlace,BigDecimal.ROUND_HALF_UP).floatValue();
}
@Autowired
KorisnikRepository kRepo;
......@@ -110,7 +115,7 @@ public class ProfileController
}
model.addAttribute("komentari", komentari);
model.addAttribute("korisniciKomentari", korisniciKomentari);
model.addAttribute("avgOcena", komRepo.averageOcenaByKorisnikId( korisnikId));
model.addAttribute("avgOcena", round(komRepo.averageOcenaByKorisnikId( korisnikId),2));
model.addAttribute("countOglas",oRepo.countOglasByKorisnikId(korisnikId));
return "korisnik";
}
......
......@@ -354,4 +354,8 @@ h3{
{ color: #ffca08 ; } /* Set yellow color when star checked */
.starrating > input:hover ~ label
{ color: #ffca08 ; } /* Set yellow color when star hover */
\ No newline at end of file
{ color: #ffca08 ; } /* St yellow color when star hover */
.w-40{
width: 40%;
}
\ No newline at end of file
......@@ -114,13 +114,9 @@ $(document).ready(function() {
function prikaziOglase(){
document.getElementById("div-oglasi").style.display = "block";
document.getElementById("div-ocene").style.display = "none";
document.getElementById("dugme-oglasi").style = "text-decoration:none; border-bottom: 3px solid grey; width:100px; text-align:center;padding-bottom:5px;";
document.getElementById("dugme-ocene").style = "";
}
function prikaziOcene(){
document.getElementById("div-oglasi").style.display = "none";
document.getElementById("div-ocene").style.display = "block";
document.getElementById("dugme-ocene").style = "text-decoration:none; border-bottom: 3px solid grey; width:100px; text-align:center;padding-bottom:5px;";
document.getElementById("dugme-oglasi").style = "";
}
\ No newline at end of file
......@@ -99,29 +99,27 @@
method="GET" th:action="@{/lista-oglasa}" id="filter">
<div class="row w-100">
<div class="col-3">
<div class="card mt-2" style="min-width: 130px" th:object="${korisnik}">
<article class="card-group-item">
<div class="card mt-2 justify-content-center align-items-center d-flex mt-5" style="min-width: 130px" th:object="${korisnik}">
<div class="profilepic">
<img class="photo profilepic__image" id="slikaProfil"
style="width: 100px;height:100px;border-radius:50%"
style="width: 120px;height:100px;border-radius:50%"
th:src="@{'data:image/png;charset=utf-8;base64,'+${korisnik.getSlika()}}"
alt="slika korisnika">
</div>
<div class="filter-content">
<p class="fw-bold h4 mt-3"><span th:text="${korisnik.ime + ' ' + korisnik.prezime}"></span></p>
<p th:object="${avgOcena}" th:text="${'Prosecna ocena korisnika: ' + avgOcena}"></p>
<p th:object="${countOglas}" th:text="${'Broj aktivnih oglasa: ' + countOglas}"></p>
<p class="fw-bold h4 mt-3 text-center"><span th:text="${korisnik.ime + ' ' + korisnik.prezime}"></span></p>
<p class="text-center" th:object="${avgOcena}" th:text="${'Prosecna ocena korisnika: ' + avgOcena}"></p>
<p class="text-center" th:object="${countOglas}" th:text="${'Broj aktivnih oglasa: ' + countOglas}"></p>
</div>
</article>
</div>
</div>
<div class="col-9" th:object="${slikeOglasa}">
<div class="row w-100 box " style="/*! border: 1px solid red; */">
<div class="row w-100 box ">
<div class="col d-flex justify-content-center">
<h4 id="dugme-oglasi" class="link-secondary" style="text-decoration:none; border-bottom: 3px solid grey; width:100px; text-align:center;padding-bottom:5px;" onclick="prikaziOglase()">Oglasi</h4>
<h4 id="dugme-oglasi" class="link-secondary" style="width:100px; text-align:center;padding-bottom:5px;cursor: pointer;" onclick="prikaziOglase()">Oglasi</h4>
</div>
<div class="col d-flex justify-content-center">
<h4 id="dugme-ocene" class="link-secondary" style="text-decoration: none" onclick="prikaziOcene()">Ocene</h4>
<h4 id="dugme-ocene" class="link-secondary" style="cursor: pointer;" onclick="prikaziOcene()">Ocene</h4>
</div>
</div>
<div id="div-oglasi">
......@@ -237,17 +235,21 @@
<p th:text="${komentar.komentar}"></p>
<div class="starrating risingstar d-flex justify-content-end flex-row-reverse">
<img src th:onload="postaviZvezdice([[${komentar.ocena}]])">
<input type="radio" id="star5" name="ocenaRadio" value="5" th:checked="${komentar.ocena == 5}" disabled/><label
for="star5" title="5 star" style="pointer-events:none"></label>
<input type="radio" id="star4" name="ocenaRadio" value="4" th:checked="${komentar.ocena == 4}" disabled/><label
for="star4" title="4 star" style="pointer-events:none"></label>
<input type="radio" id="star3" name="ocenaRadio" value="3" th:checked="${komentar.ocena == 3}" disabled/><label
for="star3" title="3 star" style="pointer-events:none"></label>
<input type="radio" id="star2" name="ocenaRadio" value="2" th:checked="${komentar.ocena == 2}" disabled/><label
for="star2" title="2 star" style="pointer-events:none"></label>
<input type="radio" id="star1" name="ocenaRadio" value="1" th:checked="${komentar.ocena == 1}" disabled/><label
for="star1" title="1 star" style="pointer-events:none"></label>
<input type="radio" th:id="${'star' + komentar.komentarVlasnikId + '-5'}" th:name="${'ocenaRadio' + komentar.komentarVlasnikId + '-5'}" value="5"
th:checked="${komentar.ocena == 5}" disabled/><label
th:for="${'star' + komentar.komentarVlasnikId + '-5'}" title="5 star" style="pointer-events:none"></label>
<input type="radio" th:id="${'star' + komentar.komentarVlasnikId + '-4'}" th:name="${'ocenaRadio' + komentar.komentarVlasnikId + '-5'}" value="4"
th:checked="${komentar.ocena == 4}" disabled/><label
th:for="${'star' + komentar.komentarVlasnikId + '-4'}" title="4 star" style="pointer-events:none"></label>
<input type="radio"th:id="${'star' + komentar.komentarVlasnikId + '-3'}" th:name="${'ocenaRadio' + komentar.komentarVlasnikId + '-5'}" value="3"
th:checked="${komentar.ocena == 3}" disabled/><label
th:for="${'star' + komentar.komentarVlasnikId + '-3'}" title="3 star" style="pointer-events:none"></label>
<input type="radio" th:id="${'star' + komentar.komentarVlasnikId + '-2'}" th:name="${'ocenaRadio' + komentar.komentarVlasnikId + '-5'}" value="2"
th:checked="${komentar.ocena == 2}" disabled/><label
th:for="${'star' + komentar.komentarVlasnikId + '-2'}" title="2 star" style="pointer-events:none"></label>
<input type="radio" th:id="${'star' + komentar.komentarVlasnikId + '-1'}" th:name="${'ocenaRadio' + komentar.komentarVlasnikId + '-5'}" value="1"
th:checked="${komentar.ocena == 1}" disabled/><label
th:for="${'star' + komentar.komentarVlasnikId + '-1'}" title="1 star" style="pointer-events:none"></label>
</div>
</div>
</div>
......
......@@ -102,30 +102,17 @@
<h2 th:if="${oglasi.size() == 0}" class="text-center">Jos niste poslali nijedan zahtev!</h2>
<div class="card mb-3" th:each="oglas: ${oglasi}" style="background: transparent" th:if="${!zahtevi[oglasStat.index].korisnikKom}">
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-2 col-xs-2 d-flex justify-content-center align-items-center">
<div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 d-flex justify-content-center align-items-center">
<img
th:if="${zahtevi[oglasStat.index].status.toString() == 'POTVRDJEN'}"
th:src="@{'data:image/png;charset=utf-8;base64,'+${slike[oglasStat.index].slikaCode}}"
style="width: 120px;height: 120px;border-radius: 50%;object-fit: cover;"
th:src="@{'data:image/png;charset=utf-8;base64,'+${vlasnici[oglasStat.index].getSlika()}}"
alt="slika korisnika"
style="width: 150px;height: 150px;border-radius: 50%;object-fit: cover; border: green 3px solid">
<img
th:if="${zahtevi[oglasStat.index].status.toString() == 'CEKANJE'}"
th:src="@{'data:image/png;charset=utf-8;base64,'+${slike[oglasStat.index].slikaCode}}"
alt="slika korisnika"
style="width: 150px;height: 150px;border-radius: 50%;object-fit: cover; border: yellow 3px solid">
<img
th:if="${zahtevi[oglasStat.index].status.toString() == 'ZAVRSEN'}"
th:src="@{'data:image/png;charset=utf-8;base64,'+${slike[oglasStat.index].slikaCode}}"
alt="slika korisnika"
style="width: 150px;height: 150px;border-radius: 50%;object-fit: cover; border: blue 3px solid"
class="w-sm-50">
<img
th:if="${zahtevi[oglasStat.index].status.toString() == 'ODBIJEN'}"
th:src="@{'data:image/png;charset=utf-8;base64,'+${slike[oglasStat.index].slikaCode}}"
alt="slika korisnika"
style="width: 150px;height: 150px;border-radius: 50%;object-fit: cover; border: red 3px solid">
th:styleappend="${zahtevi[oglasStat.index].status.toString() == 'POTVRDJEN' ? 'border: green 3px solid'
: zahtevi[oglasStat.index].status.toString() == 'CEKANJE' ? 'border: yellow 3px solid'
: zahtevi[oglasStat.index].status.toString() == 'ODBIJEN' ? 'border: red 3px solid'
: 'border: blue 3px solid'}">
</div>
<div class="col-lg-3 col-md-4 col-sm-2 col-xs-3">
<div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
<div class="card-body">
<a class="card-title"
th:href="@{/lista-oglasa/{oglasId}(oglasId=${oglas.oglasId})}"
......@@ -159,7 +146,7 @@
</button>
</form>
</div>
<div class="col-lg-7 col-md-5 col-sm-7 col-xs-7 d-flex align-items-center flex-row justify-content-center" th:if="${(zahtevi[oglasStat.index].status.toString() == 'ZAVRSEN')}">
<div class="col-lg-7 col-md-12 col-sm-12 col-xs-12 d-flex align-items-center flex-row justify-content-center" th:if="${(zahtevi[oglasStat.index].status.toString() == 'ZAVRSEN')}">
<form method="get" class="row w-100 h-100 flex-wrap flex-row"
th:action="@{/profile/moji-zahtevi/sacuvaj-komentar}"
th:if="${zahtevi[oglasStat.index].status.toString() == 'ZAVRSEN'}">
......@@ -186,14 +173,14 @@
th:for="${'star' + zahtevi[oglasStat.index].zahtevId + '-1'}" title="1 star"></label>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 d-flex justify-content-center align-items-center">
<button type="submit" class="btn btn-secondary text-wrap w-100 h-md-50">Komentarisi</button>
<div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 d-flex justify-content-center align-items-center">
<button type="submit" class="btn btn-secondary text-wrap w-100">Komentarisi</button>
<button type="button" class="btn btn-secondary text-wrap w-100 ml-1">Završi</button>
</div>
</form>
<form method="get" th:action="@{/profile/moji-zahtevi/sacuvaj-bez-komentara}">
<input type="text" th:value="${zahtevi[oglasStat.index].zahtevId}"
name="zahtevId" style="display: none">
<button class="btn btn-primary" type="submit">Završi</button>
</form>
</div>
</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