Skip to content

Commit 26c2542

Browse files
committed
8_08_bootstrap4
1 parent 643821b commit 26c2542

10 files changed

Lines changed: 97 additions & 50 deletions

File tree

config/messages/app.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
app.title=Calories management
2-
app.home=Home
3-
app.footer=Internship <a href="https://github.com/JavaOPs/topjava" target=_blank>Spring 5/JPA Enterprise (Topjava)</a> application
2+
app.footer=<a href="https://github.com/JavaOPs/topjava" target=_blank>Spring 5/JPA Enterprise (Topjava)</a> internship application
43
app.login=Login as
54

65
user.title=Users
6+
user.edit=Edit user
7+
user.add=Add user
78
user.name=Name
89
user.email=Email
910
user.roles=Roles
@@ -22,6 +23,7 @@ meal.description=Description
2223
meal.dateTime=Date/Time
2324
meal.calories=Calories
2425

26+
common.add=Add
2527
common.select=Select
2628
common.delete=Delete
2729
common.update=Update

config/messages/app_ru.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
app.title=Подсчет калорий
2-
app.home=Главная
32
app.footer=Приложение стажировки <a href="https://github.com/JavaOPs/topjava" target=_blank>Spring 5/JPA Enterprise (Topjava)</a>
43
app.login=Зайти как
54

65
user.title=Пользователи
6+
user.edit=Редактировать пользователя
7+
user.add=Добавить пользователя
78
user.name=Имя
89
user.email=Почта
910
user.roles=Роли
1011
user.active=Активный
1112
user.registered=Зарегистрирован
1213

1314
meal.title=Моя еда
14-
meal.edit=Редактирование еды
15-
meal.add=Добавление еды
15+
meal.edit=Редактировать еду
16+
meal.add=Добавить еду
1617
meal.filter=Отфильтровать
1718
meal.startDate=От даты (включая)
1819
meal.endDate=До даты (включая)
@@ -22,6 +23,7 @@ meal.description=Описание
2223
meal.dateTime=Дата/Время
2324
meal.calories=Калории
2425

26+
common.add=Добавить
2527
common.select=Выбрать
2628
common.delete=Удалить
2729
common.update=Обновить

src/main/resources/spring/spring-mvc.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<!-- all resources inside folder src/main/webapp/resources are mapped so they can be referred to inside JSP files -->
3838
<mvc:resources mapping="/resources/**" location="/resources/"/>
3939

40+
<!-- use WebJars so Javascript and CSS libs can be declared as Maven dependencies (Bootstrap, jQuery...) -->
41+
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
42+
4043
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
4144
p:prefix="/WEB-INF/jsp/"
4245
p:suffix=".jsp"/>
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<%@page contentType="text/html" pageEncoding="UTF-8" %>
22
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
33

4-
<header>
5-
<a href="meals"><spring:message code="app.title"/></a> | <a href="users"><spring:message code="user.title"/></a> | <a href="${pageContext.request.contextPath}"><spring:message code="app.home"/></a>
6-
</header>
4+
<nav class="navbar navbar-dark bg-dark py-0">
5+
<div class="container">
6+
<a href="meals" class="navbar-brand"><img src="resources/images/icon-meal.png"> <spring:message code="app.title"/></a>
7+
<form class="form-inline my-2">
8+
<a class="btn btn-info mr-1" href="users"><spring:message code="user.title"/></a>
9+
<a class="btn btn-primary" href="">
10+
<span class="fa fa-sign-in"></span>
11+
</a>
12+
</form>
13+
</div>
14+
</nav>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<%@page contentType="text/html" pageEncoding="UTF-8" %>
22
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
3-
<hr>
4-
<footer><spring:message code="app.footer"/></footer>
3+
<%--https://getbootstrap.com/docs/4.0/examples/sticky-footer/--%>
4+
<footer class="footer">
5+
<div class="container">
6+
<span class="text-muted"><spring:message code="app.footer"/></span>
7+
</div>
8+
</footer>

src/main/webapp/WEB-INF/jsp/fragments/headTag.jsp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
77
<title><spring:message code="app.title"/></title>
88
<base href="${pageContext.request.contextPath}/"/>
9-
<link rel="stylesheet" href="resources/css/style.css">
9+
10+
<link rel="stylesheet" href="resources/css/style.css?v=2">
11+
<link rel="stylesheet" href="webjars/bootstrap/4.6.2/css/bootstrap.min.css">
12+
<link rel="stylesheet" href="webjars/noty/3.1.4/demo/font-awesome/css/font-awesome.min.css">
13+
<link rel="shortcut icon" href="resources/images/icon-meal.png">
1014
</head>

