Arreglo de errores
This commit is contained in:
parent
2994b38f08
commit
e45470c263
@ -1,7 +1,7 @@
|
|||||||
package controller;
|
package controller;
|
||||||
|
|
||||||
import javax.jdo.JDOHelper;
|
import javax.jdo.JDOHelper;
|
||||||
import javax.jdo.PersistenceManagerFactory;
|
import javax.jdo.PersistenceManagerFactory;
|
||||||
|
|
||||||
/* clase "pmf.PMF" que va a tener la variable encargada de controlar las peticiones
|
/* clase "pmf.PMF" que va a tener la variable encargada de controlar las peticiones
|
||||||
* de registros y búsqueda de la información almacenada. */
|
* de registros y búsqueda de la información almacenada. */
|
||||||
|
@ -24,8 +24,12 @@ public class AccessControllerAdd extends HttpServlet {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
|
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||||
|
|
||||||
String query = "select from " + Role.class.getName();
|
String query = "select from " + Role.class.getName();
|
||||||
String query2 = "select from " + Resource.class.getName();
|
String query2 = "select from " + Resource.class.getName();
|
||||||
@ -97,6 +101,20 @@ public class AccessControllerAdd extends HttpServlet {
|
|||||||
System.err.println("IllegalStateException: There was a double redirect.");
|
System.err.println("IllegalStateException: There was a double redirect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to create an access.\"}");
|
||||||
|
response.sendRedirect("/access");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -15,6 +15,11 @@ import controller.PMF;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AccessControllerDelete extends HttpServlet {
|
public class AccessControllerDelete extends HttpServlet {
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
// create the persistence manager instance
|
// create the persistence manager instance
|
||||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||||
// create the new account
|
// create the new account
|
||||||
@ -29,6 +34,17 @@ public class AccessControllerDelete extends HttpServlet {
|
|||||||
} catch(javax.jdo.JDOObjectNotFoundException nf) {
|
} catch(javax.jdo.JDOObjectNotFoundException nf) {
|
||||||
response.sendRedirect("/access");
|
response.sendRedirect("/access");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to delete an access.\"}");
|
||||||
|
response.sendRedirect("/access");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -22,6 +22,11 @@ public class AccessControllerEdit extends HttpServlet {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
// create the persistence manager instance
|
// create the persistence manager instance
|
||||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||||
try{
|
try{
|
||||||
@ -80,10 +85,24 @@ public class AccessControllerEdit extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch(javax.jdo.JDOObjectNotFoundException nf) {
|
} catch(javax.jdo.JDOObjectNotFoundException nf) {
|
||||||
response.sendRedirect("/index.html");
|
response.sendRedirect("/index.jsp");
|
||||||
} catch (NumberFormatException e){
|
} catch (NumberFormatException e){
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/users");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to edit an access.\"}");
|
||||||
|
response.sendRedirect("/access");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -19,8 +19,13 @@ import java.util.List;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class AccessControllerIndex extends HttpServlet {
|
public class AccessControllerIndex extends HttpServlet {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
// create the persistence manager instance
|
// create the persistence manager instance
|
||||||
PersistenceManager pm = PMF.get().getPersistenceManager();
|
PersistenceManager pm = PMF.get().getPersistenceManager();
|
||||||
|
|
||||||
@ -37,6 +42,7 @@ public class AccessControllerIndex extends HttpServlet {
|
|||||||
|
|
||||||
// query for the entities by name
|
// query for the entities by name
|
||||||
String query = "select from " + Access.class.getName();
|
String query = "select from " + Access.class.getName();
|
||||||
|
|
||||||
List<Access> accesses = (List<Access>)pm.newQuery(query).execute();
|
List<Access> accesses = (List<Access>)pm.newQuery(query).execute();
|
||||||
|
|
||||||
// pass the list to the jsp
|
// pass the list to the jsp
|
||||||
@ -58,6 +64,19 @@ public class AccessControllerIndex extends HttpServlet {
|
|||||||
pm.close();
|
pm.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /access.\"}");
|
||||||
|
response.sendRedirect("/");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -29,6 +29,8 @@ public class AccessControllerView extends HttpServlet {
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())) {
|
||||||
|
|
||||||
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id")));
|
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id")));
|
||||||
Access a = pm.getObjectById(Access.class, k);
|
Access a = pm.getObjectById(Access.class, k);
|
||||||
|
|
||||||
@ -46,7 +48,15 @@ public class AccessControllerView extends HttpServlet {
|
|||||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/view.jsp");
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/view.jsp");
|
||||||
dispatcher.forward(request, response);
|
dispatcher.forward(request, response);
|
||||||
|
|
||||||
}catch(javax.jdo.JDOObjectNotFoundException nf) {
|
} else {
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to view an access.\"}");
|
||||||
|
response.sendRedirect("/access");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch(javax.jdo.JDOObjectNotFoundException nf) {
|
||||||
System.err.println("JDOObjectNotFound -> AccessControllerView");
|
System.err.println("JDOObjectNotFound -> AccessControllerView");
|
||||||
nf.printStackTrace();
|
nf.printStackTrace();
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"darkorange\",\"response\":\"Error trying to view the Access.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"darkorange\",\"response\":\"Error trying to view the Access.\"}");
|
||||||
@ -54,7 +64,8 @@ public class AccessControllerView extends HttpServlet {
|
|||||||
|
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e){
|
||||||
System.err.println("NPE -> Trying to access a servlet without logging in.");
|
System.err.println("NPE -> Trying to access a servlet without logging in.");
|
||||||
response.sendRedirect("/users");
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +103,7 @@ public class AccessControllerView extends HttpServlet {
|
|||||||
* */
|
* */
|
||||||
public static boolean checkPermission(String userID, String uri){
|
public static boolean checkPermission(String userID, String uri){
|
||||||
|
|
||||||
User user = (User) UsersControllerView.getUser(userID);
|
User user = UsersControllerView.getUser(userID);
|
||||||
String userRoleName = user.getRoleName();
|
String userRoleName = user.getRoleName();
|
||||||
String userRoleKey = user.getRoleKey();
|
String userRoleKey = user.getRoleKey();
|
||||||
if (userRoleKey == null)
|
if (userRoleKey == null)
|
||||||
@ -101,10 +112,8 @@ public class AccessControllerView extends HttpServlet {
|
|||||||
for (Access access: getAllAccess()){
|
for (Access access: getAllAccess()){
|
||||||
if (userRoleName.equals("admin")){
|
if (userRoleName.equals("admin")){
|
||||||
return true;
|
return true;
|
||||||
} else if (access.getRoleKey().equals(userRoleKey)){
|
} else if (access.getRoleKey().equals(userRoleKey) && access.getStatus()){
|
||||||
System.out.println("Encontrado USuario con Rol coincidente");
|
if (access.getResourceName().equals(uri) && ResourcesControllerView.getResource(access.getResourceKey()).getStatus()){
|
||||||
if (access.getResourceName().equals(uri)){
|
|
||||||
System.out.println("El USuario tiene acceso a esta URI");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
src/controller/index.java
Normal file
50
src/controller/index.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package controller;
|
||||||
|
|
||||||
|
import controller.users.UsersControllerView;
|
||||||
|
import model.User;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class index extends HttpServlet {
|
||||||
|
|
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
HttpSession sesion= request.getSession();
|
||||||
|
|
||||||
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
|
||||||
|
|
||||||
|
User loggedUser;
|
||||||
|
|
||||||
|
try {
|
||||||
|
loggedUser = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
loggedUser = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loggedUser != null){
|
||||||
|
|
||||||
|
request.setAttribute("User",loggedUser);
|
||||||
|
request.setAttribute("isUserLogged",true);
|
||||||
|
request.setAttribute("serverResponse","You are logged in.");
|
||||||
|
request.setAttribute("serverResponse",request.getSession().getAttribute("serverResponse"));
|
||||||
|
request.getSession().setAttribute("serverResponse","!");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request.setAttribute("isUserLogged",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatcher.forward(request,response);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
doPost(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -86,12 +86,12 @@ public class ServicesControllerAdd extends HttpServlet {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to create/update a Service.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to create/update a Service.\"}");
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e){
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +43,12 @@ public class ServicesControllerDelete extends HttpServlet {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to delete a Service.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to delete a Service.\"}");
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e){
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,11 +45,12 @@ public class ServicesControllerIndex extends HttpServlet {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /services.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /services.\"}");
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e){
|
||||||
response.sendRedirect("/users");
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public class ServicesControllerView extends HttpServlet {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to view/edit a Service.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to view/edit a Service.\"}");
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (NullPointerException e){
|
} catch (NullPointerException e){
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/services");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package controller.users;
|
package controller.users;
|
||||||
|
|
||||||
|
import controller.access.AccessControllerView;
|
||||||
import controller.roles.RolesControllerAdd;
|
import controller.roles.RolesControllerAdd;
|
||||||
import controller.roles.RolesControllerView;
|
import controller.roles.RolesControllerView;
|
||||||
import model.Role;
|
import model.Role;
|
||||||
@ -21,6 +22,11 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if(request.getParameter("action").equals("logIn") ||
|
||||||
|
AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||||
|
|
||||||
//Accion a realizar
|
//Accion a realizar
|
||||||
@ -51,6 +57,7 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
String userImg = request.getParameter("userImg");
|
String userImg = request.getParameter("userImg");
|
||||||
String userRole = request.getParameter("userRole");
|
String userRole = request.getParameter("userRole");
|
||||||
|
|
||||||
|
String rutaRedireccion = "/users";
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
//Si se quiere iniciar sesion y/o registrar un usuario desde el inicio de sesion de Google
|
//Si se quiere iniciar sesion y/o registrar un usuario desde el inicio de sesion de Google
|
||||||
@ -83,6 +90,8 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
|
|
||||||
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"You are logged in.\"}";
|
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"You are logged in.\"}";
|
||||||
|
|
||||||
|
rutaRedireccion = "/";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Si lo que se quiere es redirigir al Form para crear usuario
|
//Si lo que se quiere es redirigir al Form para crear usuario
|
||||||
@ -110,7 +119,7 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
user.setImgUrl(userImg);
|
user.setImgUrl(userImg);
|
||||||
user.setRoleKey(userRole);
|
user.setRoleKey(userRole);
|
||||||
|
|
||||||
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"Service updated successfully.\"}";
|
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"User updated successfully.\"}";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -118,13 +127,26 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
pm.close();
|
pm.close();
|
||||||
try{
|
try{
|
||||||
request.getSession().setAttribute("serverResponse",serverResponse);
|
request.getSession().setAttribute("serverResponse",serverResponse);
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect(rutaRedireccion);
|
||||||
}
|
}
|
||||||
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
//Al redirigr al jsp para crear, se usa RequestDispatcher, y este entra en conflicto con sendRedirect.
|
||||||
catch (IllegalStateException e){
|
catch (IllegalStateException e){
|
||||||
System.err.println("IllegalStateException: There was a double redirect.");
|
System.err.println("IllegalStateException: There was a double redirect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to create a user.\"}");
|
||||||
|
response.sendRedirect("/users");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +200,16 @@ public class UsersControllerAdd extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//Si el usuario ya existe, lo obtiene, revisa su imagen de perfil, y la actualiza (si al iniciar sesion con Google no coinciden).
|
||||||
|
else {
|
||||||
|
|
||||||
|
User loggedUser = pm.getObjectById(User.class,userID);
|
||||||
|
|
||||||
|
if (!userImg.equals(loggedUser.getImgUrl()))
|
||||||
|
loggedUser.setImgUrl(userImg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package controller.users;
|
package controller.users;
|
||||||
|
|
||||||
|
import controller.access.AccessControllerView;
|
||||||
import model.User;
|
import model.User;
|
||||||
|
|
||||||
import javax.jdo.JDOObjectNotFoundException;
|
import javax.jdo.JDOObjectNotFoundException;
|
||||||
@ -14,13 +15,17 @@ import java.io.IOException;
|
|||||||
public class UsersControllerDelete extends HttpServlet {
|
public class UsersControllerDelete extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||||
|
|
||||||
String userID = request.getParameter("userID");
|
String userID = request.getParameter("userID");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
pm.deletePersistent(pm.getObjectById(User.class, userID));
|
pm.deletePersistent(pm.getObjectById(User.class, userID));
|
||||||
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Service deleted sucessfully.\"}");
|
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"User deleted sucessfully.\"}");
|
||||||
} catch (JDOObjectNotFoundException e){
|
} catch (JDOObjectNotFoundException e){
|
||||||
System.err.println("Exception catched -> " + e.getMessage());
|
System.err.println("Exception catched -> " + e.getMessage());
|
||||||
}
|
}
|
||||||
@ -29,6 +34,19 @@ public class UsersControllerDelete extends HttpServlet {
|
|||||||
|
|
||||||
response.sendRedirect("/users");
|
response.sendRedirect("/users");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to delete a user.\"}");
|
||||||
|
response.sendRedirect("/users");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -1,27 +1,28 @@
|
|||||||
package controller.users;
|
package controller.users;
|
||||||
|
|
||||||
|
import controller.access.AccessControllerView;
|
||||||
import model.User;
|
import model.User;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.jdo.PersistenceManager;
|
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class UsersControllerIndex extends HttpServlet {
|
public class UsersControllerIndex extends HttpServlet {
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
//Se usa para revisar si hay una sesion activa
|
//Se usa para revisar si hay una sesion activa
|
||||||
HttpSession sesion= request.getSession();
|
HttpSession sesion= request.getSession();
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(sesion.getAttribute("userID").toString(),request.getRequestURI())){
|
||||||
|
|
||||||
//Intenta hallar una sesion activa
|
//Intenta hallar una sesion activa
|
||||||
try{
|
|
||||||
User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
User user = UsersControllerView.getUser(sesion.getAttribute("userID").toString());
|
||||||
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
|
||||||
|
|
||||||
@ -32,11 +33,16 @@ public class UsersControllerIndex extends HttpServlet {
|
|||||||
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/index.jsp");
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/index.jsp");
|
||||||
dispatcher.forward(request,response);
|
dispatcher.forward(request,response);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /users.\"}");
|
||||||
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Si no la encuentra, redirige a la pagina inicial.
|
//Si no la encuentra, redirige a la pagina inicial.
|
||||||
catch (Exception e){
|
//Si el usuario no tiene permiso tambien redirigie a la pagina inicial
|
||||||
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
|
} catch (Exception e){
|
||||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package controller.users;
|
package controller.users;
|
||||||
|
|
||||||
|
import controller.access.AccessControllerView;
|
||||||
import controller.roles.RolesControllerView;
|
import controller.roles.RolesControllerView;
|
||||||
import model.User;
|
import model.User;
|
||||||
|
|
||||||
@ -12,15 +13,22 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class UsersControllerView extends HttpServlet {
|
public class UsersControllerView extends HttpServlet {
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())) {
|
||||||
|
|
||||||
String action = request.getParameter("action");
|
String action = request.getParameter("action");
|
||||||
|
|
||||||
//Para evitar errores, si no hay ninguna accion, se establece a vacio.
|
//Para evitar errores, si no hay ninguna accion, se establece a vacio.
|
||||||
|
|
||||||
if (action == null)
|
if (action == null)
|
||||||
action = "";
|
action = "";
|
||||||
|
|
||||||
@ -69,10 +77,24 @@ public class UsersControllerView extends HttpServlet {
|
|||||||
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
|
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to edit/view a user.\"}");
|
||||||
|
response.sendRedirect("/users");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
response.sendRedirect("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
doPost(request, response);
|
doPost(request, response);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,4 +166,6 @@ public class UsersControllerView extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import javax.jdo.annotations.IdentityType;
|
|||||||
import javax.jdo.annotations.PersistenceCapable;
|
import javax.jdo.annotations.PersistenceCapable;
|
||||||
import javax.jdo.annotations.Persistent;
|
import javax.jdo.annotations.Persistent;
|
||||||
import javax.jdo.annotations.PrimaryKey;
|
import javax.jdo.annotations.PrimaryKey;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@PersistenceCapable(identityType = IdentityType.APPLICATION)
|
@PersistenceCapable(identityType = IdentityType.APPLICATION)
|
||||||
public class User {
|
public class User {
|
||||||
|
@ -174,6 +174,8 @@
|
|||||||
<span class="heading">No Accesses registered.</span>
|
<span class="heading">No Accesses registered.</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,8 +203,19 @@
|
|||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Controlador para gestionar el comportamiento del menu de inicio -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>index</servlet-name>
|
||||||
|
<servlet-class>controller.index</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>index</servlet-name>
|
||||||
|
<url-pattern>/</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>index.html</welcome-file>
|
<welcome-file>index.jsp</welcome-file>
|
||||||
</welcome-file-list>
|
</welcome-file-list>
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
||||||
|
@ -87,30 +87,5 @@ 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");
|
|
||||||
}
|
|
@ -7,7 +7,6 @@
|
|||||||
}
|
}
|
||||||
.postLink:hover{
|
.postLink:hover{
|
||||||
color: green;
|
color: green;
|
||||||
font-size: larger;
|
|
||||||
}
|
}
|
||||||
body{
|
body{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -59,3 +58,20 @@ body{
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.transition{
|
||||||
|
overflow: hidden;
|
||||||
|
height: auto;
|
||||||
|
|
||||||
|
transition: max-height 250ms ease-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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");
|
||||||
|
}
|
8
war/css/materialize.css
vendored
8
war/css/materialize.css
vendored
@ -3388,20 +3388,20 @@ nav ul a span.badge {
|
|||||||
margin-right: -0.75rem;
|
margin-right: -0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.mainDiv {
|
||||||
padding-top: 1rem;
|
padding-top: 1rem;
|
||||||
padding-bottom: 1rem;
|
padding-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section.no-pad {
|
.mainDiv.no-pad {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section.no-pad-bot {
|
.mainDiv.no-pad-bot {
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.section.no-pad-top {
|
.mainDiv.no-pad-top {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
war/css/materialize.min.css
vendored
2
war/css/materialize.min.css
vendored
File diff suppressed because one or more lines are too long
314
war/index.jsp
Normal file
314
war/index.jsp
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
<%@ page import="model.User" %>
|
||||||
|
<% boolean isUserLogged;
|
||||||
|
try {
|
||||||
|
isUserLogged = Boolean.parseBoolean(request.getAttribute("isUserLogged").toString());
|
||||||
|
}
|
||||||
|
catch (NullPointerException e){
|
||||||
|
isUserLogged = false;
|
||||||
|
}
|
||||||
|
User usuario = (User) request.getAttribute("User");
|
||||||
|
String serverResponse = (String) request.getAttribute("serverResponse");
|
||||||
|
if (serverResponse == null) serverResponse = "!";
|
||||||
|
%>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<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 type="text/css" rel="stylesheet" href="./css/Elements.css?v=2">
|
||||||
|
|
||||||
|
<script src="./js/GlobalJs.js" async defer></script>
|
||||||
|
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
.transition{
|
||||||
|
overflow: hidden;
|
||||||
|
height: auto;
|
||||||
|
|
||||||
|
transition: max-height 250ms ease-in;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<% if(!isUserLogged){ %>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div style="font-size: x-large">
|
||||||
|
<span id="mainText">Welcome! Log In to Start</span>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<div id="mainDiv" class="transition" style="max-height: 400px">
|
||||||
|
<div style="font-size: large">
|
||||||
|
With Google:
|
||||||
|
<div class="g-signin2" data-onsuccess="onSignIn" style="margin: 10px"></div>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="loadingDiv" class="transition" style="max-height: 0">
|
||||||
|
<div class="preloader-wrapper big active">
|
||||||
|
<div class="spinner-layer spinner-blue">
|
||||||
|
<div class="circle-clipper left">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="gap-patch">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="circle-clipper right">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="spinner-layer spinner-red">
|
||||||
|
<div class="circle-clipper left">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="gap-patch">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="circle-clipper right">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="spinner-layer spinner-yellow">
|
||||||
|
<div class="circle-clipper left">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="gap-patch">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="circle-clipper right">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="spinner-layer spinner-green">
|
||||||
|
<div class="circle-clipper left">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="gap-patch">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div><div class="circle-clipper right">
|
||||||
|
<div class="circle"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
Developed by:<br />
|
||||||
|
Fernando Araoz, 20173373<br />
|
||||||
|
Jose Rodriguez, 20101650<br />
|
||||||
|
Gustavo Turpo, 20173374<br />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function onSignIn(googleUser) {
|
||||||
|
|
||||||
|
document.getElementById("mainDiv").style.maxHeight = "0";
|
||||||
|
document.getElementById("loadingDiv").style.maxHeight = "100px";
|
||||||
|
|
||||||
|
var profile = googleUser.getBasicProfile();
|
||||||
|
|
||||||
|
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(),
|
||||||
|
userImg : profile.getImageUrl(),
|
||||||
|
userRole : "User",
|
||||||
|
action : "logIn"
|
||||||
|
});
|
||||||
|
},500);
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% } else { %>
|
||||||
|
|
||||||
|
<nav style="background-color: #67c9b3">
|
||||||
|
<div class="nav-wrapper">
|
||||||
|
<a class="whiteLink hide-on-small-only" 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; min-width: 150px;" onclick="changeUserOptions()">
|
||||||
|
|
||||||
|
<span style="min-width: 80px;">
|
||||||
|
<%= usuario.getName()%>
|
||||||
|
</span>
|
||||||
|
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||||
|
<i class="material-icons">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'})">Log Out</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 hide-on-med-and-down">
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank">
|
||||||
|
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<title id="simpleicons-github-icon">
|
||||||
|
GitHub icon
|
||||||
|
</title>
|
||||||
|
<path fill="white" d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12">
|
||||||
|
</path>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||||
|
<li>|</li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./services')">Services</a></li>
|
||||||
|
<li>|</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
|
||||||
|
<div id="dropdownContent">
|
||||||
|
<a onclick="postRedirect('./roles')">Roles</a>
|
||||||
|
<a href="#" style="background-color: lightgray">Users</a>
|
||||||
|
<a onclick="postRedirect('./resources')">Resources</a>
|
||||||
|
<a onclick="postRedirect('./access')">Access</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<br />
|
||||||
|
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Home</span>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%if (!serverResponse.equals("!")){ %>
|
||||||
|
|
||||||
|
<div id="serverResponse">
|
||||||
|
<div style="margin: 10px"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
var respDiv = document.getElementById("serverResponse");
|
||||||
|
|
||||||
|
var responseData = JSON.parse('<%=serverResponse%>');
|
||||||
|
|
||||||
|
respDiv.style.backgroundColor = responseData["color"];
|
||||||
|
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
respDiv.style.maxHeight = "500px";
|
||||||
|
setTimeout(function () {
|
||||||
|
respDiv.style.maxHeight = "0";
|
||||||
|
},1500);
|
||||||
|
},300);
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<% } %>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<div style="font-size: x-large">
|
||||||
|
Welcome, <%=usuario.getName()%>.<br />
|
||||||
|
<br />
|
||||||
|
Here's some data:<br />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col l9 m9 s8">
|
||||||
|
Your name: <%=usuario.getName()%><br />
|
||||||
|
Your email: <%=usuario.getEmail()%><br />
|
||||||
|
Your Role: <%=usuario.getRoleName()%>
|
||||||
|
</div>
|
||||||
|
<div class="col l3 m3 s4">
|
||||||
|
<img src="<%=usuario.getImgUrl()%>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<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>
|
Loading…
Reference in New Issue
Block a user