show users

This commit is contained in:
Anton Romanov 2019-11-28 10:33:36 +04:00
parent 7d1f5e9059
commit a136acb0b4
9 changed files with 173 additions and 22 deletions

View File

@ -1,6 +1,10 @@
package ru.ulstu.configuration; package ru.ulstu.configuration;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -10,4 +14,12 @@ public class MvcConfiguration implements WebMvcConfigurer {
public void addViewControllers(ViewControllerRegistry registry) { public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/", "/index.xhtml"); registry.addRedirectViewController("/", "/index.xhtml");
} }
@Bean
public ErrorPageRegistrar errorPageRegistrar() {
return registry -> {
registry.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error/404.xhtml"));
registry.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500.xhtml"));
};
}
} }

View File

@ -7,6 +7,7 @@ public class Page {
public static final String INDEX = "/index.xhtml"; public static final String INDEX = "/index.xhtml";
public static final String PAPER_LIST = "/paper/papers.xhtml"; public static final String PAPER_LIST = "/paper/papers.xhtml";
public static final String DASHBOARD = "/paper/dashboard.xhtml"; public static final String DASHBOARD = "/paper/dashboard.xhtml";
public static final String USER_LIST = "/admin/users.xhtml";
public static final String LOGOUT = "/logout"; public static final String LOGOUT = "/logout";
public String getPAPER_LIST() { public String getPAPER_LIST() {
@ -21,6 +22,10 @@ public class Page {
return DASHBOARD; return DASHBOARD;
} }
public String getUSER_LIST() {
return USER_LIST;
}
public String getLOGOUT() { public String getLOGOUT() {
return LOGOUT; return LOGOUT;
} }

View File

@ -0,0 +1,29 @@
package ru.ulstu.user.component;
import ru.ulstu.user.model.User;
import ru.ulstu.user.service.UserService;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.List;
@Named
@ViewScoped
public class UserView implements Serializable {
@Inject
private UserService userService;
private List<User> users;
@PostConstruct
public void init() {
users = userService.findAll();
}
public List<User> getUsers() {
return users;
}
}

View File

@ -0,0 +1,34 @@
<!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">
<style>
.ui-datatable .ui-datatable-header {
text-align: right !important;
}
</style>
<p:dataTable value="#{userView.users}" var="user" paginator="true" rows="10" id="usersTable"
widgetVar="usersTable" emptyMessage="Не найдено пользователей">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Поиск:"/>
<p:inputText id="globalFilter" onkeyup="PF('usersTable').filter()" style="width:150px"
placeholder="Строка поиска..."/>
</p:outputPanel>
</f:facet>
<p:column headerText="Имя" filterBy="#{user.userAbbreviate}" filterMatchMode="contains">
<h:outputLink value="/admin/user.xhtml">
#{user.userAbbreviate}
<f:param name="id" value="#{user.id}"/>
</h:outputLink>
</p:column>
<p:column headerText="Email" filterBy="#{user.email}" filterMatchMode="contains">
<p:outputLabel value="#{user.email}"/>
</p:column>
</p:dataTable>
</ui:define>
</ui:composition>
</html>

View File

@ -32,6 +32,7 @@
<p:menuitem value="Мои статьи" icon="fa fa-calendar" url="#{page.DASHBOARD}"/> <p:menuitem value="Мои статьи" icon="fa fa-calendar" url="#{page.DASHBOARD}"/>
<p:menuitem value="Все статьи" icon="fa fa-file-o" url="#{page.PAPER_LIST}"/> <p:menuitem value="Все статьи" icon="fa fa-file-o" url="#{page.PAPER_LIST}"/>
</p:submenu> </p:submenu>
<p:menuitem value="Пользователи" icon="fa fa-calendar" url="#{page.USER_LIST}"/>
<f:facet name="options"> <f:facet name="options">
<p:link href="#{page.LOGOUT}" value="Выход"/> <p:link href="#{page.LOGOUT}" value="Выход"/>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Доступ запрещен</title>
<h:outputStylesheet name="css/styles.css"/>
<h:outputScript name="js/jquery-2.2.4.min.js"/>
<link rel="stylesheet" href="/resources/css/font-awesome.css"/>
</h:head>
<h:body>
<div class="container">
<div class="row">
<div class="center-block" style="width:400px;">
<div class="content">
<h3><b>Доступ запрещен</b></h3>
<h:link outcome="#{page.MAIN}" styleClass="btn btn-primary">
<i class="fa fa-home fa-4"></i> Вернуться на главную
</h:link>
</div>
</div>
</div>
</div> <!-- /container -->
</h:body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Страница не найдена</title>
<h:outputStylesheet name="css/styles.css"/>
</h:head>
<h:body>
<div class="ui-g">
<div class="ui-g-5"></div>
<div class="ui-g-2">
<p:panel header="Страница не найдена" style="margin-bottom:20px">
<h:link outcome="#{page.MAIN}" styleClass="btn btn-primary">
<i class="fa fa-home fa-4"></i> Вернуться на главную
</h:link>
</p:panel>
</div>
</div>
</h:body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Ошибка сервера</title>
</h:head>
<h:body>
<div class="ui-g">
<div class="ui-g-2"></div>
<div class="ui-g-8">
<p:panel header="Ошибка" style="margin-bottom:20px">
<h:link outcome="#{page.INDEX}" styleClass="btn btn-primary">
<i class="fa fa-home fa-4"></i> Вернуться на главную
</h:link>
<p:panel id="toggleable" header="Подробности" toggleable="true" toggleSpeed="500" closeSpeed="500"
widgetVar="panel" style="margin-bottom:20px" collapsed="true">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="User agent:"/> <h:outputText value="#{header['user-agent']}"/>
<h:outputText value="User IP:"/> <h:outputText
value="#{empty header['x-forwarded-for'] ? request.remoteAddr : header['x-forwarded-for']}"/>
<h:outputText value="Status code:"/> <h:outputText
value="#{requestScope['javax.servlet.error.status_code']}"/>
<h:outputText value="Stack trace:"/>
<p:fragment>
<pre style="font-size: 10px">
#{requestScope['javax.servlet.error.exception']}
</pre>
</p:fragment>
</h:panelGrid>
</p:panel>
</p:panel>
</div>
</div>
</h:body>
</html>

View File

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Oauth2 Login</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
</head>
<body>
<div class="container">
<div class="col-sm-3 well">
<h3>Login with:</h3>
<div class="list-group">
<p th:each="url : ${urls}">
<a th:text="${url.key}" th:href="${url.value}" class="list-group-item active">Client</a>
</p>
</div>
</div>
</div>
</body>
</html>