Funcionalidad al 90%:
-Front-End Completo. -Falta conectar Roles con Access -Errores menores
This commit is contained in:
parent
f10fe6b81b
commit
55ef3eb2ef
@ -2,6 +2,10 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER/appengine-java-sdk-1.9.54"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.9.54.jar|appengine-api-labs.jar|appengine-endpoints-deps.jar|appengine-endpoints.jar|appengine-jsr107cache-1.9.54.jar|asm-5.0.4.jar|datanucleus-api-jdo-3.1.3.jar|datanucleus-api-jpa-3.1.3.jar|datanucleus-appengine-2.1.2.jar|datanucleus-core-3.1.3.jar|geronimo-jpa_2.0_spec-1.0.jar|jdo-api-3.0.1.jar|jsr107cache-1.1.jar|jta-1.1.jar
|
||||
gaeDatanucleusVersion=v2
|
||||
gaeDeployDialogSettings=
|
||||
gaeHrdEnabled=true
|
||||
gaeLaunchAppInBrowser=true
|
||||
|
@ -1,7 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
</faceted-project>
|
||||
|
@ -41,5 +41,6 @@
|
||||
<orderEntry type="library" name="com.google.appengine.eclipse.core.GAE_CONTAINER/appengine-java-sdk-1.9.54" level="application" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="library" name="API AppEngine 1" level="project" />
|
||||
<orderEntry type="library" name="platform" level="application" />
|
||||
</component>
|
||||
</module>
|
@ -1,18 +1,94 @@
|
||||
package controller.roles;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
import controller.users.UsersControllerView;
|
||||
import model.Role;
|
||||
|
||||
import javax.jdo.JDOObjectNotFoundException;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerAdd extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
|
||||
//Accion a realizar
|
||||
String action = request.getParameter("action");
|
||||
|
||||
if (action == null)
|
||||
action = "";
|
||||
|
||||
switch (action){
|
||||
case "create":
|
||||
|
||||
String name = request.getParameter("roleName");
|
||||
Boolean status = Boolean.parseBoolean(request.getParameter("roleStatus"));
|
||||
|
||||
Role role = new Role(name,status);
|
||||
|
||||
try{
|
||||
pm.makePersistent(role);
|
||||
} finally {
|
||||
System.out.println("Role creado");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "redirect":
|
||||
HttpSession sesion= request.getSession();
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Roles/Add.jsp");
|
||||
request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString()));
|
||||
dispatcher.forward(request, response);
|
||||
break;
|
||||
|
||||
case "update":
|
||||
|
||||
Key a = KeyFactory.stringToKey(request.getParameter("key"));
|
||||
|
||||
Role role1 = pm.getObjectById(Role.class, a);
|
||||
|
||||
role1.setName(request.getParameter("roleName"));
|
||||
role1.setStatus(Boolean.parseBoolean(request.getParameter("roleStatus")));
|
||||
//role1.setImgUrl(userImg);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
|
||||
a = KeyFactory.stringToKey(request.getParameter("key"));
|
||||
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(Role.class, a));
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
pm.close();
|
||||
try{
|
||||
response.sendRedirect("/roles");
|
||||
}
|
||||
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
||||
catch (IllegalStateException e){
|
||||
System.err.println("IllegalStateException: There was a double redirect.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
package controller.roles;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
import model.Role;
|
||||
|
||||
import javax.jdo.JDOObjectNotFoundException;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -10,9 +16,26 @@ import java.io.IOException;
|
||||
public class RolesControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
|
||||
try {
|
||||
Key k = KeyFactory.stringToKey(request.getParameter("key"));
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(Role.class, k));
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
System.err.println("Exception catched -> " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
} catch (NullPointerException e){
|
||||
System.err.println("Exception captured -> " + e.getMessage());
|
||||
}
|
||||
|
||||
response.sendRedirect("/roles");
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,44 @@
|
||||
package controller.roles;
|
||||
|
||||
import controller.users.UsersControllerView;
|
||||
import model.User;
|
||||
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerIndex extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
//Se usa para revisar si hay una sesion activa
|
||||
HttpSession sesion= request.getSession();
|
||||
|
||||
//Intenta hallar una sesion activa
|
||||
try{
|
||||
User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
||||
|
||||
request.setAttribute("User",user);
|
||||
request.setAttribute("RoleList",RolesControllerView.getAllRoles());
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Roles/index.jsp");
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
}
|
||||
//Si no la encuentra, redirige a la pagina inicial.
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></body></html>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
doPost(request, response);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,94 @@
|
||||
package controller.roles;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
import controller.users.UsersControllerView;
|
||||
import model.Role;
|
||||
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class RolesControllerView extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
String action = request.getParameter("action");
|
||||
|
||||
//Para evitar errores, si no hay ninguna accion, se establece a vacio.
|
||||
if (action == null)
|
||||
action = "";
|
||||
|
||||
String key = request.getParameter("key");
|
||||
|
||||
//Redirige al formulario para editar un Role (role/view)
|
||||
if (action.equals("editRedirect") && key != null){
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Roles/view.jsp");
|
||||
request.setAttribute("Role",getRole(key));
|
||||
request.setAttribute("UserLogged",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
|
||||
|
||||
//Ya que se quiere editar, el atributo permitirEdicion es verdadero. Este atributo se comprueba en el JSP.
|
||||
request.setAttribute("editAllowed",true);
|
||||
request.setAttribute("action","Edit");
|
||||
try{
|
||||
dispatcher.forward(request,response);
|
||||
} catch (javax.servlet.ServletException e){
|
||||
System.err.println("Exception captured -> " + e.getMessage());
|
||||
}
|
||||
}
|
||||
//Redirige al formulario para ver un usuario (user/view)
|
||||
else if (action.equals("viewRedirect") && key != null){
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Roles/view.jsp");
|
||||
request.setAttribute("Role",getRole(key));
|
||||
request.setAttribute("UserLogged",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
|
||||
|
||||
//Ya que no quiere editar, el atributo permitirEdicion es falso. Este atributo se comprueba en el JSP.
|
||||
request.setAttribute("editAllowed",false);
|
||||
request.setAttribute("action","View");
|
||||
try{
|
||||
dispatcher.forward(request,response);
|
||||
} catch (javax.servlet.ServletException e){
|
||||
System.err.println("Exception captured -> " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
//Si no se encontró acción, regresa al inicio
|
||||
else {
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo Estatico getAllRoles
|
||||
*
|
||||
* Devuelve un list con todos los Roles que existen desde cualquier parte del codigo.
|
||||
*
|
||||
* @return Un List<Role> con todos los Roles
|
||||
* */
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<Role> getAllRoles(){
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
List<Role> users = (List<Role>) pm.newQuery("select from " + Role.class.getName()).execute();
|
||||
pm.close();
|
||||
return users;
|
||||
}
|
||||
|
||||
static Role getRole(String key){
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
Key k = KeyFactory.stringToKey(key);
|
||||
Role role = pm.getObjectById(Role.class, k);
|
||||
pm.close();
|
||||
return role;
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,14 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
|
||||
//Accion a realizar
|
||||
String action = request.getParameter("action");
|
||||
|
||||
if (action == null)
|
||||
action = "";
|
||||
|
||||
//Email del usuario
|
||||
String userEmail = request.getParameter("userEmail");
|
||||
|
||||
@ -40,37 +45,34 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
String userImg = request.getParameter("userImg");
|
||||
String userRole = request.getParameter("userRole");
|
||||
|
||||
//Accion a realizar
|
||||
String action = request.getParameter("action");
|
||||
|
||||
if (action == null)
|
||||
action = "";
|
||||
|
||||
|
||||
switch (action) {
|
||||
//Si se quiere iniciar sesion y/o registrar un usuario desde el inicio de sesion de Google
|
||||
case "logIn":
|
||||
|
||||
//Busca si ya existe una sesion iniciada
|
||||
HttpSession misesion = request.getSession(true);
|
||||
HttpSession misesion = request.getSession();
|
||||
|
||||
crearUsuario(userID, userEmail, userName, userImg, userRole, pm);
|
||||
|
||||
//Si no existe la sesion, la crea usando el ID del usuario
|
||||
if (!sesionExist(misesion)) {
|
||||
|
||||
misesion = request.getSession(true);
|
||||
misesion.setAttribute("userID", userID);
|
||||
System.out.println("Sesiones: luego de add -> " + misesion.getAttribute("userID"));
|
||||
|
||||
//La sesion perdurara sin actividad durante 6 minutos
|
||||
misesion.setMaxInactiveInterval(360);
|
||||
//La sesion perdurara sin actividad durante 1h.
|
||||
misesion.setMaxInactiveInterval(3600);
|
||||
}
|
||||
|
||||
crearUsuario(userID, userEmail, userName, userImg, userRole, pm);
|
||||
|
||||
break;
|
||||
|
||||
//Si lo que se quiere es redirigir al Form para crear usuario
|
||||
case "redirect":
|
||||
HttpSession sesion= request.getSession();
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/Add.jsp");
|
||||
request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString()));
|
||||
dispatcher.forward(request, response);
|
||||
break;
|
||||
|
||||
@ -87,23 +89,20 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
user.setName(userName);
|
||||
user.setEmail(userEmail);
|
||||
user.setImgUrl(userImg);
|
||||
user.setRole(new Role(userRole));
|
||||
user.setRole(new Role(userRole,true));
|
||||
|
||||
break;
|
||||
//Intenta eliminar un usario con el paramaetro userID
|
||||
case "delete":
|
||||
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(User.class, userID));
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
pm.close();
|
||||
try{
|
||||
response.sendRedirect("/users");
|
||||
}
|
||||
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
||||
catch (IllegalStateException e){
|
||||
System.err.println("IllegalStateException: There was a double redirect.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -131,12 +130,13 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
private boolean sesionExist(HttpSession sesion){
|
||||
try{
|
||||
//Intenta buscar el atributo userID dentro de la sesion
|
||||
boolean a = sesion.getAttribute("userID").toString().isEmpty();
|
||||
String a = sesion.getAttribute("userID").toString();
|
||||
System.out.println("Sesion existe -> " + a);
|
||||
//Si lo encuentra, la sesion si existe
|
||||
System.out.println("Session exists");
|
||||
return true;
|
||||
} catch (NullPointerException e){
|
||||
//Si no, la sesion no existe
|
||||
System.out.println("Sesion no existe");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -144,19 +144,16 @@ public class UsersControllerAdd extends HttpServlet {
|
||||
private void crearUsuario(String userID, String userEmail, String userName, String userImg, String userRole, PersistenceManager pm){
|
||||
|
||||
//Revisa si el usuario con su ID ya tiene un objeto User Persistente almacenado.
|
||||
if (userExists(userID, pm)){
|
||||
System.out.println("User exists!!!!");
|
||||
}
|
||||
//Si no existe, crea el objeto de tipo User con los datos que se obtienen del request, y lo hace Persistente.
|
||||
else {
|
||||
if (!userExists(userID, pm)){
|
||||
|
||||
//El new Role es provisional, hasta que termine la implementacion del CRUD de Role.
|
||||
User user = new User(userID, userName, userImg, userEmail, new Role(userRole));
|
||||
User user = new User(userID, userName, userImg, userEmail, new Role(userRole,true));
|
||||
|
||||
try{
|
||||
pm.makePersistent(user);
|
||||
} finally {
|
||||
System.out.println("Usuario creado con exito.");
|
||||
System.out.println("Usuario creado con exito -> " + user);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package controller.users;
|
||||
|
||||
import model.User;
|
||||
|
||||
import javax.jdo.JDOObjectNotFoundException;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -10,9 +14,22 @@ import java.io.IOException;
|
||||
public class UsersControllerDelete extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
|
||||
String userID = request.getParameter("userID");
|
||||
|
||||
try{
|
||||
pm.deletePersistent(pm.getObjectById(User.class, userID));
|
||||
} catch (JDOObjectNotFoundException e){
|
||||
System.err.println("Exception catched -> " + e.getMessage());
|
||||
}
|
||||
|
||||
response.sendRedirect("/users");
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doPost(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package controller.users;
|
||||
|
||||
import model.User;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
@ -11,28 +12,28 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.google.appengine.api.users.User;
|
||||
import com.google.appengine.api.users.UserService;
|
||||
import com.google.appengine.api.users.UserServiceFactory;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UsersControllerIndex extends HttpServlet {
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
|
||||
//Se usa para revisar si hay nua sesion activa
|
||||
//Se usa para revisar si hay una sesion activa
|
||||
HttpSession sesion= request.getSession();
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
|
||||
//Intenta hallar una sesion activa
|
||||
try{
|
||||
request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString()));
|
||||
User usario = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||
if (usario == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
||||
|
||||
request.setAttribute("User",usario);
|
||||
request.setAttribute("UsersList",UsersControllerView.getAllUsers());
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/index.jsp");
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
}
|
||||
//Si no la encuentra, redirige a la pagina inicial.
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
System.err.println("Error catched. " + e.getMessage());
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></bodyy></html>");
|
||||
}
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
package controller.users;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UsersControllerTest extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
}
|
||||
}
|
@ -33,6 +33,8 @@ public class UsersControllerView extends HttpServlet {
|
||||
else if (action.equals("editRedirect") && userID != null){
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/view.jsp");
|
||||
request.setAttribute("User",getUser(userID));
|
||||
request.setAttribute("UserLogged",getUser(request.getSession().getAttribute("userID").toString()));
|
||||
|
||||
|
||||
//Ya que se quiere editar, el atributo permitirEdicion es verdadero. Este atributo se comprueba en el JSP.
|
||||
request.setAttribute("editAllowed",true);
|
||||
@ -47,6 +49,7 @@ public class UsersControllerView extends HttpServlet {
|
||||
else if (action.equals("viewRedirect") && userID != null){
|
||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/view.jsp");
|
||||
request.setAttribute("User",getUser(userID));
|
||||
request.setAttribute("UserLogged",getUser(request.getSession().getAttribute("userID").toString()));
|
||||
|
||||
//Ya que no quiere editar, el atributo permitirEdicion es falso. Este atributo se comprueba en el JSP.
|
||||
request.setAttribute("editAllowed",false);
|
||||
@ -79,10 +82,9 @@ public class UsersControllerView extends HttpServlet {
|
||||
* @see User
|
||||
*
|
||||
* */
|
||||
static User getUser(String userID){
|
||||
public static User getUser(String userID){
|
||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||
try{
|
||||
System.out.println("UserID: " + userID);
|
||||
User user = pm.getObjectById(User.class, userID);
|
||||
pm.close();
|
||||
return user;
|
||||
@ -113,8 +115,7 @@ public class UsersControllerView extends HttpServlet {
|
||||
* Metodo closeSession
|
||||
*
|
||||
* Este metodo cierra la sesion actual y la sesion de Google. Primero, obtiene la sesion actual del objeto HttpSession y la elimina,
|
||||
* e imprime la url desde la cual fue llamado. Esta url es la respuesta a la llamada que se hace mediante AJAX.
|
||||
* Ver metodo signOut() en users/index.jsp
|
||||
* e imprime un documento HTML basico, que se encarga de cerrar la sesion de Google y redirigir a la pagina de inicio.
|
||||
*
|
||||
*
|
||||
* @param request Request
|
||||
@ -125,14 +126,19 @@ public class UsersControllerView extends HttpServlet {
|
||||
HttpSession sesion = request.getSession();
|
||||
sesion.invalidate();
|
||||
String urlRef = request.getRequestURL().toString();
|
||||
try{
|
||||
|
||||
if (urlRef.contains("8/")){
|
||||
response.getWriter().println(urlRef.substring(0,urlRef.indexOf("8/")+2));
|
||||
urlRef =(urlRef.substring(0,urlRef.indexOf("8/")+2));
|
||||
} else {
|
||||
response.getWriter().println(urlRef.substring(0,urlRef.indexOf("m/")+2));
|
||||
urlRef = (urlRef.substring(0,urlRef.indexOf("m/")+2));
|
||||
}
|
||||
|
||||
try {
|
||||
response.getWriter().println("<html><head><script>window.location.replace(\"https://www.google.com/accounts/" +
|
||||
"Logout?continue=https://appengine.google.com/_ah/logout?continue=" + urlRef + "\");</script></head></html>");
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,17 @@
|
||||
package model;
|
||||
|
||||
import com.google.appengine.api.datastore.Key;
|
||||
import com.google.appengine.api.datastore.KeyFactory;
|
||||
|
||||
import javax.jdo.annotations.IdGeneratorStrategy;
|
||||
import javax.jdo.annotations.PersistenceCapable;
|
||||
import javax.jdo.annotations.Persistent;
|
||||
import javax.jdo.annotations.PrimaryKey;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@PersistenceCapable
|
||||
public class Role {
|
||||
@ -17,12 +23,60 @@ public class Role {
|
||||
@Persistent
|
||||
private String name;
|
||||
|
||||
public Role(String name){
|
||||
@Persistent
|
||||
private String createDate;
|
||||
|
||||
@Persistent
|
||||
private boolean status;
|
||||
|
||||
@Persistent
|
||||
private List<Access> accessesList;
|
||||
|
||||
public Role(String name, boolean status) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
//this.accessesList = accessesList;
|
||||
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
|
||||
createDate = df.format(Calendar.getInstance().getTime());
|
||||
}
|
||||
|
||||
//Getters y Setters
|
||||
public String getKey() {
|
||||
return KeyFactory.keyToString(key);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
public void setCreateDate(String createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public List<Access> getAccessesList() {
|
||||
return accessesList;
|
||||
}
|
||||
public void setAccessesList(List<Access> accessesList) {
|
||||
this.accessesList = accessesList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Role name: " + name +"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<%--
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="java.util.List" %><%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Fernando
|
||||
Date: 07/06/2018
|
||||
@ -6,11 +7,163 @@
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<% User user = (User) request.getAttribute("User"); %>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<title>Add a Role - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
color: blue;
|
||||
font-size: large;
|
||||
cursor: pointer;
|
||||
|
||||
transition: color 250ms ease-in;
|
||||
}
|
||||
.postLink:hover{
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= user.getName()%>
|
||||
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li class="active"><a class="whiteLink" href="">Users</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Add a Role</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form method="post" action="./add">
|
||||
<input name="action" value="create" type="hidden">
|
||||
|
||||
Name of the Role:<br />
|
||||
<input name="roleName" placeholder="Name of the Role" required><br />
|
||||
Status of the Role:<br />
|
||||
<select name="roleStatus" class="browser-default" required>
|
||||
<option value="" disabled selected>Choose a status</option>
|
||||
<option value="true">true</option>
|
||||
<option value="false">false</option>
|
||||
</select>
|
||||
<br />
|
||||
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
<hr />
|
||||
<br />
|
||||
<a href="../roles" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var sourceImg = document.getElementById("sourceImg");
|
||||
|
||||
function cambiarImg(input) {
|
||||
sourceImg.src = input.value;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<%--
|
||||
<%@ page import="model.Role" %>
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="java.util.List" %><%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Fernando
|
||||
Date: 07/06/2018
|
||||
@ -6,11 +8,182 @@
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<% User usuario = (User) request.getAttribute("User"); %>
|
||||
<% List<Role> roleList = (List<Role>) request.getAttribute("RoleList");%>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<title>Roles - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
color: blue;
|
||||
font-size: large;
|
||||
cursor: pointer;
|
||||
|
||||
transition: color 250ms ease-in;
|
||||
}
|
||||
.postLink:hover{
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink hide-on-med-and-down" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= usuario.getName()%>
|
||||
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li>
|
||||
<li class="active"><a class="whiteLink" href="">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Roles</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/roles/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<table class="striped responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Status</td>
|
||||
<td>Date created</td>
|
||||
<td>Actions</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<% for (int i = 0; i < roleList.size(); i++) {%>
|
||||
<% Role role = roleList.get(i); %>
|
||||
<% String key = role.getKey();
|
||||
|
||||
String[] arr = key.split("");
|
||||
|
||||
key = "";
|
||||
for (String a : arr) {
|
||||
if (a.equals("\"")){
|
||||
key += """;
|
||||
} else{
|
||||
key += a;
|
||||
}
|
||||
}
|
||||
|
||||
%>
|
||||
<tr>
|
||||
<td><%= role.getName()%></td>
|
||||
<td><%= role.getStatus()%></td>
|
||||
<td><%= role.getCreateDate()%></td>
|
||||
<td>
|
||||
<a class="postLink" onclick="postRedirect('roles/view',{action:'viewRedirect',key:'<%=key%>'})">View</a>
|
||||
| <a class="postLink" onclick="postRedirect('roles/view',{action:'editRedirect',key:'<%=key%>'})">Edit</a>
|
||||
| <a class="postLink" onclick="postRedirect('roles/delete',{key:'<%=key%>'})">Delete</a></td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
||||
</tbody>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,3 +1,5 @@
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="model.Role" %>
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Fernando
|
||||
@ -5,12 +7,175 @@
|
||||
Time: 16:39
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<% Role role = (Role) request.getAttribute("Role");
|
||||
User userLogged = (User) request.getAttribute("UserLogged");
|
||||
boolean editAllowed = (Boolean) request.getAttribute("editAllowed");
|
||||
String action = (String) request.getAttribute("action");%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<title><%=action%> a User - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
color: blue;
|
||||
font-size: large;
|
||||
cursor: pointer;
|
||||
|
||||
transition: color 250ms ease-in;
|
||||
}
|
||||
.postLink:hover{
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= userLogged.getName()%>
|
||||
<img src="<%=userLogged.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('/users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li>
|
||||
<li class="active"><a class="whiteLink" href="">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a User</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<% if (editAllowed) {%>
|
||||
|
||||
<form action="./add" method="post">
|
||||
|
||||
<input name="key" value="<%=role.getKey()%>" type="hidden">
|
||||
<input name="action" value="update" type="hidden">
|
||||
|
||||
Name:<br />
|
||||
<input name="roleName" value="<%=role.getName()%>" placeholder="Name" required><br/>
|
||||
<br/>
|
||||
Status:<br />
|
||||
<select name="roleStatus" class="browser-default" required>
|
||||
<option value="" disabled selected>Choose a status</option>
|
||||
<option value="true">true</option>
|
||||
<option value="false">false</option>
|
||||
</select>
|
||||
<br />
|
||||
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<% } else {%>
|
||||
|
||||
|
||||
<div style="font-size: x-large">
|
||||
Name: <%=role.getName()%><br />
|
||||
Email: <%=role.getStatus()%><br />
|
||||
</div>
|
||||
|
||||
|
||||
<% } %>
|
||||
|
||||
<hr />
|
||||
<br />
|
||||
<a href="../roles" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<%--
|
||||
<%@ page import="model.User" %>
|
||||
<%@ page import="java.util.List" %><%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Fernando
|
||||
Date: 07/06/2018
|
||||
@ -6,13 +7,172 @@
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<% User user = (User) request.getAttribute("User"); %>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>Create a User</title>
|
||||
<title>Add a User - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
color: blue;
|
||||
font-size: large;
|
||||
cursor: pointer;
|
||||
|
||||
transition: color 250ms ease-in;
|
||||
}
|
||||
.postLink:hover{
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Create a User!!!
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= user.getName()%>
|
||||
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li class="active"><a class="whiteLink" href="">Users</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Add a User</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<form method="post" action="./add">
|
||||
<input name="action" value="create" type="hidden">
|
||||
|
||||
Name of the User:<br />
|
||||
<input name="userName" placeholder="Name of the User" required><br />
|
||||
Email of the User:<br />
|
||||
<input name="userEmail" placeholder="Email" type="email" required>
|
||||
|
||||
<div class="row">
|
||||
<div class="col l10 m10">
|
||||
Profile Image link<br />
|
||||
<input name="userImg" value="https://i.stack.imgur.com/34AD2.jpg" placeholder="Link" required oninput="cambiarImg(this)"><br />
|
||||
<br />
|
||||
</div>
|
||||
<div class="col l2 m2">
|
||||
<img id="sourceImg" src="https://i.stack.imgur.com/34AD2.jpg" alt="" width="70px">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Role of the User:<br />
|
||||
<input name="userRole" placeholder="Role" required>
|
||||
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
<hr />
|
||||
<br />
|
||||
<a href="../users" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var sourceImg = document.getElementById("sourceImg");
|
||||
|
||||
function cambiarImg(input) {
|
||||
sourceImg.src = input.value;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,13 +9,20 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<% User usuario = (User) request.getAttribute("User"); %>
|
||||
<% List<User> userList = (List<User>) request.getAttribute("UsersList");%>
|
||||
<html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<title>Titulo</title>
|
||||
<title>Users - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
@ -29,60 +36,116 @@
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
User: <%= usuario.getName()%><img src="<%=usuario.getImgUrl()%>"><br/>
|
||||
You can
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink hide-on-med-and-down" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<a href="#" onclick="signOut();">Sign out</a> there v:<br />
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= usuario.getName()%>
|
||||
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li class="active"><a class="whiteLink" href="">Users</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Users</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<table>
|
||||
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/users/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<table class="striped responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Email</td>
|
||||
<td>Img</td>
|
||||
<td>Actions</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<% for (int i = 0; i < userList.size(); i++) {%>
|
||||
<% User user = userList.get(i); %>
|
||||
<tr>
|
||||
<td><%= user.getName()%></td>
|
||||
<td><%= user.getEmail()%></td>
|
||||
<td><img src="<%= user.getImgUrl()%>"/></td>
|
||||
<td><img src="<%= user.getImgUrl()%>" width="55px"/></td>
|
||||
<td>
|
||||
<a class="postLink" onclick="postRedirect('users/view',{action:'viewRedirect',userID:'<%=user.getId()%>'})">View</a>
|
||||
| <a class="postLink" onclick="postRedirect('users/view',{action:'editRedirect',userID:'<%=user.getId()%>'})">Edit</a>
|
||||
| <a class="postLink" onclick="postRedirect('users/add',{action:'delete',userID:'<%=user.getId()%>'})">Delete</a></td>
|
||||
| <a class="postLink" onclick="postRedirect('users/delete',{userID:'<%=user.getId()%>'})">Delete</a></td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
||||
</tbody>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function signOut() {
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
req.onreadystatechange = function () {
|
||||
if (req.readyState === 4 && req.status === 200){
|
||||
<%-- Hace una solicitud al metodo UsersControllerView, y recibe una url. Luego, cierra la sesion de Google, y luego redirige
|
||||
a la url recibida.--%>
|
||||
document.location.href = "https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=" + req.responseText;
|
||||
}
|
||||
};
|
||||
|
||||
req.open("GET","/users/view?action=closeSession",true);
|
||||
req.send();
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
|
@ -8,16 +8,89 @@
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<% User user = (User) request.getAttribute("User");
|
||||
User userLogged = (User) request.getAttribute("UserLogged");
|
||||
boolean editAllowed = (Boolean) request.getAttribute("editAllowed");
|
||||
String action = (String) request.getAttribute("action");%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<head>
|
||||
<title><%=action%> a User</title>
|
||||
<title><%=action%> a Role - Hotel Services</title>
|
||||
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
.postLink{
|
||||
color: blue;
|
||||
font-size: large;
|
||||
cursor: pointer;
|
||||
|
||||
transition: color 250ms ease-in;
|
||||
}
|
||||
.postLink:hover{
|
||||
color: green;
|
||||
font-size: larger;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
.whiteLink{
|
||||
color: white;
|
||||
}
|
||||
.whiteLink:hover{
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Datos del usuario:<br />
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||
|
||||
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||
<%= userLogged.getName()%>
|
||||
<img src="<%=userLogged.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||
<i class="material-icons right">arrow_drop_down</i>
|
||||
|
||||
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||
<ul style="color: black">
|
||||
|
||||
<li style="padding: 0 5px;">
|
||||
<a style="color: black" onclick="postRedirect('/users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||
</li>
|
||||
|
||||
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||
<i class="small material-icons">arrow_drop_up</i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="nav-mobile" class="right">
|
||||
<li class="active"><a class="whiteLink" href="">Users</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<br />
|
||||
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a Role</span>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<% if (editAllowed) {%>
|
||||
@ -27,34 +100,105 @@ Datos del usuario:<br />
|
||||
<input name="userID" value="<%=user.getId()%>" type="hidden">
|
||||
<input name="action" value="update" type="hidden">
|
||||
|
||||
Nombre:<br />
|
||||
<input name="userName" value="<%=user.getName()%>" placeholder="Nombre" required><br/>
|
||||
Name:<br />
|
||||
<input name="userName" value="<%=user.getName()%>" placeholder="Name" required><br/>
|
||||
<br/>
|
||||
Email:<br />
|
||||
<input name="userEmail" value="<%=user.getEmail()%>" placeholder="Email" type="email" required><br />
|
||||
<br />
|
||||
Imagen de perfil<br />
|
||||
<input name="userImg" value="<%=user.getImgUrl()%>" placeholder="Link de la imagen" required><br />
|
||||
|
||||
<div class="row">
|
||||
<div class="col l10 m10">
|
||||
Profile Image link<br />
|
||||
<input name="userImg" value="<%=user.getImgUrl()%>" placeholder="Link" required oninput="cambiarImg(this)"><br />
|
||||
<br />
|
||||
</div>
|
||||
<div class="col l2 m2">
|
||||
<img id="sourceImg" src="<%=user.getImgUrl()%>" alt="" width="70px">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Rol<br />
|
||||
<input name="userRole" value="<%=user.getRole()%>" placeholder="Rol" required><br />
|
||||
<input name="userRole" value="<%=user.getRole()%>" placeholder="Role" required><br />
|
||||
<br />
|
||||
<input type="submit"><br />
|
||||
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<% } else {%>
|
||||
|
||||
<img src="<%=user.getImgUrl()%>"><br />
|
||||
<br />
|
||||
|
||||
Nombre: <%=user.getName()%><br />
|
||||
<div class="row">
|
||||
<div class="col l8 m8" style="font-size: x-large">
|
||||
Name: <%=user.getName()%><br />
|
||||
Email: <%=user.getEmail()%><br />
|
||||
Rol: <%= user.getRole()%><br />
|
||||
Role: <%= user.getRole()%><br />
|
||||
</div>
|
||||
<div class="col l4 m4">
|
||||
<img src="<%=user.getImgUrl()%>" width="96px"><br />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% } %>
|
||||
|
||||
Eso es todo :c
|
||||
<hr />
|
||||
<br />
|
||||
<a href="../users" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var sourceImg = document.getElementById("sourceImg");
|
||||
|
||||
function cambiarImg(input) {
|
||||
sourceImg.src = input.value;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
var userOptions = document.getElementById("userOptions");
|
||||
|
||||
var isUserOptionsEnable = true;
|
||||
|
||||
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||
|
||||
function changeUserOptions() {
|
||||
if (isUserOptionsEnable){
|
||||
userOptions.style.display = "none";
|
||||
} else {
|
||||
userOptions.style.display = "block";
|
||||
}
|
||||
|
||||
isUserOptionsEnable = !isUserOptionsEnable;
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function postRedirect(url, postData){
|
||||
|
||||
var postForm = document.createElement("form");
|
||||
postForm.action = url;
|
||||
postForm.method = "POST";
|
||||
|
||||
postForm.style.display = "none";
|
||||
|
||||
for (var key in postData){
|
||||
if (postData.hasOwnProperty(key)){
|
||||
var input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = key;
|
||||
input.value = postData[key];
|
||||
postForm.appendChild(input);
|
||||
}
|
||||
}
|
||||
|
||||
document.body.appendChild(postForm);
|
||||
|
||||
postForm.submit();
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||
<application>lab08-SU_CUI</application>
|
||||
<application>lab08-20173373</application>
|
||||
<version>1</version>
|
||||
<sessions-enabled>true</sessions-enabled>
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -154,19 +154,6 @@
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<servlet>
|
||||
<servlet-name>UsersControllerTest</servlet-name>
|
||||
<servlet-class>controller.users.UsersControllerTest</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>UsersControllerTest</servlet-name>
|
||||
<url-pattern>/users/test</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
116
war/css/Diseno.css
Normal file
116
war/css/Diseno.css
Normal file
@ -0,0 +1,116 @@
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, font, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td {
|
||||
border: 0;
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
font-style: inherit;
|
||||
font-weight: inherit;
|
||||
margin: 0;
|
||||
outline: 0;
|
||||
padding: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
html {
|
||||
font-size: 62.5%; /* Corrects text resizing oddly in IE6/7 when body font-size is set using em units http://clagnut.com/blog/348/#c790 */
|
||||
overflow-y: scroll; /* Keeps page centered in all browsers regardless of content height */
|
||||
-webkit-text-size-adjust: 100%; /* Prevents iOS text size adjust after orientation change, without disabling user zoom */
|
||||
-ms-text-size-adjust: 100%; /* www.456bereastreet.com/archive/201012/controlling_text_size_in_safari_for_ios_without_disabling_user_zoom/ */
|
||||
}
|
||||
*,
|
||||
*:before,
|
||||
*:after { /* apply a natural box layout model to all elements; see http://www.paulirish.com/2012/box-sizing-border-box-ftw/ */
|
||||
-webkit-box-sizing: border-box; /* Not needed for modern webkit but still used by Blackberry Browser 7.0; see http://caniuse.com/#search=box-sizing */
|
||||
-moz-box-sizing: border-box; /* Still needed for Firefox 28; see http://caniuse.com/#search=box-sizing */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
background: #EEEEEE; /*Por defecto es F0F0F0 */
|
||||
}
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
main,
|
||||
nav,
|
||||
section {
|
||||
display: block;
|
||||
}
|
||||
ol,
|
||||
ul {
|
||||
list-style: none;
|
||||
}
|
||||
table { /* tables still need 'cellspacing="0"' in the markup */
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
caption,
|
||||
th,
|
||||
td {
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
}
|
||||
blockquote:before,
|
||||
blockquote:after,
|
||||
q:before,
|
||||
q:after {
|
||||
content: "";
|
||||
}
|
||||
blockquote,
|
||||
q {
|
||||
quotes: "" "";
|
||||
}
|
||||
a:focus {
|
||||
outline: thin dotted;
|
||||
}
|
||||
a:hover,
|
||||
a:active {
|
||||
outline: 0;
|
||||
}
|
||||
a img {
|
||||
border: 0;
|
||||
}
|
||||
/*
|
||||
|
||||
-----------------------------------------------------
|
||||
|
||||
RESET
|
||||
|
||||
-----------------------------------------------------
|
||||
*/
|
||||
|
||||
a {
|
||||
color: #404040; /* por defecto 404040*/
|
||||
text-decoration: none;
|
||||
-o-transition: all .8s ease-in-out;
|
||||
-moz-transition: all .8s ease-in-out;
|
||||
-webkit-transition: all .8s ease-in-out;
|
||||
transition: all .8s ease-in-out;
|
||||
}
|
||||
a:hover,
|
||||
a:focus,
|
||||
a:active {
|
||||
color: #23BF87;
|
||||
-o-transition: all 0s ease-in-out;
|
||||
-moz-transition: all 0s ease-in-out;
|
||||
-webkit-transition: all 0s ease-in-out;
|
||||
transition: all 0s ease-in-out;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Product Sans";
|
||||
src: url("../fonts/ProductSansRegular.ttf");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Product Sans";
|
||||
font-weight: bold;
|
||||
src: url("../fonts/ProductSansBold.ttf");
|
||||
}
|
9407
war/css/materialize.css
vendored
Normal file
9407
war/css/materialize.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
war/css/materialize.min.css
vendored
Normal file
1
war/css/materialize.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
war/fonts/ProductSansBold.ttf
Normal file
BIN
war/fonts/ProductSansBold.ttf
Normal file
Binary file not shown.
BIN
war/fonts/ProductSansRegular.ttf
Normal file
BIN
war/fonts/ProductSansRegular.ttf
Normal file
Binary file not shown.
@ -1,36 +1,85 @@
|
||||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Hotel Services</title>
|
||||
<meta charset="UTF-8">
|
||||
<title>Home - Hotel Service</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="./css/Diseno.css">
|
||||
<link type="text/css" rel="stylesheet" href="./css/materialize.min.css">
|
||||
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||
|
||||
<style>
|
||||
#mainHeader{
|
||||
background: url('http://www.hotelimperialeroma.it/data/mobile/hotel-imperiale-roma-camere-01-2.jpg') no-repeat local center;
|
||||
height: 40%;
|
||||
text-align: center;
|
||||
padding: 100px;
|
||||
background-size: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
transition: opacity 500ms, max-height 250ms,padding 500ms;
|
||||
}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: white;
|
||||
font-family: Roboto, serif;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Hotel Services.</h1>
|
||||
<div id="mainHeader">
|
||||
<h1 style="font-size: 50px; color: white; display: inline; font-weight: bold; font-family: 'Product Sans',serif">Hotel Services</h1>
|
||||
</div>
|
||||
<nav style="background-color: #67c9b3">
|
||||
<div class="nav-wrapper">
|
||||
<a href="./" class="brand-logo" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif">Hotel Services</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
Please log in to continue:<br />
|
||||
<br />
|
||||
<div class="container">
|
||||
|
||||
<div style="font-size: x-large">
|
||||
<span id="mainText">Welcome! Log In to Start:</span>
|
||||
<br />
|
||||
<br />
|
||||
<div class="g-signin2" data-onsuccess="onSignIn"></div>
|
||||
</div>
|
||||
<br />
|
||||
<hr />
|
||||
Developed by:<br />
|
||||
Fernando Araoz, 2017337<br />
|
||||
Jose Rodriguez, <br />
|
||||
Gustavo Turpo, <br />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
You can Sign out here:
|
||||
<a href="#" onclick="signOut();">Sign out</a>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
function onSignIn(googleUser) {
|
||||
var profile = googleUser.getBasicProfile();
|
||||
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
|
||||
console.log('Name: ' + profile.getName());
|
||||
console.log('Image URL: ' + profile.getImageUrl());
|
||||
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
|
||||
|
||||
document.getElementById("mainText").innerText = "Logged In. Redirecting...";
|
||||
|
||||
document.getElementById("mainHeader").style.maxHeight = "0";
|
||||
document.getElementById("mainHeader").style.padding = "0";
|
||||
|
||||
setTimeout(function () {
|
||||
postRedirect("/users/add",{
|
||||
userEmail : profile.getEmail(),
|
||||
userName : profile.getName(),
|
||||
@ -38,6 +87,7 @@ You can Sign out here:
|
||||
userRole : "admin",
|
||||
action : "logIn"
|
||||
});
|
||||
},500);
|
||||
|
||||
}
|
||||
|
||||
|
10021
war/js/materialize.js
vendored
Normal file
10021
war/js/materialize.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
war/js/materialize.min.js
vendored
Normal file
6
war/js/materialize.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user