adding full calendar support

This commit is contained in:
2019-02-09 15:52:19 +01:00
parent e6b7297e3d
commit b978765df7
3 changed files with 158 additions and 100 deletions

View File

@ -25,6 +25,7 @@ import org.jooq.DeleteConditionStep;
import org.jooq.InsertValuesStep6;
import org.jooq.Record;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.SelectConditionStep;
import org.jooq.SelectWhereStep;
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.TProjectRecord;
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
*
* @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
*/
@ -222,8 +224,7 @@ public class DoneGateway extends JooqGateway {
/**
* get day summary
*
* @param day
* the day
* @param day the day
* @return the day summary if found, an empty map otherwise
*/
public WholeDaySummaryBean getDaySummary(Date day) {
@ -261,8 +262,7 @@ public class DoneGateway extends JooqGateway {
/**
* get all jobs of day
*
* @param day
* the day
* @param day the day
* @return list of found jobs; an empty list at least
*/
public List<DailySummaryBean> getAllJobs(Date day) {
@ -287,4 +287,54 @@ public class DoneGateway extends JooqGateway {
}
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();
}
}

View File

@ -42,6 +42,7 @@ public class DoneModel implements Model, Serializable {
private List<DailySummaryBean> allJobs;
private WholeDaySummaryBean daySummary;
private Date day;
private String calendarEvents;
public boolean init(FacesContext facesContext) {
try {
@ -53,6 +54,7 @@ public class DoneModel implements Model, Serializable {
projects = gw.getAllProjects();
daySummary = gw.getDaySummary(day);
allJobs = gw.getAllJobs(day);
calendarEvents = gw.getAllCalendarEvents();
return true;
} catch (DataAccessException e) {
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) {
this.day = day;
}
public String getCalendarEvents() {
return calendarEvents;
}
}

View File

@ -33,22 +33,6 @@
<b:dataTableColumn label="" value="#{b.moduleName}" contentStyleClass="doneoverviewtext" orderable="false" />
<b:dataTableColumn label="" value="#{b.jobName}" contentStyleClass="doneoverviewtext" orderable="false" />
</b:dataTable>
</b:tab>
<b:tab title="Zusammenfassung">
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false"
searching="false">
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" />
</b:dataTable>
</b:tab>
<b:tab title="Anhang">
<p>
<b:inputTextarea value="#{doneModel.attach}" readonly="true" />
</p>
</b:tab>
</b:tabView>
<b:row rendered="#{doneModel.daySummary != null}">
<b:column colXs="4">
<b:well styleClass="dangerWell">Pause
@ -86,6 +70,24 @@
</b:well>
</b:column>
</b:row>
</b:tab>
<b:tab title="Zusammenfassung">
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false" searching="false">
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
<b:dataTableColumn label="" value="#{col.duration}" contentStyle="font-size: 120%" orderable="false" />
</b:dataTable>
</b:tab>
<b:tab title="Anhang">
<p>
<b:inputTextarea value="#{doneModel.attach}" readonly="true" />
</p>
</b:tab>
<b:tab title="Kalender">
<b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="400" defaultDate="#{doneModel.day}" />
</b:tab>
</b:tabView>
</b:form>
</b:panel>
</ui:define>