added percent usage

This commit is contained in:
Jörg Henke
2022-07-05 22:00:41 +02:00
parent a0e1aaa990
commit d3a2b11f86
6 changed files with 92 additions and 84 deletions

View File

@ -18,7 +18,7 @@ targetCompatibility = 11
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { url "https://www.jottyfan.de/mvnrepo" } maven { url "https://www.jottyfan.de/libs" }
maven { url "https://repo.maven.apache.org/maven2" } maven { url "https://repo.maven.apache.org/maven2" }
// maven { url "https://gitlab.com/jottyfan/libs/-/raw/main" } // maven { url "https://gitlab.com/jottyfan/libs/-/raw/main" }
} }
@ -50,7 +50,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
implementation 'de.jottyfan:timetrackjooq:0.1.0' implementation 'de.jottyfan:timetrackjooq:0.1.1'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0' implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0'

View File

@ -9,11 +9,11 @@ import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import de.jottyfan.timetrack.db.done.tables.records.TBillingRecord; import de.jottyfan.timetrack.db.done.tables.records.VBillingRecord;
import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord; import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord;
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord; import de.jottyfan.timetrack.db.done.tables.records.VJobRecord;
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord; import de.jottyfan.timetrack.db.done.tables.records.VModuleRecord;
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord; import de.jottyfan.timetrack.db.done.tables.records.VProjectRecord;
/** /**
* *
@ -29,10 +29,10 @@ public class DoneBean implements Serializable, Comparable<DoneBean> {
private LocalDate day; private LocalDate day;
private LocalDateTime timeFrom; private LocalDateTime timeFrom;
private LocalDateTime timeUntil; private LocalDateTime timeUntil;
private TProjectRecord project; private VProjectRecord project;
private TModuleRecord module; private VModuleRecord module;
private TJobRecord activity; private VJobRecord activity;
private TBillingRecord billing; private VBillingRecord billing;
private Integer fkProject; private Integer fkProject;
private Integer fkModule; private Integer fkModule;
private Integer fkJob; private Integer fkJob;
@ -42,8 +42,8 @@ public class DoneBean implements Serializable, Comparable<DoneBean> {
this.day = null; this.day = null;
} }
public DoneBean(TDoneRecord r, Map<Integer, TProjectRecord> projectMap, Map<Integer, TModuleRecord> moduleMap, public DoneBean(TDoneRecord r, Map<Integer, VProjectRecord> projectMap, Map<Integer, VModuleRecord> moduleMap,
Map<Integer, TJobRecord> jobMap, Map<Integer, TBillingRecord> billingMap) { Map<Integer, VJobRecord> jobMap, Map<Integer, VBillingRecord> billingMap) {
this.pk = r.getPk(); this.pk = r.getPk();
this.day = r.getTimeFrom() != null ? r.getTimeFrom().toLocalDate() : (r.getTimeUntil() == null ? r.getTimeUntil().toLocalDate() : LocalDate.now()); this.day = r.getTimeFrom() != null ? r.getTimeFrom().toLocalDate() : (r.getTimeUntil() == null ? r.getTimeUntil().toLocalDate() : LocalDate.now());
this.timeFrom = r.getTimeFrom(); this.timeFrom = r.getTimeFrom();
@ -260,29 +260,29 @@ public class DoneBean implements Serializable, Comparable<DoneBean> {
this.timeUntil = timeUntil; this.timeUntil = timeUntil;
} }
public TProjectRecord getProject() { public VProjectRecord getProject() {
return project; return project;
} }
public void setProject(TProjectRecord project) { public void setProject(VProjectRecord project) {
this.project = project; this.project = project;
this.fkProject = project != null ? project.getPk() : null; this.fkProject = project != null ? project.getPk() : null;
} }
public TModuleRecord getModule() { public VModuleRecord getModule() {
return module; return module;
} }
public void setModule(TModuleRecord module) { public void setModule(VModuleRecord module) {
this.module = module; this.module = module;
this.fkModule = module != null ? module.getPk() : null; this.fkModule = module != null ? module.getPk() : null;
} }
public TJobRecord getActivity() { public VJobRecord getActivity() {
return activity; return activity;
} }
public void setActivity(TJobRecord activity) { public void setActivity(VJobRecord activity) {
this.activity = activity; this.activity = activity;
this.fkJob = activity != null ? activity.getPk() : null; this.fkJob = activity != null ? activity.getPk() : null;
} }
@ -290,14 +290,14 @@ public class DoneBean implements Serializable, Comparable<DoneBean> {
/** /**
* @return the billing * @return the billing
*/ */
public TBillingRecord getBilling() { public VBillingRecord getBilling() {
return billing; return billing;
} }
/** /**
* @param billing the billing to set * @param billing the billing to set
*/ */
public void setBilling(TBillingRecord billing) { public void setBilling(VBillingRecord billing) {
this.billing = billing; this.billing = billing;
this.fkBilling = billing != null ? billing.getPk() : null; this.fkBilling = billing != null ? billing.getPk() : null;
} }

