show users
This commit is contained in:
parent
7d1f5e9059
commit
a136acb0b4
@ -1,6 +1,10 @@
|
||||
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.http.HttpStatus;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@ -10,4 +14,12 @@ public class MvcConfiguration implements WebMvcConfigurer {
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
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"));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ public class Page {
|
||||
public static final String INDEX = "/index.xhtml";
|
||||
public static final String PAPER_LIST = "/paper/papers.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 String getPAPER_LIST() {
|
||||
@ -21,6 +22,10 @@ public class Page {
|
||||
return DASHBOARD;
|
||||
}
|
||||
|
||||
public String getUSER_LIST() {
|
||||
return USER_LIST;
|
||||
}
|
||||
|
||||
public String getLOGOUT() {
|
||||
return LOGOUT;
|
||||
}
|
||||
|
29
src/main/java/ru/ulstu/user/component/UserView.java
Normal file
29
src/main/java/ru/ulstu/user/component/UserView.java
Normal 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;
|
||||
}
|
||||
}
|
34
src/main/resources/META-INF/resources/admin/users.xhtml
Normal file
34
src/main/resources/META-INF/resources/admin/users.xhtml
Normal 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>
|
@ -32,6 +32,7 @@
|
||||
<p:menuitem value="Мои статьи" icon="fa fa-calendar" url="#{page.DASHBOARD}"/>
|
||||
<p:menuitem value="Все статьи" icon="fa fa-file-o" url="#{page.PAPER_LIST}"/>
|
||||
</p:submenu>
|
||||
<p:menuitem value="Пользователи" icon="fa fa-calendar" url="#{page.USER_LIST}"/>
|
||||
|
||||
<f:facet name="options">
|
||||
<p:link href="#{page.LOGOUT}" value="Выход"/>
|
||||
|
27
src/main/resources/META-INF/resources/error/403.xhtml
Normal file
27
src/main/resources/META-INF/resources/error/403.xhtml
Normal 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>
|
23
src/main/resources/META-INF/resources/error/404.xhtml
Normal file
23
src/main/resources/META-INF/resources/error/404.xhtml
Normal 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>
|
42
src/main/resources/META-INF/resources/error/500.xhtml
Normal file
42
src/main/resources/META-INF/resources/error/500.xhtml
Normal 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>
|
@ -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>
|
Loading…
Reference in New Issue
Block a user