preparations for adding camp locations

This commit is contained in:
Jörg Henke 2023-03-10 23:37:44 +01:00
parent 27ee382f4a
commit b3a186f5ca
9 changed files with 192 additions and 8 deletions

View File

@ -1,2 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir= connection.project.dir=
eclipse.preferences.version=1 eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=false
show.console.view=false
show.executions.view=false

View File

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="CampOrganizer2"> <wb-module deploy-name="CampOrganizer2">
<property name="context-root" value="CampOrganizer2"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/> <property name="context-root" value="CampOrganizer2"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
</wb-module> <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
</wb-module>
</project-modules> </project-modules>

View File

@ -18,7 +18,7 @@ apply plugin: 'war'
apply plugin: 'application' apply plugin: 'application'
group = 'de.jottyfan.camporganizer' group = 'de.jottyfan.camporganizer'
version = '0.3.0' version = '0.3.1'
sourceCompatibility = 17 sourceCompatibility = 17
mainClassName = "de.jottyfan.camporganizer.Main" mainClassName = "de.jottyfan.camporganizer.Main"

View File

@ -109,4 +109,11 @@ public class AdminController extends CommonController {
service.deleteDocument(id); service.deleteDocument(id);
return "redirect:/admin/document"; 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";
}
} }

View File

@ -20,6 +20,7 @@ import org.jooq.InsertResultStep;
import org.jooq.InsertReturningStep; import org.jooq.InsertReturningStep;
import org.jooq.Record5; import org.jooq.Record5;
import org.jooq.SelectSeekStep1; import org.jooq.SelectSeekStep1;
import org.jooq.SelectWhereStep;
import org.jooq.UpdateConditionStep; import org.jooq.UpdateConditionStep;
import org.jooq.UpdateSetMoreStep; import org.jooq.UpdateSetMoreStep;
import org.jooq.exception.DataAccessException; import org.jooq.exception.DataAccessException;
@ -242,4 +243,19 @@ public class AdminRepository {
return lrw.getCounter(); 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;
}
} }

View File

@ -75,4 +75,13 @@ public class AdminService {
public Integer deleteDocument(Integer id) { public Integer deleteDocument(Integer id) {
return adminRepository.deleteDocument(id); return adminRepository.deleteDocument(id);
} }
/**
* get all locations
*
* @return the locations
*/
public List<LocationBean> getLocations() {
return adminRepository.getLocations();
}
} }

View File

@ -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;
}
}

View 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>

View File

@ -18,6 +18,9 @@
<ul class="navbar-nav mb-2 mb-lg-0" sec:authorize="hasRole('admin')"> <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> <li class="nav-item"><a th:href="@{/admin/document}" class="btn btn-secondary btn-icon-silent">Dokumente</a></li>
</ul> </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>
<th:block layout:fragment="content"> <th:block layout:fragment="content">
<div sec:authorize="hasRole('admin')"> <div sec:authorize="hasRole('admin')">