color in calendar
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_BILLING;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_DONE;
|
||||
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_PROJECT;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.T_BILLING;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_HAMSTERSUMMARY;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_TOTALOFDAY;
|
||||
import static de.jottyfan.timetrack.db.done.Tables.V_WORKTIME;
|
||||
@ -367,8 +367,10 @@ public class DoneGateway extends JooqGateway {
|
||||
String jobName = r.get(V_WORKTIME.JOB_NAME);
|
||||
String billingShortcut = r.get(V_WORKTIME.BILLING_SHORTCUT);
|
||||
String billingCsskey = r.get(V_WORKTIME.BILLING_CSSKEY);
|
||||
durationHours = durationHours == null ? null : new BigDecimal(durationHours).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
list.add(new DailySummaryBean(projectName, moduleName, jobName, duration, billingShortcut, billingCsskey, durationHours));
|
||||
durationHours = durationHours == null ? null
|
||||
: new BigDecimal(durationHours).setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
list.add(new DailySummaryBean(projectName, moduleName, jobName, duration, billingShortcut, billingCsskey,
|
||||
durationHours));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -388,10 +390,10 @@ public class DoneGateway extends JooqGateway {
|
||||
// @formatter:off
|
||||
.select(T_DONE.TIME_FROM,
|
||||
T_DONE.TIME_UNTIL,
|
||||
T_BILLING.NAME,
|
||||
T_PROJECT.NAME,
|
||||
T_MODULE.NAME,
|
||||
T_JOB.NAME)
|
||||
T_JOB.NAME,
|
||||
T_BILLING.CSSKEY)
|
||||
.from(T_DONE)
|
||||
.leftJoin(T_PROJECT).on(T_PROJECT.PK.eq(T_DONE.FK_PROJECT))
|
||||
.leftJoin(T_MODULE).on(T_MODULE.PK.eq(T_DONE.FK_MODULE))
|
||||
@ -405,15 +407,12 @@ public class DoneGateway extends JooqGateway {
|
||||
String projectName = r.get(T_PROJECT.NAME);
|
||||
String moduleName = r.get(T_MODULE.NAME);
|
||||
String jobName = r.get(T_JOB.NAME);
|
||||
String billingName = r.get(T_BILLING.NAME);
|
||||
LocalDateTime timeFrom = r.get(T_DONE.TIME_FROM);
|
||||
LocalDateTime timeUntil = r.get(T_DONE.TIME_UNTIL);
|
||||
String cssKey = r.get(T_BILLING.CSSKEY);
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(projectName);
|
||||
if (billingName != null && !billingName.isBlank()) {
|
||||
buf.append(" (").append(billingName).append(")");
|
||||
}
|
||||
buf.append(", ");
|
||||
buf.append(moduleName);
|
||||
buf.append(": ");
|
||||
@ -429,7 +428,11 @@ public class DoneGateway extends JooqGateway {
|
||||
};
|
||||
Date endDate = timeUntil == null ? null : Date.from(timeUntil.atZone(ZoneId.systemDefault()).toInstant());
|
||||
bean.setEnd(endDate);
|
||||
if (cssKey != null && !cssKey.isBlank()) {
|
||||
bean.setColor(new RgbColor().determineColorFromCssKey(cssKey));
|
||||
} else {
|
||||
bean.setColor(new RgbColor().determineRgbColor(projectName, moduleName, jobName));
|
||||
}
|
||||
list.getList().add(bean);
|
||||
}
|
||||
return list.toJson();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -41,4 +43,19 @@ public class RgbColor {
|
||||
return new StringBuilder("rgb(").append(c.getRed()).append(",").append(c.getGreen()).append(",").append(c.getBlue())
|
||||
.append(")").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* find the corresponding rgb color for the css key
|
||||
* @param cssKey the key
|
||||
* @return the hex color code
|
||||
*/
|
||||
public String determineColorFromCssKey(String cssKey) {
|
||||
// for now, only map the css key to a defined list
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("TA3", "rgb(0, 255, 0)");
|
||||
map.put("WP2", "rgb(192, 192, 0)");
|
||||
map.put("WP4", "rgb(32, 192, 255)");
|
||||
map.put("WP5", "rgb(255, 0, 0)");
|
||||
return map.get(cssKey);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user