calendar colors

This commit is contained in:
2019-02-12 11:59:33 +01:00
parent b978765df7
commit ef7d4bb99e
5 changed files with 178 additions and 102 deletions

View File

@ -129,7 +129,8 @@ public class DoneGateway extends JooqGateway {
/** /**
* get all from t_done of the given day * get all from t_done of the given day
* *
* @param day the day; if null, the current date is used * @param day
* the day; if null, the current date is used
* *
* @return a list of found times, an empty one at least * @return a list of found times, an empty one at least
*/ */
@ -224,7 +225,8 @@ public class DoneGateway extends JooqGateway {
/** /**
* get day summary * get day summary
* *
* @param day the day * @param day
* the day
* @return the day summary if found, an empty map otherwise * @return the day summary if found, an empty map otherwise
*/ */
public WholeDaySummaryBean getDaySummary(Date day) { public WholeDaySummaryBean getDaySummary(Date day) {
@ -262,7 +264,8 @@ public class DoneGateway extends JooqGateway {
/** /**
* get all jobs of day * get all jobs of day
* *
* @param day the day * @param day
* the day
* @return list of found jobs; an empty list at least * @return list of found jobs; an empty list at least
*/ */
public List<DailySummaryBean> getAllJobs(Date day) { public List<DailySummaryBean> getAllJobs(Date day) {
@ -297,10 +300,10 @@ public class DoneGateway extends JooqGateway {
SelectConditionStep<Record5<Timestamp, Timestamp, String, String, String>> sql = getJooq() SelectConditionStep<Record5<Timestamp, Timestamp, String, String, String>> sql = getJooq()
// @formatter:off // @formatter:off
.select(T_DONE.TIME_FROM, .select(T_DONE.TIME_FROM,
T_DONE.TIME_UNTIL, T_DONE.TIME_UNTIL,
T_PROJECT.NAME, T_PROJECT.NAME,
T_MODULE.NAME, T_MODULE.NAME,
T_JOB.NAME) T_JOB.NAME)
.from(T_DONE) .from(T_DONE)
.leftJoin(T_PROJECT).on(T_PROJECT.PK.eq(T_DONE.FK_PROJECT)) .leftJoin(T_PROJECT).on(T_PROJECT.PK.eq(T_DONE.FK_PROJECT))
.leftJoin(T_MODULE).on(T_MODULE.PK.eq(T_DONE.FK_MODULE)) .leftJoin(T_MODULE).on(T_MODULE.PK.eq(T_DONE.FK_MODULE))
@ -324,17 +327,16 @@ public class DoneGateway extends JooqGateway {
buf.append(jobName); buf.append(jobName);
FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) { FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) {
private static final long serialVersionUID = 1L;
@Override @Override
public void addExtendedFields(StringBuilder buf) { public void addExtendedFields(StringBuilder buf) {
} }
}; };
bean.setEnd(timeUntil); bean.setEnd(timeUntil);
bean.setColor("#444444"); // TODO: colors by project name, maybe find a way to determine color by project bean.setColor(new RgbColor().determineRgbColor(projectName, moduleName, jobName));
// name
list.getList().add(bean); list.getList().add(bean);
} }
return list.toJson(); return list.toJson();
} }
} }

View File

@ -176,6 +176,10 @@ public class DoneModel implements Model, Serializable {
return buf.toString(); return buf.toString();
} }
public String getDayIso8601() {
return day == null ? "" : new SimpleDateFormat("yyyy-MM-dd").format(day);
}
public void setBean(DoneBean bean) { public void setBean(DoneBean bean) {
this.bean = bean; this.bean = bean;
} }

View File

@ -0,0 +1,44 @@
package de.jottyfan.timetrack.modules.done;
import java.awt.Color;
/**
*
* @author henkej
*
*/
public class RgbColor {
/**
* find a rgb color code for the combination of the given params
*
* @param bigInfluence
* @param mediumInfluence
* @param littleInfluence
* @return the hex color code
*/
public String determineRgbColor(String bigInfluence, String mediumInfluence, String littleInfluence) {
int big = bigInfluence == null ? 0 : bigInfluence.hashCode();
int med = mediumInfluence == null ? 0 : mediumInfluence.hashCode();
int lit = littleInfluence == null ? 0 : littleInfluence.hashCode();
float bI = (1f / String.valueOf(big).length());
float mI = (0.5f / String.valueOf(med).length());
float lI = (0.25f / String.valueOf(lit).length());
float r = 0.0f + bI + mI + lI; // + makes it brighter
float g = 0.5f - bI - mI - lI; // - makes it darker
float b = 0.5f - bI - mI - lI;
r = r < 0 ? r * -1 : r;
r = r > 1.0f ? 1 / r : r;
g = g < 0 ? g * -1 : g;
g = g > 1.0f ? 1 / g : g;
b = b < 0 ? b * -1 : b;
b = b > 1.0f ? 1 / b : b;
Color c = new Color(r, g, b);
return new StringBuilder("rgb(").append(c.getRed()).append(",").append(c.getGreen()).append(",").append(c.getBlue())
.append(")").toString();
}
}