src/main/webapp/WEB-INF/jsp/index.jsp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66
<jsp:include page="fragments/headTag.jsp"/>
77
<body>
88
<jsp:include page="fragments/bodyHeader.jsp"/>
9-
<br>
10-
<section>
11-
<form method="post" action="users">
12-
<spring:message code="app.login"/>: <select name="userId">
13-
<option value="100000" selected>User</option>
14-
<option value="100001">Admin</option>
15-
</select>
16-
<button type="submit"><spring:message code="common.select"/></button>
17-
</form>
18-
</section>
9+
<div class="jumbotron">
10+
<div class="container">
11+
<form method="post" action="users" class="form-inline">
12+
<label><spring:message code="app.login"/></label>
13+
<select name="userId" class="form-control mx-3">
14+
<option value="100000" selected>User</option>
15+
<option value="100001">Admin</option>
16+
</select>
17+
<button type="submit" class="btn btn-primary"><spring:message code="common.select"/></button>
18+
</form>
19+
</div>
20+
</div>
1921
<jsp:include page="fragments/footer.jsp"/>
2022
</body>
2123
</html>

src/main/webapp/WEB-INF/jsp/users.jsp

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,40 @@
88
<body>
99
<jsp:include page="fragments/bodyHeader.jsp"/>
1010

11-
<section>
12-
<h3><spring:message code="user.title"/></h3>
13-
14-
<table border="1" cellpadding="8" cellspacing="0">
15-
<thead>
16-
<tr>
17-
<th><spring:message code="user.name"/></th>
18-
<th><spring:message code="user.email"/></th>
19-
<th><spring:message code="user.roles"/></th>
20-
<th><spring:message code="user.active"/></th>
21-
<th><spring:message code="user.registered"/></th>
22-
</tr>
23-
</thead>
24-
<c:forEach items="${requestScope.users}" var="user">
25-
<jsp:useBean id="user" type="ru.javawebinar.topjava.model.User"/>
11+
<div class="jumbotron pt-4">
12+
<div class="container">
13+
<h3 class="text-center"><spring:message code="user.title"/></h3>
14+
<button class="btn btn-primary">
15+
<span class="fa fa-plus"></span>
16+
<spring:message code="common.add"/>
17+
</button>
18+
<table class="table table-striped mt-3">
19+
<thead>
2620
<tr>
27-
<td><c:out value="${user.name}"/></td>
28-
<td><a href="mailto:${user.email}">${user.email}</a></td>
29-
<td>${user.roles}</td>
30-
<td>${user.enabled}</td>
31-
<td><fmt:formatDate value="${user.registered}" pattern="dd-MM-yyyy"/></td>
21+
<th><spring:message code="user.name"/></th>
22+
<th><spring:message code="user.email"/></th>
23+
<th><spring:message code="user.roles"/></th>
24+
<th><spring:message code="user.active"/></th>
25+
<th><spring:message code="user.registered"/></th>
26+
<th></th>
27+
<th></th>
3228
</tr>
33-
</c:forEach>
34-
</table>
35-
</section>
29+
</thead>
30+
<c:forEach items="${requestScope.users}" var="user">
31+
<jsp:useBean id="user" type="ru.javawebinar.topjava.model.User"/>
32+
<tr>
33+
<td><c:out value="${user.name}"/></td>
34+
<td><a href="mailto:${user.email}">${user.email}</a></td>
35+
<td>${user.roles}</td>
36+
<td><input type="checkbox" <c:if test="${user.enabled}">checked</c:if>/></td>
37+
<td><fmt:formatDate value="${user.registered}" pattern="dd-MMMM-yyyy"/></td>
38+
<td><a><span class="fa fa-pencil"></span></a></td>
39+
<td><a><span class="fa fa-remove"></span></a></td>
40+
</tr>
41+
</c:forEach>
42+
</table>
43+
</div>
44+
</div>
3645
<jsp:include page="fragments/footer.jsp"/>
3746
</body>
3847
</html>

src/main/webapp/resources/css/style.css

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,23 @@ tr[data-meal-excess="true"] {
2323
color: red;
2424
}
2525

26-
header, footer {
27-
background: none repeat scroll 0 0 #A6C9E2;
28-
color: #2E6E9E;
29-
font-size: 20px;
30-
padding: 5px 20px;
31-
margin: 6px 0;
26+
.fa {
27+
cursor: pointer;
28+
}
29+
30+
/*https://getbootstrap.com/docs/4.0/examples/sticky-footer/sticky-footer.css*/
31+
html {
32+
position: relative;
33+
min-height: 100%;
34+
}
35+
body {
36+
margin-bottom: 60px !important; /* Margin bottom by footer height */
37+
}
38+
.footer {
39+
position: absolute;
40+
bottom: 0;
41+
width: 100%;
42+
height: 60px; /* Set the fixed height of the footer here */
43+
line-height: 60px; /* Vertically center the text there */
44+
background-color: #f5f5f5;
3245
}
2.2 KB
Loading

0 commit comments

Comments
 (0)