add papers dashboard
This commit is contained in:
parent
107ddb90ac
commit
5ee1f33de1
28
src/main/java/ru/ulstu/paper/controller/DashboardView.java
Normal file
28
src/main/java/ru/ulstu/paper/controller/DashboardView.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package ru.ulstu.paper.controller;
|
||||||
|
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Named
|
||||||
|
@ViewScoped
|
||||||
|
public class DashboardView {
|
||||||
|
@Inject
|
||||||
|
private PaperService paperService;
|
||||||
|
|
||||||
|
private List<Paper> papers;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
papers = paperService.findAllActiveByCurrentUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Paper> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
}
|
@ -85,13 +85,20 @@ public class PaperService {
|
|||||||
return papers;
|
return papers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Paper> findAllActive() {
|
public List<Paper> findAllActive() {
|
||||||
return findAll()
|
return findAll()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Paper> findAllActiveByCurrentUser() {
|
||||||
|
return findAllActive()
|
||||||
|
.stream()
|
||||||
|
.filter(paper -> paper.getAuthors().contains(userService.getCurrentUser()))
|
||||||
|
.collect(toList());
|
||||||
|
}
|
||||||
|
|
||||||
public List<PaperDto> findAllActiveDto() {
|
public List<PaperDto> findAllActiveDto() {
|
||||||
return convert(findAllActive(), PaperDto::new);
|
return convert(findAllActive(), PaperDto::new);
|
||||||
}
|
}
|
||||||
|
23
src/main/resources/META-INF/resources/paper/dashboard.xhtml
Normal file
23
src/main/resources/META-INF/resources/paper/dashboard.xhtml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<ui:composition template="/basicTemplate.xhtml">
|
||||||
|
<ui:define name="content">
|
||||||
|
<p:dataTable value="#{dashboardView.papers}" var="paper" paginator="true" rows="10">
|
||||||
|
<p:column headerText="Название">
|
||||||
|
<h:outputLink value="/paper/paper.xhtml">
|
||||||
|
#{paper.title}
|
||||||
|
<f:param name="id" value="#{paper.id}"/>
|
||||||
|
</h:outputLink>
|
||||||
|
</p:column>
|
||||||
|
<p:column headerText="Статус">
|
||||||
|
<ui:include src="paperStatusFragment.xhtml">
|
||||||
|
<ui:param name="paper" value="#{paper}"/>
|
||||||
|
</ui:include>
|
||||||
|
</p:column>
|
||||||
|
</p:dataTable>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user