View File

@ -1,104 +1,107 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:my="http://xmlns.jcp.org/jsf/composite/my" xmlns:b="http://bootsfaces.net/ui"> xmlns:f="http://java.sun.com/jsf/core" xmlns:my="http://xmlns.jcp.org/jsf/composite/my" xmlns:b="http://bootsfaces.net/ui">
<h:head> <h:head>
<title>Arbeitszeit</title> <title>Arbeitszeit</title>
</h:head> </h:head>
<h:body> <h:body>
<ui:composition template="/pages/template.xhtml"> <ui:composition template="/pages/template.xhtml">
<ui:define name="top"></ui:define> <ui:define name="top"></ui:define>
<ui:define name="main"> <ui:define name="main">
<b:panel title="Arbeitszeit" look="primary"> <b:panel title="Arbeitszeit" look="primary">
<b:form> <b:form>
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputText value="für den Tag" /> <h:outputText value="für den Tag" />
<b:dateTimePicker value="#{doneModel.day}" showTime="false" style="padding-left: 4px" /> <b:dateTimePicker value="#{doneModel.day}" showTime="false" style="padding-left: 4px" />
<b:commandButton action="#{doneControl.toList}" value="neu laden" look="default" iconAwesome="refresh" <b:commandButton action="#{doneControl.toList}" value="neu laden" look="default" iconAwesome="refresh"
style="padding-left: 4px" /> style="padding-left: 4px" />
</h:panelGrid> </h:panelGrid>
<b:tabView> <b:tabView>
<b:tab title="Liste"> <b:tab title="Liste">
<b:dataTable value="#{doneModel.beans}" var="b" border="false" info="false" paginated="false" searching="false" <b:dataTable value="#{doneModel.beans}" var="b" border="false" info="false" paginated="false" searching="false"
styleClass="doneoverview"> styleClass="doneoverview">
<b:dataTableColumn label="" orderable="false"> <b:dataTableColumn label="" orderable="false">
<b:commandButton action="#{doneControl.toDelete(b)}" value="Entfernen" look="danger" iconAwesome="trash" /> <b:commandButton action="#{doneControl.toDelete(b)}" value="Entfernen" look="danger" iconAwesome="trash" />
</b:dataTableColumn> </b:dataTableColumn>
<b:dataTableColumn label="" value="#{b.timeSummary}" contentStyleClass="doneoverviewtext" orderable="false" /> <b:dataTableColumn label="" value="#{b.timeSummary}" contentStyleClass="doneoverviewtext" orderable="false" />
<b:dataTableColumn label="" value="#{b.projectName}" contentStyleClass="doneoverviewtextemph" orderable="false" /> <b:dataTableColumn label="" value="#{b.projectName}" contentStyleClass="doneoverviewtextemph" orderable="false" />
<b:dataTableColumn label="" value="#{b.timeDiff}" contentStyleClass="doneoverviewtextemph" orderable="false" /> <b:dataTableColumn label="" value="#{b.timeDiff}" contentStyleClass="doneoverviewtextemph" orderable="false" />
<b:dataTableColumn label="" orderable="false"> <b:dataTableColumn label="" orderable="false">
<b:commandButton action="#{doneControl.toEdit(b)}" value="Editieren" look="warning" iconAwesome="pencil" /> <b:commandButton action="#{doneControl.toEdit(b)}" value="Editieren" look="warning" iconAwesome="pencil" />
</b:dataTableColumn> </b:dataTableColumn>
<b:dataTableColumn label="" value="#{b.moduleName}" contentStyleClass="doneoverviewtext" orderable="false" /> <b:dataTableColumn label="" value="#{b.moduleName}" contentStyleClass="doneoverviewtext" orderable="false" />
<b:dataTableColumn label="" value="#{b.jobName}" contentStyleClass="doneoverviewtext" orderable="false" /> <b:dataTableColumn label="" value="#{b.jobName}" contentStyleClass="doneoverviewtext" orderable="false" />
</b:dataTable> </b:dataTable>
<b:row rendered="#{doneModel.daySummary != null}"> <b:row rendered="#{doneModel.daySummary != null}">
<b:column colXs="4"> <b:column colXs="4">
<b:well styleClass="dangerWell">Pause <b:well styleClass="dangerWell">Pause
<h3> <h3>
<h:outputText value="#{doneModel.daySummary.breakTime}" /> <h:outputText value="#{doneModel.daySummary.breakTime}" />
</h3> </h3>
</b:well> </b:well>
</b:column> </b:column>
<b:column colXs="4"> <b:column colXs="4">
<b:well>Startzeit <b:well>Startzeit
<h3> <h3>
<h:outputText value="#{doneModel.daySummary.startTime}" /> <h:outputText value="#{doneModel.daySummary.startTime}" />
</h3> </h3>
</b:well> </b:well>
</b:column> </b:column>
<b:column colXs="4"> <b:column colXs="4">
<b:well>Überstunden <b:well>Überstunden
<h3> <h3>
<h:outputText value="#{doneModel.daySummary.overtime}" /> <h:outputText value="#{doneModel.daySummary.overtime}" />
</h3> </h3>
</b:well> </b:well>
</b:column> </b:column>
<b:column colXs="4"> <b:column colXs="4">
<b:well styleClass="successWell">Arbeitszeit <b:well styleClass="successWell">Arbeitszeit
<h3> <h3>
<h:outputText value="#{doneModel.daySummary.workTime}" /> <h:outputText value="#{doneModel.daySummary.workTime}" />
</h3> </h3>
</b:well> </b:well>
</b:column> </b:column>
<b:column colXs="4"> <b:column colXs="4">
<b:well>Endzeit <b:well>Endzeit
<h3> <h3>
<h:outputText value="#{doneModel.daySummary.endTime}" /> <h:outputText value="#{doneModel.daySummary.endTime}" />
</h3> </h3>
</b:well> </b:well>
</b:column> </b:column>
</b:row> </b:row>
</b:tab> </b:tab>
<b:tab title="Zusammenfassung"> <b:tab title="Zusammenfassung">
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false" searching="false"> <b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false"
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" /> searching="false">
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" /> <b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
</b:dataTable> <b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" />
</b:tab> </b:dataTable>
<b:tab title="Anhang"> </b:tab>
<p> <b:tab title="Anhang">
<b:inputTextarea value="#{doneModel.attach}" readonly="true" /> <p>
</p> <b:inputTextarea value="#{doneModel.attach}" readonly="true" />
</b:tab> </p>
<b:tab title="Kalender"> </b:tab>
<b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="400" defaultDate="#{doneModel.day}" /> <b:tab title="Kalender">
</b:tab> <b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="600"
</b:tabView> defaultDate="#{doneModel.dayIso8601}" defaultView="agendaDay" hidden="xs" scrollTime="08:00:00"
</b:form> slotDuration="00:15:00" span="half" allDaySlot="false" lang="de" />
</b:panel> </b:tab>
</ui:define> </b:tabView>
<ui:define name="navigation"> </b:form>
<b:form> </b:panel>
<b:buttonGroup> </ui:define>
<b:commandButton action="#{doneControl.toStart}" value="zurück" look="primary" iconAwesome="arrow-left" /> <ui:define name="navigation">
<b:commandButton action="#{doneControl.toAdd}" value="Neuer Eintrag" look="success" iconAwesome="plus" /> <b:form>
</b:buttonGroup> <b:buttonGroup>
</b:form> <b:commandButton action="#{doneControl.toStart}" value="zurück" look="primary" iconAwesome="arrow-left" />
</ui:define> <b:commandButton action="#{doneControl.toAdd}" value="Neuer Eintrag" look="success" iconAwesome="plus" />
</ui:composition> </b:buttonGroup>
</b:form>
</ui:define>
</ui:composition>
</h:body> </h:body>
</html> </html>

View File

@ -0,0 +1,23 @@
package de.jottyfan.timetrack.moduls.done;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import de.jottyfan.timetrack.modules.done.RgbColor;
/**
*
* @author henkej
*
*/
public class TestRgbColor {
@Test
public void testDetermineRgbColor() {
RgbColor c = new RgbColor();
assertEquals("rgb(146,204,204)", c.determineRgbColor(null, null, null));
assertEquals("rgb(61,66,66)", c.determineRgbColor("Ship", "alles", "Mail"));
assertEquals("rgb(43,85,85)", c.determineRgbColor("Square", "Entwicklung_Programmierung", "alles"));
}
}