adding full calendar support
This commit is contained in:
@ -25,6 +25,7 @@ import org.jooq.DeleteConditionStep;
|
|||||||
import org.jooq.InsertValuesStep6;
|
import org.jooq.InsertValuesStep6;
|
||||||
import org.jooq.Record;
|
import org.jooq.Record;
|
||||||
import org.jooq.Record4;
|
import org.jooq.Record4;
|
||||||
|
import org.jooq.Record5;
|
||||||
import org.jooq.SelectConditionStep;
|
import org.jooq.SelectConditionStep;
|
||||||
import org.jooq.SelectWhereStep;
|
import org.jooq.SelectWhereStep;
|
||||||
import org.jooq.UpdateConditionStep;
|
import org.jooq.UpdateConditionStep;
|
||||||
@ -35,6 +36,8 @@ import de.jottyfan.timetrack.db.done.tables.records.TJobRecord;
|
|||||||
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord;
|
import de.jottyfan.timetrack.db.done.tables.records.TModuleRecord;
|
||||||
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord;
|
import de.jottyfan.timetrack.db.done.tables.records.TProjectRecord;
|
||||||
import de.jottyfan.timetrack.modules.JooqGateway;
|
import de.jottyfan.timetrack.modules.JooqGateway;
|
||||||
|
import net.bootsfaces.component.fullCalendar.FullCalendarEventBean;
|
||||||
|
import net.bootsfaces.component.fullCalendar.FullCalendarEventList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -126,8 +129,7 @@ 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
|
* @param day the day; if null, the current date is used
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
@ -222,8 +224,7 @@ public class DoneGateway extends JooqGateway {
|
|||||||
/**
|
/**
|
||||||
* get day summary
|
* get day summary
|
||||||
*
|
*
|
||||||
* @param day
|
* @param day the 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) {
|
||||||
@ -261,8 +262,7 @@ public class DoneGateway extends JooqGateway {
|
|||||||
/**
|
/**
|
||||||
* get all jobs of day
|
* get all jobs of day
|
||||||
*
|
*
|
||||||
* @param day
|
* @param day the 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) {
|
||||||
@ -287,4 +287,54 @@ public class DoneGateway extends JooqGateway {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get json representation of all calendar events of user
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getAllCalendarEvents() {
|
||||||
|
SelectConditionStep<Record5<Timestamp, Timestamp, String, String, String>> sql = getJooq()
|
||||||
|
// @formatter:off
|
||||||
|
.select(T_DONE.TIME_FROM,
|
||||||
|
T_DONE.TIME_UNTIL,
|
||||||
|
T_PROJECT.NAME,
|
||||||
|
T_MODULE.NAME,
|
||||||
|
T_JOB.NAME)
|
||||||
|
.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))
|
||||||
|
.leftJoin(T_JOB).on(T_JOB.PK.eq(T_DONE.FK_JOB))
|
||||||
|
.where(T_DONE.FK_LOGIN.eq(getFkLogin()));
|
||||||
|
// @formatter:on
|
||||||
|
LOGGER.debug(sql.toString());
|
||||||
|
FullCalendarEventList list = new FullCalendarEventList();
|
||||||
|
for (Record r : sql.fetch()) {
|
||||||
|
String projectName = r.get(T_PROJECT.NAME);
|
||||||
|
String moduleName = r.get(T_MODULE.NAME);
|
||||||
|
String jobName = r.get(T_JOB.NAME);
|
||||||
|
Date timeFrom = r.get(T_DONE.TIME_FROM);
|
||||||
|
Date timeUntil = r.get(T_DONE.TIME_UNTIL);
|
||||||
|
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
|
buf.append(projectName);
|
||||||
|
buf.append(", ");
|
||||||
|
buf.append(moduleName);
|
||||||
|
buf.append(": ");
|
||||||
|
buf.append(jobName);
|
||||||
|
|
||||||
|
FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) {
|
||||||
|
@Override
|
||||||
|
public void addExtendedFields(StringBuilder buf) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
bean.setEnd(timeUntil);
|
||||||
|
bean.setColor("#444444"); // TODO: colors by project name, maybe find a way to determine color by project
|
||||||
|
// name
|
||||||
|
|
||||||
|
list.getList().add(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.toJson();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public class DoneModel implements Model, Serializable {
|
|||||||
private List<DailySummaryBean> allJobs;
|
private List<DailySummaryBean> allJobs;
|
||||||
private WholeDaySummaryBean daySummary;
|
private WholeDaySummaryBean daySummary;
|
||||||
private Date day;
|
private Date day;
|
||||||
|
private String calendarEvents;
|
||||||
|
|
||||||
public boolean init(FacesContext facesContext) {
|
public boolean init(FacesContext facesContext) {
|
||||||
try {
|
try {
|
||||||
@ -53,6 +54,7 @@ public class DoneModel implements Model, Serializable {
|
|||||||
projects = gw.getAllProjects();
|
projects = gw.getAllProjects();
|
||||||
daySummary = gw.getDaySummary(day);
|
daySummary = gw.getDaySummary(day);
|
||||||
allJobs = gw.getAllJobs(day);
|
allJobs = gw.getAllJobs(day);
|
||||||
|
calendarEvents = gw.getAllCalendarEvents();
|
||||||
return true;
|
return true;
|
||||||
} catch (DataAccessException e) {
|
} catch (DataAccessException e) {
|
||||||
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage()));
|
||||||
@ -217,4 +219,8 @@ public class DoneModel implements Model, Serializable {
|
|||||||
public void setDay(Date day) {
|
public void setDay(Date day) {
|
||||||
this.day = day;
|
this.day = day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCalendarEvents() {
|
||||||
|
return calendarEvents;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,102 +1,104 @@
|
|||||||
<!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:tab>
|
<b:row rendered="#{doneModel.daySummary != null}">
|
||||||
<b:tab title="Zusammenfassung">
|
<b:column colXs="4">
|
||||||
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false"
|
<b:well styleClass="dangerWell">Pause
|
||||||
searching="false">
|
<h3>
|
||||||
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
|
<h:outputText value="#{doneModel.daySummary.breakTime}" />
|
||||||
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
|
</h3>
|
||||||
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
|
</b:well>
|
||||||
<b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" />
|
</b:column>
|
||||||
</b:dataTable>
|
<b:column colXs="4">
|
||||||
</b:tab>
|
<b:well>Startzeit
|
||||||
<b:tab title="Anhang">
|
<h3>
|
||||||
<p>
|
<h:outputText value="#{doneModel.daySummary.startTime}" />
|
||||||
<b:inputTextarea value="#{doneModel.attach}" readonly="true" />
|
</h3>
|
||||||
</p>
|
</b:well>
|
||||||
</b:tab>
|
</b:column>
|
||||||
</b:tabView>
|
<b:column colXs="4">
|
||||||
<b:row rendered="#{doneModel.daySummary != null}">
|
<b:well>Überstunden
|
||||||
<b:column colXs="4">
|
<h3>
|
||||||
<b:well styleClass="dangerWell">Pause
|
<h:outputText value="#{doneModel.daySummary.overtime}" />
|
||||||
<h3>
|
</h3>
|
||||||
<h:outputText value="#{doneModel.daySummary.breakTime}" />
|
</b:well>
|
||||||
</h3>
|
</b:column>
|
||||||
</b:well>
|
<b:column colXs="4">
|
||||||
</b:column>
|
<b:well styleClass="successWell">Arbeitszeit
|
||||||
<b:column colXs="4">
|
<h3>
|
||||||
<b:well>Startzeit
|
<h:outputText value="#{doneModel.daySummary.workTime}" />
|
||||||
<h3>
|
</h3>
|
||||||
<h:outputText value="#{doneModel.daySummary.startTime}" />
|
</b:well>
|
||||||
</h3>
|
</b:column>
|
||||||
</b:well>
|
<b:column colXs="4">
|
||||||
</b:column>
|
<b:well>Endzeit
|
||||||
<b:column colXs="4">
|
<h3>
|
||||||
<b:well>Überstunden
|
<h:outputText value="#{doneModel.daySummary.endTime}" />
|
||||||
<h3>
|
</h3>
|
||||||
<h:outputText value="#{doneModel.daySummary.overtime}" />
|
</b:well>
|
||||||
</h3>
|
</b:column>
|
||||||
</b:well>
|
</b:row>
|
||||||
</b:column>
|
</b:tab>
|
||||||
<b:column colXs="4">
|
<b:tab title="Zusammenfassung">
|
||||||
<b:well styleClass="successWell">Arbeitszeit
|
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false" searching="false">
|
||||||
<h3>
|
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
|
||||||
<h:outputText value="#{doneModel.daySummary.workTime}" />
|
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
|
||||||
</h3>
|
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
|
||||||
</b:well>
|
<b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" />
|
||||||
</b:column>
|
</b:dataTable>
|
||||||
<b:column colXs="4">
|
</b:tab>
|
||||||
<b:well>Endzeit
|
<b:tab title="Anhang">
|
||||||
<h3>
|
<p>
|
||||||
<h:outputText value="#{doneModel.daySummary.endTime}" />
|
<b:inputTextarea value="#{doneModel.attach}" readonly="true" />
|
||||||
</h3>
|
</p>
|
||||||
</b:well>
|
</b:tab>
|
||||||
</b:column>
|
<b:tab title="Kalender">
|
||||||
</b:row>
|
<b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="400" defaultDate="#{doneModel.day}" />
|
||||||
</b:form>
|
</b:tab>
|
||||||
</b:panel>
|
</b:tabView>
|
||||||
</ui:define>
|
</b:form>
|
||||||
<ui:define name="navigation">
|
</b:panel>
|
||||||
<b:form>
|
</ui:define>
|
||||||
<b:buttonGroup>
|
<ui:define name="navigation">
|
||||||
<b:commandButton action="#{doneControl.toStart}" value="zurück" look="primary" iconAwesome="arrow-left" />
|
<b:form>
|
||||||
<b:commandButton action="#{doneControl.toAdd}" value="Neuer Eintrag" look="success" iconAwesome="plus" />
|
<b:buttonGroup>
|
||||||
</b:buttonGroup>
|
<b:commandButton action="#{doneControl.toStart}" value="zurück" look="primary" iconAwesome="arrow-left" />
|
||||||
</b:form>
|
<b:commandButton action="#{doneControl.toAdd}" value="Neuer Eintrag" look="success" iconAwesome="plus" />
|
||||||
</ui:define>
|
</b:buttonGroup>
|
||||||
</ui:composition>
|
</b:form>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
</h:body>
|
</h:body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user