Changeset 501396e


Ignore:
Timestamp:
02/03/24 15:58:58 (9 months ago)
Author:
Blazho <aleksandar.blazhevski@…>
Branches:
master
Children:
aea04dd
Parents:
3e572eb
Message:

added missing files

Files:
21 edited

Legend:

Unmodified
Added
Removed
  • pom.xml

    r3e572eb r501396e  
    4141            <scope>test</scope>
    4242        </dependency>
     43        <!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
     44        <dependency>
     45            <groupId>com.jcraft</groupId>
     46            <artifactId>jsch</artifactId>
     47            <version>0.1.55</version>
     48        </dependency>
     49
     50        <!-- https://mvnrepository.com/artifact/org.json/json -->
     51        <dependency>
     52            <groupId>org.json</groupId>
     53            <artifactId>json</artifactId>
     54            <version>20231013</version>
     55        </dependency>
     56
    4357    </dependencies>
    4458
  • src/main/java/com/example/cookbook/controller/HomeController.java

    r3e572eb r501396e  
    1 package com.example.cookbook.controller;public class HomeController {
     1package com.example.cookbook.controller;
     2
     3
     4import com.example.cookbook.model.Recept;
     5import com.example.cookbook.model.Slika;
     6import com.example.cookbook.model.Sostojka;
     7import com.example.cookbook.model.exception.ReceptNeEPronajdenException;
     8import com.example.cookbook.service.ReceptService;
     9import com.example.cookbook.service.SlikiService;
     10import com.example.cookbook.service.SostojkiService;
     11import org.springframework.stereotype.Controller;
     12import org.springframework.ui.Model;
     13import org.springframework.web.bind.annotation.GetMapping;
     14import org.springframework.web.bind.annotation.PathVariable;
     15
     16import java.sql.SQLException;
     17import java.util.List;
     18
     19@Controller
     20public class HomeController {
     21
     22    private final ReceptService receptService;
     23    private final SlikiService slikiService;
     24
     25    private final SostojkiService sostojkiService;
     26
     27    public HomeController(ReceptService receptService, SlikiService slikiService, SostojkiService sostojkiService) {
     28
     29        this.receptService = receptService;
     30        this.slikiService = slikiService;
     31        this.sostojkiService = sostojkiService;
     32    }
     33
     34    @GetMapping({"/", "/recepti"})
     35    public String getHomePage(Model model){
     36
     37        List<Recept> recepti = null;
     38        try {
     39            recepti = receptService.listAll();
     40        } catch (SQLException e) {
     41            return "redirect:/error-page/SQL%20Exception";
     42        }
     43        model.addAttribute("recepti", recepti);
     44        return "home";
     45    }
     46
     47    @GetMapping("/recept/{id}")
     48    public String getReceptPage(@PathVariable Long id, Model model){
     49
     50        Recept recept = null;
     51        List<Slika> sliki;
     52        List<Sostojka> sostojki;
     53        try {
     54            recept = receptService.findById(id);
     55            sliki = slikiService.findAllPicById(id);
     56            sostojki = sostojkiService.findAllById(id);
     57        } catch (SQLException e) {
     58            return "redirect:/error-page/SQL%20Exception";
     59        }catch (ReceptNeEPronajdenException e){
     60            return "redirect:/error-page/" + e.getMessage();
     61        }
     62        model.addAttribute("recept", recept);
     63        model.addAttribute("sliki", sliki);
     64        model.addAttribute("sostojki", sostojki);
     65        return "recept";
     66    }
     67
     68
     69    @GetMapping("/error-page/{error}")
     70    public String getErrorPage(@PathVariable(required = false) String error, Model model){
     71
     72        if (error != null){
     73            model.addAttribute("error", error);
     74        }
     75        return "error-page";
     76    }
    277}
  • src/main/java/com/example/cookbook/dbConfig/DB.java

    r3e572eb r501396e  
    1 package com.example.cookbook.dbConfig;public class DB {
     1package com.example.cookbook.dbConfig;
     2
     3
     4import org.springframework.stereotype.Component;
     5
     6
     7import java.sql.Connection;
     8import java.sql.DriverManager;
     9import java.sql.SQLException;
     10
     11@Component
     12public class DB {
     13//    private static final String SSH_HOST = "194.149.135.130";
     14//    private static final String SSH_USER = "t_cbdb";
     15//    private static final String SSH_PASSWORD = "b6cd27a3";
     16
     17    private static final String DB_URL = "jdbc:postgresql://localhost:9999/db_202324z_va_prj_cbdb";
     18    private static final String DB_USERNAME = "db_202324z_va_prj_cbdb_owner";
     19    private static final String DB_PASSWORD = "d922daf2bfec";
     20
     21
     22    private static final String LDB_URL = "jdbc:postgresql://localhost:5432/cbdb";
     23    private static final String LDB_USERNAME = "postgres";
     24    private static final String LDB_PASSWORD = "04UF@bak";
     25
     26    private static Connection connection = null;
     27
     28
     29
     30
     31
     32
     33    private static void setConnection() throws SQLException {
     34
     35        if (connection == null || connection.isClosed()){
     36            connection = DriverManager.getConnection(LDB_URL, LDB_USERNAME, LDB_PASSWORD);
     37            connection.createStatement().execute("set search_path to project");
     38        }
     39    }
     40
     41    public static Connection getConnection() throws SQLException {
     42        setConnection();
     43        return connection;
     44    }
     45
     46
     47    public static void closeConnection() throws SQLException {
     48        if (connection != null){
     49            connection.close();
     50        }
     51    }
    252}
     53
  • src/main/java/com/example/cookbook/model/DostavaDTO.java

    r3e572eb r501396e  
    1 package com.example.cookbook.model;public class Dostava {
     1package com.example.cookbook.model;
     2
     3import java.time.LocalDateTime;
     4
     5public record DostavaDTO (String recIme, String adresa, String sostojka, LocalDateTime vreme, String telefon){
     6    public DostavaDTO(String recIme, String adresa, String sostojka, LocalDateTime vreme, String telefon) {
     7        this.recIme = recIme;
     8        this.adresa = adresa;
     9        this.sostojka = sostojka;
     10        this.vreme = vreme;
     11        this.telefon = telefon;
     12    }
    213}
  • src/main/java/com/example/cookbook/model/Recept.java

    r3e572eb r501396e  
    11package com.example.cookbook.model;
    22
    3 public class ReceptForList {
     3public class Recept {
    44
    55    private Long recId;
    66
    77    private String recIme;
    8 
    9     public String getPostapka() {
    10         return postapka;
    11     }
    12 
    13     public void setPostapka(String postapka) {
    14         this.postapka = postapka;
    15     }
    168
    179    private String postapka;
     
    2719    }
    2820
    29     public ReceptForList(Long recId, String recIme, String postapka) {
     21    public Recept(Long recId, String recIme, String postapka) {
    3022        this.recId = recId;
    3123        this.recIme = recIme;
     
    3426    }
    3527
    36     public ReceptForList() {
     28    public Recept() {
    3729    }
    3830
     
    5345    }
    5446
     47    public String getPostapka() {
     48        return postapka;
     49    }
    5550
     51    public void setPostapka(String postapka) {
     52        this.postapka = postapka;
     53    }
    5654}
  • src/main/java/com/example/cookbook/model/Slika.java

    r3e572eb r501396e  
    1 package com.example.cookbook.model;public class Slika {
     1package com.example.cookbook.model;
     2
     3public class Slika {
     4
     5    private Integer redenBroj;
     6
     7    private Long recId;
     8
     9    private String pic;
     10
     11    public Slika() {
     12    }
     13
     14    public Slika(Integer redenBroj, Long recId, String pic) {
     15        this.redenBroj = redenBroj;
     16        this.recId = recId;
     17        this.pic = pic;
     18    }
     19
     20    public String getPic() {
     21        return pic;
     22    }
     23
     24    public void setPic(String pic) {
     25        this.pic = pic;
     26    }
     27
     28    public Integer getRedenBroj() {
     29        return redenBroj;
     30    }
     31
     32    public void setRedenBroj(Integer redenBroj) {
     33        this.redenBroj = redenBroj;
     34    }
     35
     36    public Long getRecId() {
     37        return recId;
     38    }
     39
     40    public void setRecId(Long recId) {
     41        this.recId = recId;
     42    }
    243}
  • src/main/java/com/example/cookbook/model/Sostojka.java

    r3e572eb r501396e  
    1 package com.example.cookbook.model;public class Sostojki {
     1package com.example.cookbook.model;
     2
     3public class Sostojka {
     4
     5    private Long sId;
     6
     7    private String sNaziv;
     8
     9    public Sostojka(Long sId, String sNaziv) {
     10        this.sId = sId;
     11        this.sNaziv = sNaziv;
     12    }
     13
     14    public Sostojka() {
     15    }
     16
     17    public Long getsId() {
     18        return sId;
     19    }
     20
     21    public void setsId(Long sId) {
     22        this.sId = sId;
     23    }
     24
     25    public String getsNaziv() {
     26        return sNaziv;
     27    }
     28
     29    public void setsNaziv(String sNaziv) {
     30        this.sNaziv = sNaziv;
     31    }
    232}
  • src/main/java/com/example/cookbook/model/exception/ReceptNeEPronajdenException.java

    r3e572eb r501396e  
    1 package com.example.cookbook.model.exception;public class ReceptNeEPronajdenException {
     1package com.example.cookbook.model.exception;
     2
     3public class ReceptNeEPronajdenException extends RuntimeException{
     4    public ReceptNeEPronajdenException() {
     5        super("Receptot ne e pronajden");
     6    }
    27}
  • src/main/java/com/example/cookbook/repository/ReceptRepository.java

    r3e572eb r501396e  
    1 package com.example.cookbook.repository;public class ReceptRepository {
     1package com.example.cookbook.repository;
     2
     3
     4import com.example.cookbook.dbConfig.DB;
     5import com.example.cookbook.model.Recept;
     6import org.springframework.stereotype.Repository;
     7
     8import java.sql.*;
     9import java.util.ArrayList;
     10import java.util.List;
     11import java.util.Optional;
     12
     13@Repository
     14public class ReceptRepository {
     15
     16
     17    public List<Recept> findAll() throws SQLException {
     18        Connection connection = DB.getConnection();
     19
     20        Statement stm = connection.createStatement();
     21        String query = "select r.rec_id, r.rec_ime , r.postapka,  avg(k.ocena) average\n" +
     22                "from  recepti r\n" +
     23                "    left join komentari k\n" +
     24                "        on r.rec_id = k.rec_id\n" +
     25                "group by r.rec_id, r.rec_ime";
     26        ResultSet result = stm.executeQuery(query);
     27
     28        List<Recept> recepti = new ArrayList<>();
     29        while (result.next()){
     30            Recept recept = new Recept();
     31
     32            recept.setRecId(result.getLong("rec_id"));
     33            recept.setRecIme(result.getString("rec_ime"));
     34            recept.setPostapka(result.getString("postapka"));
     35            recept.setSrednaOcena(result.getFloat("average"));
     36
     37            recepti.add(recept);
     38
     39        }
     40        stm.close();
     41        result.close();
     42        DB.closeConnection();
     43        return recepti;
     44    }
     45
     46    public Optional<Recept> findById(Long recId) throws SQLException {
     47        Connection connection = DB.getConnection();
     48
     49        String query = "select * from recepti r where r.rec_id = ?";
     50        PreparedStatement prepStm = connection.prepareStatement(query);
     51        prepStm.setLong(1, recId);
     52
     53        ResultSet result = prepStm.executeQuery();
     54        Recept recept = null;
     55        if(result.next()){
     56            recept = new Recept();
     57            recept.setRecId(result.getLong("rec_id"));
     58            recept.setRecIme(result.getString("rec_ime"));
     59            recept.setPostapka(result.getString("postapka"));
     60        }
     61        result.close();
     62        prepStm.close();
     63        DB.closeConnection();
     64        return Optional.ofNullable(recept);
     65       
     66    }
    267}
  • src/main/java/com/example/cookbook/repository/SlikiZaReceptRepository.java

    r3e572eb r501396e  
    1 package com.example.cookbook.repository;public class SlikiZaReceptRepository {
     1package com.example.cookbook.repository;
     2
     3import com.example.cookbook.dbConfig.DB;
     4import com.example.cookbook.model.Recept;
     5import com.example.cookbook.model.Slika;
     6import org.springframework.stereotype.Repository;
     7
     8import java.nio.charset.StandardCharsets;
     9import java.sql.Connection;
     10import java.sql.PreparedStatement;
     11import java.sql.ResultSet;
     12import java.sql.SQLException;
     13import java.util.ArrayList;
     14import java.util.List;
     15
     16@Repository
     17public class SlikiZaReceptRepository {
     18
     19    public List<Slika> findAllForRecipe(Long recId) throws SQLException {
     20        Connection connection = DB.getConnection();
     21
     22        String query = "select * from sliki s where s.rec_id = ? order by s.reden_broj asc";
     23        PreparedStatement prepStm = connection.prepareStatement(query);
     24        prepStm.setLong(1, recId);
     25
     26        ResultSet result = prepStm.executeQuery();
     27        List<Slika> sliki = new ArrayList<>();
     28
     29        while (result.next()){
     30            Slika slika = new Slika();
     31            slika.setRecId(result.getLong("rec_id"));
     32            slika.setRedenBroj(result.getInt("reden_broj"));
     33            slika.setPic(new String(result.getBytes("slika"), StandardCharsets.UTF_8));
     34            sliki.add(slika);
     35        }
     36
     37        result.close();
     38        prepStm.close();
     39        DB.closeConnection();
     40
     41        return sliki;
     42    }
    243}
  • src/main/java/com/example/cookbook/repository/SostojkiRespository.java

    r3e572eb r501396e  
    1 package com.example.cookbook.repository;public class SostojkiRespository {
     1package com.example.cookbook.repository;
     2
     3
     4import com.example.cookbook.dbConfig.DB;
     5import com.example.cookbook.model.Slika;
     6import com.example.cookbook.model.Sostojka;
     7import org.springframework.stereotype.Repository;
     8
     9import java.nio.charset.StandardCharsets;
     10import java.sql.Connection;
     11import java.sql.PreparedStatement;
     12import java.sql.ResultSet;
     13import java.sql.SQLException;
     14import java.util.ArrayList;
     15import java.util.List;
     16
     17@Repository
     18public class SostojkiRespository {
     19
     20
     21    public List<Sostojka> findAllByRId(Long rId) throws SQLException {
     22        Connection connection = DB.getConnection();
     23
     24        String query = "select s.s_id, s_naziv\n" +
     25                "from sodrzi\n" +
     26                "    left join sostojki s on\n" +
     27                "        sodrzi.s_id = s.s_id\n" +
     28                "where rec_id = ?";
     29
     30        PreparedStatement prepStm = connection.prepareStatement(query);
     31        prepStm.setLong(1, rId);
     32
     33        ResultSet result = prepStm.executeQuery();
     34        List<Sostojka> sostojki = new ArrayList<>();
     35
     36        while (result.next()){
     37            Sostojka sostojka = new Sostojka();
     38            sostojka.setsId(result.getLong("s_id"));
     39            sostojka.setsNaziv(result.getString("s_naziv"));
     40            sostojki.add(sostojka);
     41        }
     42
     43        result.close();
     44        prepStm.close();
     45        DB.closeConnection();
     46
     47        return sostojki;
     48    }
    249}
  • src/main/java/com/example/cookbook/service/ReceptService.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service;public interface ReceptService {
     1package com.example.cookbook.service;
     2
     3import com.example.cookbook.model.Recept;
     4
     5import java.sql.SQLException;
     6import java.util.List;
     7
     8public interface ReceptService {
     9
     10    List<Recept> listAll() throws SQLException;
     11
     12    Recept findById(Long id) throws SQLException;
    213}
  • src/main/java/com/example/cookbook/service/SlikiService.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service;public class SlikiService {
     1package com.example.cookbook.service;
     2
     3import com.example.cookbook.model.Slika;
     4
     5import java.sql.SQLException;
     6import java.util.List;
     7
     8public interface SlikiService {
     9
     10    List<Slika> findAllPicById(Long recId) throws SQLException;
     11
     12
    213}
  • src/main/java/com/example/cookbook/service/SostojkiService.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service;public interface SostojkiService {
     1package com.example.cookbook.service;
     2
     3import com.example.cookbook.model.Sostojka;
     4
     5import java.sql.SQLException;
     6import java.util.List;
     7
     8public interface SostojkiService {
     9
     10    List<Sostojka> findAllById(Long rId) throws SQLException;
    211}
  • src/main/java/com/example/cookbook/service/impl/ReceptServiceImpl.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service.impl;public class ReceptServiceImpl {
     1package com.example.cookbook.service.impl;
     2
     3import com.example.cookbook.model.Recept;
     4import com.example.cookbook.model.exception.ReceptNeEPronajdenException;
     5import com.example.cookbook.repository.ReceptRepository;
     6import com.example.cookbook.service.ReceptService;
     7import org.springframework.stereotype.Service;
     8
     9import java.sql.SQLException;
     10import java.util.List;
     11import java.util.Optional;
     12
     13@Service
     14public class ReceptServiceImpl implements ReceptService {
     15
     16    private final ReceptRepository receptRepository;
     17
     18    public ReceptServiceImpl(ReceptRepository receptRepository) {
     19        this.receptRepository = receptRepository;
     20    }
     21
     22    @Override
     23    public List<Recept> listAll() throws SQLException {
     24        return receptRepository.findAll();
     25    }
     26
     27    @Override
     28    public Recept findById(Long id) throws SQLException {
     29        Recept recept;
     30
     31        recept = receptRepository.findById(id).orElseThrow(ReceptNeEPronajdenException::new);
     32
     33        return recept;
     34    }
    235}
  • src/main/java/com/example/cookbook/service/impl/SlikiServiceImpl.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service.impl;public class SlikiService {
     1package com.example.cookbook.service.impl;
     2
     3
     4import com.example.cookbook.model.Slika;
     5import com.example.cookbook.repository.SlikiZaReceptRepository;
     6import com.example.cookbook.service.SlikiService;
     7import org.springframework.stereotype.Service;
     8
     9import java.sql.SQLException;
     10import java.util.List;
     11
     12@Service
     13public class SlikiServiceImpl implements SlikiService {
     14
     15    private final SlikiZaReceptRepository slikiZaReceptRepository;
     16
     17    public SlikiServiceImpl(SlikiZaReceptRepository slikiZaReceptRepository) {
     18        this.slikiZaReceptRepository = slikiZaReceptRepository;
     19    }
     20
     21    @Override
     22    public List<Slika> findAllPicById(Long recId) throws SQLException {
     23        return slikiZaReceptRepository.findAllForRecipe(recId);
     24    }
    225}
  • src/main/java/com/example/cookbook/service/impl/SostojkiServiceImpl.java

    r3e572eb r501396e  
    1 package com.example.cookbook.service.impl;public class SostojkiServiceImpl {
     1package com.example.cookbook.service.impl;
     2
     3
     4import com.example.cookbook.model.Sostojka;
     5import com.example.cookbook.repository.SostojkiRespository;
     6import com.example.cookbook.service.SostojkiService;
     7import org.springframework.stereotype.Service;
     8
     9import java.sql.SQLException;
     10import java.util.List;
     11
     12@Service
     13public class SostojkiServiceImpl implements SostojkiService {
     14
     15    private final SostojkiRespository sostojkiRepository;
     16
     17    public SostojkiServiceImpl(SostojkiRespository sostojkiRepository) {
     18        this.sostojkiRepository = sostojkiRepository;
     19    }
     20
     21    @Override
     22    public List<Sostojka> findAllById(Long rId) throws SQLException {
     23        return sostojkiRepository.findAllByRId(rId);
     24    }
    225}
  • src/main/resources/application.properties

    r3e572eb r501396e  
    11
     2spring.datasource.url=jdbc:postgresql://localhost:9999/db_202324z_va_prj_cbdb
     3spring.datasource.username=db_202324z_va_prj_cbdb_owner
     4spring.datasource.password=d922daf2bfec
     5
     6
  • src/main/resources/templates/error-page.html

    r3e572eb r501396e  
    11<!DOCTYPE html>
    2 <html lang="en">
     2<html xmlns="http://www.w3.org/1999/xhtml"
     3      xmlns:th="http://www.thymeleaf.org">
    34<head>
    4   <meta charset="UTF-8">
    5   <title>$Title$</title>
     5    <meta charset="UTF-8">
     6    <title>Home page</title>
     7    <!-- Add Bootstrap CSS link -->
     8    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    69</head>
    710<body>
    8 $END$
     11<!-- Bootstrap Navbar -->
     12<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
     13    <a class="navbar-brand" href="#">
     14        CookBook
     15    </a>
     16    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
     17        <span class="navbar-toggler-icon"></span>
     18    </button>
     19    <div class="collapse navbar-collapse" id="navbarNav">
     20        <ul class="navbar-nav ml-auto">
     21            <li class="nav-item active">
     22                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     23            </li>
     24            <li class="nav-item">
     25                <a class="nav-link" href="#">About</a>
     26            </li>
     27            <li class="nav-item">
     28                <a class="nav-link" href="#">Contact</a>
     29            </li>
     30        </ul>
     31    </div>
     32</nav>
     33
     34<div class="container mt-5">
     35    <h1>This is an error page</h1>
     36    <div th:if="${error != null}">
     37        <h5 th:text="${error}"></h5>
     38    </div>
     39
     40    <h3>Something went wrong!</h3>
     41
     42
     43</div>
     44
     45<!-- Add Bootstrap JS and Popper.js scripts (required for Bootstrap components) -->
     46<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
     47<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
     48<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    949</body>
    1050</html>
  • src/main/resources/templates/home.html

    r3e572eb r501396e  
    11<!DOCTYPE html>
    2 <html lang="en">
     2<html xmlns="http://www.w3.org/1999/xhtml"
     3      xmlns:th="http://www.thymeleaf.org">
    34<head>
    4   <meta charset="UTF-8">
    5   <title>$Title$</title>
     5    <meta charset="UTF-8">
     6    <title>Home page</title>
     7    <!-- Add Bootstrap CSS link -->
     8    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
    69</head>
    710<body>
    8 $END$
     11<!-- Bootstrap Navbar -->
     12<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
     13    <a class="navbar-brand" href="#">
     14        CookBook
     15    </a>
     16    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
     17        <span class="navbar-toggler-icon"></span>
     18    </button>
     19    <div class="collapse navbar-collapse" id="navbarNav">
     20        <ul class="navbar-nav ml-auto">
     21            <li class="nav-item active">
     22                <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     23            </li>
     24            <li class="nav-item">
     25                <a class="nav-link" href="#">About</a>
     26            </li>
     27            <li class="nav-item">
     28                <a class="nav-link" href="#">Contact</a>
     29            </li>
     30        </ul>
     31    </div>
     32</nav>
     33
     34<div class="container mt-5">
     35    <h1>This is home page</h1>
     36
     37    <table class="table">
     38        <thead>
     39        <tr>
     40            <th>Ime</th>
     41            <th>Ocena</th>
     42            <th>Action</th>
     43        </tr>
     44        </thead>
     45        <tbody>
     46        <tr th:each="recept : ${recepti}">
     47            <td><a th:href="@{'/recept/{id}' (id=${recept.recId})}" th:text="${recept.recIme}"></a></td>
     48            <td th:text="${recept.srednaOcena}"></td>
     49            <td>
     50                <button class="btn btn-primary">Edit</button>
     51                <button class="btn btn-danger">Delete</button>
     52            </td>
     53        </tr>
     54        </tbody>
     55    </table>
     56</div>
     57
     58<!-- Add Bootstrap JS and Popper.js scripts (required for Bootstrap components) -->
     59<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
     60<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
     61<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    962</body>
    1063</html>
  • src/main/resources/templates/recept.html

    r3e572eb r501396e  
    77    <!-- Add Bootstrap CSS link -->
    88    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
     9    <style>
     10        img{
     11            margin: 16px;
     12            border-style: groove;
     13        }
     14    </style>
    915</head>
    1016<body>
    1117    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    12     <a class="navbar-brand" href="#">
     18    <a class="navbar-brand" th:href="@{/}">
    1319        CookBook
    1420    </a>
     
    1925        <ul class="navbar-nav ml-auto">
    2026            <li class="nav-item active">
    21                 <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     27                <a class="nav-link" th:href="@{/}">Home <span class="sr-only">(current)</span></a>
    2228            </li>
    2329            <li class="nav-item">
     
    3137</nav>
    3238
    33     <h1 th:text="${recept.recIme}"></h1>
    34 
    35     <h4 th:text="${recept.srednaOcena}"></h4>
    36 
    37     <div th:text="${recept.postapka}"></div>
    3839
    3940
    40     <div>KOMENTARI TO DO</div>
     41    <div class="container mt-4">
     42        <h1 th:text="${recept.recIme}"></h1>
     43
     44        <h4 th:text="${recept.srednaOcena}"></h4>
     45
     46        <div class="row">
     47            <div class="col-12">
     48                <h6>Pictures</h6>
     49            </div>
     50            <div class="col-12">
     51                <img th:each="slika : ${sliki}" th:src="${slika.pic}" class="img-fluid" alt="Recipe Image" width="200px" height="200px">
     52            </div>
     53        </div>
     54
     55        <div>
     56            <h5>Состојки</h5>
     57            <div th:if="${sostojki.size() == 0}">Состојките не се додадени!</div>
     58            <ul>
     59                <li th:each="sostojka : ${sostojki}" th:text="${sostojka.sNaziv}"></li>
     60            </ul>
     61        </div>
     62
     63
     64        <div>
     65            <h5>Постапка</h5>
     66            <p class="mt-4" th:text="${recept.postapka}"></p>
     67        </div>
     68
     69
     70        <div class="mt-4">KOMENTARI TO DO</div>
     71    </div>
    4172
    4273<!-- Add Bootstrap JS and Popper.js scripts (required for Bootstrap components) -->
Note: See TracChangeset for help on using the changeset viewer.