View File

@ -5,10 +5,10 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import de.jottyfan.timetrack.db.done.tables.records.TBillingRecord; import de.jottyfan.timetrack.db.done.tables.records.VBillingRecord;
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord; import de.jottyfan.timetrack.db.done.tables.records.VJobRecord;
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord; import de.jottyfan.timetrack.db.done.tables.records.VModuleRecord;
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord; import de.jottyfan.timetrack.db.done.tables.records.VProjectRecord;
/** /**
* *
@ -22,13 +22,13 @@ public interface IDoneService {
public String getCurrentUser(HttpServletRequest request); public String getCurrentUser(HttpServletRequest request);
public List<TProjectRecord> getProjects(boolean includeNull); public List<VProjectRecord> getProjects(boolean includeNull);
public List<TModuleRecord> getModules(boolean includeNull); public List<VModuleRecord> getModules(boolean includeNull);
public List<TJobRecord> getJobs(boolean includeNull); public List<VJobRecord> getJobs(boolean includeNull);
public List<TBillingRecord> getBillings(boolean includeNull); public List<VBillingRecord> getBillings(boolean includeNull);
public Integer doUpsert(DoneBean bean, String username); public Integer doUpsert(DoneBean bean, String username);

View File

@ -6,6 +6,10 @@ import static de.jottyfan.timetrack.db.done.Tables.T_JOB;
import static de.jottyfan.timetrack.db.done.Tables.T_MODULE; import static de.jottyfan.timetrack.db.done.Tables.T_MODULE;
import static de.jottyfan.timetrack.db.done.Tables.T_PROJECT; import static de.jottyfan.timetrack.db.done.Tables.T_PROJECT;
import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN; import static de.jottyfan.timetrack.db.profile.Tables.T_LOGIN;
import static de.jottyfan.timetrack.db.done.Tables.V_BILLING;
import static de.jottyfan.timetrack.db.done.Tables.V_JOB;
import static de.jottyfan.timetrack.db.done.Tables.V_MODULE;
import static de.jottyfan.timetrack.db.done.Tables.V_PROJECT;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
@ -28,11 +32,11 @@ import org.jooq.exception.DataAccessException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import de.jottyfan.timetrack.db.done.tables.records.TBillingRecord; import de.jottyfan.timetrack.db.done.tables.records.VBillingRecord;
import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord; import de.jottyfan.timetrack.db.done.tables.records.TDoneRecord;
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord; import de.jottyfan.timetrack.db.done.tables.records.VJobRecord;
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord; import de.jottyfan.timetrack.db.done.tables.records.VModuleRecord;
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord; import de.jottyfan.timetrack.db.done.tables.records.VProjectRecord;
import de.jottyfan.timetrack.db.profile.tables.records.TLoginRecord; import de.jottyfan.timetrack.db.profile.tables.records.TLoginRecord;
import de.jottyfan.timetrack.spring.done.DoneBean; import de.jottyfan.timetrack.spring.done.DoneBean;
@ -76,12 +80,13 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws SQLException * @throws SQLException
*/ */
public List<TProjectRecord> getAllProjects(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { public List<VProjectRecord> getAllProjects(boolean includeNull)
List<TProjectRecord> list = new ArrayList<>(); throws DataAccessException, ClassNotFoundException, SQLException {
List<VProjectRecord> list = new ArrayList<>();
if (includeNull) { if (includeNull) {
list.add(new TProjectRecord(null, null, "---")); list.add(new VProjectRecord());
} }
list.addAll(getJooq().selectFrom(T_PROJECT).orderBy(T_PROJECT.NAME).fetchInto(TProjectRecord.class)); list.addAll(getJooq().selectFrom(V_PROJECT).orderBy(V_PROJECT.NAME).fetchInto(VProjectRecord.class));
return list; return list;
} }
@ -96,12 +101,13 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws SQLException * @throws SQLException
*/ */
public List<TModuleRecord> getAllModules(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { public List<VModuleRecord> getAllModules(boolean includeNull)
List<TModuleRecord> list = new ArrayList<>(); throws DataAccessException, ClassNotFoundException, SQLException {
List<VModuleRecord> list = new ArrayList<>();
if (includeNull) { if (includeNull) {
list.add(new TModuleRecord(null, null, "---")); list.add(new VModuleRecord());
} }
list.addAll(getJooq().selectFrom(T_MODULE).orderBy(T_MODULE.NAME).fetchInto(TModuleRecord.class)); list.addAll(getJooq().selectFrom(T_MODULE).orderBy(T_MODULE.NAME).fetchInto(VModuleRecord.class));
return list; return list;
} }
@ -116,12 +122,13 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws SQLException * @throws SQLException
*/ */
public List<TJobRecord> getAllJobs(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { public List<VJobRecord> getAllJobs(boolean includeNull)
List<TJobRecord> list = new ArrayList<>(); throws DataAccessException, ClassNotFoundException, SQLException {
List<VJobRecord> list = new ArrayList<>();
if (includeNull) { if (includeNull) {
list.add(new TJobRecord(null, null, "---")); list.add(new VJobRecord());
} }
list.addAll(getJooq().selectFrom(T_JOB).orderBy(T_JOB.NAME).fetchInto(TJobRecord.class)); list.addAll(getJooq().selectFrom(T_JOB).orderBy(T_JOB.NAME).fetchInto(VJobRecord.class));
return list; return list;
} }
@ -136,12 +143,13 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws SQLException * @throws SQLException
*/ */
public List<TBillingRecord> getAllBillings(boolean includeNull) throws DataAccessException, ClassNotFoundException, SQLException { public List<VBillingRecord> getAllBillings(boolean includeNull)
List<TBillingRecord> list = new ArrayList<>(); throws DataAccessException, ClassNotFoundException, SQLException {
List<VBillingRecord> list = new ArrayList<>();
if (includeNull) { if (includeNull) {
list.add(new TBillingRecord(null, null, "---", null, null)); list.add(new VBillingRecord(null, null, "---", null, null));
} }
list.addAll(getJooq().selectFrom(T_BILLING).orderBy(T_BILLING.NAME).fetchInto(TBillingRecord.class)); list.addAll(getJooq().selectFrom(T_BILLING).orderBy(T_BILLING.NAME).fetchInto(VBillingRecord.class));
return list; return list;
} }
@ -153,10 +161,10 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @throws DataAccessException
*/ */
private Map<Integer, TProjectRecord> getProjectMap() private Map<Integer, VProjectRecord> getProjectMap()
throws DataAccessException, ClassNotFoundException, SQLException { throws DataAccessException, ClassNotFoundException, SQLException {
Map<Integer, TProjectRecord> map = new HashMap<>(); Map<Integer, VProjectRecord> map = new HashMap<>();
for (TProjectRecord r : getAllProjects(false)) { for (VProjectRecord r : getAllProjects(false)) {
map.put(r.getPk(), r); map.put(r.getPk(), r);
} }
return map; return map;
@ -170,9 +178,9 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @throws DataAccessException
*/ */
private Map<Integer, TModuleRecord> getModuleMap() throws DataAccessException, ClassNotFoundException, SQLException { private Map<Integer, VModuleRecord> getModuleMap() throws DataAccessException, ClassNotFoundException, SQLException {
Map<Integer, TModuleRecord> map = new HashMap<>(); Map<Integer, VModuleRecord> map = new HashMap<>();
for (TModuleRecord r : getAllModules(false)) { for (VModuleRecord r : getAllModules(false)) {
map.put(r.getPk(), r); map.put(r.getPk(), r);
} }
return map; return map;
@ -186,9 +194,9 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @throws DataAccessException
*/ */
private Map<Integer, TJobRecord> getJobMap() throws DataAccessException, ClassNotFoundException, SQLException { private Map<Integer, VJobRecord> getJobMap() throws DataAccessException, ClassNotFoundException, SQLException {
Map<Integer, TJobRecord> map = new HashMap<>(); Map<Integer, VJobRecord> map = new HashMap<>();
for (TJobRecord r : getAllJobs(false)) { for (VJobRecord r : getAllJobs(false)) {
map.put(r.getPk(), r); map.put(r.getPk(), r);
} }
return map; return map;
@ -202,10 +210,10 @@ public class DoneGateway {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* @throws DataAccessException * @throws DataAccessException
*/ */
private Map<Integer, TBillingRecord> getBillingMap() private Map<Integer, VBillingRecord> getBillingMap()
throws DataAccessException, ClassNotFoundException, SQLException { throws DataAccessException, ClassNotFoundException, SQLException {
Map<Integer, TBillingRecord> map = new HashMap<>(); Map<Integer, VBillingRecord> map = new HashMap<>();
for (TBillingRecord r : getAllBillings(false)) { for (VBillingRecord r : getAllBillings(false)) {
map.put(r.getPk(), r); map.put(r.getPk(), r);
} }
return map; return map;
@ -241,10 +249,10 @@ public class DoneGateway {
// @formatter:on // @formatter:on
LOGGER.debug("{}", sql.toString()); LOGGER.debug("{}", sql.toString());
List<DoneBean> list = new ArrayList<>(); List<DoneBean> list = new ArrayList<>();
Map<Integer, TProjectRecord> projectMap = getProjectMap(); Map<Integer, VProjectRecord> projectMap = getProjectMap();
Map<Integer, TModuleRecord> moduleMap = getModuleMap(); Map<Integer, VModuleRecord> moduleMap = getModuleMap();
Map<Integer, TJobRecord> jobMap = getJobMap(); Map<Integer, VJobRecord> jobMap = getJobMap();
Map<Integer, TBillingRecord> billingMap = getBillingMap(); Map<Integer, VBillingRecord> billingMap = getBillingMap();
for (Record7<Integer, LocalDateTime, LocalDateTime, Integer, Integer, Integer, Integer> r : sql.fetch()) { for (Record7<Integer, LocalDateTime, LocalDateTime, Integer, Integer, Integer, Integer> r : sql.fetch()) {
DoneBean bean = new DoneBean(); DoneBean bean = new DoneBean();
bean.setPk(r.get(T_DONE.PK)); bean.setPk(r.get(T_DONE.PK));
@ -303,10 +311,10 @@ public class DoneGateway {
.where(T_DONE.PK.eq(pk)); .where(T_DONE.PK.eq(pk));
// @formatter:on // @formatter:on
LOGGER.debug("{}", sql.toString()); LOGGER.debug("{}", sql.toString());
Map<Integer, TProjectRecord> projectMap = getProjectMap(); Map<Integer, VProjectRecord> projectMap = getProjectMap();
Map<Integer, TModuleRecord> moduleMap = getModuleMap(); Map<Integer, VModuleRecord> moduleMap = getModuleMap();
Map<Integer, TJobRecord> jobMap = getJobMap(); Map<Integer, VJobRecord> jobMap = getJobMap();
Map<Integer, TBillingRecord> billingMap = getBillingMap(); Map<Integer, VBillingRecord> billingMap = getBillingMap();
for (Record7<Integer, LocalDateTime, LocalDateTime, Integer, Integer, Integer, Integer> r : sql.fetch()) { for (Record7<Integer, LocalDateTime, LocalDateTime, Integer, Integer, Integer, Integer> r : sql.fetch()) {
DoneBean bean = new DoneBean(); DoneBean bean = new DoneBean();
bean.setPk(r.get(T_DONE.PK)); bean.setPk(r.get(T_DONE.PK));

View File

@ -14,10 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import de.jottyfan.timetrack.db.done.tables.records.TBillingRecord; import de.jottyfan.timetrack.db.done.tables.records.VBillingRecord;
import de.jottyfan.timetrack.db.done.tables.records.TJobRecord; import de.jottyfan.timetrack.db.done.tables.records.VJobRecord;
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord; import de.jottyfan.timetrack.db.done.tables.records.VModuleRecord;
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord; import de.jottyfan.timetrack.db.done.tables.records.VProjectRecord;
import de.jottyfan.timetrack.spring.done.DoneBean; import de.jottyfan.timetrack.spring.done.DoneBean;
import de.jottyfan.timetrack.spring.done.IDoneService; import de.jottyfan.timetrack.spring.done.IDoneService;
import de.jottyfan.timetrack.spring.note.impl.NoteService; import de.jottyfan.timetrack.spring.note.impl.NoteService;
@ -68,7 +68,7 @@ public class DoneService implements IDoneService {
} }
@Override @Override
public List<TProjectRecord> getProjects(boolean includeNull) { public List<VProjectRecord> getProjects(boolean includeNull) {
try { try {
return new DoneGateway(dsl).getAllProjects(includeNull); return new DoneGateway(dsl).getAllProjects(includeNull);
} catch (Exception e) { } catch (Exception e) {
@ -78,7 +78,7 @@ public class DoneService implements IDoneService {
} }
@Override @Override
public List<TModuleRecord> getModules(boolean includeNull) { public List<VModuleRecord> getModules(boolean includeNull) {
try { try {
return new DoneGateway(dsl).getAllModules(includeNull); return new DoneGateway(dsl).getAllModules(includeNull);
} catch (Exception e) { } catch (Exception e) {
@ -88,7 +88,7 @@ public class DoneService implements IDoneService {
} }
@Override @Override
public List<TJobRecord> getJobs(boolean includeNull) { public List<VJobRecord> getJobs(boolean includeNull) {
try { try {
return new DoneGateway(dsl).getAllJobs(includeNull); return new DoneGateway(dsl).getAllJobs(includeNull);
} catch (Exception e) { } catch (Exception e) {
@ -98,7 +98,7 @@ public class DoneService implements IDoneService {
} }
@Override @Override
public List<TBillingRecord> getBillings(boolean includeNull) { public List<VBillingRecord> getBillings(boolean includeNull) {
try { try {
return new DoneGateway(dsl).getAllBillings(includeNull); return new DoneGateway(dsl).getAllBillings(includeNull);
} catch (Exception e) { } catch (Exception e) {

View File

@ -78,13 +78,13 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Benutzt</th> <th>Benutzt in %</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="project : ${projectList}"> <tr th:each="project : ${projectList}">
<td><span th:text="${project.name}"></span></td> <td><span th:text="${project.name}"></span></td>
<td>TODO</td> <td><span th:text="${project.percentUsage}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -94,13 +94,13 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Benutzt</th> <th>Benutzt in %</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="module : ${moduleList}"> <tr th:each="module : ${moduleList}">
<td><span th:text="${module.name}"></span></td> <td><span th:text="${module.name}"></span></td>
<td>TODO</td> <td><span th:text="${module.percentUsage}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -110,13 +110,13 @@
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Benutzt</th> <th>Benutzt in %</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="job : ${jobList}"> <tr th:each="job : ${jobList}">
<td><span th:text="${job.name}"></span></td> <td><span th:text="${job.name}"></span></td>
<td>TODO</td> <td><span th:text="${job.percentUsage}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -127,14 +127,14 @@
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Symbol</th> <th>Symbol</th>
<th>Benutzt</th> <th>Benutzt in %</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="billing : ${billingList}"> <tr th:each="billing : ${billingList}">
<td><span th:text="${billing.name}"></span></td> <td><span th:text="${billing.name}"></span></td>
<td><span th:text="${billing.shortcut}" th:class="'billing ' + ${billing.csskey}"></span></td> <td><span th:text="${billing.shortcut}" th:class="'billing ' + ${billing.csskey}"></span></td>
<td>TODO</td> <td><span th:text="${billing.percentUsage}"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>