preparations for adding camp locations
This commit is contained in:
		| @@ -109,4 +109,11 @@ public class AdminController extends CommonController { | ||||
| 		service.deleteDocument(id); | ||||
| 		return "redirect:/admin/document"; | ||||
| 	} | ||||
|  | ||||
| 	@GetMapping("/admin/location") | ||||
| 	public String getLocations(Model model, HttpServletRequest request) { | ||||
| 		super.setupSession(model, request); | ||||
| 		model.addAttribute("locations", service.getLocations()); | ||||
| 		return "/admin/location"; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import org.jooq.InsertResultStep; | ||||
| import org.jooq.InsertReturningStep; | ||||
| import org.jooq.Record5; | ||||
| import org.jooq.SelectSeekStep1; | ||||
| import org.jooq.SelectWhereStep; | ||||
| import org.jooq.UpdateConditionStep; | ||||
| import org.jooq.UpdateSetMoreStep; | ||||
| import org.jooq.exception.DataAccessException; | ||||
| @@ -242,4 +243,19 @@ public class AdminRepository { | ||||
| 		return lrw.getCounter(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * get all locations from the database | ||||
| 	 * | ||||
| 	 * @return the locations | ||||
| 	 */ | ||||
| 	public List<LocationBean> getLocations() { | ||||
| 		SelectWhereStep<TLocationRecord> sql = jooq.selectFrom(T_LOCATION); | ||||
| 		LOGGER.debug(sql.toString()); | ||||
| 		List<LocationBean> list = new ArrayList<>(); | ||||
| 		for (TLocationRecord r : sql.fetch()) { | ||||
| 			list.add(LocationBean.of(r)); | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -75,4 +75,13 @@ public class AdminService { | ||||
| 	public Integer deleteDocument(Integer id) { | ||||
| 		return adminRepository.deleteDocument(id); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * get all locations | ||||
| 	 * | ||||
| 	 * @return the locations | ||||
| 	 */ | ||||
| 	public List<LocationBean> getLocations() { | ||||
| 		return adminRepository.getLocations(); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,84 @@ | ||||
| package de.jottyfan.camporganizer.module.admin; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| import de.jottyfan.camporganizer.db.jooq.tables.records.TLocationRecord; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| public class LocationBean implements Serializable { | ||||
| 	private static final long serialVersionUID = 1L; | ||||
|  | ||||
| 	private Integer pk; | ||||
| 	private String name; | ||||
| 	private Integer fkDocument; | ||||
| 	private String url; | ||||
|  | ||||
| 	public static LocationBean of(TLocationRecord r) { | ||||
| 		LocationBean bean = new LocationBean(); | ||||
| 		bean.setPk(r.getPk()); | ||||
| 		bean.setName(r.getName()); | ||||
| 		bean.setFkDocument(r.getFkDocument()); | ||||
| 		bean.setUrl(r.getUrl()); | ||||
| 		return bean; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @return the pk | ||||
| 	 */ | ||||
| 	public Integer getPk() { | ||||
| 		return pk; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param pk the pk to set | ||||
| 	 */ | ||||
| 	public void setPk(Integer pk) { | ||||
| 		this.pk = pk; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @return the name | ||||
| 	 */ | ||||
| 	public String getName() { | ||||
| 		return name; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param name the name to set | ||||
| 	 */ | ||||
| 	public void setName(String name) { | ||||
| 		this.name = name; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @return the fkDocument | ||||
| 	 */ | ||||
| 	public Integer getFkDocument() { | ||||
| 		return fkDocument; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param fkDocument the fkDocument to set | ||||
| 	 */ | ||||
| 	public void setFkDocument(Integer fkDocument) { | ||||
| 		this.fkDocument = fkDocument; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @return the url | ||||
| 	 */ | ||||
| 	public String getUrl() { | ||||
| 		return url; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @param url the url to set | ||||
| 	 */ | ||||
| 	public void setUrl(String url) { | ||||
| 		this.url = url; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										48
									
								
								src/main/resources/templates/admin/location.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/main/resources/templates/admin/location.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| <!DOCTYPE html> | ||||
| <html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security"> | ||||
| <body> | ||||
| 	<th:block layout:fragment="header"> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('admin')"> | ||||
| 			<li class="nav-item"><a th:href="@{/rss/admin}" class="btn btn-seconary btn-icon-silent"><i class="fas fa-rss"></i></a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0"> | ||||
| 			<li class="nav-item"><a th:href="@{/dashboard}" class="btn btn-secondary btn-icon-silent">Hauptseite</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('admin')"> | ||||
| 			<li class="nav-item"><a th:href="@{/admin}" class="btn btn-secondary btn-icon-silent">Administration</a></li> | ||||
| 		</ul> | ||||
| 	</th:block> | ||||
| 	<th:block layout:fragment="content"> | ||||
| 		<div class="tablebox" sec:authorize="hasRole('admin')"> | ||||
| 			<table id="docs" class="table table-striped" style="width: 100% !important"> | ||||
| 				<thead> | ||||
| 					<tr> | ||||
| 						<td>Name</td> | ||||
| 						<td>URL</td> | ||||
| 						<td>Wegbeschreibung</td> | ||||
| 					</tr> | ||||
| 				</thead> | ||||
| 				<tbody> | ||||
| 					<tr th:each="l : ${locations}"> | ||||
| 						<td><a th:href="@{/admin/location/edit/{id}(id=${l.pk})}"><span th:text="${l.name}"></span></a></td> | ||||
| 						<td th:text="${l.url}"></td> | ||||
| 						<td><a th:href="@{/document/{id}(id=${l.fkDocument})}"><i class="fas fa-download"></i></a></td> | ||||
| 					</tr> | ||||
| 				</tbody> | ||||
| 				<tfoot> | ||||
| 					<tr> | ||||
| 						<td colspan="6" style="text-align: center"><a th:href="@{/admin/location/add}" class="btn btn-outline-primary">neues Freizeitheim anlegen</a></td> | ||||
| 					</tr> | ||||
| 				</tfoot> | ||||
| 			</table> | ||||
| 			<script> | ||||
| 				$(document).ready(function() { | ||||
| 					$("#docs").DataTable({ | ||||
| 						language : locale_de | ||||
| 					}); | ||||
| 				}); | ||||
| 			</script> | ||||
| 		</div> | ||||
| 	</th:block> | ||||
| </body> | ||||
| </html> | ||||
| @@ -18,6 +18,9 @@ | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('admin')"> | ||||
| 			<li class="nav-item"><a th:href="@{/admin/document}" class="btn btn-secondary btn-icon-silent">Dokumente</a></li> | ||||
| 		</ul> | ||||
| 		<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('admin')"> | ||||
| 		  <li class="nav-item"><a th:href="@{/admin/location}" class="btn btn-secondary btn-icon-silent">Freizeitheime</a></li> | ||||
| 		</ul> | ||||
| 	</th:block> | ||||
| 	<th:block layout:fragment="content"> | ||||
| 		<div sec:authorize="hasRole('admin')"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user