From 98b3f9d804c65881bd817de5d0144edaa5c97dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Henke?= Date: Fri, 1 Jul 2022 18:13:18 +0200 Subject: [PATCH] further processing --- .settings/org.eclipse.buildship.core.prefs | 11 +++ .../timetrack/spring/done/DoneBean.java | 18 +++++ .../timetrack/spring/done/DoneController.java | 1 + .../timetrack/spring/done/SummaryBean.java | 69 +++++++++++++++++++ .../spring/done/impl/DoneGateway.java | 56 +++++++++++---- .../spring/done/impl/DoneService.java | 8 +-- src/main/resources/static/css/style.css | 54 +++++++++++++++ .../resources/templates/contact/list.html | 2 +- src/main/resources/templates/done/list.html | 33 ++++++--- src/main/resources/templates/note/list.html | 2 +- 10 files changed, 223 insertions(+), 31 deletions(-) create mode 100644 src/main/java/de/jottyfan/timetrack/spring/done/SummaryBean.java diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index e889521..e479558 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,13 @@ +arguments= +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= 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 diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java b/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java index f380e1c..cf8cecf 100644 --- a/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java +++ b/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java @@ -106,6 +106,24 @@ public class DoneBean implements Serializable, Comparable { return o == null || timeFrom == null || o.getTimeFrom() == null ? 0 : timeFrom.compareTo(o.getTimeFrom()); } + public String getTimeNote() { + LocalDateTime earlier = timeFrom != null ? timeFrom : LocalDateTime.now(); + LocalDateTime later = timeUntil != null ? timeUntil : LocalDateTime.now(); + StringBuilder buf = new StringBuilder(); + if (timeFrom == null) { + buf.append(" "); + } else { + buf.append(String.format("%02d:%02d", earlier.getHour(), earlier.getMinute() % 60)); + } + buf.append(" - "); + if (timeUntil == null) { + buf.append(" "); + } else { + buf.append(String.format("%02d:%02d", later.getHour(), later.getMinute() % 60)); + } + return buf.toString(); + } + public String getTimeDiff() { LocalDateTime earlier = timeFrom != null ? timeFrom : LocalDateTime.now(); LocalDateTime later = timeUntil != null ? timeUntil : LocalDateTime.now(); diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java b/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java index 59359cb..11d8a11 100644 --- a/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java +++ b/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java @@ -42,6 +42,7 @@ public class DoneController { List list = doneService.getList(doneModel.getDay(), username); model.addAttribute("doneList", list); model.addAttribute("doneModel", doneModel); + model.addAttribute("sum", new SummaryBean(list)); model.addAttribute("projectList", doneService.getProjects()); model.addAttribute("moduleList", doneService.getModules()); model.addAttribute("jobList", doneService.getJobs()); diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/SummaryBean.java b/src/main/java/de/jottyfan/timetrack/spring/done/SummaryBean.java new file mode 100644 index 0000000..7259204 --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/spring/done/SummaryBean.java @@ -0,0 +1,69 @@ +package de.jottyfan.timetrack.spring.done; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.List; + +/** + * + * @author henkej + * + */ +public class SummaryBean implements Serializable { + private static final long serialVersionUID = 1L; + + private final List list; + + public SummaryBean(List list) { + this.list = list; + } + + /** + * @return the start + */ + public String getStart() { + LocalDateTime found = LocalDateTime.now(); + for (DoneBean bean : list) { + LocalDateTime ldt = bean.getTimeFrom(); + if (ldt != null && ldt.isBefore(found)) { + found = ldt; + } + } + return String.format("%02d:%02d", found.getHour(), found.getMinute() % 60); + } + + /** + * @return the end + */ + public String getEnd() { + LocalDateTime found = LocalDateTime.now(); + for (DoneBean bean : list) { + LocalDateTime ldt = bean.getTimeUntil(); + if (ldt != null && found.isBefore(ldt)) { + found = ldt; + } + } + return String.format("%02d:%02d", found.getHour(), found.getMinute() % 60); + } + + /** + * @return the total + */ + public String getTotal() { + return "TODO"; + } + + /** + * @return the pause + */ + public String getPause() { + return "TODO"; + } + + /** + * @return the overdue + */ + public String getOverdue() { + return "TODO"; + } +} diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneGateway.java b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneGateway.java index 19ca296..d077d0a 100644 --- a/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneGateway.java +++ b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneGateway.java @@ -68,53 +68,81 @@ public class DoneGateway { /** * get all projects from the database * + * @param includeNull if true, add a null value at the beginning of the result + * * @return a list of found projects * * @throws DataAccessException * @throws ClassNotFoundException * @throws SQLException */ - public List getAllProjects() throws DataAccessException, ClassNotFoundException, SQLException { - return getJooq().selectFrom(T_PROJECT).orderBy(T_PROJECT.NAME).fetchInto(TProjectRecord.class); + public List getAllProjects(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { + List list = new ArrayList<>(); + if (includeNull) { + list.add(new TProjectRecord(null, null, "---")); + } + list.addAll(getJooq().selectFrom(T_PROJECT).orderBy(T_PROJECT.NAME).fetchInto(TProjectRecord.class)); + return list; } /** * get all modules from the database * + * @param includeNull if true, add a null value at the beginning of the result + * * @return a list of found modules * * @throws DataAccessException * @throws ClassNotFoundException * @throws SQLException */ - public List getAllModules() throws DataAccessException, ClassNotFoundException, SQLException { - return getJooq().selectFrom(T_MODULE).orderBy(T_MODULE.NAME).fetchInto(TModuleRecord.class); + public List getAllModules(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { + List list = new ArrayList<>(); + if (includeNull) { + list.add(new TModuleRecord(null, null, "---")); + } + list.addAll(getJooq().selectFrom(T_MODULE).orderBy(T_MODULE.NAME).fetchInto(TModuleRecord.class)); + return list; } /** * get all jobs from the database * + * @param includeNull if true, add a null value at the beginning of the result + * * @return a list of found jobs * * @throws DataAccessException * @throws ClassNotFoundException * @throws SQLException */ - public List getAllJobs() throws DataAccessException, ClassNotFoundException, SQLException { - return getJooq().selectFrom(T_JOB).orderBy(T_JOB.NAME).fetchInto(TJobRecord.class); + public List getAllJobs(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { + List list = new ArrayList<>(); + if (includeNull) { + list.add(new TJobRecord(null, null, "---")); + } + list.addAll(getJooq().selectFrom(T_JOB).orderBy(T_JOB.NAME).fetchInto(TJobRecord.class)); + return list; } /** * get all billings from the database * + * @param includeNull if true, add a null value at the beginning of the result + * * @return a list of found billings * * @throws DataAccessException * @throws ClassNotFoundException * @throws SQLException */ - public List getAllBillings() throws DataAccessException, ClassNotFoundException, SQLException { - return getJooq().selectFrom(T_BILLING).orderBy(T_BILLING.NAME).fetchInto(TBillingRecord.class); + public List getAllBillings(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { + List list = new ArrayList<>(); + if (includeNull) { + list.add(new TBillingRecord(null, null, "---", null, null)); + } + list.addAll(getJooq().selectFrom(T_BILLING).orderBy(T_BILLING.NAME).fetchInto(TBillingRecord.class)); + return list; } /** @@ -128,7 +156,7 @@ public class DoneGateway { private Map getProjectMap() throws DataAccessException, ClassNotFoundException, SQLException { Map map = new HashMap<>(); - for (TProjectRecord r : getAllProjects()) { + for (TProjectRecord r : getAllProjects(false)) { map.put(r.getPk(), r); } return map; @@ -144,7 +172,7 @@ public class DoneGateway { */ private Map getModuleMap() throws DataAccessException, ClassNotFoundException, SQLException { Map map = new HashMap<>(); - for (TModuleRecord r : getAllModules()) { + for (TModuleRecord r : getAllModules(false)) { map.put(r.getPk(), r); } return map; @@ -160,7 +188,7 @@ public class DoneGateway { */ private Map getJobMap() throws DataAccessException, ClassNotFoundException, SQLException { Map map = new HashMap<>(); - for (TJobRecord r : getAllJobs()) { + for (TJobRecord r : getAllJobs(false)) { map.put(r.getPk(), r); } return map; @@ -177,7 +205,7 @@ public class DoneGateway { private Map getBillingMap() throws DataAccessException, ClassNotFoundException, SQLException { Map map = new HashMap<>(); - for (TBillingRecord r : getAllBillings()) { + for (TBillingRecord r : getAllBillings(false)) { map.put(r.getPk(), r); } return map; @@ -207,8 +235,8 @@ public class DoneGateway { T_DONE.FK_JOB, T_DONE.FK_BILLING) .from(T_DONE) - .where(T_DONE.TIME_FROM.between(dayStart, dayEnd)) - .and(T_DONE.TIME_UNTIL.between(dayStart, dayEnd)) + .where(T_DONE.TIME_FROM.between(dayStart, dayEnd).or(T_DONE.TIME_FROM.isNull())) + .and(T_DONE.TIME_UNTIL.between(dayStart, dayEnd).or(T_DONE.TIME_UNTIL.isNull())) .and(T_DONE.FK_LOGIN.eq(userId == null ? -999999 : userId)); // @formatter:on LOGGER.debug("{}", sql.toString()); diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java index ac4b15d..7259263 100644 --- a/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java +++ b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java @@ -70,7 +70,7 @@ public class DoneService implements IDoneService { @Override public List getProjects() { try { - return new DoneGateway(dsl).getAllProjects(); + return new DoneGateway(dsl).getAllProjects(true); } catch (Exception e) { LOGGER.error(e); return new ArrayList<>(); @@ -80,7 +80,7 @@ public class DoneService implements IDoneService { @Override public List getModules() { try { - return new DoneGateway(dsl).getAllModules(); + return new DoneGateway(dsl).getAllModules(true); } catch (Exception e) { LOGGER.error(e); return new ArrayList<>(); @@ -90,7 +90,7 @@ public class DoneService implements IDoneService { @Override public List getJobs() { try { - return new DoneGateway(dsl).getAllJobs(); + return new DoneGateway(dsl).getAllJobs(true); } catch (Exception e) { LOGGER.error(e); return new ArrayList<>(); @@ -100,7 +100,7 @@ public class DoneService implements IDoneService { @Override public List getBillings() { try { - return new DoneGateway(dsl).getAllBillings(); + return new DoneGateway(dsl).getAllBillings(true); } catch (Exception e) { LOGGER.error(e); return new ArrayList<>(); diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index ad33dc1..9bad7ec 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -163,3 +163,57 @@ body { .fc-content { cursor: pointer; } + +.btn-white-text { + color: white !important; + font-weight: bolder; +} + +.hoverlink { + text-decoration: none; + color: black; +} + +.hoverlink:hover { + color: #1a5f64; +} + +.boldtext { + font-weight: bolder; +} + +.emphgreen { + font-weight: bolder; + color: #136600; + border: 1px solid gray; + border-radius: 8px; + background-image: linear-gradient(to left, #e6e6e6, white); + padding: 4px; +} + +.emphblue { + font-weight: bolder; + color: #1a5fb4; + border: 1px solid gray; + border-radius: 8px; + background-image: linear-gradient(to left, #e6e6e6, white); + padding: 4px; +} + +.emphorange { + font-weight: bolder; + color: #c64600; + border: 1px solid gray; + border-radius: 8px; + background-image: linear-gradient(to left, #e6e6e6, white); + padding: 4px; +} + +.emphred { + font-weight: bolder; + color: #a51d2d; + border: 1px solid gray; + border-radius: 8px; + background-image: linear-gradient(to left, #e6e6e6, white); + padding: 4px; +} \ No newline at end of file diff --git a/src/main/resources/templates/contact/list.html b/src/main/resources/templates/contact/list.html index f5d31d1..f766cfc 100644 --- a/src/main/resources/templates/contact/list.html +++ b/src/main/resources/templates/contact/list.html @@ -7,7 +7,7 @@ Kontakte
diff --git a/src/main/resources/templates/done/list.html b/src/main/resources/templates/done/list.html index 952fae8..f0aed67 100644 --- a/src/main/resources/templates/done/list.html +++ b/src/main/resources/templates/done/list.html @@ -9,7 +9,7 @@
@@ -38,25 +38,36 @@ - - + + + - - - - - - + + + + + + + + + + + + + + + + +
VonBisZeit Projekt Modul Aufgabe AbrechnungDauer
ZusammenfassungStart: Ende: Arbeitszeit total: Pausezeit total: Überstunden:
Zusammenfassung
diff --git a/src/main/resources/templates/note/list.html b/src/main/resources/templates/note/list.html index bc43d7e..3cb4e1c 100644 --- a/src/main/resources/templates/note/list.html +++ b/src/main/resources/templates/note/list.html @@ -7,7 +7,7 @@ Notizen