From 8f29a6c788dbe5de6d6ea9556a3cb14a53466baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Henke?= Date: Wed, 4 May 2022 17:19:31 +0200 Subject: [PATCH] layout optimization --- .settings/org.eclipse.wst.common.component | 26 ++-- .../timetrack/spring/done/DoneBean.java | 20 +++ .../timetrack/spring/done/DoneController.java | 63 +++++++++ .../timetrack/spring/done/IDoneService.java | 18 +++ .../spring/done/impl/DoneService.java | 57 ++++++++ .../timetrack/modules/note/NoteBean.java | 91 ------------- .../timetrack/modules/note/NoteControl.java | 104 --------------- .../timetrack/modules/note/NoteGateway.java | 125 ------------------ .../timetrack/modules/note/NoteModel.java | 112 ---------------- src/main/resources/static/css/style.css | 28 +++- .../resources/templates/contact/list.html | 91 ++++++------- src/main/resources/templates/done/list.html | 38 ++++++ src/main/resources/templates/layout/main.html | 2 + src/main/resources/templates/note/list.html | 99 +++++++------- 14 files changed, 331 insertions(+), 543 deletions(-) create mode 100644 src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java create mode 100644 src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java create mode 100644 src/main/java/de/jottyfan/timetrack/spring/done/IDoneService.java create mode 100644 src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java delete mode 100644 src/main/old/de/jottyfan/timetrack/modules/note/NoteBean.java delete mode 100644 src/main/old/de/jottyfan/timetrack/modules/note/NoteControl.java delete mode 100644 src/main/old/de/jottyfan/timetrack/modules/note/NoteGateway.java delete mode 100644 src/main/old/de/jottyfan/timetrack/modules/note/NoteModel.java create mode 100644 src/main/resources/templates/done/list.html diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index acd1828..0d9c0d3 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,27 +1,37 @@ - + + - + + - + + - + + - + + - + + + + - + + - + + diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java b/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java new file mode 100644 index 0000000..d1b7785 --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/spring/done/DoneBean.java @@ -0,0 +1,20 @@ +package de.jottyfan.timetrack.spring.done; + +import java.io.Serializable; + +/** + * + * @author henkej + * + */ +public class DoneBean implements Serializable, Comparable{ + + private static final long serialVersionUID = 1L; + + @Override + public int compareTo(DoneBean bean) { + // TODO: implement + return 0; + } + +} diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java b/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java new file mode 100644 index 0000000..51d6c62 --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/spring/done/DoneController.java @@ -0,0 +1,63 @@ +package de.jottyfan.timetrack.spring.done; + +import java.util.List; + +import javax.annotation.security.RolesAllowed; +import javax.servlet.http.HttpServletRequest; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * + * @author henkej + * + */ +@Controller +public class DoneController { + private static final Logger LOGGER = LogManager.getLogger(DoneController.class); + + private final HttpServletRequest request; + + @Autowired + private IDoneService doneService; + + @Autowired + public DoneController(HttpServletRequest request) { + this.request = request; + } + + @RolesAllowed("timetrack_user") + @RequestMapping(value = "/done/list") + public String getList(Model model) { + List list = doneService.getList(); + model.addAttribute("doneList", list); + return "done/list"; + } + + @RolesAllowed("timetrack_user") + @RequestMapping(value = "/done/add", method = RequestMethod.GET) + public String toAdd(Model model) { + return toItem(null, model); + } + + @RolesAllowed("timetrack_user") + @GetMapping("/done/edit/{id}") + public String toItem(@PathVariable Integer id, Model model) { + DoneBean bean = doneService.getBean(id); + if (bean == null) { + bean = new DoneBean(); // the add case + } + model.addAttribute("doneBean", bean); +// model.addAttribute("types", Arrays.asList(EnumNotetype.values())); +// model.addAttribute("categories", Arrays.asList(EnumCategory.values())); + return "done/item"; + } +} diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/IDoneService.java b/src/main/java/de/jottyfan/timetrack/spring/done/IDoneService.java new file mode 100644 index 0000000..e7f9a2f --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/spring/done/IDoneService.java @@ -0,0 +1,18 @@ +package de.jottyfan.timetrack.spring.done; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +/** + * + * @author henkej + * + */ +public interface IDoneService { + public List getList(); + + public DoneBean getBean(Integer id); + + public String getCurrentUser(HttpServletRequest request); +} diff --git a/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java new file mode 100644 index 0000000..cd9ad11 --- /dev/null +++ b/src/main/java/de/jottyfan/timetrack/spring/done/impl/DoneService.java @@ -0,0 +1,57 @@ +package de.jottyfan.timetrack.spring.done.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jooq.DSLContext; +import org.keycloak.KeycloakSecurityContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import de.jottyfan.timetrack.spring.done.DoneBean; +import de.jottyfan.timetrack.spring.done.IDoneService; +import de.jottyfan.timetrack.spring.note.NoteBean; +import de.jottyfan.timetrack.spring.note.impl.NoteGateway; +import de.jottyfan.timetrack.spring.note.impl.NoteService; + +/** + * + * @author henkej + * + */ +@Service +@Transactional(transactionManager = "transactionManager") +public class DoneService implements IDoneService { + private static final Logger LOGGER = LogManager.getLogger(NoteService.class); + + @Autowired + private DSLContext dsl; + + @Override + public String getCurrentUser(HttpServletRequest request) { + KeycloakSecurityContext ksc = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName()); + return ksc == null ? "" : ksc.getIdToken().getPreferredUsername(); + } + + @Override + public List getList() { +// try { +// return new DoneGateway(dsl).getAll(); +// } catch (Exception e) { +// LOGGER.error(e); + return new ArrayList<>(); +// } + } + + @Override + public DoneBean getBean(Integer id) { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/main/old/de/jottyfan/timetrack/modules/note/NoteBean.java b/src/main/old/de/jottyfan/timetrack/modules/note/NoteBean.java deleted file mode 100644 index 1ab6cb9..0000000 --- a/src/main/old/de/jottyfan/timetrack/modules/note/NoteBean.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.jottyfan.timetrack.modules.note; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import de.jottyfan.timetrack.db.note.enums.EnumCategory; -import de.jottyfan.timetrack.db.note.enums.EnumNotetype; -import de.jottyfan.timetrack.modules.Bean; - -/** - * - * @author henkej - * - */ -public class NoteBean implements Bean, Serializable -{ - private static final long serialVersionUID = 1L; - - private final Integer pk; - private String title; - private EnumCategory category; - private EnumNotetype type; - private String content; - private LocalDateTime lastchange; - - public NoteBean(Integer pk) - { - super(); - this.pk = pk; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public EnumCategory getCategory() - { - return category; - } - - public void setCategory(EnumCategory category) - { - this.category = category; - } - - public EnumNotetype getType() - { - return type; - } - - public void setType(EnumNotetype type) - { - this.type = type; - } - - public String getContent() - { - return content; - } - - public void setContent(String content) - { - this.content = content; - } - - public LocalDateTime getLastchange() - { - return lastchange; - } - - public void setLastchange(LocalDateTime lastchange) - { - this.lastchange = lastchange; - } - - public static long getSerialversionuid() - { - return serialVersionUID; - } - - public Integer getPk() - { - return pk; - } -} diff --git a/src/main/old/de/jottyfan/timetrack/modules/note/NoteControl.java b/src/main/old/de/jottyfan/timetrack/modules/note/NoteControl.java deleted file mode 100644 index ca19bd2..0000000 --- a/src/main/old/de/jottyfan/timetrack/modules/note/NoteControl.java +++ /dev/null @@ -1,104 +0,0 @@ -package de.jottyfan.timetrack.modules.note; - -import java.io.Serializable; - -import javax.enterprise.context.RequestScoped; -import javax.faces.context.FacesContext; -import javax.inject.Inject; -import javax.inject.Named; - -import de.jooqfaces.JooqFacesContext; -import de.jottyfan.timetrack.help.Navigation; -import de.jottyfan.timetrack.help.Pages; -import de.jottyfan.timetrack.modules.ControlInterface; - -/** - * - * @author henkej - * - */ -@Named -@RequestScoped -public class NoteControl extends Navigation implements ControlInterface, Serializable -{ - private static final long serialVersionUID = 1L; - - @Inject - @Named("noteModel") - private NoteModel model; - - public String toStart() - { - return navigateTo(Pages.START); - } - - public String toList() - { - boolean ready = model.init((JooqFacesContext) FacesContext.getCurrentInstance()); - return ready ? navigateTo(Pages.NOTE_LIST) : ""; - } - - public String toItem(NoteBean bean) - { - model.setBean(bean); - return navigateTo(Pages.NOTE_ITEM); - } - - public String toAdd() - { - return toItem(new NoteBean(null)); - } - - public String doAdd() - { - boolean ready = model.add((JooqFacesContext) FacesContext.getCurrentInstance()); - return ready ? toList() : toItem(model.getBean()); - } - - public String doUpdate() - { - boolean ready = model.update((JooqFacesContext) FacesContext.getCurrentInstance()); - return ready ? toList() : toItem(model.getBean()); - } - - public String doDelete() - { - boolean ready = model.delete((JooqFacesContext) FacesContext.getCurrentInstance()); - return ready ? toList() : toItem(model.getBean()); - } - - /** - * trim s to maxLength; if s > maxLength, append ... - * - * @param s - * @param maxLength - * @return - */ - public String trimTo(String s, Integer maxLength) - { - if (s == null) - { - return s; - } - else - { - String firstLine = s.contains("\n") ? s.substring(0, s.indexOf("\n")) : s; - if (firstLine.length() > maxLength) - { - return firstLine.substring(0, maxLength).concat("..."); - } - else if (s.contains("\n")) - { - return firstLine.concat("..."); - } - else - { - return firstLine; - } - } - } - - public Long getAmount() { - return model.getAmount((JooqFacesContext) FacesContext.getCurrentInstance()); - } -} diff --git a/src/main/old/de/jottyfan/timetrack/modules/note/NoteGateway.java b/src/main/old/de/jottyfan/timetrack/modules/note/NoteGateway.java deleted file mode 100644 index 150b17a..0000000 --- a/src/main/old/de/jottyfan/timetrack/modules/note/NoteGateway.java +++ /dev/null @@ -1,125 +0,0 @@ -package de.jottyfan.timetrack.modules.note; - -import static de.jottyfan.timetrack.db.note.Tables.T_NOTE; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jooq.CloseableDSLContext; -import org.jooq.DeleteConditionStep; -import org.jooq.InsertValuesStep4; -import org.jooq.Record; -import org.jooq.SelectJoinStep; -import org.jooq.UpdateConditionStep; -import org.jooq.exception.DataAccessException; - -import de.jooqfaces.JooqFacesContext; -import de.jottyfan.timetrack.db.note.enums.EnumCategory; -import de.jottyfan.timetrack.db.note.enums.EnumNotetype; -import de.jottyfan.timetrack.db.note.tables.records.TNoteRecord; -import de.jottyfan.timetrack.modules.JooqGateway; - -/** - * - * @author henkej - * - */ -public class NoteGateway extends JooqGateway { - private static final Logger LOGGER = LogManager.getLogger(NoteGateway.class); - - public NoteGateway(JooqFacesContext facesContext) { - super(facesContext); - } - - /** - * insert into t_note - * - * @param noteBean - * @throws DataAccessException - * @throws SQLException - * @throws ClassNotFoundException - * @returns amount of affected rows in db - */ - public void insert(NoteBean bean) throws DataAccessException, ClassNotFoundException, SQLException { - try (CloseableDSLContext jooq = getJooq()) { - InsertValuesStep4 sql = jooq - // @formatter:off - .insertInto(T_NOTE, - T_NOTE.TITLE, - T_NOTE.CATEGORY, - T_NOTE.NOTETYPE, - T_NOTE.CONTENT) - .values(bean.getTitle(), bean.getCategory(), bean.getType(), bean.getContent()); - // @formatter:on - LOGGER.debug(sql.toString()); - sql.execute(); - } - } - - /** - * update content of bean - * - * @param bean - * @throws DataAccessException - * @throws SQLException - * @throws ClassNotFoundException - */ - public void update(NoteBean bean) throws DataAccessException, ClassNotFoundException, SQLException { - try (CloseableDSLContext jooq = getJooq()) { - UpdateConditionStep sql = jooq - // @formatter:off - .update(T_NOTE) - .set(T_NOTE.TITLE, bean.getTitle()) - .set(T_NOTE.CONTENT, bean.getContent()) - .where(T_NOTE.PK.eq(bean.getPk())); - // @formatter:on - LOGGER.debug(sql.toString()); - sql.execute(); - } - } - - /** - * delete from t_note - * - * @param pk - * @throws DataAccessException - * @throws SQLException - * @throws ClassNotFoundException - */ - public void delete(Integer pk) throws DataAccessException, ClassNotFoundException, SQLException { - try (CloseableDSLContext jooq = getJooq()) { - DeleteConditionStep sql = jooq.deleteFrom(T_NOTE).where(T_NOTE.PK.eq(pk)); - LOGGER.debug(sql.toString()); - sql.execute(); - } - } - - /** - * get all from t_note - * - * @return - * @throws DataAccessException - * @throws SQLException - * @throws ClassNotFoundException - */ - public List getAll() throws DataAccessException, ClassNotFoundException, SQLException { - try (CloseableDSLContext jooq = getJooq()) { - SelectJoinStep sql = jooq.select().from(T_NOTE); - LOGGER.debug(sql.toString()); - List list = new ArrayList<>(); - for (Record r : sql.fetch()) { - NoteBean bean = new NoteBean(r.get(T_NOTE.PK)); - bean.setTitle(r.get(T_NOTE.TITLE)); - bean.setCategory(r.get(T_NOTE.CATEGORY)); - bean.setContent(r.get(T_NOTE.CONTENT)); - bean.setType(r.get(T_NOTE.NOTETYPE)); - bean.setLastchange(r.get(T_NOTE.LASTCHANGE)); - list.add(bean); - } - return list; - } - } -} diff --git a/src/main/old/de/jottyfan/timetrack/modules/note/NoteModel.java b/src/main/old/de/jottyfan/timetrack/modules/note/NoteModel.java deleted file mode 100644 index 0df044d..0000000 --- a/src/main/old/de/jottyfan/timetrack/modules/note/NoteModel.java +++ /dev/null @@ -1,112 +0,0 @@ -package de.jottyfan.timetrack.modules.note; - -import java.io.Serializable; -import java.sql.SQLException; -import java.util.List; - -import javax.enterprise.context.SessionScoped; -import javax.faces.application.FacesMessage; -import javax.inject.Named; - -import org.jooq.exception.DataAccessException; - -import de.jooqfaces.JooqFacesContext; -import de.jottyfan.timetrack.db.note.Tables; -import de.jottyfan.timetrack.modules.Model; - -/** - * - * @author henkej - * - */ -@Named -@SessionScoped -public class NoteModel implements Model, Serializable -{ - private static final long serialVersionUID = 1L; - - private List beans; - private NoteBean bean; - - public boolean init(JooqFacesContext facesContext) - { - try - { - beans = new NoteGateway(facesContext).getAll(); - return true; - } - catch (DataAccessException | ClassNotFoundException | SQLException e) - { - facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage())); - return false; - } - } - - public boolean add(JooqFacesContext facesContext) - { - try - { - new NoteGateway(facesContext).insert(bean); - return true; - } - catch (DataAccessException | ClassNotFoundException | SQLException e) - { - facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage())); - return false; - } - } - - public boolean update(JooqFacesContext facesContext) - { - try - { - new NoteGateway(facesContext).update(bean); - return true; - } - catch (DataAccessException | ClassNotFoundException | SQLException e) - { - facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage())); - return false; - } - } - - public boolean delete(JooqFacesContext facesContext) - { - try - { - new NoteGateway(facesContext).delete(bean.getPk()); - return true; - } - catch (DataAccessException | ClassNotFoundException | SQLException e) - { - facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage())); - return false; - } - } - - public Long getAmount(JooqFacesContext facesContext) - { - try { - return new NoteGateway(facesContext).getAmount(Tables.T_NOTE); - } catch (ClassNotFoundException | SQLException e) { - facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", e.getMessage())); - return -1l; - } - } - - @Override - public NoteBean getBean() - { - return bean; - } - - public void setBean(NoteBean bean) - { - this.bean = bean; - } - - public List getBeans() - { - return beans; - } -} diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index f5969a5..98569cb 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -7,6 +7,31 @@ body { height: calc(100% - 56px); } +.titlemod { + font-weight: bolder; + color: darkcyan !important; + font-variant: small-caps; +} + +.navlinkstyle { + color: black; +} + +.navlinkstyle:hover { + color: #1a5fb4; +} + +.navback { + background-color: ghostwhite; +} + +.tabdivblurred { + padding: 8px; + padding-bottom: 0px; + background-color: rgba(255, 255, 255, 0.5); + height: calc(100% - 42px); +} + .float-right { float: right; } @@ -16,7 +41,7 @@ body { } .glassy { - background-color: rgba(1,1,1,0.1); + background-color: rgba(0, 0, 0s, 0.1); } .formpane { @@ -47,7 +72,6 @@ body { .page { width: 100%; - padding-bottom: 12px; background-image: linear-gradient(to bottom, #99c1f1, #1a5f64) !important; } diff --git a/src/main/resources/templates/contact/list.html b/src/main/resources/templates/contact/list.html index edd3699..fa9c182 100644 --- a/src/main/resources/templates/contact/list.html +++ b/src/main/resources/templates/contact/list.html @@ -5,65 +5,60 @@ Kontakte +
-
-
-

- -

-
-
-
-
-
-
- -
-
-
- - -
+ +
+
+
+
+
+
+
+ +
+
+
-
-

- -

-
-
- - - - - - - - - - - - - - - - - -
VornameNachnameKontaktTyp
-
-
+
+
+
+ + + + + + + + + + + + + + + + + +
VornameNachnameKontaktTyp
diff --git a/src/main/resources/templates/done/list.html b/src/main/resources/templates/done/list.html new file mode 100644 index 0000000..829d1ef --- /dev/null +++ b/src/main/resources/templates/done/list.html @@ -0,0 +1,38 @@ + + + +Notizen + + + + +
+ +
+
Liste
+
Zusammenfassung
+
Anhang
+
Kalender
+
Projekt
+
Modul
+
Tätigkeit
+
Abrechnung
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/layout/main.html b/src/main/resources/templates/layout/main.html index f52509b..3817e61 100644 --- a/src/main/resources/templates/layout/main.html +++ b/src/main/resources/templates/layout/main.html @@ -31,11 +31,13 @@ +
  • diff --git a/src/main/resources/templates/note/list.html b/src/main/resources/templates/note/list.html index aada454..282eb57 100644 --- a/src/main/resources/templates/note/list.html +++ b/src/main/resources/templates/note/list.html @@ -5,69 +5,62 @@ Notizen +
    -
    -
    -

    - -

    -
    -
    -
    -
    -
    -
    - : -
    -
    -
    -
    
    -											
    -												
    -											
    -										
    -
    - + +
    +
    +
    +
    +
    +
    + : +
    +
    +
    +
    
    +									
    +										
    +									
     								
    +
    -
    -

    - -

    -
    -
    - - - - - - - - - - - - - - - - - -
    TitelKategorieInhaltTyp
    -
    -
    +
    +
    +
    + + + + + + + + + + + + + + + + + +
    TitelKategorieInhaltTyp