Skip to content
Snippets Groups Projects
Commit 62af42a0 authored by Falucho's avatar Falucho
Browse files

Mas Front End

parent fa7130d9
No related branches found
No related tags found
No related merge requests found
Showing
with 233 additions and 13 deletions
package uy.edu.fing.tse.jsf;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import java.util.Objects;
@RequestScoped
@Named("security")
public class SecurityBean {
public boolean isLogged() {
final var token = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("token");
return token != null;
}
public boolean hasRole(final String role) {
final var rol = FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("role");
return Objects.equals(rol, role);
}
public String getUser() {
return (String) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("user");
}
}
......@@ -74,8 +74,7 @@ public class UserLoginBean implements Serializable {
if (token != null) {
addCookieToken(token);
PrimeFaces.current().executeScript("window.location.href='jsf/gestionhechos.xhtml'");
//return "jsf/gestionhechos";
PrimeFaces.current().executeScript("window.location.href='jsf/listarHechos.xhtml'");
} else {
FacesContext.getCurrentInstance().addMessage(
null,
......@@ -100,7 +99,7 @@ public class UserLoginBean implements Serializable {
//TODO
if (valid) {
final var s = securityLocal.register(user);
PrimeFaces.current().executeScript("window.location.href='jsf/gestionhechos.xhtml'");
PrimeFaces.current().executeScript("window.location.href='jsf/listarHechos.xhtml'");
} else {
FacesContext.getCurrentInstance().addMessage(
null,
......
......@@ -35,7 +35,7 @@ public class LoginFilter implements Filter {
try {
final Claims claims = Jwts.parser().setSigningKey("1q2w3e4r5t6y7u8i9o0p").parseClaimsJws(token).getBody();
response.sendRedirect(request.getContextPath() + "/jsf/gestionhechos.xhtml");
response.sendRedirect(request.getContextPath() + "/jsf/listarHechos.xhtml");
} catch (final Exception e) {
chain.doFilter(req, res);
return;
......
......@@ -34,12 +34,29 @@
<header>
<h1>BackOffice - feiknius</h1>
<h:form>
<p:megaMenu orientation="horizontal" style="margin-top:20px"
rendered="#{session.getAttribute('user')!=null}">
<p:menuitem value="Salir" action="#{userLoginView.logout()}"/>
<p:menuitem value="Listar Hechos" action="gestionhechos.xhtml?faces-redirect=true" async="true"/>
<p:menuitem value="Publicar Hechos" action="publicarcancelar.xhtml?faces-redirect=true" async="true"
rendered="#{session.getAttribute('role') == 'Submitter'}"/>
<p:megaMenu orientation="horizontal" style="margin-top:20px" rendered="#{security.logged}">
<p:submenu label="#{security.user}">
<p:column>
<p:submenu label="Gestion">
<p:menuitem value="Salir" action="#{userLoginView.logout()}"/>
</p:submenu>
</p:column>
</p:submenu>
<p:menuitem value="Listar Hechos" action="listarHechos.xhtml?faces-redirect=true"/>
<p:menuitem value="Mecanismos" action="gestionMecanismos.xhtml?faces-redirect=true"
rendered="#{security.hasRole('Admin')}"/>
<p:menuitem value="Perifericos" action="gestionPerifericos.xhtml?faces-redirect=true"
rendered="#{security.hasRole('Admin')}"/>
<p:menuitem value="Usuarios" action="gestionUsuarios.xhtml?faces-redirect=true"
rendered="#{security.hasRole('Admin')}"/>
<p:menuitem value="Gestionar Hechos" action="gestionSubmitter.xhtml?faces-redirect=true"
rendered="#{security.hasRole('Submitter')}"/>
<p:menuitem value="Verificar Hechos" action="gestionChecker.xhtml?faces-redirect=true"
rendered="#{security.hasRole('Checker')}"/>
</p:megaMenu>
</h:form>
</header>
......
......@@ -11,8 +11,7 @@
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Bienvenido "/>
<h:outputText value="#{session.getAttribute('user')}"/>
<h:outputText value="Verificacion de hechos - Checker"/>
</p:outputPanel>
<p:dataTable var="hecho" id="dataHecho" value="#{gestionHechos.facts}" widgetVar="NoticiasTable"
......
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<body>
<ui:decorate template="/WEB-INF/templates/template.xhtml">
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Gestion de Mecanismos Internos"/>
</p:outputPanel>
</h:form>
</ui:define>
</ui:decorate>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<body>
<ui:decorate template="/WEB-INF/templates/template.xhtml">
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Gestion de Perifericos"/>
</p:outputPanel>
</h:form>
</ui:define>
</ui:decorate>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
<body>
<ui:decorate template="/WEB-INF/templates/template.xhtml">
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Gestion de hechos - Submitter"/>
</p:outputPanel>
<p:dataTable var="hecho" id="dataHecho" value="#{gestionHechos.facts}" widgetVar="NoticiasTable"
emptyMessage="Hecho no encontrado" filteredValue="#{gestionHechos.filteredFacts}">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Buscar en todos los campos:"/>
<p:inputText id="globalFilter" onkeyup="PF('NoticiasTable').filter()" style="width:150px"
placeholder="Enter keyword"/>
</p:outputPanel>
</f:facet>
<p:column filterBy="#{hecho.title}" headerText="Titulo" filterMatchMode="contains">
<h:outputText value="#{hecho.title}"/>
</p:column>
<p:column filterBy="#{hecho.description}" headerText="Descripción" filterMatchMode="contains">
<h:outputText value="#{hecho.description}"/>
</p:column>
<p:column filterBy="#{hecho.actualState.value}" headerText="Estados" filterMatchMode="exact">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('NoticiasTable').filter()" styleClass="custom-filter">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="#{gestionHechos.estados}" var="e" itemLabel="#{e.value}"
itemValue="#{hecho.actualState.value}"/>
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{hecho.actualState.value}"/>
</p:column>
<p:column headerText="" style="text-align: center">
<p:growl id="message" showDetail="true"/>
<p:commandButton value="Enviar Verificación" action="#{hecho.setEstado()}" update="@form"
disabled="#{hecho.EstaVerifcado()}">
<p:confirm header="Confirmar" message="¿Enviar Solicitud?" icon="pi pi-exclamation-triangle"/>
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Si" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="pi pi-times"/>
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:decorate>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
>
<body>
<ui:decorate template="/WEB-INF/templates/template.xhtml">
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Gestion de Usuarios"/>
</p:outputPanel>
</h:form>
</ui:define>
</ui:decorate>
</body>
</html>
......@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>BackOffice - feiknius</title>
<meta http-equiv="refresh" content="0; url=gestionhechos.xhtml">
<meta http-equiv="refresh" content="0; url=listarHechos.xhtml">
</head>
<body></body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
>
<body>
<ui:decorate template="/WEB-INF/templates/template.xhtml">
<ui:define name="contenido">
<h:form>
<p:outputPanel style="font-size: 30px;text-align: center">
<h:outputText value="Bienvenido "/>
<h:outputText value="#{security.user}"/>
</p:outputPanel>
<p:dataTable var="hecho" id="dataHecho" value="#{gestionHechos.facts}" widgetVar="NoticiasTable"
emptyMessage="Hecho no encontrada" filteredValue="#{gestionHechos.filteredFacts}">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Buscar en todos los campos:"/>
<p:inputText id="globalFilter" onkeyup="PF('NoticiasTable').filter()" style="width:150px"
placeholder="Enter keyword"/>
</p:outputPanel>
</f:facet>
<p:column filterBy="#{hecho.title}" headerText="Titulo" filterMatchMode="contains">
<h:outputText value="#{hecho.title}"/>
</p:column>
<p:column filterBy="#{hecho.description}" headerText="Descripción" filterMatchMode="contains">
<h:outputText value="#{hecho.description}"/>
</p:column>
<p:column filterBy="#{hecho.actualState.value}" headerText="Estados" filterMatchMode="exact">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('NoticiasTable').filter()" styleClass="custom-filter">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="#{gestionHechos.estados}" var="e" itemLabel="#{e.value}"
itemValue="#{hecho.actualState.value}"/>
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{hecho.actualState.value}"/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:decorate>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment