Compare commits

..

10 Commits

Author SHA1 Message Date
Araozu
0dffef12b4 Arreglo de Errores 2018-07-17 22:18:51 -05:00
Araozu
8c060382f0 Agregada funcion Ver Historial de Compras del Usuario
Arreglo de Errores
2018-07-16 09:52:57 -05:00
Araozu
4a164fd1a1 Arreglo de errores 2018-07-15 17:16:35 -05:00
Araozu
a44f2d9fad Arreglo de errores 2018-07-15 15:28:04 -05:00
Araozu
97036bf369 Traduccion completa a Espanol 2018-07-15 11:34:28 -05:00
Araozu
09bee5da7c Agregado el CRUD de Materiales.
Completada la funcionalidad Administración de recursos.
2018-07-14 21:43:48 -05:00
Araozu
69c419791a Arreglo de errores. 2018-07-14 17:38:27 -05:00
Araozu
9e5b81032a Agregado Employee 2018-07-14 15:51:34 -05:00
Araozu
1e96f6f222 Division de la aplicacion:
El sector inicial esta dirigido a los clientes, mientras que las herramientos coma el CRUD solo son solo para empleados.
2018-07-14 10:29:59 -05:00
Araozu
e45470c263 Arreglo de errores 2018-07-07 15:42:57 -05:00
111 changed files with 7152 additions and 2514 deletions

View File

@ -1,10 +1,10 @@
<component name="libraryTable"> <component name="libraryTable">
<library name="API AppEngine 1"> <library name="API AppEngine 1">
<CLASSES> <CLASSES>
<root url="file://$USER_HOME$/Desktop/Java EE/API AppEngine 1.9" /> <root url="file://$USER_HOME$/Desktop/Universidad/Java EE/API AppEngine 1.9" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
<jarDirectory url="file://$USER_HOME$/Desktop/Java EE/API AppEngine 1.9" recursive="false" /> <jarDirectory url="file://$USER_HOME$/Desktop/Universidad/Java EE/API AppEngine 1.9" recursive="false" />
</library> </library>
</component> </component>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES5" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content> </content>
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="com.google.appengine.eclipse.core.GAE_CONTAINER/appengine-java-sdk-1.9.54" level="application" /> <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="library" name="API AppEngine 1" level="project" /> <orderEntry type="library" name="API AppEngine 1" level="project" />
<orderEntry type="library" name="platform" level="application" /> <orderEntry type="library" name="platform" level="application" />
</component> </component>

View File

@ -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. */

View File

@ -1,129 +0,0 @@
package controller.access;
import controller.PMF;
import controller.resources.ResourcesControllerView;
import controller.roles.RolesControllerView;
import controller.users.UsersControllerView;
import model.Access;
import model.Resource;
import model.Role;
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;
import java.util.List;
@SuppressWarnings("serial")
public class AccessControllerAdd extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "select from " + Role.class.getName();
String query2 = "select from " + Resource.class.getName();
List<Role> roles = RolesControllerView.getAllRoles();
List<Resource> resources = ResourcesControllerView.getAllResources();
request.setAttribute("roles", roles);
request.setAttribute("resources", resources);
boolean redirect = true;
//String queryp = "select " + Role.class.getName();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/add.jsp");
if (request.getParameter("info") == null){
try{
HttpSession sesion= request.getSession();
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("ResourceList",ResourcesControllerView.getAllResources());
dispatcher.forward(request,response);
redirect = false;
}
//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>");
}
}
else if(request.getParameter("info").equals("agregar")){
String idRole = request.getParameter("rolesl");
String idResource = request.getParameter("resourcesl");
if(idRole == null || idRole.equals("")|| idResource == null || idResource.equals("")){
System.out.print("nombre vacio");
}
else {
Access a = new Access(idRole, idResource,true);
//persist the entity
pm.makePersistent(a);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Access created successfully.\"}");
}
}
else if (request.getParameter("info").equals("check")){
response.getWriter().print(accessExist(request.getParameter("rolesl"),request.getParameter("resourcesl")));
redirect = false;
}
pm.close();
try{
if (redirect){
request.setAttribute("serverResponse","");
response.sendRedirect("/access");
}
}
//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.");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
@SuppressWarnings("unchecked")
private boolean accessExist(String role, String resource){
PersistenceManager pm = PMF.get().getPersistenceManager();
List<Access> accessList = (List<Access>) pm.newQuery("select from " + Access.class.getName()).execute();
try {
String roleKey = RolesControllerView.getRole(role).getKey();
String resourceKey = ResourcesControllerView.getResource(resource).getKey();
for (Access access: accessList){
if (access.getRoleKey().equals(roleKey)){
if (access.getResourceKey().equals(resourceKey)){
return true;
}
}
}
return false;
} catch (IllegalArgumentException e){
return true;
}
}
}

View File

@ -1,38 +0,0 @@
package controller.access;
import java.io.IOException;
import javax.servlet.http.*;
import java.util.Date;
import java.util.List;
import java.text.DateFormat;
import javax.servlet.*;
import javax.jdo.PersistenceManager;
import model.*;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
@SuppressWarnings("serial")
public class AccessControllerDelete extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
// create the new account
try{
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("accessId")));
Access r = pm.getObjectById(Access.class, k);
pm.deletePersistent(r);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Access deleted successfully.\"}");
response.sendRedirect("/access");
} catch(javax.jdo.JDOObjectNotFoundException nf) {
response.sendRedirect("/access");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -1,93 +0,0 @@
package controller.access;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.users.UsersControllerView;
import model.Access;
import model.Resource;
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 AccessControllerEdit extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
try{
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id")));
Access a = pm.getObjectById(Access.class, k);
request.setAttribute("access", a);
String query = "select from " + Role.class.getName();
String query2 = "select from " + Resource.class.getName();
List<Role> roles = (List<Role>)pm.newQuery(query).execute();
List<Resource> resources = (List<Resource>)pm.newQuery(query2).execute();
request.setAttribute("roles", roles);
request.setAttribute("resources", resources);
try{
if(request.getParameter("info").equals("editar")){
String idRole = request.getParameter("rolesl");
String idResource = request.getParameter("resourcesl");
if(idRole == null || idRole.equals("")|| idResource == null || idResource.equals("")){
System.out.print("nombre vacio");
}
else{
if(!a.getRoleKey().equals(idRole)){
a.setRoleKey(idRole);
}
if(!a.getResourceKey().equals(idResource)){
a.setResourceKey(idResource);
}
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Access updated successfully.\"}");
response.sendRedirect("/access");
}
} else if(request.getParameter("info").equals("redirect")){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/edit.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
dispatcher.forward(request, response);
}
}catch (java.lang.NullPointerException np){
System.err.println("AccessControllerEdit Exception -> NPE:");
np.printStackTrace();
}
} catch(javax.jdo.JDOObjectNotFoundException nf) {
response.sendRedirect("/index.html");
} catch (NumberFormatException e){
response.sendRedirect("/users");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -1,67 +0,0 @@
package controller.access;
import controller.PMF;
import controller.resources.ResourcesControllerView;
import controller.users.UsersControllerView;
import model.Access;
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;
import java.util.List;
@SuppressWarnings("serial")
public class AccessControllerIndex extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
//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);
// query for the entities by name
String query = "select from " + Access.class.getName();
List<Access> accesses = (List<Access>)pm.newQuery(query).execute();
// pass the list to the jsp
request.setAttribute("accesses", accesses);
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
// forward the request to the jsp
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/index.jsp");
dispatcher.forward(request, response);
}
//Si no la encuentra, redirige a la pagina inicial para que se cree la sesion.
catch (Exception e){
e.printStackTrace();
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></body></html>");
} finally {
pm.close();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -0,0 +1,78 @@
package controller.clientControllers;
import controller.usersManagement.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;
import java.util.ArrayList;
public class transactionsHistory extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
//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("serverResponse",sesion.getAttribute("serverResponse"));
ArrayList<String> lista = crearArrayList(user.getTransactionList());
if (lista != null){
request.setAttribute("transactionList",lista);
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/ClientViews/transactionsHistory.jsp");
dispatcher.forward(request,response);
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"orange\",\"response\":\"Aún no tienes ninguna transacción..\"}");
response.sendRedirect("/");
}
}
//Si no la encuentra, redirige a la pagina inicial.
catch (Exception e){
System.err.println("Error catched. " + e.getMessage());
e.printStackTrace();
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
private ArrayList<String> crearArrayList(String datos){
ArrayList<String> lista = new ArrayList<>();
if (datos.length() > 2){
do
{
lista.add(datos.substring(0,datos.indexOf(",")));
datos = datos.substring(datos.indexOf(",")+1);
}
while (datos.length() > 2);
return lista;
}
return null;
}
}

View File

@ -0,0 +1,58 @@
package controller.financesManagement;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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 IncomeReport extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
//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("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Finances/index.jsp");
dispatcher.forward(request,response);
}
//Si no la encuentra, redirige a la pagina inicial.
catch (Exception e){
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"You don\\'t have permission to access /reports.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
response.sendRedirect("/e/users");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,66 @@
package controller.financesManagement.transactions;
import controller.PMF;
import controller.resourcesManagement.services.ServicesControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Service;
import model.Transaction;
import model.User;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class TransactionsControllerAdd extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
String action = request.getParameter("action");
//Para evitar errores, si no hay ninguna accion, se establece a vacio.
if (action == null)
action = "";
if (action.equals("userAddTransaction")){
PersistenceManager pm = PMF.get().getPersistenceManager();
String userId = request.getSession().getAttribute("userID").toString();
Service service = ServicesControllerView.getService(request.getParameter("serviceKey").toString());
Transaction transaction = new Transaction(userId,service.getKey(),service.getPrice() + "");
User user = pm.getObjectById(User.class, request.getSession().getAttribute("userID").toString());
pm.makePersistent(transaction);
user.addTransaction(transaction.getKey());
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"¡Listo! Tu transacción se completó.\"}");
pm.close();
}
try{
response.sendRedirect("/");
}
//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.");
}
} catch (NullPointerException e){
System.err.println("Error NPE ->");
e.printStackTrace();
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -1,9 +1,8 @@
package controller.roles; package controller.financesManagement.transactions;
import controller.users.UsersControllerView; import controller.usersManagement.users.UsersControllerView;
import model.User; import model.User;
import javax.jdo.PersistenceManager;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -12,9 +11,11 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.IOException; import java.io.IOException;
@SuppressWarnings("serial") import static controller.financesManagement.transactions.TransactionsControllerView.getAllTransactions;
public class RolesControllerIndex extends HttpServlet {
public class TransactionsControllerIndex extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
//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();
@ -25,17 +26,17 @@ public class RolesControllerIndex extends HttpServlet {
if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo."); if (user == null) throw new NullPointerException("UsersControllerIndex: El usuario recibido es nulo.");
request.setAttribute("User",user); request.setAttribute("User",user);
request.setAttribute("RoleList",RolesControllerView.getAllRoles()); request.setAttribute("transactionsList",getAllTransactions());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse")); request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!"); sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Roles/index.jsp"); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Transactions/index.jsp");
dispatcher.forward(request,response); dispatcher.forward(request,response);
} }
//Si no la encuentra, redirige a la pagina inicial. //Si no la encuentra, redirige a la pagina inicial.
catch (Exception e){ catch (Exception e){
e.printStackTrace(); System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></body></html>"); response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
} }
} }

View File

@ -0,0 +1,42 @@
package controller.financesManagement.transactions;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import model.Transaction;
import javax.jdo.PersistenceManager;
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;
public class TransactionsControllerView extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
@SuppressWarnings("unchecked")
static List<Transaction> getAllTransactions (){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Transaction> transactions = (List<Transaction>) pm.newQuery("select from " + Transaction.class.getName()).execute();
pm.close();
return transactions;
}
public static Transaction getTransaction(String key){
PersistenceManager pm = PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key);
Transaction service = pm.getObjectById(Transaction.class,k);
pm.close();
return service;
}
}

54
src/controller/index.java Normal file
View File

@ -0,0 +1,54 @@
package controller;
import controller.resourcesManagement.services.ServicesControllerView;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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 {
response.setCharacterEncoding("UTF-8");
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("hasAccess",AccessControllerView.checkPermission(sesion.getAttribute("userID").toString(),"/e/"));
request.setAttribute("User",loggedUser);
request.setAttribute("isUserLogged",true);
request.setAttribute("servicesList",ServicesControllerView.getAllServices());
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);
}
}

View File

@ -1,88 +0,0 @@
package controller.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.users.UsersControllerView;
import model.Resource;
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 ResourcesControllerAdd 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){
//Crea
case "create":
String url = request.getParameter("url");
Boolean status = Boolean.parseBoolean(request.getParameter("status"));
createRole(url,status,pm);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Resource created successfully.\"}");
break;
case "redirect":
HttpSession sesion= request.getSession();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/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"));
Resource resourc = pm.getObjectById(Resource.class, a);
resourc.setUrl(request.getParameter("url"));
resourc.setStatus(Boolean.parseBoolean(request.getParameter("status")));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Resource updated successfully.\"}");
break;
}
pm.close();
try{
response.sendRedirect("/resources");
}
//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);
}
public static String createRole(String url, boolean status, PersistenceManager pm){
Resource role = new Resource(url,status);
try{
pm.makePersistent(role);
return role.getKey();
} finally {
System.out.println("Role creado");
}
}
}

View File

@ -1,45 +0,0 @@
package controller.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import model.Resource;
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
public class ResourcesControllerDelete extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
try {
Key key = KeyFactory.stringToKey(request.getParameter("key"));
try{
pm.deletePersistent(pm.getObjectById(Resource.class, key));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Resource deleted successfully.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
} catch (NullPointerException e){
System.err.println("Exception captured -> " + e.getMessage());
}
response.sendRedirect("/resources");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -1,47 +0,0 @@
package controller.resources;
import controller.roles.RolesControllerView;
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 ResourcesControllerIndex 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("ResourceList",ResourcesControllerView.getAllResources());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/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);
}
}

View File

@ -1,97 +0,0 @@
package controller.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.users.UsersControllerView;
import model.Resource;
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;
import static controller.roles.RolesControllerView.getRole;
@SuppressWarnings("serial")
public class ResourcesControllerView 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 Resource (resource/view)
if (action.equals("editRedirect") && key != null){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/view.jsp");
request.setAttribute("Resource",getResource(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/Resources/view.jsp");
request.setAttribute("Resource",getResource(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 getAllResources
*
* Devuelve un list con todos los Recursos que existen desde cualquier parte del codigo.
*
* @return Un List<Resource> con todos los Recursos
* */
@SuppressWarnings("unchecked")
public static List<Resource> getAllResources(){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Resource> resources = (List<Resource>) pm.newQuery("select from " + Resource.class.getName()).execute();
pm.close();
return resources;
}
public static Resource getResource(String key){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key);
Resource resource = pm.getObjectById(Resource.class, k);
pm.close();
return resource;
}
}

View File

@ -0,0 +1,101 @@
package controller.resourcesManagement.employees;
import java.io.IOException;
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 com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Employee;
@SuppressWarnings("serial")
public class EmployeesControllerAdd extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = PMF.get().getPersistenceManager();
String action = request.getParameter("action");
if (action == null)
action = "";
if (action.equals("create")){
String name = request.getParameter("Name");
String phone = request.getParameter("Phone");
String email = request.getParameter("Email");
Long dni = Long.parseLong(request.getParameter("Dni"));
String userCreatorKey = request.getParameter("userId");
Employee employee = new Employee (name, phone, email,dni,true,userCreatorKey);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Employee created successfully.\"}");
pm.makePersistent(employee);
} else if (action.equals("update")){
Key k = KeyFactory.stringToKey(request.getParameter("key"));
Employee employee = pm.getObjectById(Employee.class,k);
employee.setName(request.getParameter("Name"));
employee.setDni(Long.parseLong(request.getParameter("Dni")));
employee.setEmail(request.getParameter("Email"));
employee.setPhone(request.getParameter("Phone"));
pm.close();
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Empleado creado con éxito.\"}");
} else if (action.equals("redirect")){
HttpSession sesion= request.getSession();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Employees/add.jsp");
request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString()));
dispatcher.forward(request, response);
}
pm.close();
try{
response.sendRedirect("/e/employees");
}
//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.");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para crear un Empleado.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
doGet(request, response);
}
}

View File

@ -0,0 +1,61 @@
package controller.resourcesManagement.employees;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import model.Employee;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
public class EmployeesControllerDelete extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = PMF.get().getPersistenceManager();
String employeeKey = request.getParameter("employeeKey");
try{
Key k = KeyFactory.stringToKey(employeeKey);
Employee employee = pm.getObjectById(Employee.class, k);
pm.deletePersistent(employee);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Empleado eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
pm.close();
response.sendRedirect("/e/employees");
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Empleado.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException{
doGet(request, response);
}
}

View File

@ -0,0 +1,64 @@
package controller.resourcesManagement.employees;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.User;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import static controller.resourcesManagement.employees.EmployeesControllerView.getAllEmployees;
public class EmployeesControllerIndex extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
//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("EmployeesList",getAllEmployees());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Employees/index.jsp");
dispatcher.forward(request,response);
}
//Si no la encuentra, redirige a la pagina inicial.
catch (Exception e){
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/employees.\"}");
response.sendRedirect("/e/");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doPost(req, resp);
}
}

View File

@ -0,0 +1,108 @@
package controller.resourcesManagement.employees;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Employee;
import javax.jdo.PersistenceManager;
import javax.servlet.RequestDispatcher;
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 EmployeesControllerView extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
String action = request.getParameter("action");
if (action == null)
action = "";
PersistenceManager pm = PMF.get().getPersistenceManager();
if (action.equals("editRedirect")) {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Employees/view.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
request.setAttribute("Employee",getEmployee(request.getParameter("employeeKey")));
request.setAttribute("editAllowed",true);
request.setAttribute("action","Edit");
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
}
}
else if (action.equals("viewRedirect")) {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Employees/view.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
request.setAttribute("Employee",getEmployee(request.getParameter("employeeKey")));
request.setAttribute("editAllowed",false);
request.setAttribute("action","View");
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
}
}
//Si no se encontró acción, regresa al inicio
else {
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
}
pm.close();
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para editar/ver un Empleado.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
doGet(req, resp);
}
@SuppressWarnings("unchecked")
static List<Employee> getAllEmployees(){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Employee> employees = (List<Employee>) pm.newQuery("select from " + Employee.class.getName()).execute();
pm.close();
return employees;
}
private static Employee getEmployee(String key){
PersistenceManager pm = PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key);
Employee employee = pm.getObjectById(Employee.class,k);
pm.close();
return employee;
}
}

View File

@ -0,0 +1,97 @@
package controller.resourcesManagement.materials;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Material;
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;
public class MaterialsControllerAdd extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = PMF.get().getPersistenceManager();
String action = request.getParameter("action");
if (action == null)
action = "";
if (action.equals("create")){
String name = request.getParameter("Name");
int price = Integer.parseInt(request.getParameter("Price"));
int amount = Integer.parseInt(request.getParameter("Amount"));
String unity = request.getParameter("Unity");
Material material = new Material(name, price, amount, unity);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Material creado con éxito.\"}");
pm.makePersistent(material);
} else if (action.equals("update")){
Key k = KeyFactory.stringToKey(request.getParameter("key"));
Material material = pm.getObjectById(Material.class,k);
material.setName(request.getParameter("Name"));
material.setPrice(Integer.parseInt(request.getParameter("Price")));
material.setAmount(Integer.parseInt(request.getParameter("Amount")));
material.setUnity(request.getParameter("Unity"));
pm.close();
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Material actualizado con éxito.\"}");
} else if (action.equals("redirect")){
HttpSession sesion= request.getSession();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Materials/add.jsp");
request.setAttribute("User",UsersControllerView.getUser(sesion.getAttribute("userID").toString()));
dispatcher.forward(request, response);
}
pm.close();
try{
response.sendRedirect("/e/materials");
}
//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.");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para crear un Material.\"}");
response.sendRedirect("/e/materials");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,58 @@
package controller.resourcesManagement.materials;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import model.Material;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class MaterialsControllerDelete extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = PMF.get().getPersistenceManager();
String materialKey = request.getParameter("materialKey");
try{
Key k = KeyFactory.stringToKey(materialKey);
Material material = pm.getObjectById(Material.class, k);
pm.deletePersistent(material);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Material eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
pm.close();
response.sendRedirect("/e/materials");
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Material.\"}");
response.sendRedirect("/e/materials");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,61 @@
package controller.resourcesManagement.materials;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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;
import static controller.resourcesManagement.materials.MaterialsControllerView.getAllMaterials;
public class MaterialsControllerIndex extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
//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("materialList",getAllMaterials());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Materials/index.jsp");
dispatcher.forward(request,response);
}
//Si no la encuentra, redirige a la pagina inicial.
catch (Exception e){
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/materials.\"}");
response.sendRedirect("/e/");
}
}catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,108 @@
package controller.resourcesManagement.materials;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Material;
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;
public class MaterialsControllerView extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
String action = request.getParameter("action");
if (action == null)
action = "";
PersistenceManager pm = PMF.get().getPersistenceManager();
if (action.equals("editRedirect")) {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Materials/view.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
request.setAttribute("Material",getMaterial(request.getParameter("materialKey")));
request.setAttribute("editAllowed",true);
request.setAttribute("action","Editar");
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
}
}
else if (action.equals("viewRedirect")) {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Materials/view.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
request.setAttribute("Material",getMaterial(request.getParameter("materialKey")));
request.setAttribute("editAllowed",false);
request.setAttribute("action","Ver");
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
}
}
//Si no se encontró acción, regresa al inicio
else {
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
}
pm.close();
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para editar/ver un Material.\"}");
response.sendRedirect("/e/materials");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@SuppressWarnings("unchecked")
static List<Material> getAllMaterials(){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Material> employees = (List<Material>) pm.newQuery("select from " + Material.class.getName()).execute();
pm.close();
return employees;
}
private static Material getMaterial(String key){
PersistenceManager pm = PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key);
Material material = pm.getObjectById(Material.class,k);
pm.close();
return material;
}
}

View File

@ -1,7 +1,6 @@
package controller.services; package controller.resourcesManagement.services;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManager;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
@ -15,15 +14,14 @@ import javax.servlet.http.HttpSession;
import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF; import controller.PMF;
import controller.access.AccessControllerView; import controller.usersManagement.access.AccessControllerView;
import controller.roles.RolesControllerView; import controller.usersManagement.users.UsersControllerView;
import controller.users.UsersControllerView;
import model.Access;
import model.Service; import model.Service;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ServicesControllerAdd extends HttpServlet { public class ServicesControllerAdd extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setCharacterEncoding("UTF-8");
try{ try{
@ -46,10 +44,10 @@ public class ServicesControllerAdd extends HttpServlet {
Service service = new Service (name, price, description,userCreatorKey); Service service = new Service (name, price, description,userCreatorKey);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Service created successfully.\"}");
pm.makePersistent(service); pm.makePersistent(service);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Servicio creado con éxito.\"}");
} else if (action.equals("update")){ } else if (action.equals("update")){
@ -63,7 +61,7 @@ public class ServicesControllerAdd extends HttpServlet {
pm.close(); pm.close();
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Service updated successfully.\"}"); request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Servicio editado con éxito.\"}");
} else if (action.equals("redirect")){ } else if (action.equals("redirect")){
@ -76,7 +74,7 @@ public class ServicesControllerAdd extends HttpServlet {
pm.close(); pm.close();
try{ try{
response.sendRedirect("/services"); response.sendRedirect("/e/services");
} }
//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){
@ -85,13 +83,13 @@ 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\":\"No tienes permiso para crear un Servicio.\"}");
response.sendRedirect("/users"); response.sendRedirect("/e/services");
} }
} catch (NullPointerException e){ } catch (NullPointerException e){
response.sendRedirect("/users"); response.sendRedirect("/");
} }

View File

@ -1,9 +1,9 @@
package controller.services; package controller.resourcesManagement.services;
import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF; import controller.PMF;
import controller.access.AccessControllerView; import controller.usersManagement.access.AccessControllerView;
import model.Service; import model.Service;
import javax.jdo.JDOObjectNotFoundException; import javax.jdo.JDOObjectNotFoundException;
@ -12,11 +12,11 @@ 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 java.io.IOException; import java.io.IOException;
import java.util.List;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ServicesControllerDelete extends HttpServlet { public class ServicesControllerDelete extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{ try{
@ -32,23 +32,23 @@ public class ServicesControllerDelete extends HttpServlet {
pm.deletePersistent(service); pm.deletePersistent(service);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Service deleted successfully.\"}"); request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Servicio eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){ } catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage()); System.err.println("Exception catched -> " + e.getMessage());
} }
pm.close(); pm.close();
response.sendRedirect("/services"); response.sendRedirect("/e/services");
} 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\":\"No tienes permiso para eliminar un Servicio.\"}");
response.sendRedirect("/users"); response.sendRedirect("/e/services");
} }
} catch (NullPointerException e){ } catch (NullPointerException e){
response.sendRedirect("/users"); response.sendRedirect("/");
} }

View File

@ -1,7 +1,7 @@
package controller.services; package controller.resourcesManagement.services;
import controller.access.AccessControllerView; import controller.usersManagement.access.AccessControllerView;
import controller.users.UsersControllerView; import controller.usersManagement.users.UsersControllerView;
import model.User; import model.User;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
@ -11,11 +11,12 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.IOException; import java.io.IOException;
import static controller.services.ServicesControllerView.getAllServices; import static controller.resourcesManagement.services.ServicesControllerView.getAllServices;
public class ServicesControllerIndex extends HttpServlet { public class ServicesControllerIndex extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{ try{
@ -44,12 +45,13 @@ 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\":\"No tienes permiso para acceder a /e/services.\"}");
response.sendRedirect("/users"); response.sendRedirect("/e/");
} }
} catch (NullPointerException e){ } catch (NullPointerException e){
response.sendRedirect("/users"); e.printStackTrace();
response.sendRedirect("/");
} }

View File

@ -1,13 +1,12 @@
package controller.services; package controller.resourcesManagement.services;
import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF; import controller.PMF;
import controller.access.AccessControllerView; import controller.usersManagement.access.AccessControllerView;
import controller.users.UsersControllerView; import controller.usersManagement.users.UsersControllerView;
import model.Service; import model.Service;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManager;
import javax.servlet.RequestDispatcher; import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@ -21,6 +20,7 @@ public class ServicesControllerView extends HttpServlet {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{ try{
@ -73,12 +73,12 @@ public class ServicesControllerView extends HttpServlet {
pm.close(); pm.close();
} 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\":\"No tienes permiso para ver/editar un Servicio.\"}");
response.sendRedirect("/users"); response.sendRedirect("/e/services");
} }
} catch (NullPointerException e){ } catch (NullPointerException e){
response.sendRedirect("/users"); response.sendRedirect("/");
} }
} }
@ -88,14 +88,14 @@ public class ServicesControllerView extends HttpServlet {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static List<Service> getAllServices(){ public static List<Service> getAllServices(){
PersistenceManager pm = controller.PMF.get().getPersistenceManager(); PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Service> services = (List<Service>) pm.newQuery("select from " + Service.class.getName()).execute(); List<Service> services = (List<Service>) pm.newQuery("select from " + Service.class.getName()).execute();
pm.close(); pm.close();
return services; return services;
} }
private static Service getService(String key){ public static Service getService(String key){
PersistenceManager pm = PMF.get().getPersistenceManager(); PersistenceManager pm = PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key); Key k = KeyFactory.stringToKey(key);

View File

@ -1,102 +0,0 @@
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 javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* RolesControllerAdd
*
* Permite lo siguiente:
*
* Crear un Rol -> con el parametro action = create
* Redireccionar al form para crear un Rol -> parametro action = redirect
* Actualizar un Rol -> parametro action = update
*
*
*
* */
@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){
//Crea
case "create":
String name = request.getParameter("roleName");
Boolean status = Boolean.parseBoolean(request.getParameter("roleStatus"));
createRole(name,status,pm);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role created successfully.\"}");
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);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role updated successfully.\"}");
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);
}
public static String createRole(String name, boolean status, PersistenceManager pm){
Role role = new Role(name,status);
try{
pm.makePersistent(role);
return role.getKey();
} finally {
System.out.println("Role creado");
}
}
}

View File

@ -1,42 +0,0 @@
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
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));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Role deleted successfully.\"}");
} 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);
}
}

View File

@ -1,119 +0,0 @@
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;
/**
* RolesControllerView
*
* Permite ver los Roles
*
* Metodos importantes:
*
* public static getAllRoles()
* Devuelve un List<Role> con todos los roles que existen.
*
* public static getRoleKey(String key)
* Devuelve un Rol dada una key.
* La key se obtiene usando el metodo getKey() de un objeto Role
*
* */
@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;
}
public 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;
}
@SuppressWarnings("unchecked")
public static List<Role> searchRole(String name){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Role> users = (List<Role>) pm.newQuery("select from " + Role.class.getName() + " where name == '" + name + "'").execute();
pm.close();
return users;
}
}

View File

@ -1,184 +0,0 @@
package controller.users;
import controller.roles.RolesControllerAdd;
import controller.roles.RolesControllerView;
import model.Role;
import model.User;
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;
import java.util.List;
@SuppressWarnings("serial")
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");
//Respuesta del servidor
String serverResponse = "!";
if (action == null)
action = "";
//Email del usuario
String userEmail = request.getParameter("userEmail");
//Solo se usa al actualizar un usuario.
String prevUserID = request.getParameter("userID");
//El ID del usuario. Este id se obtiene del email -> en richard@gmail.com el ID es richard
String userID;
try {
userID = userEmail.substring(0,userEmail.indexOf("@"));
} catch (NullPointerException e){
userID = prevUserID;
}
//Parametros necesarios.
String userName = request.getParameter("userName");
String userImg = request.getParameter("userImg");
String userRole = request.getParameter("userRole");
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();
List<Role> roleList = RolesControllerView.searchRole(userRole);
if (roleList.size() > 0){
userRole = roleList.get(0).getKey();
} else {
userRole = RolesControllerAdd.createRole(userRole,true,pm);
}
createUser(userID, userEmail, userName, userImg, userRole, pm);
//Si no existe la sesion, la crea usando el ID del usuario
if (!sesionExist(misesion)) {
misesion.invalidate();
misesion = request.getSession(true);
misesion.setAttribute("userID", userID);
//La sesion perdurara sin actividad durante 1h.
misesion.setMaxInactiveInterval(3600);
}
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"You are logged in.\"}";
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()));
request.setAttribute("Roles",RolesControllerView.getAllRoles());
dispatcher.forward(request, response);
break;
//Si lo que se quiere es Crear (proviene del formulario)
case "create":
createUser(userID, userEmail, userName, userImg, userRole, pm);
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"User created successfully.\"}";
break;
//Si lo que se quiere es actualizar un Usuario
case "update":
User user = pm.getObjectById(User.class, prevUserID);
user.setName(userName);
user.setEmail(userEmail);
user.setImgUrl(userImg);
user.setRoleKey(userRole);
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"Service updated successfully.\"}";
break;
}
pm.close();
try{
request.getSession().setAttribute("serverResponse",serverResponse);
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.");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Redirige a doPost
doPost(request, response);
}
//Revisa si un usuario existe: id -> ID del usuario (ejm. en richard@gmail.com el ID es richard)
private boolean userExists(String userID, PersistenceManager pm){
try{
//Intenta buscar en el DataStore un usuario con el ID respectivo.
User usr = pm.getObjectById(User.class, userID);
//Si lo encuentra devuelve true (el usuario si existe)
return true;
} catch (JDOObjectNotFoundException exc){
//Si no lo encuentra, se lanza una Excepción, se captura, y se devuelve false (el usuario no existe)
return false;
}
}
//Comprueba si existe una sesion: sesion -> Objeto HttpSesion que contiene la sesion actual
private boolean sesionExist(HttpSession sesion){
try{
//Intenta buscar el atributo userID dentro de la sesion
String a = sesion.getAttribute("userID").toString();
System.out.println("Sesion existe -> " + a);
//Si lo encuentra, la sesion si existe
return true;
} catch (NullPointerException e){
//Si no, la sesion no existe
System.out.println("Sesion no existe");
return false;
}
}
private void createUser(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.
//Si no existe, crea el objeto de tipo User con los datos que se obtienen del request, y lo hace Persistente.
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, userRole);
try{
pm.makePersistent(user);
} finally {
System.out.println("Usuario creado con exito -> " + user);
}
}
}
}

View File

@ -1,38 +0,0 @@
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
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));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Service deleted sucessfully.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
pm.close();
response.sendRedirect("/users");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -1,47 +0,0 @@
package controller.users;
import model.User;
import java.io.IOException;
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;
@SuppressWarnings("serial")
public class UsersControllerIndex extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws 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("UsersList",UsersControllerView.getAllUsers());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
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){
System.err.println("UserControllerIndex: Error catched. " + e.getMessage());
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head></html>");
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,149 @@
package controller.usersManagement.access;
import controller.PMF;
import controller.usersManagement.resources.ResourcesControllerView;
import controller.usersManagement.roles.RolesControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Access;
import model.Resource;
import model.Role;
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;
import java.util.List;
@SuppressWarnings("serial")
public class AccessControllerAdd extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "select from " + Role.class.getName();
String query2 = "select from " + Resource.class.getName();
List<Role> roles = RolesControllerView.getAllRoles();
List<Resource> resources = ResourcesControllerView.getAllResources();
request.setAttribute("roles", roles);
request.setAttribute("resources", resources);
boolean redirect = true;
//String queryp = "select " + Role.class.getName();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/add.jsp");
if (request.getParameter("info") == null){
try{
HttpSession sesion= request.getSession();
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("ResourceList",ResourcesControllerView.getAllResources());
dispatcher.forward(request,response);
redirect = false;
}
//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>");
}
}
else if(request.getParameter("info").equals("agregar")){
String idRole = request.getParameter("rolesl");
String idResource = request.getParameter("resourcesl");
boolean status = Boolean.parseBoolean(request.getParameter("status"));
if(idRole == null || idRole.equals("")|| idResource == null || idResource.equals("")){
System.out.print("nombre vacio");
}
else {
Access a = new Access(idRole, idResource,status);
//persist the entity
pm.makePersistent(a);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Acceso creado con éxito.\"}");
}
}
else if (request.getParameter("info").equals("check")){
response.getWriter().print(accessExist(request.getParameter("rolesl"),request.getParameter("resourcesl")));
redirect = false;
}
pm.close();
try{
if (redirect){
request.setAttribute("serverResponse","");
response.sendRedirect("/e/access");
}
}
//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.");
}
}else{
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para crear un Acceso.\"}");
response.sendRedirect("/e/access");
}
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
@SuppressWarnings("unchecked")
private boolean accessExist(String role, String resource){
PersistenceManager pm = PMF.get().getPersistenceManager();
List<Access> accessList = (List<Access>) pm.newQuery("select from " + Access.class.getName()).execute();
try {
String roleKey = RolesControllerView.getRole(role).getKey();
String resourceKey = ResourcesControllerView.getResource(resource).getKey();
for (Access access: accessList){
if (access.getRoleKey().equals(roleKey)){
if (access.getResourceKey().equals(resourceKey)){
return true;
}
}
}
return false;
} catch (IllegalArgumentException e){
return true;
}
}
}

View File

@ -0,0 +1,52 @@
package controller.usersManagement.access;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.*;
import javax.jdo.PersistenceManager;
import model.*;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
@SuppressWarnings("serial")
public class AccessControllerDelete extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
// create the new account
try{
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("accessId")));
Access r = pm.getObjectById(Access.class, k);
pm.deletePersistent(r);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Acceso eliminado con éxito.\"}");
response.sendRedirect("/e/access");
} catch(javax.jdo.JDOObjectNotFoundException nf) {
response.sendRedirect("/e/access");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Acceso.\"}");
response.sendRedirect("/e/access");
}
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -0,0 +1,116 @@
package controller.usersManagement.access;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF;
import controller.usersManagement.users.UsersControllerView;
import model.Access;
import model.Resource;
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 AccessControllerEdit extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
try{
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id")));
Access a = pm.getObjectById(Access.class, k);
request.setAttribute("access", a);
String query = "select from " + Role.class.getName();
String query2 = "select from " + Resource.class.getName();
List<Role> roles = (List<Role>)pm.newQuery(query).execute();
List<Resource> resources = (List<Resource>)pm.newQuery(query2).execute();
request.setAttribute("roles", roles);
request.setAttribute("resources", resources);
try{
if(request.getParameter("info").equals("editar")){
String idRole = request.getParameter("rolesl");
String idResource = request.getParameter("resourcesl");
boolean status = Boolean.parseBoolean(request.getParameter("status"));
if(idRole == null || idRole.equals("")|| idResource == null || idResource.equals("")){
System.out.print("nombre vacio");
}
else{
if(!a.getRoleKey().equals(idRole)){
a.setRoleKey(idRole);
}
if(!a.getResourceKey().equals(idResource)){
a.setResourceKey(idResource);
}
a.setStatus(status);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Acceso editado con éxito.\"}");
response.sendRedirect("/e/access");
}
} else if(request.getParameter("info").equals("redirect")){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/edit.jsp");
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
dispatcher.forward(request, response);
}
}catch (java.lang.NullPointerException np){
System.err.println("AccessControllerEdit Exception -> NPE:");
np.printStackTrace();
}
} catch(javax.jdo.JDOObjectNotFoundException nf) {
response.sendRedirect("/");
} catch (NumberFormatException e){
response.sendRedirect("/e/users");
}
}else{
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para editar un Acceso.\"}");
response.sendRedirect("/e/access");
}
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -0,0 +1,85 @@
package controller.usersManagement.access;
import controller.PMF;
import controller.usersManagement.users.UsersControllerView;
import model.Access;
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;
import java.util.List;
@SuppressWarnings("serial")
public class AccessControllerIndex extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
//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);
// query for the entities by name
String query = "select from " + Access.class.getName();
List<Access> accesses = (List<Access>)pm.newQuery(query).execute();
// pass the list to the jsp
request.setAttribute("accesses", accesses);
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
// forward the request to the jsp
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/index.jsp");
dispatcher.forward(request, response);
}
//Si no la encuentra, redirige a la pagina inicial para que se cree la sesion.
catch (Exception e){
e.printStackTrace();
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></body></html>");
} finally {
pm.close();
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/access.\"}");
response.sendRedirect("/e/");
}
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

View File

@ -1,11 +1,11 @@
package controller.access; package controller.usersManagement.access;
import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import controller.PMF; import controller.PMF;
import controller.resources.ResourcesControllerView; import controller.usersManagement.resources.ResourcesControllerView;
import controller.roles.RolesControllerView; import controller.usersManagement.roles.RolesControllerView;
import controller.users.UsersControllerView; import controller.usersManagement.users.UsersControllerView;
import model.Access; import model.Access;
import model.Resource; import model.Resource;
import model.Role; import model.Role;
@ -24,37 +24,50 @@ import java.util.List;
public class AccessControllerView extends HttpServlet { public class AccessControllerView extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
// create the persistence manager instance // create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager(); PersistenceManager pm = PMF.get().getPersistenceManager();
try{ try{
Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id"))); if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())) {
Access a = pm.getObjectById(Access.class, k);
request.setAttribute("access", a); Key k = KeyFactory.createKey(Access.class.getSimpleName(), new Long(request.getParameter("id")));
Access a = pm.getObjectById(Access.class, k);
Role rol = RolesControllerView.getRole(a.getRoleKey()); request.setAttribute("access", a);
String nrol = rol.getName(); Role rol = RolesControllerView.getRole(a.getRoleKey());
Resource res = ResourcesControllerView.getResource(a.getResourceKey()); String nrol = rol.getName();
String nres = res.getUrl();
request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString())); Resource res = ResourcesControllerView.getResource(a.getResourceKey());
String nres = res.getUrl();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/view.jsp"); request.setAttribute("User",UsersControllerView.getUser(request.getSession().getAttribute("userID").toString()));
dispatcher.forward(request, response);
}catch(javax.jdo.JDOObjectNotFoundException nf) { RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Access/view.jsp");
dispatcher.forward(request, response);
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver un Acceso.\"}");
response.sendRedirect("/e/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\":\"Ocurrio un error.\"}");
response.sendRedirect("/access"); response.sendRedirect("/e/access");
} 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,19 +105,18 @@ 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 userRoleKey = user.getRoleKey(); String userRoleKey = user.getRoleKey();
if (userRoleKey == null) if (userRoleKey == null)
userRoleKey = ""; userRoleKey = "";
if (user.getRoleName().equals("admin")) {
return true;
}
for (Access access: getAllAccess()){ for (Access access: getAllAccess()){
if (userRoleName.equals("admin")){ if (access.getRoleKey().equals(userRoleKey) && access.getStatus()){
return true; if (access.getResourceName().equals(uri) && ResourcesControllerView.getResource(access.getResourceKey()).getStatus()){
} else if (access.getRoleKey().equals(userRoleKey)){
System.out.println("Encontrado USuario con Rol coincidente");
if (access.getResourceName().equals(uri)){
System.out.println("El USuario tiene acceso a esta URI");
return true; return true;
} }
} }

View File

@ -0,0 +1,70 @@
package controller.usersManagement;
import controller.PMF;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Access;
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;
import java.util.List;
public class index extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
// create the persistence manager instance
PersistenceManager pm = PMF.get().getPersistenceManager();
//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("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
// forward the request to the jsp
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/eIndex.jsp");
dispatcher.forward(request, response);
}
//Si no la encuentra, redirige a la pagina inicial para que se cree la sesion.
catch (Exception e){
e.printStackTrace();
response.getWriter().println("<html><head><script>window.location.replace(\"../\")</script></head><body></body></html>");
} finally {
pm.close();
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"Oops. No tienes permiso para acceder.\"}");
response.sendRedirect("/");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,101 @@
package controller.usersManagement.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Resource;
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 ResourcesControllerAdd extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
//Accion a realizar
String action = request.getParameter("action");
if (action == null)
action = "";
switch (action){
//Crea
case "create":
String url = request.getParameter("url");
Boolean status = Boolean.parseBoolean(request.getParameter("status"));
createRole(url,status,pm);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Recurso creado con éxito.\"}");
break;
case "redirect":
HttpSession sesion= request.getSession();
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/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"));
Resource resourc = pm.getObjectById(Resource.class, a);
resourc.setUrl(request.getParameter("url"));
resourc.setStatus(Boolean.parseBoolean(request.getParameter("status")));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Recurso Actualizado con éxito.\"}");
break;
}
pm.close();
try{
response.sendRedirect("/e/resources");
}
//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.");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para crear un Recurso.\"}");
response.sendRedirect("/e/resources");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public static String createRole(String url, boolean status, PersistenceManager pm){
Resource role = new Resource(url,status);
try{
pm.makePersistent(role);
return role.getKey();
} finally {
System.out.println("Role creado");
}
}
}

View File

@ -0,0 +1,59 @@
package controller.usersManagement.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
import model.Resource;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
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 ResourcesControllerDelete extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
try {
Key key = KeyFactory.stringToKey(request.getParameter("key"));
try{
pm.deletePersistent(pm.getObjectById(Resource.class, key));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Recurso eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
} catch (NullPointerException e){
System.err.println("Exception captured -> " + e.getMessage());
}
response.sendRedirect("/e/resources");
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Recurso.\"}");
response.sendRedirect("/e/resources");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,59 @@
package controller.usersManagement.resources;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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;
@SuppressWarnings("serial")
public class ResourcesControllerIndex extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
//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("ResourceList",ResourcesControllerView.getAllResources());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/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>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/resources.\"}");
response.sendRedirect("/e/");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,108 @@
package controller.usersManagement.resources;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.users.UsersControllerView;
import model.Resource;
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 ResourcesControllerView extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
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 Resource (resource/view)
if (action.equals("editRedirect") && key != null){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resources/view.jsp");
request.setAttribute("Resource",getResource(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/Resources/view.jsp");
request.setAttribute("Resource",getResource(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>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver Recursos.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* Metodo Estatico getAllResources
*
* Devuelve un list con todos los Recursos que existen desde cualquier parte del codigo.
*
* @return Un List<Resource> con todos los Recursos
* */
@SuppressWarnings("unchecked")
public static List<Resource> getAllResources(){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Resource> resources = (List<Resource>) pm.newQuery("select from " + Resource.class.getName()).execute();
pm.close();
return resources;
}
public static Resource getResource(String key){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
Key k = KeyFactory.stringToKey(key);
Resource resource = pm.getObjectById(Resource.class, k);
pm.close();
return resource;
}
}

View File

@ -0,0 +1,114 @@
package controller.usersManagement.roles;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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 javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* RolesControllerAdd
*
* Permite lo siguiente:
*
* Crear un Rol -> con el parametro action = create
* Redireccionar al form para crear un Rol -> parametro action = redirect
* Actualizar un Rol -> parametro action = update
* */
@SuppressWarnings("serial")
public class RolesControllerAdd extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
//Accion a realizar
String action = request.getParameter("action");
if (action == null)
action = "";
switch (action){
//Crea
case "create":
String name = request.getParameter("roleName");
Boolean status = Boolean.parseBoolean(request.getParameter("roleStatus"));
createRole(name,status,pm);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol creado con éxito.\"}");
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);
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol editado con éxito.\"}");
break;
}
pm.close();
try{
response.sendRedirect("/e/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.");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/roles.\"}");
response.sendRedirect("/e/roles");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public static String createRole(String name, boolean status, PersistenceManager pm){
Role role = new Role(name,status);
try{
pm.makePersistent(role);
return role.getKey();
} finally {
System.out.println("Role creado");
}
}
}

View File

@ -0,0 +1,57 @@
package controller.usersManagement.roles;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
public class RolesControllerDelete extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
try {
Key k = KeyFactory.stringToKey(request.getParameter("key"));
try{
pm.deletePersistent(pm.getObjectById(Role.class, k));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Rol eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
} catch (NullPointerException e){
System.err.println("Exception captured -> " + e.getMessage());
}
response.sendRedirect("/e/roles");
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Rol.\"}");
response.sendRedirect("/e/roles");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,58 @@
package controller.usersManagement.roles;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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;
@SuppressWarnings("serial")
public class RolesControllerIndex extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if(AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
//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());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
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>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/roles.\"}");
response.sendRedirect("/e/");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,115 @@
package controller.usersManagement.roles;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.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 {
response.setCharacterEncoding("UTF-8");
try {
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
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>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver un Rol.\"}");
response.sendRedirect("/e/roles");
}
} catch (NullPointerException e){
response.sendRedirect("/");
}
}
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;
}
public 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;
}
@SuppressWarnings("unchecked")
public static List<Role> searchRole(String name){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
List<Role> users = (List<Role>) pm.newQuery("select from " + Role.class.getName() + " where name == '" + name + "'").execute();
pm.close();
return users;
}
}

View File

@ -0,0 +1,215 @@
package controller.usersManagement.users;
import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.roles.RolesControllerAdd;
import controller.usersManagement.roles.RolesControllerView;
import model.Role;
import model.User;
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;
import java.util.List;
@SuppressWarnings("serial")
public class UsersControllerAdd extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if(request.getParameter("action").equals("logIn") ||
AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
//Accion a realizar
String action = request.getParameter("action");
//Respuesta del servidor
String serverResponse = "!";
if (action == null)
action = "";
//Email del usuario
String userEmail = request.getParameter("userEmail");
//Solo se usa al actualizar un usuario.
String prevUserID = request.getParameter("userID");
//El ID del usuario. Este id se obtiene del email -> en richard@gmail.com el ID es richard
String userID;
try {
userID = userEmail.substring(0,userEmail.indexOf("@"));
} catch (NullPointerException e){
userID = prevUserID;
}
//Parametros necesarios.
String userName = request.getParameter("userName");
String userImg = request.getParameter("userImg");
String userRole = request.getParameter("userRole");
String rutaRedireccion = "/e/users";
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();
List<Role> roleList = RolesControllerView.searchRole(userRole);
if (roleList.size() > 0){
userRole = roleList.get(0).getKey();
} else {
userRole = RolesControllerAdd.createRole("Cliente",true,pm);
}
createUser(userID, userEmail, userName, userImg, userRole, pm);
//Si no existe la sesion, la crea usando el ID del usuario
if (!sesionExist(misesion)) {
misesion.invalidate();
misesion = request.getSession(true);
misesion.setAttribute("userID", userID);
//La sesion perdurara sin actividad durante 1h.
misesion.setMaxInactiveInterval(3600);
}
rutaRedireccion = "/";
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()));
request.setAttribute("Roles",RolesControllerView.getAllRoles());
dispatcher.forward(request, response);
break;
//Si lo que se quiere es Crear (proviene del formulario)
case "create":
createUser(userID, userEmail, userName, userImg, userRole, pm);
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"Usuario creado con éxito.\"}";
break;
//Si lo que se quiere es actualizar un Usuario
case "update":
User user = pm.getObjectById(User.class, prevUserID);
user.setName(userName);
user.setEmail(userEmail);
user.setImgUrl(userImg);
user.setRoleKey(userRole);
serverResponse = "{\"color\": \"#26a69a\",\"response\":\"Usuario editado con éxito.\"}";
break;
}
pm.close();
try{
request.getSession().setAttribute("serverResponse",serverResponse);
response.sendRedirect(rutaRedireccion);
}
//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.");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para editar un usuario.\"}");
response.sendRedirect("/e/users");
}
}catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Redirige a doPost
doPost(request, response);
}
//Revisa si un usuario existe: id -> ID del usuario (ejm. en richard@gmail.com el ID es richard)
private boolean userExists(String userID, PersistenceManager pm){
try{
//Intenta buscar en el DataStore un usuario con el ID respectivo.
User usr = pm.getObjectById(User.class, userID);
//Si lo encuentra devuelve true (el usuario si existe)
return true;
} catch (JDOObjectNotFoundException exc){
//Si no lo encuentra, se lanza una Excepción, se captura, y se devuelve false (el usuario no existe)
return false;
}
}
//Comprueba si existe una sesion: sesion -> Objeto HttpSesion que contiene la sesion actual
private boolean sesionExist(HttpSession sesion){
try{
//Intenta buscar el atributo userID dentro de la sesion
String a = sesion.getAttribute("userID").toString();
System.out.println("Sesion existe -> " + a);
//Si lo encuentra, la sesion si existe
return true;
} catch (NullPointerException e){
//Si no, la sesion no existe
System.out.println("Sesion no existe");
return false;
}
}
private void createUser(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.
//Si no existe, crea el objeto de tipo User con los datos que se obtienen del request, y lo hace Persistente.
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, userRole);
try{
pm.makePersistent(user);
} finally {
System.out.println("Usuario creado con exito -> " + user);
}
}
//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);
}
}
}

View File

@ -0,0 +1,57 @@
package controller.usersManagement.users;
import controller.usersManagement.access.AccessControllerView;
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;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@SuppressWarnings("serial")
public class UsersControllerDelete extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
try{
if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())){
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
String userID = request.getParameter("userID");
try{
pm.deletePersistent(pm.getObjectById(User.class, userID));
request.getSession().setAttribute("serverResponse","{\"color\": \"#26a69a\",\"response\":\"Usuario eliminado con éxito.\"}");
} catch (JDOObjectNotFoundException e){
System.err.println("Exception catched -> " + e.getMessage());
}
pm.close();
response.sendRedirect("/e/users");
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para eliminar un Usuario.\"}");
response.sendRedirect("/e/users");
}
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
}

View File

@ -0,0 +1,52 @@
package controller.usersManagement.users;
import controller.usersManagement.access.AccessControllerView;
import model.User;
import javax.servlet.RequestDispatcher;
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 UsersControllerIndex extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setCharacterEncoding("UTF-8");
try{
//Se usa para revisar si hay una sesion activa
HttpSession sesion= request.getSession();
if (AccessControllerView.checkPermission(sesion.getAttribute("userID").toString(),request.getRequestURI())){
//Intenta hallar una sesion activa
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("UsersList",UsersControllerView.getAllUsers());
request.setAttribute("serverResponse",sesion.getAttribute("serverResponse"));
sesion.setAttribute("serverResponse","!");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/index.jsp");
dispatcher.forward(request,response);
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para acceder a /e/users.\"}");
response.sendRedirect("/e/");
}
//Si no la encuentra, redirige a la pagina inicial.
//Si el usuario no tiene permiso tambien redirigie a la pagina inicial
} catch (Exception e){
e.printStackTrace();
response.sendRedirect("/");
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
doPost(request, response);
}
}

View File

@ -1,6 +1,7 @@
package controller.users; package controller.usersManagement.users;
import controller.roles.RolesControllerView; import controller.usersManagement.access.AccessControllerView;
import controller.usersManagement.roles.RolesControllerView;
import model.User; import model.User;
import javax.jdo.JDOObjectNotFoundException; import javax.jdo.JDOObjectNotFoundException;
@ -17,62 +18,81 @@ 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 {
response.setCharacterEncoding("UTF-8");
String action = request.getParameter("action"); try{
//Para evitar errores, si no hay ninguna accion, se establece a vacio. String action = request.getParameter("action");
if (action == null)
action = "";
String userID = request.getParameter("userID"); //Para evitar errores, si no hay ninguna accion, se establece a vacio.
if (action == null)
action = "";
//Si se quiere cerrar la sesion actual if(action.equals("closeSession")){
if (action.equals("closeSession")){ closeSession(request,response);
closeSession(request,response);
}
//Redirige al formulario para editar un usario (user/view)
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);
request.setAttribute("action","Edit");
request.setAttribute("Roles",RolesControllerView.getAllRoles());
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
} }
} else if (AccessControllerView.checkPermission(request.getSession().getAttribute("userID").toString(),request.getRequestURI())) {
//Redirige al formulario para ver un usuario (user/view)
else if (action.equals("viewRedirect") && userID != null){
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Users/view.jsp"); String userID = request.getParameter("userID");
request.setAttribute("User",getUser(userID));
request.setAttribute("UserLogged",getUser(request.getSession().getAttribute("userID").toString())); //Redirige al formulario para editar un usario (user/view)
request.setAttribute("Roles",RolesControllerView.getAllRoles()); 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);
request.setAttribute("action","Edit");
request.setAttribute("Roles",RolesControllerView.getAllRoles());
try{
dispatcher.forward(request,response);
} catch (javax.servlet.ServletException e){
e.printStackTrace();
}
}
//Redirige al formulario para ver un usuario (user/view)
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()));
request.setAttribute("Roles",RolesControllerView.getAllRoles());
//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){
e.printStackTrace();
}
}
//Si no se encontró acción, regresa al inicio
else {
response.getWriter().println("<html><head><script>window.location.replace(\"../\");</script><body></body></html>");
}
} else {
request.getSession().setAttribute("serverResponse","{\"color\": \"red\",\"response\":\"No tienes permiso para ver/editar un usuario.\"}");
response.sendRedirect("/e/users");
//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){
e.printStackTrace();
} }
} catch (NullPointerException e){
e.printStackTrace();
response.sendRedirect("/");
} }
//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 { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response); doPost(request, response);
} }
/** /**
@ -144,4 +164,6 @@ public class UsersControllerView extends HttpServlet {
} }
} }
} }

View File

@ -1,7 +1,7 @@
package model; package model;
import controller.resources.ResourcesControllerView; import controller.usersManagement.resources.ResourcesControllerView;
import controller.roles.RolesControllerView; import controller.usersManagement.roles.RolesControllerView;
import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.IdentityType;

102
src/model/Employee.java Normal file
View File

@ -0,0 +1,102 @@
package model;
import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.usersManagement.users.UsersControllerView;
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Employee {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
@Persistent
private String phone;
@Persistent
private String email;
@Persistent
private Long dni;
@Persistent
private boolean status;
@Persistent
private String creatorUserId;
public Employee(String name, String phone, String email, Long dni,boolean status,String creatorUserKey) {
this.name = name;
this.phone = phone;
this.email = email;
this.dni = dni;
this.status = status;
this.creatorUserId = creatorUserKey;
}
/*Getters and Setters*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Long getDni() {
return dni;
}
public void setDni(Long dni) {
this.dni = dni;
}
public boolean getStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public String getKey() {
return KeyFactory.keyToString(key);
}
public String getCreatorUserId(){
return creatorUserId;
}
public String getCreatorUserName(){
String name;
try{
name = UsersControllerView.getUser(creatorUserId).getName();
} catch (Exception e){
name = "<span style=\"color: red; font-weight: bold\">The User doesn't exists.</span>";
}
return name;
}
/*To String*/
public String toString(){
return "Name: " + name + "\n Dni: " + dni + "\n Email: " + email + "\n Phone: " + phone + ".\n";
}
}

82
src/model/Material.java Normal file
View File

@ -0,0 +1,82 @@
package model;
import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Material {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
//Precio por unity
@Persistent
private int price;
//Tipo de unidad -> Peso, cantidad, medida, volumen, etc.
@Persistent
private String unity;
@Persistent
private int amount;
@Persistent
private String createDate;
public Material(String name, int price, int quantity, String unity) {
this.name = name;
this.price = price;
this.amount = quantity;
this.unity = unity;
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
this.createDate = df.format(Calendar.getInstance().getTime());
}
public String getKey() {
return KeyFactory.keyToString(key);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public String getUnity() {
return unity;
}
public void setUnity(String unity) {
this.unity = unity;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public String getCreateDate() {
return createDate;
}
}

View File

@ -3,7 +3,7 @@ package model;
import javax.jdo.annotations.*; import javax.jdo.annotations.*;
import com.google.appengine.api.datastore.Key; import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory; import com.google.appengine.api.datastore.KeyFactory;
import controller.users.UsersControllerView; import controller.usersManagement.users.UsersControllerView;
@PersistenceCapable(identityType=IdentityType.APPLICATION) @PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Service { public class Service {

View File

@ -0,0 +1,62 @@
package model;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import controller.resourcesManagement.services.ServicesControllerView;
import javax.jdo.annotations.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Transaction {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String userID;
@Persistent
private String serviceKey;
@Persistent
private String servicePrice;
@Persistent
private String createDate;
public Transaction(String userID, String serviceKey, String servicePrice) {
this.userID = userID;
this.serviceKey = serviceKey;
this.servicePrice = servicePrice;
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
this.createDate = df.format(Calendar.getInstance().getTime());
}
public String getKey() {
return KeyFactory.keyToString(key);
}
public String getUserID() {
return userID;
}
public String getServiceKey() {
return serviceKey;
}
public String getServiceName(){
return ServicesControllerView.getService(serviceKey).getName();
}
public String getServicePrice() {
return servicePrice;
}
public String getCreateDate() {
return createDate;
}
}

View File

@ -1,11 +1,12 @@
package model; package model;
import controller.roles.RolesControllerView; import controller.usersManagement.roles.RolesControllerView;
import javax.jdo.annotations.IdentityType; 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 {
@ -32,6 +33,10 @@ public class User {
@Persistent @Persistent
private String roleKey; private String roleKey;
//Lista de Strings con Keys de las transacciones del usuario -> trans,trans,trans,
@Persistent
private String transactionList;
//Constructor //Constructor
public User(String id, String name, String imgUrl, String email ,String role){ public User(String id, String name, String imgUrl, String email ,String role){
this.id = id; this.id = id;
@ -39,9 +44,9 @@ public class User {
this.imgUrl = imgUrl; this.imgUrl = imgUrl;
this.email = email; this.email = email;
this.roleKey = role; this.roleKey = role;
transactionList = "";
} }
//Getters y Setters //Getters y Setters
public String getId() { public String getId() {
return id; return id;
@ -85,6 +90,14 @@ public class User {
this.roleKey = roleKey; this.roleKey = roleKey;
} }
public String getTransactionList() {
return transactionList;
}
public void addTransaction(String transactionKey){
transactionList = transactionKey + "," + transactionList;
}
//To String //To String
@Override @Override
public String toString() { public String toString() {

View File

@ -12,32 +12,32 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Add an access - Hotel Services</title> <title>Añadir un Acceso - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../..//css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span> </span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -48,7 +48,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -58,9 +58,9 @@
</div> </div>
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -70,39 +70,45 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li class="active"><a class="whiteLink" href="../access">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a href="#" style="background-color: lightgray">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab active"><a class="active" href="../access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Add an Access</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Añadir un Acceso</span>
<br /> <br />
<br /> <br />
<div> <div>
<div style="float: left; display: inline;"> <div style="float: left; display: inline;">
<i class="material-icons large" style=" color: #67c9b3">info_outline</i> <i class="material-icons large" style=" color: #3f51b5">info_outline</i>
</div> </div>
<div style="font-size: x-large; clear: right; min-height: 87px;"> <div style="font-size: x-large; clear: right; min-height: 87px;">
The admin Role has full access by default. El "admin" tiene acceso total.
</div> </div>
</div> </div>
<br /> <br />
@ -115,7 +121,7 @@
<input type="hidden" name="info" value="agregar"/> <input type="hidden" name="info" value="agregar"/>
Role: Rol:
<% if(roles.size() > 0) {%> <% if(roles.size() > 0) {%>
<select id="formRole" name="rolesl" class="browser-default" required oninput="accessExists()"> <select id="formRole" name="rolesl" class="browser-default" required oninput="accessExists()">
<option value="!" disabled selected>Choose a Role</option> <option value="!" disabled selected>Choose a Role</option>
@ -126,16 +132,16 @@
</select> </select>
<% } else {%> <% } else {%>
<br /> <br />
<span style="color: darkorange; font-size: x-large">No Roles registered.</span> <span style="color: darkorange; font-size: x-large">No hay Roles registrados.</span>
<script>buttonDisabled = true</script> <script>buttonDisabled = true</script>
<% } %> <% } %>
<br /> <br />
Resource: Recurso:
<% if (resourses.size() > 0) { %> <% if (resourses.size() > 0) { %>
<select id="formResource" name="resourcesl" class="browser-default" required oninput="accessExists()"> <select id="formResource" name="resourcesl" class="browser-default" required oninput="accessExists()">
<option value="!" disabled selected>Choose a Resource</option> <option value="!" disabled selected>Escoja un Recurso.</option>
<% for (Resource res: resourses) { %> <% for (Resource res: resourses) { %>
<option value="<%= res.getKey() %>"><%= res.getUrl() %></option> <option value="<%= res.getKey() %>"><%= res.getUrl() %></option>
@ -144,13 +150,37 @@
</select> </select>
<% } else { %> <% } else { %>
<br /> <br />
<span style="color: darkorange; font-size: x-large">No Resources registered.</span> <span style="color: darkorange; font-size: x-large">No hay Recursos disponibles.</span>
<script>buttonDisabled = true</script> <script>buttonDisabled = true</script>
<% } %> <% } %>
<br />
Estado del Recurso:<br />
<br />
<div class="switch" id="siwtchContainer">
<label>
Falso
<input id="sivth" type="checkbox" name="status" value="false">
<span class="lever"></span>
Verdadero
</label>
</div>
<br /> <br />
<button id="sendButton" class="btn waves-effect waves-light" type="submit" name="action">Submit <script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
}
</script>
<button id="sendButton" class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
@ -158,7 +188,7 @@
<hr /> <hr />
<br /> <br />
<a href="../access" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../access" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -13,30 +13,30 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Edit an Access - Hotel Services</title> <title>Editar un Acceso - Hotel Services</title>
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span> </span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -47,7 +47,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesion</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -57,9 +57,9 @@
</div> </div>
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -69,41 +69,47 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li class="active"><a href="" class="whiteLink">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a href="#" style="background-color: lightgray">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab active"><a class="active" href="../access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Edit an Access</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Editar un Acceso</span>
<br /> <br />
<br /> <br />
<form id="mainForm" name="post" method="post" action="edit" onsubmit="return safeSend()"> <form id="mainForm" name="post" method="post" action="./edit" onsubmit="return safeSend()">
<input type="hidden" name="id" value="<%= a.getId() %>"/> <input type="hidden" name="id" value="<%= a.getId() %>"/>
<input type="hidden" name="info" value="editar"/> <input type="hidden" name="info" value="editar"/>
New Role: Nuevo Rol:
<select id="formRole" name="rolesl" class="browser-default" oninput="accessExists()" required> <select id="formRole" name="rolesl" class="browser-default" oninput="accessExists()" required>
<option value="!" disabled selected>Choose a Role</option> <option value="!" disabled selected>Escoje un Rol</option>
<% if (roles.size() > 0) { %> <% if (roles.size() > 0) { %>
<% for (Role r: roles) { %> <% for (Role r: roles) { %>
@ -113,14 +119,14 @@
<% } %> <% } %>
<% } else { %> <% } else { %>
<span class="heading">There are no Roles.</span> <span class="heading">No hay Roles.</span>
<% } %> <% } %>
</select> </select>
<br /> <br />
New Resource: Nuevo Recurso:
<select id="formResource" name="resourcesl" class="browser-default" oninput="accessExists()" required> <select id="formResource" name="resourcesl" class="browser-default" oninput="accessExists()" required>
<option value="!" disabled selected>Choose a Resource</option> <option value="!" disabled selected>Escoge un Recurso</option>
<% if (resources.size() > 0) { %> <% if (resources.size() > 0) { %>
<% for (Resource res: resources) { %> <% for (Resource res: resources) { %>
@ -130,16 +136,52 @@
<% } %> <% } %>
<% } else { %> <% } else { %>
<span class="heading">There are no Access.</span> <span class="heading">No hay Recursos.</span>
<% } %> <% } %>
</select><br /> </select><br />
<button id="sendButton" class="btn waves-effect waves-light" type="submit" name="action">Edit Estado:<br />
<br />
<div class="switch" id="siwtchContainer">
<label>
Falso
<input id="sivth" type="checkbox" name="status" value="false">
<span class="lever"></span>
Verdadero
</label>
</div>
<br />
<script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
if ("<%=a.getStatus()%>" === "true"){
elSwitch.checked = "true";
elSwitch.value = "true";
}
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
console.log("anumaaa -> " + elSwitch.value);
}
</script>
<button id="sendButton" class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
</form> </form>
<hr />
<br />
<a href="../access" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -12,32 +12,32 @@
<html> <html>
<head> <head>
<title>Access - Hotel Services</title> <title>Accesos - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -48,7 +48,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -59,8 +59,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -70,28 +70,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li> <li><a class="whiteLink" href="./">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li> <li class="active"><a class="whiteLink active" onclick="postRedirect('./roles')">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li> <li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li class="active"><a class="whiteLink">Access</a></li> <li><a class="whiteLink" href="./reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('./services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('./roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('./users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('./resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a href="#" style="background-color: lightgray">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./roles">Roles</a></li>
<li class="tab"><a href="./users">Usuarios</a></li>
<li class="tab"><a href="./resources">Recursos</a></li>
<li class="tab active"><a class="active" href="#">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Access</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Accesos</span>
<br /> <br />
<br /> <br />
@ -108,10 +115,13 @@
respDiv.style.backgroundColor = responseData["color"]; respDiv.style.backgroundColor = responseData["color"];
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>"; respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
respDiv.style.maxHeight = "500px";
setTimeout(function () { setTimeout(function () {
respDiv.style.maxHeight = "0"; respDiv.style.maxHeight = "500px";
},1500); setTimeout(function () {
respDiv.style.maxHeight = "0";
},1500);
},10);
</script> </script>
@ -121,15 +131,15 @@
<div> <div>
<div style="float: left; display: inline;"> <div style="float: left; display: inline;">
<i class="material-icons large" style=" color: #67c9b3">info_outline</i> <i class="material-icons large" style=" color: #3f51b5">info_outline</i>
</div> </div>
<div style="font-size: x-large; clear: right; min-height: 87px;"> <div style="font-size: x-large; clear: right; min-height: 87px;">
The admin Role has full access by default. El Rol "admin" tiene acceso total.
</div> </div>
</div> </div>
<br /> <br />
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/access/add')"><i class="material-icons left">add</i>Create</a> <a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/access/add')"><i class="material-icons left">add</i>Create</a>
<br /> <br />
<br /> <br />
@ -158,12 +168,19 @@
<td><%= e.getResourceName() %></td> <td><%= e.getResourceName() %></td>
<td><%= e.getStatus() %></td> <td><%= e.getStatus() %></td>
<td> <td>
<a onclick="postRedirect('/access/view',{id: '<%=e.getId() %>'})" class="postLink">View</a> | <a onclick="postRedirect('./access/view',{id: '<%=e.getId() %>'})" class="postLink">View</a> |
<a onclick="postRedirect('/access/edit',{id:'<%= e.getId() %>', info:'redirect'})" class="postLink">Edit</a> | <a onclick="postRedirect('./access/edit',{id:'<%= e.getId() %>', info:'redirect'})" class="postLink">Edit</a> |
<form name="post_<%= e.getId() %>" style="display:none;" method="post" action="/access/delete"><input type="hidden" name="accessId" value="<%= e.getId() %>"/> <form name="post_<%= e.getId() %>" style="display:none;" method="post" action="./access/delete"><input type="hidden" name="accessId" value="<%= e.getId() %>"/>
</form> </form>
<a href="#" class="postLink" onclick="if (confirm('Are you sure you want to delete # <%= e.getId() %>?')) { document.post_<%= e.getId() %>.submit(); } event.returnValue = false; return false;">Delete</a></td> <a href="#" class="postLink" onclick="
if (confirm('¿Estás seguro de que quieres eliminar #<%= e.getId() %>?')) {
document.post_<%= e.getId() %>.submit();
}
event.returnValue = false; return false;">
Delete
</a>
</td>
</tr> </tr>
<% } %> <% } %>
@ -174,6 +191,8 @@
<span class="heading">No Accesses registered.</span> <span class="heading">No Accesses registered.</span>
<% } %> <% } %>
</div> </div>

View File

@ -10,27 +10,27 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title> <title>Ver un Acceso</title>
<link type="text/css" rel="stylesheet" href="../css/Diseno.css"> <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/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span> </span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -41,7 +41,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -51,9 +51,9 @@
</div> </div>
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -63,41 +63,47 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li class="active"><a href="" class="whiteLink">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a href="#" style="background-color: lightgray">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab active"><a class="active" href="../access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">View an Access</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Ver un Acceso</span>
<br /> <br />
<br /> <br />
<div style="font-size: x-large"> <div style="font-size: x-large">
ID: <%=access.getId()%><br /> ID: <%=access.getId()%><br />
Role: <%=access.getRoleName()%><br /> Rol: <%=access.getRoleName()%><br />
Resource: <%= access.getResourceName() %> Recurso: <%= access.getResourceName() %>
</div> </div>
<hr/> <hr/>
<br /> <br />
<a href="../access" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../access" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -0,0 +1,192 @@
<%@ page import="model.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="model.Transaction" %>
<%@ page import="controller.financesManagement.transactions.TransactionsControllerView" %>
<% User usuario = (User) request.getAttribute("User");
String serverResponse = (String) request.getAttribute("serverResponse");
ArrayList<String> transactionList = (ArrayList<String>) request.getAttribute("transactionList");
if (serverResponse == null) serverResponse = "!";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Historial - 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>
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>
<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: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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('../e/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 hide-on-med-and-down">
<li>
<a href="https://github.com/Grupo-PW2/Web-Hostal" 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" href="#">Historial de Compras</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">Historial de compras</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 />
Mi Historial<br />
<br />
<table class="striped responsive-table">
<thead>
<tr>
<td>Servicio</td>
<td>Precio</td>
<td>Fecha de compra</td>
</tr>
</thead>
<tbody id="tableBody">
<% for (String key: transactionList) {
Transaction transaction = TransactionsControllerView.getTransaction(key);
%>
<tr>
<td><%=transaction.getServiceName()%></td>
<td><%=transaction.getServicePrice()%></td>
<td><%=transaction.getCreateDate()%></td>
</tr>
<% } %>
</tbody>
</table>
</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>

View File

@ -0,0 +1,133 @@
<%@ page import="model.User" %>
<%@ page import="java.util.List" %>
<%@ page import="model.Role" %><%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User user = (User) request.getAttribute("User"); %>
<html lang="es">
<head>
<title>Añadir un Empleado - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" style="min-width: 80px;">
<%= user.getName()%>
</span>
<img src="<%=user.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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="../">Inicio</a></li>
<li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" href="../reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../services">Servicios</a></li>
<li class="tab active"><a class="active" href="../employees">Empleados</a></li>
<li class="tab"><a href="../materials">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Crear un Empleado</span>
<br />
<br />
<form method="post" action="./add">
<input name="action" value="create" type="hidden">
Nombre del Empleado:<br>
<input name="Name" placeholder="Nombre" required><br>
Dni del Empleado:<br>
<input name="Dni" placeholder="Dni" pattern="[0-9]{8}" title="Ingrese su numero de DNI(8 digitos)" required><br>
Correo electrónico del Empleado:<br>
<input name="Email" placeholder="Correo Electrónico" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" title="caracteres@nombre del dominio" required=""><br>
Teléfono del Empleado:<br>
<input name="Phone" placeholder="Teléfono" type="number" pattern="[0-9]{6,9}" title="Ingrese un numero de 6 o 9 digitos" required=""><br>
<input type="hidden" name="userId" value="<%= user.getId() %>">
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Create
<i class="material-icons right">send</i>
</button>
</form>
<hr />
<br />
<a href="../employees" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div>
</body>
</html>

View File

@ -0,0 +1,175 @@
<%@ page import="model.User" %>
<%@ page import="java.util.List" %>
<%@ page import="model.Employee" %><%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User usuario = (User) request.getAttribute("User");
List<Employee> employeeList = (List<Employee>) request.getAttribute("EmployeesList");
String serverResponse = (String) request.getAttribute("serverResponse");
if (serverResponse == null) serverResponse = "!";
%>
<html lang="es">
<head>
<title>Empleados - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css?v=2">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="./">Inicio</a></li>
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" href="./reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./services">Servicios</a></li>
<li class="tab active"><a class="active" href="#">Empleados</a></li>
<li class="tab"><a href="./materials">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Empleados</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);
},50);
</script>
<% } %>
<br />
<br />
<a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/employees/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a>
<br />
<br />
<table class="striped responsive-table">
<thead>
<tr>
<td>Nombre</td>
<td>DNI</td>
<td>Email</td>
<td>Teléfono</td>
<td>Creado Por</td>
<td>Actions</td>
</tr>
</thead>
<tbody>
<% for (Employee employee: employeeList) {%>
<tr>
<td><%= employee.getName()%></td>
<td><%= employee.getDni() %></td>
<td><%= employee.getEmail() %></td>
<td><%= employee.getPhone() %></td>
<td><%= employee.getCreatorUserName() %></td>
<td>
<a class="postLink" onclick="postRedirect('./employees/view',{action:'viewRedirect',employeeKey:'<%=employee.getKey()%>'})">View</a>
| <a class="postLink" onclick="postRedirect('./employees/view',{action:'editRedirect',employeeKey:'<%=employee.getKey()%>'})">Edit</a>
| <a class="postLink" onclick="postRedirect('./employees/delete',{employeeKey:'<%=employee.getKey()%>'})">Delete</a></td>
</tr>
<% } %>
</tbody>
</table>
</div>
</body>
</html>

View File

@ -0,0 +1,152 @@
<%@ page import="model.User" %>
<%@ page import="model.Employee" %>
<%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<% Employee employee = (Employee) request.getAttribute("Employee");
User usuario = (User) request.getAttribute("User");
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 Service - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="../">Inicio</a></li>
<li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" href="../reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../services">Servicios</a></li>
<li class="tab active"><a class="active" href="../employees">Empleados</a></li>
<li class="tab"><a href="../materials">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Servicio</span>
<br />
<br />
<% if (editAllowed) {%>
<form action="./add" method="post">
<input name="key" value="<%=employee.getKey()%>" type="hidden">
<input name="action" value="update" type="hidden">
Nombre del Servicio:<br />
<input name="Name" value="<%=employee.getName()%>" placeholder="Nombre" required><br/>
DNI del Empleado:<br />
<input name="Dni" type="number" min="0" required placeholder="Dni" value="<%= employee.getDni() %>"><br />
Correo electrónico del Empleado:<br />
<input name="Email" type="email" placeholder="Description" required value="<%= employee.getEmail() %>"><br />
Teléfono del Empleado:<br>
<input name="Phone" placeholder="Teléfono" type="number" pattern="[0-9]{6,9}" title="Ingrese un numero de 6 o 9 digitos"
required="" value="<%= employee.getPhone() %>">
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i>
</button>
</form>
<% } else {%>
<div style="font-size: x-large">
Nombre: <%= employee.getName() %><br />
Dni: <%= employee.getDni() %><br />
Correo electrónico: <%= employee.getEmail() %><br />
Creado por: <a style="cursor:pointer;" onclick="postRedirect('/e/users/view',{action:'viewRedirect',userID:'<%=employee.getCreatorUserId()%>'})"><%= employee.getCreatorUserName() %></a>
</div>
<% } %>
<hr />
<br />
<a href="../employees" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div>
</body>
</html>

View File

@ -0,0 +1,139 @@
<%@ page import="model.Resource" %>
<%@ page import="model.User" %>
<%--
Created by IntelliJ IDEA.
User: Jose
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User usuario = (User) request.getAttribute("User");
String serverResponse = (String) request.getAttribute("serverResponse");
if (serverResponse == null) serverResponse = "!";
%>
<html lang="es">
<head>
<title>Finanzas - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="./">Inicio</a></li>
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li class="active"><a class="whiteLink active" href="#">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="#">Finanzas</a></li>
<li class="tab"><a href="./trans">Transacciones</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Finanzas</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);
},50);
</script>
<% } %>
<br />
<br />
Incompleto. Faltan datos acerca de:<br />
<ol>
<li>Egresos mediante pagos a Empleados</li>
</ol>
</div>
</body>
</html>

View File

@ -0,0 +1,149 @@
<%@ page import="model.User" %>
<%@ page import="model.Service" %>
<%@ page import="model.Material" %>
<%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<% Material material = (Material) request.getAttribute("Material");
User usuario = (User) request.getAttribute("User");
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%> un Material - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="../">Inicio</a></li>
<li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" href="../reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../services">Servicios</a></li>
<li class="tab"><a href="../employees">Empleados</a></li>
<li class="tab active"><a class="active" href="../materials">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Material</span>
<br />
<br />
<% if (editAllowed) {%>
<form method="post" action="./add">
<input name="action" value="create" type="hidden">
Nombre del Material:<br />
<input name="Name" placeholder="Nombre" required value="<%= material.getName() %>"><br />
Cantidad:<br />
<input name="Amount" placeholder="Cantidad" type="number" min="0" required value="<%= material.getAmount() %>"><br />
Precio por unidad:<br />
<input name="Price" placeholder="Precio" type="number" required min="0" step="0.1" value="<%= material.getPrice() %>"><br />
Unidad (ejm. Kg, Litros):<br />
<input name="Unity" placeholder="Unidad" required value="<%= material.getUnity() %>"><br />
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action" >Editar
<i class="material-icons right">send</i>
</button>
</form>
<% } else {%>
<div style="font-size: x-large">
Nombre: <%= material.getName() %><br />
Cantidad: <%= material.getAmount() %><br />
Precio: <%= material.getPrice() %><br />
Unidad: <%= material.getUnity() %><br />
</div>
<% } %>
<hr />
<br />
<a href="../materials" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div>
</body>
</html>

View File

@ -0,0 +1,129 @@
<%@ page import="model.User" %>
<%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User user = (User) request.getAttribute("User"); %>
<html lang="es">
<head>
<title>Añadir un Material - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario"%= user.getName()%>
</span>
<img src="<%=user.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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="../">Inicio</a></li>
<li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" href="../reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../services">Servicios</a></li>
<li class="tab"><a href="../employees">Empleados</a></li>
<li class="tab active"><a class="active" href="../material">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Crear un Material</span>
<br />
<br />
<form method="post" action="./add">
<input name="action" value="create" type="hidden">
Nombre del Material:<br />
<input name="Name" placeholder="Nombre" required><br />
Precio por unidad:<br />
<input name="Price" placeholder="Precio" type="number" required min="0" step="0.1"><br />
Cantidad:<br />
<input name="Amount" placeholder="Cantidad" type="number" min="0" required><br />
Unidad (ejm. Kg, Litros):<br />
<input name="Unity" placeholder="Unidad" required><br />
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i>
</button>
</form>
<hr />
<br />
<a href="../materials" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div>
</body>
</html>

View File

@ -0,0 +1,173 @@
<%@ page import="model.User" %>
<%@ page import="java.util.List" %>
<%@ page import="model.Material" %>
<%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User usuario = (User) request.getAttribute("User");
List<Material> materialList = (List<Material>) request.getAttribute("materialList");
String serverResponse = (String) request.getAttribute("serverResponse");
if (serverResponse == null) serverResponse = "!";
%>
<html lang="es">
<head>
<title>Materiales - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css?v=2">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="./">Inicio</a></li>
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink active" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" href="./reports">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./services">Servicios</a></li>
<li class="tab"><a href="./employees">Empleados</a></li>
<li class="tab active"><a class="active" href="#">Materiales</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Materiales</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);
},50);
</script>
<% } %>
<br />
<br />
<a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/materials/add',{action:'redirect'})"><i class="material-icons left">add</i>Crear</a>
<br />
<br />
<table class="striped responsive-table">
<thead>
<tr>
<td>Nombre</td>
<td>Precio Unitario</td>
<td>Cantidad</td>
<td>Unidad</td>
<td>Fecha de Creación</td>
<td>Acciones</td>
</tr>
</thead>
<tbody>
<% for (Material material : materialList) {%>
<tr>
<td><%= material.getName()%></td>
<td><%= material.getPrice() %></td>
<td><%= material.getAmount() %></td>
<td><%= material.getUnity() %></td>
<td><%= material.getCreateDate() %></td>
<td>
<a class="postLink" onclick="postRedirect('./materials/view',{action:'viewRedirect',materialKey:'<%=material.getKey()%>'})">View</a>
| <a class="postLink" onclick="postRedirect('./materials/view',{action:'editRedirect',materialKey:'<%=material.getKey()%>'})">Edit</a>
| <a class="postLink" onclick="postRedirect('./materials/delete',{materialKey:'<%=material.getKey()%>'})">Delete</a></td>
</tr>
<% } %>
</tbody>
</table>
</div>
</body>
</html>

View File

@ -11,31 +11,31 @@
<% User user = (User) request.getAttribute("User"); %> <% User user = (User) request.getAttribute("User"); %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Add a Resource - Hotel Services</title> <title>Añadir un Recurso - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span> </span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -46,7 +46,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -57,8 +57,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -68,52 +68,76 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink" href="">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a href="#" style="background-color: lightgray">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab active"><a class="active" href="#">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Add a Resource</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Añadir un Recurso</span>
<br /> <br />
<br /> <br />
<form method="post" action="./add"> <form method="post" action="./add">
<input name="action" value="create" type="hidden"> <input name="action" value="create" type="hidden">
Url of the Resource:<br /> URI del Recurso:<br />
<input name="url" placeholder="Url of the Resource" required><br /> <input name="url" placeholder="URI del Recurso" required><br />
Status of the Resource:<br /> Estado del Recurso:<br />
<select name="status" class="browser-default" required> <br />
<option value="" disabled selected>Choose a status</option> <div class="switch" id="siwtchContainer">
<option value="true">true</option> <label>
<option value="false">false</option> Falso
</select> <input id="sivth" type="checkbox" name="status" value="false">
<span class="lever"></span>
Verdadero
</label>
</div>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
<script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
}
</script>
</form> </form>
<hr /> <hr />
<br /> <br />
<a href="../resources" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../resources" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -16,32 +16,32 @@
%> %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Resources - Hotel Services</title> <title>Recursos - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -52,7 +52,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -63,8 +63,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -74,29 +74,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li> <li><a class="whiteLink" href="./">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink" href="">Resources</a></li> <li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li> <li><a class="whiteLink" href="./reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('./services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('./roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('./users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a href="#" style="background-color: lightgray">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('./access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./roles">Roles</a></li>
<li class="tab"><a href="./users">Usuarios</a></li>
<li class="tab active"><a class="active" href="#">Recursos</a></li>
<li class="tab"><a href="./access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Resources</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Recursos</span>
<br /> <br />
<br /> <br />
@ -113,10 +119,13 @@
respDiv.style.backgroundColor = responseData["color"]; respDiv.style.backgroundColor = responseData["color"];
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>"; respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
respDiv.style.maxHeight = "500px";
setTimeout(function () { setTimeout(function () {
respDiv.style.maxHeight = "0"; respDiv.style.maxHeight = "500px";
},1500); setTimeout(function () {
respDiv.style.maxHeight = "0";
},1500);
},50);
</script> </script>
@ -124,17 +133,17 @@
<br /> <br />
<br /> <br />
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/resources/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a> <a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/resources/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a>
<br /> <br />
<br /> <br />
<table class="striped responsive-table"> <table class="striped responsive-table">
<thead> <thead>
<tr> <tr>
<td>URL</td> <td>URI</td>
<td>Status</td> <td>Estado</td>
<td>Date created</td> <td>Fecha de creación</td>
<td>Actions</td> <td>Acciones</td>
</tr> </tr>
</thead> </thead>
@ -158,9 +167,9 @@
<td><%= resource.getStatus()%></td> <td><%= resource.getStatus()%></td>
<td><%= resource.getCreateDate()%></td> <td><%= resource.getCreateDate()%></td>
<td> <td>
<a class="postLink" onclick="postRedirect('resources/view',{action:'viewRedirect',key:'<%=key%>'})">View</a> <a class="postLink" onclick="postRedirect('resources/view',{action:'viewRedirect',key:'<%=key%>'})">Ver</a>
| <a class="postLink" onclick="postRedirect('resources/view',{action:'editRedirect',key:'<%=key%>'})">Edit</a> | <a class="postLink" onclick="postRedirect('resources/view',{action:'editRedirect',key:'<%=key%>'})">Editar</a>
| <a class="postLink" onclick="postRedirect('resources/delete',{key:'<%=key%>'})">Delete</a></td> | <a class="postLink" onclick="postRedirect('resources/delete',{key:'<%=key%>'})">Eliminar</a></td>
</tr> </tr>
<% } %> <% } %>

View File

@ -15,31 +15,31 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<head> <head>
<title><%=action%> a User - Hotel Services</title> <title><%=action%> un Usuario - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()">
<span style="min-width: 80px;"> <span id="nombreUsuario" style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -50,7 +50,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -61,8 +61,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -72,28 +72,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li class="active"><a class="whiteLink" href="">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a href="#" style="background-color: lightgray">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab active"><a class="active" href="#">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a Resource</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Recurso</span>
<br /> <br />
<br /> <br />
@ -104,18 +111,42 @@
<input name="key" value="<%=resource.getKey()%>" type="hidden"> <input name="key" value="<%=resource.getKey()%>" type="hidden">
<input name="action" value="update" type="hidden"> <input name="action" value="update" type="hidden">
Url:<br /> URI:<br />
<input name="url" value="<%=resource.getUrl()%>" placeholder="url" required><br/> <input name="url" value="<%=resource.getUrl()%>" placeholder="URI" required><br/>
<br/> <br/>
Status:<br /> Estado:<br />
<select name="status" class="browser-default" required> <br />
<option value="" disabled selected>Choose a status</option> <div class="switch" id="siwtchContainer">
<option value="true">true</option> <label>
<option value="false">false</option> Falso
</select> <input id="sivth" type="checkbox" name="status" value="false">
<span class="lever"></span>
Verdadero
</label>
</div>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
if ("<%=resource.getStatus()%>" === "true"){
elSwitch.checked = "true";
elSwitch.value = "true";
}
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
console.log("anumaaa -> " + elSwitch.value);
}
</script>
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
@ -125,7 +156,7 @@
<div style="font-size: x-large"> <div style="font-size: x-large">
Url: <%=resource.getUrl()%><br /> Uri: <%=resource.getUrl()%><br />
Status: <%=resource.getStatus()%><br /> Status: <%=resource.getStatus()%><br />
</div> </div>
@ -134,7 +165,7 @@
<hr /> <hr />
<br /> <br />
<a href="../resources" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../resources" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -8,33 +8,33 @@
--%> --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User user = (User) request.getAttribute("User"); %> <% User user = (User) request.getAttribute("User"); %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Add a Role - Hotel Services</title> <title>Añadir un Rol - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span> </span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -45,7 +45,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -56,8 +56,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -67,52 +67,76 @@
</svg> </svg>
</a> </a>
</li> </li>
<li class="active"><a class="whiteLink" href="">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a href="#" style="background-color: lightgray">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Create a Role</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Crear un Role</span>
<br /> <br />
<br /> <br />
<form method="post" action="./add"> <form method="post" action="./add">
<input name="action" value="create" type="hidden"> <input name="action" value="create" type="hidden">
Name of the Role:<br /> Nombre del Rol:<br />
<input name="roleName" placeholder="Name of the Role" required><br /> <input name="roleName" placeholder="Nombre del Rol" required><br />
Status of the Role:<br /> Estado del Rol:<br />
<select name="roleStatus" class="browser-default" required> <br />
<option value="" disabled selected>Choose a status</option> <div class="switch" id="siwtchContainer">
<option value="true">true</option> <label>
<option value="false">false</option> Falso
</select> <input id="sivth" type="checkbox" name="roleStatus" value="false">
<span class="lever"></span>
Verdadero
</label>
</div>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
<script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
}
</script>
</form> </form>
<hr /> <hr />
<br /> <br />
<a href="../roles" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../roles" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -15,31 +15,48 @@
%> %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Roles - Hotel Services</title> <meta charset="UTF-8">
<title>Roles - Hotel Service</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <!--<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="https://apis.google.com/js/platform.js" async defer></script> <script src="../js/GlobalJs.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 type="text/css" rel="stylesheet" href="/css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<style>
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> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -50,7 +67,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -61,8 +78,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -72,24 +89,30 @@
</svg> </svg>
</a> </a>
</li> </li>
<li class="active"><a class="whiteLink" href="">Roles</a></li> <li><a class="whiteLink" href="./">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li> <li class="active"><a class="whiteLink active" href="#">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li> <li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li> <li><a class="whiteLink" href="./reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('./services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a href="#" style="background-color: lightgray">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('./users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('./resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('./access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="#">Roles</a></li>
<li class="tab"><a href="./users">Usuarios</a></li>
<li class="tab"><a href="./resources">Recursos</a></li>
<li class="tab"><a href="./access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
@ -100,39 +123,41 @@
<%if (!serverResponse.equals("!")){ %> <%if (!serverResponse.equals("!")){ %>
<div id="serverResponse"> <div id="serverResponse">
<div style="margin: 10px"></div> <div style="margin: 10px"></div>
</div> </div>
<script> <script>
var respDiv = document.getElementById("serverResponse"); var respDiv = document.getElementById("serverResponse");
var responseData = JSON.parse('<%=serverResponse%>'); var responseData = JSON.parse('<%=serverResponse%>');
respDiv.style.backgroundColor = responseData["color"]; respDiv.style.backgroundColor = responseData["color"];
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>"; respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
respDiv.style.maxHeight = "500px"; setTimeout(function () {
setTimeout(function () { respDiv.style.maxHeight = "500px";
respDiv.style.maxHeight = "0"; setTimeout(function () {
},1500); respDiv.style.maxHeight = "0";
},1500);
},10);
</script> </script>
<% } %> <% } %>
<br /> <br />
<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> <a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('./roles/add',{action:'redirect'})"><i class="material-icons left">add</i>Crear</a>
<br /> <br />
<br /> <br />
<table class="striped responsive-table"> <table class="striped responsive-table">
<thead> <thead>
<tr> <tr>
<td>Name</td> <td>Nombre</td>
<td>Status</td> <td>Estado</td>
<td>Date created</td> <td>Fecha de Creación</td>
<td>Actions</td> <td>Acciones</td>
</tr> </tr>
</thead> </thead>
@ -159,19 +184,45 @@
<td><%= roleKey.getStatus()%></td> <td><%= roleKey.getStatus()%></td>
<td><%= roleKey.getCreateDate()%></td> <td><%= roleKey.getCreateDate()%></td>
<td> <td>
<a class="postLink" onclick="postRedirect('roles/view',{action:'viewRedirect',key:'<%=key%>'})">View</a> <a class="postLink" onclick="postRedirect('./roles/view',{action:'viewRedirect',key:'<%=key%>'})">Ver</a>
| <a class="postLink" onclick="postRedirect('roles/view',{action:'editRedirect',key:'<%=key%>'})">Edit</a> | <a class="postLink" onclick="postRedirect('./roles/view',{action:'editRedirect',key:'<%=key%>'})">Editar</a>
| <a class="postLink" onclick="postRedirect('roles/delete',{key:'<%=key%>'})">Delete</a></td> | <a class="postLink" onclick="postRedirect('./roles/delete',{key:'<%=key%>'})">Eliminar</a></td>
</tr> </tr>
<% } %> <% } %>
</tbody> </tbody>
</table> </table>
</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> </body>
</html> </html>

View File

@ -14,31 +14,31 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<head> <head>
<title><%=action%> a User - Hotel Services</title> <title><%=action%> un Rol - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -49,7 +49,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -60,8 +60,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -71,30 +71,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li class="active"><a class="whiteLink" href="/roles">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()"> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
Show Services
</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a href="#" style="background-color: lightgray">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="../roles">Roles</a></li>
<li class="tab"><a href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a Role</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Rol</span>
<br /> <br />
<br /> <br />
@ -105,18 +110,41 @@
<input name="key" value="<%=roleKey.getKey()%>" type="hidden"> <input name="key" value="<%=roleKey.getKey()%>" type="hidden">
<input name="action" value="update" type="hidden"> <input name="action" value="update" type="hidden">
Name:<br /> Nombre:<br />
<input name="roleName" value="<%=roleKey.getName()%>" placeholder="Name" required><br/> <input name="roleName" value="<%=roleKey.getName()%>" placeholder="Nombre" required><br/>
<br/> Estado:<br />
Status:<br /> <br />
<select name="roleStatus" class="browser-default" required> <div class="switch" id="siwtchContainer">
<option value="" disabled selected>Choose a status</option> <label>
<option value="true">true</option> Falso
<option value="false">false</option> <input id="sivth" type="checkbox" name="roleStatus" value="false">
</select> <span class="lever"></span>
Verdadero
</label>
</div>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <script>
document.getElementById("siwtchContainer").addEventListener("mouseup",changeSwitch);
var elSwitch = document.getElementById("sivth");
if ("<%=roleKey.getStatus()%>" === "true"){
elSwitch.checked = "true";
elSwitch.value = "true";
}
function changeSwitch() {
if (elSwitch.value === "false") {
elSwitch.value = "true";
} else {
elSwitch.value = "false";
}
console.log("anumaaa -> " + elSwitch.value);
}
</script>
<button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
@ -127,7 +155,7 @@
<div style="font-size: x-large"> <div style="font-size: x-large">
Name: <%=roleKey.getName()%><br /> Name: <%=roleKey.getName()%><br />
Email: <%=roleKey.getStatus()%><br /> Status: <%=roleKey.getStatus()%><br />
</div> </div>
@ -135,7 +163,7 @@
<hr /> <hr />
<br /> <br />
<a href="../roles" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../roles" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -1,6 +1,5 @@
<%@ page import="model.User" %> <%@ page import="model.User" %>
<%@ page import="java.util.List" %> <%--
<%@ page import="model.Role" %><%--
Created by IntelliJ IDEA. Created by IntelliJ IDEA.
User: Fernando User: Fernando
Date: 07/06/2018 Date: 07/06/2018
@ -11,39 +10,43 @@
<% User user = (User) request.getAttribute("User"); %> <% User user = (User) request.getAttribute("User"); %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Add a Service - Hotel Services</title> <title>Crear un Servicio - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
<i class="material-icons right">arrow_drop_down</i> <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;"> <div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute;
width: auto; display: none;">
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('../view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -54,8 +57,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -65,53 +68,59 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li class="active"><a class="whiteLink" href="">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a href="#" style="background-color: lightgray">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="../services">Servicios</a></li>
<li class="tab"><a href="../employees">Empleados</a></li>
<li class="tab"><a href="../materials">Materiales</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Create a Service</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Crear un Servicio</span>
<br /> <br />
<br /> <br />
<form method="post" action="./add"> <form method="post" action="./add">
<input name="action" value="create" type="hidden"> <input name="action" value="create" type="hidden">
Name of the Service:<br /> Nombre del Servicio:<br />
<input name="Name" placeholder="Name" required><br /> <input name="Name" placeholder="Nombre" required><br />
Price of the Service:<br /> Precio del Servicio:<br />
<input name="Price" placeholder="Price" type="number" required min="0" step="0.1"><br /> <input name="Price" placeholder="Precio" type="number" required min="0" step="0.1"><br />
Description of the Service:<br /> Descripción del Servicio:<br />
<input name="Description" placeholder="Description" required><br /> <input name="Description" placeholder="Descripción" required><br />
<input type="hidden" name="userId" value="<%=user.getId()%>"> <input type="hidden" name="userId" value="<%=user.getId()%>">
<button class="btn waves-effect waves-light" type="submit" name="action">Create <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
</form> </form>
<hr /> <hr />
<br /> <br />
<a href="../services" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../services" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -15,32 +15,32 @@
%> %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Services - Hotel Services</title> <title>Servicios - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css?v=2"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css?v=2">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -51,7 +51,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -62,8 +62,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -73,29 +73,34 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li> <li><a class="whiteLink" href="./">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li> <li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li> <li class="active"><a class="whiteLink active" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li> <li><a class="whiteLink" href="./reports">Reportes de Ingresos</a></li>
<li>|</li>
<li class="active"><a class="whiteLink" href="">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('./roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a href="#" style="background-color: lightgray">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('./resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('./access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="#">Servicios</a></li>
<li class="tab"><a href="./employees">Empleados</a></li>
<li class="tab"><a href="./materials">Materiales</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Services</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Servicios</span>
<br /> <br />
<br /> <br />
@ -112,10 +117,13 @@
respDiv.style.backgroundColor = responseData["color"]; respDiv.style.backgroundColor = responseData["color"];
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>"; respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
respDiv.style.maxHeight = "500px";
setTimeout(function () { setTimeout(function () {
respDiv.style.maxHeight = "0"; respDiv.style.maxHeight = "500px";
},1500); setTimeout(function () {
respDiv.style.maxHeight = "0";
},1500);
},50);
</script> </script>
@ -123,18 +131,18 @@
<br /> <br />
<br /> <br />
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/services/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a> <a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/services/add',{action:'redirect'})"><i class="material-icons left">add</i>Crear</a>
<br /> <br />
<br /> <br />
<table class="striped responsive-table"> <table class="striped responsive-table">
<thead> <thead>
<tr> <tr>
<td>Name</td> <td>Nombre</td>
<td>Price</td> <td>Precio</td>
<td>Description</td> <td>Descripción</td>
<td>Created by</td> <td>Creado por</td>
<td>Actions</td> <td>Acciones</td>
</tr> </tr>
</thead> </thead>
@ -147,9 +155,9 @@
<td><%= service.getDescription() %></td> <td><%= service.getDescription() %></td>
<td><%= service.getCreatorUserName() %></td> <td><%= service.getCreatorUserName() %></td>
<td> <td>
<a class="postLink" onclick="postRedirect('services/view',{action:'viewRedirect',serviceKey:'<%=service.getKey()%>'})">View</a> <a class="postLink" onclick="postRedirect('services/view',{action:'viewRedirect',serviceKey:'<%=service.getKey()%>'})">Ver</a>
| <a class="postLink" onclick="postRedirect('services/view',{action:'editRedirect',serviceKey:'<%=service.getKey()%>'})">Edit</a> | <a class="postLink" onclick="postRedirect('services/view',{action:'editRedirect',serviceKey:'<%=service.getKey()%>'})">Editar</a>
| <a class="postLink" onclick="postRedirect('services/delete',{serviceKey:'<%=service.getKey()%>'})">Delete</a></td> | <a class="postLink" onclick="postRedirect('services/delete',{serviceKey:'<%=service.getKey()%>'})">Eliminar</a></td>
</tr> </tr>
<% } %> <% } %>

View File

@ -21,24 +21,24 @@
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -49,7 +49,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -60,8 +60,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -71,30 +71,34 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li><a class="whiteLink" onclick="postRedirect('../users')">Users</a></li> <li><a class="whiteLink" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li class="active"><a class="whiteLink active" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li class="active"><a class="whiteLink" href="">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()"> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
Show Services
</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a href="#" style="background-color: lightgray">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a onclick="postRedirect('../users')">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab active"><a class="active" href="../services">Servicios</a></li>
<li class="tab"><a href="../employees">Empleados</a></li>
<li class="tab"><a href="../materials">Materiales</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a Service</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Servicio</span>
<br /> <br />
<br /> <br />
@ -105,17 +109,17 @@
<input name="key" value="<%=service.getKey()%>" type="hidden"> <input name="key" value="<%=service.getKey()%>" type="hidden">
<input name="action" value="update" type="hidden"> <input name="action" value="update" type="hidden">
Name of the Service:<br /> Nombre del Servicio:<br />
<input name="Name" value="<%=service.getName()%>" placeholder="Name" required><br/> <input name="Name" value="<%=service.getName()%>" placeholder="Nombre" required><br/>
Price of the Service:<br /> Precio del Servicio:<br />
<input name="Price" type="number" min="0" step="0.1" required placeholder="Price" value="<%= service.getPrice() %>"><br /> <input name="Price" type="number" min="0" step="0.1" required placeholder="Precio" value="<%= service.getPrice() %>"><br />
Description of the Service:<br /> Descripción del Servicio:<br />
<input name="Description" placeholder="Description" required value="<%= service.getDescription() %>"><br /> <input name="Description" placeholder="Descripción" required value="<%= service.getDescription() %>"><br />
<button class="btn waves-effect waves-light" type="submit" name="action">Edit <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
@ -125,10 +129,10 @@
<div style="font-size: x-large"> <div style="font-size: x-large">
Name: <%= service.getName() %><br /> Nombre: <%= service.getName() %><br />
Price: <%= service.getPrice() %><br /> Precio: <%= service.getPrice() %><br />
Description: <%= service.getDescription() %><br /> Descripción: <%= service.getDescription() %><br />
Created by: <a style="cursor:pointer;" onclick="postRedirect('/users/view',{action:'viewRedirect',userID:'<%=service.getCreatorUserId()%>'})"><%= service.getCreatorUserName() %></a> Creado por: <a style="cursor:pointer;" onclick="postRedirect('/e/users/view',{action:'viewRedirect',userID:'<%=service.getCreatorUserId()%>'})"><%= service.getCreatorUserName() %></a>
</div> </div>
@ -136,7 +140,7 @@
<hr /> <hr />
<br /> <br />
<a href="../roles" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../services" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -0,0 +1,165 @@
<%@ page import="model.Resource" %>
<%@ page import="model.User" %>
<%@ page import="model.Transaction" %>
<%@ page import="java.util.List" %>
<%--
Created by IntelliJ IDEA.
User: Jose
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User usuario = (User) request.getAttribute("User");
List<Transaction> transitionList = (List<Transaction>) request.getAttribute("transactionsList");
String serverResponse = (String) request.getAttribute("serverResponse");
if (serverResponse == null) serverResponse = "!";
%>
<html lang="es">
<head>
<title>Transacciones - 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 type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../../js/GlobalJs.js" async defer></script>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" 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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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" href="./">Inicio</a></li>
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li class="active"><a class="whiteLink active" href="#">Reportes de Ingresos</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 href="#" 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>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./reports">Finanzas</a></li>
<li class="tab active"><a class="active" href="#">Transacciones</a></li>
</ul>
</div>
</nav>
<div class="container">
<br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Transacciones</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);
},50);
</script>
<% } %>
<br />
<br />
<table class="striped responsive-table">
<thead>
<tr>
<td>ID del Usuario</td>
<td>Servicio</td>
<td>Costo</td>
<td>Fecha de facturación</td>
</tr>
</thead>
<% for (Transaction transaction: transitionList) {%>
<tr>
<td><%=transaction.getUserID()%></td>
<td><%=transaction.getServiceName()%></td>
<td><%=transaction.getServicePrice()%></td>
<td><%=transaction.getCreateDate()%></td>
</tr>
<% } %>
</table>
<br />
<br />
<br />
<br />
<br />
</div>
</body>
</html>

View File

@ -12,39 +12,43 @@
<% List<Role> roles = (List<Role>) request.getAttribute("Roles"); %> <% List<Role> roles = (List<Role>) request.getAttribute("Roles"); %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Add a User - Hotel Services</title> <title>Crear un Usuario - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<%= user.getName()%> <%= user.getName()%>
</span>
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
<i class="material-icons right">arrow_drop_down</i> <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;"> <div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute;
width: auto; display: none;">
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('../view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -55,8 +59,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -66,42 +70,49 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li class="active"><a class="whiteLink" href="">Users</a></li> <li class="active"><a class="whiteLink active" href="../roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a href="#" style="background-color: lightgray">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab active"><a class="active" href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Create a User</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Crear un Usuario</span>
<br /> <br />
<br /> <br />
<form method="post" action="./add"> <form method="post" action="./add">
<input name="action" value="create" type="hidden"> <input name="action" value="create" type="hidden">
Name of the User:<br /> Nombre del Usuario:<br />
<input name="userName" placeholder="Name of the User" required><br /> <input name="userName" placeholder="Nombre" required><br />
Email of the User:<br /> Correo electrónico del Usuario:<br />
<input name="userEmail" placeholder="Email" type="email" required> <input name="userEmail" placeholder="Correo electrónico" type="email" required>
<div class="row"> <div class="row">
<div class="col l10 m10"> <div class="col l10 m10">
Profile Image link<br /> Imagen<br />
<input name="userImg" value="https://i.stack.imgur.com/34AD2.jpg" placeholder="Link" required oninput="cambiarImg(this)"><br /> <input name="userImg" value="https://i.stack.imgur.com/34AD2.jpg" placeholder="Link" required oninput="cambiarImg(this)"><br />
<br /> <br />
</div> </div>
@ -110,23 +121,23 @@
</div> </div>
</div> </div>
Role of the User:<br /> Role del Usuario:<br />
<select name="userRole" class="browser-default" required> <select name="userRole" class="browser-default" required>
<option value="" disabled selected>Choose a Role</option> <option value="" disabled selected>Escoje un Rol</option>
<% for(Role roleKey: roles){ %> <% for(Role roleKey: roles){ %>
<option value="<%=roleKey.getKey()%>"><%=roleKey.getName()%></option> <option value="<%=roleKey.getKey()%>"><%=roleKey.getName()%></option>
<% } %> <% } %>
</select> </select>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
</form> </form>
<hr /> <hr />
<br /> <br />
<a href="../users" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../users" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>

View File

@ -14,32 +14,32 @@
%> %>
<html lang="es"> <html lang="es">
<head> <head>
<title>Users - Hotel Services</title> <title>Usuarios - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css?v=2"> <link type="text/css" rel="stylesheet" href="../css/Elements.css?v=2">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../js/GlobalJs.js" async defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <span id="nombreUsuario" style="min-width: 80px;">
<span style="min-width: 80px;">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
@ -50,7 +50,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -61,8 +61,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -72,29 +72,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li> <li><a class="whiteLink" href="./">Inicio</a></li>
<li class="active"><a class="whiteLink" href="">Users</a></li> <li class="active"><a class="whiteLink active">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li> <li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li> <li><a class="whiteLink" href="./reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('./services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('./roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a href="#" style="background-color: lightgray">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('./resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('./access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div> </div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="./roles">Roles</a></li>
<li class="tab active"><a class="active" href="">Usuarios</a></li>
<li class="tab"><a href="./resources">Recursos</a></li>
<li class="tab"><a href="./access">Accesos</a></li>
</ul>
</div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Users</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Usuarios</span>
<br /> <br />
<br /> <br />
@ -111,10 +117,13 @@
respDiv.style.backgroundColor = responseData["color"]; respDiv.style.backgroundColor = responseData["color"];
respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>"; respDiv.innerHTML = "<div style=\"margin: 10px\">" + responseData["response"] + "</div>";
respDiv.style.maxHeight = "500px";
setTimeout(function () { setTimeout(function () {
respDiv.style.maxHeight = "0"; respDiv.style.maxHeight = "500px";
},1500); setTimeout(function () {
respDiv.style.maxHeight = "0";
},1500);
},50);
</script> </script>
@ -122,18 +131,18 @@
<br /> <br />
<br /> <br />
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/users/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a> <a class="waves-effect waves-light btn whiteLink indigo darken-1" onclick="postRedirect('/e/users/add',{action:'redirect'})"><i class="material-icons left">add</i>Crear</a>
<br /> <br />
<br /> <br />
<table class="striped responsive-table"> <table class="striped responsive-table">
<thead> <thead>
<tr> <tr>
<td>Name</td> <td>Nombre</td>
<td>Email</td> <td>Correo electrónico</td>
<td>Role</td> <td>Rol</td>
<td>Img</td> <td>Imagen</td>
<td>Actions</td> <td>Acciones</td>
</tr> </tr>
</thead> </thead>
@ -149,9 +158,9 @@
</td> </td>
<td><img src="<%= user.getImgUrl()%>" width="55px"/></td> <td><img src="<%= user.getImgUrl()%>" width="55px"/></td>
<td> <td>
<a class="postLink" onclick="postRedirect('users/view',{action:'viewRedirect',userID:'<%=user.getId()%>'})">View</a> <a class="postLink" onclick="postRedirect('users/view',{action:'viewRedirect',userID:'<%=user.getId()%>'})">Ver</a>
| <a class="postLink" onclick="postRedirect('users/view',{action:'editRedirect',userID:'<%=user.getId()%>'})">Edit</a> | <a class="postLink" onclick="postRedirect('users/view',{action:'editRedirect',userID:'<%=user.getId()%>'})">Editar</a>
| <a class="postLink" onclick="postRedirect('users/delete',{userID:'<%=user.getId()%>'})">Delete</a></td> | <a class="postLink" onclick="postRedirect('users/delete',{userID:'<%=user.getId()%>'})">Eliminar</a></td>
</tr> </tr>
<% } %> <% } %>

View File

@ -16,34 +16,34 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<head> <head>
<title><%=action%> a Role - Hotel Services</title> <title><%=action%> un Usuario - Hotel Services</title>
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com"> <meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script> <script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <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/Diseno.css">
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css"> <link type="text/css" rel="stylesheet" href="../../css/materialize.min.css">
<link type="text/css" rel="stylesheet" href="/css/Elements.css"> <link type="text/css" rel="stylesheet" href="../../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="/js/GlobalJs.js" async defer></script> <script src="../../js/GlobalJs.js" defer></script>
</head> </head>
<body> <body>
<nav style="background-color: #67c9b3"> <nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper"> <div class="nav-wrapper" style="max-height: 64px">
<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> <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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()"> <div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 150px;" onclick="changeUserOptions()">
<span style="min-width: 80px;"> <span id="nombreUsuario" style="min-width: 80px">
<%= usuario.getName()%> <%= usuario.getName()%>
</span> </span>
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px"> <img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
<i class="material-icons">arrow_drop_down</i> <i class="material-icons">arrow_drop_down</i>
@ -52,7 +52,7 @@
<ul style="color: black"> <ul style="color: black">
<li style="padding: 0 5px;"> <li style="padding: 0 5px;">
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Log Out</a> <a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesión</a>
</li> </li>
<li id="cerrar" style="padding: 0 5px; cursor: pointer"> <li id="cerrar" style="padding: 0 5px; cursor: pointer">
@ -63,8 +63,8 @@
</div> </div>
<ul id="nav-mobile" class="right hide-on-med-and-down"> <ul id="nav-mobile" class="right hide-on-med-and-down">
<li> <li style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Lab08" target="_blank"> <a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<svg style="width: 32px; height: 32px; margin: 20px 0" aria-labelledby="simpleicons-github-icon" roleKey="img" xmlns="http://www.w3.org/2000/svg"> <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"> <title id="simpleicons-github-icon">
GitHub icon GitHub icon
@ -74,28 +74,35 @@
</svg> </svg>
</a> </a>
</li> </li>
<li><a class="whiteLink" onclick="postRedirect('../roles')">Roles</a></li> <li><a class="whiteLink" href="../">Inicio</a></li>
<li class="active"><a class="whiteLink" href="">Users</a></li> <li class="active"><a class="whiteLink active" href="#">Administración de Usuarios</a></li>
<li><a class="whiteLink" onclick="postRedirect('../resources')">Resources</a></li> <li><a class="whiteLink" href="../services">Administración de recursos</a></li>
<li><a class="whiteLink" onclick="postRedirect('../access')">Access</a></li> <li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
<li>|</li>
<li><a class="whiteLink" onclick="postRedirect('../services')">Services</a></li>
<li>|</li> <li>|</li>
</ul> </ul>
<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div> <!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
<div id="dropdownContent"> <div id="dropdownContent">
<a onclick="postRedirect('../roles')">Roles</a> <a href="#" onclick="postRedirect('./roles')">Roles</a>
<a href="#" style="background-color: lightgray">Users</a> <a href="#" style="background-color: lightgray">Users</a>
<a onclick="postRedirect('../resources')">Resources</a> <a onclick="postRedirect('./resources')">Resources</a>
<a onclick="postRedirect('../access')">Access</a> <a onclick="postRedirect('./access')">Access</a>
</div> </div>-->
</div>
<div class="nav-content" style="background-color: #3949a3">
<ul class="tabs tabs-transparent">
<li class="tab"><a href="../roles">Roles</a></li>
<li class="tab active"><a class="active" href="../users">Usuarios</a></li>
<li class="tab"><a href="../resources">Recursos</a></li>
<li class="tab"><a href="../access">Accesos</a></li>
</ul>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
<br /> <br />
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a User</span> <span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> un Usuario</span>
<br /> <br />
<br /> <br />
@ -106,11 +113,11 @@
<input name="userID" value="<%=user.getId()%>" type="hidden"> <input name="userID" value="<%=user.getId()%>" type="hidden">
<input name="action" value="update" type="hidden"> <input name="action" value="update" type="hidden">
Name:<br /> Nombre:<br />
<input name="userName" value="<%=user.getName()%>" placeholder="Name" required><br/> <input name="userName" value="<%=user.getName()%>" placeholder="Nombre" required><br/>
<br/> <br/>
Email:<br /> Correo electrónico:<br />
<input name="userEmail" value="<%=user.getEmail()%>" placeholder="Email" type="email" required><br /> <input name="userEmail" value="<%=user.getEmail()%>" placeholder="Correo electrónico" type="email" required><br />
<br /> <br />
<div class="row"> <div class="row">
@ -124,16 +131,16 @@
</div> </div>
</div> </div>
Role of the User:<br /> Rol del Usuario:<br />
<select name="userRole" class="browser-default" required> <select name="userRole" class="browser-default" required>
<option value="" disabled selected>Choose a Role</option> <option value="" disabled selected>Escoje un Rol</option>
<% for(Role roleKey: roles){ %> <% for(Role roleKey: roles){ %>
<option value="<%=roleKey.getKey()%>"><%=roleKey.getName()%></option> <option value="<%=roleKey.getKey()%>"><%=roleKey.getName()%></option>
<% } %> <% } %>
</select> </select>
<br /> <br />
<button class="btn waves-effect waves-light" type="submit" name="action">Submit <button class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Editar
<i class="material-icons right">send</i> <i class="material-icons right">send</i>
</button> </button>
@ -143,9 +150,9 @@
<div class="row"> <div class="row">
<div class="col l8 m8" style="font-size: x-large"> <div class="col l8 m8" style="font-size: x-large">
Name: <%=user.getName()%><br /> Nombre: <%=user.getName()%><br />
Email: <%=user.getEmail()%><br /> Correo electrónico: <%=user.getEmail()%><br />
Role: <%= user.getRoleName()%><br /> Rol: <%= user.getRoleName()%><br />
</div> </div>
<div class="col l4 m4"> <div class="col l4 m4">
<img src="<%=user.getImgUrl()%>" width="96px"><br /> <img src="<%=user.getImgUrl()%>" width="96px"><br />
@ -157,7 +164,7 @@
<hr /> <hr />
<br /> <br />
<a href="../users" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a> <a href="../users" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
</div> </div>
@ -170,5 +177,6 @@
} }
</script> </script>
</body> </body>
</html> </html>

188
war/WEB-INF/View/eIndex.jsp Normal file
View File

@ -0,0 +1,188 @@
<%@ page import="model.User" %>
<%--
Created by IntelliJ IDEA.
User: Fernando
Date: 07/06/2018
Time: 16:39
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% User user = (User) request.getAttribute("User");
String serverResponse = (String) request.getAttribute("serverResponse");
if (serverResponse == null) serverResponse = "!";
%>
<html lang="es">
<head>
<title>Area de Empleados - 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 type="text/css" rel="stylesheet" href="../css/Elements.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="../js/GlobalJs.js" async defer></script>
<style>
.cards{
padding: 10px;
border-radius: 3px;
box-shadow: 2px 2px lightgray;
background: -moz-linear-gradient(left, #3949a3 55%, white 90%);
background: -webkit-linear-gradient(left, #3949a3 55%, white 90%);
}
.cards a{
text-decoration: underline;
color: white;
}
</style>
</head>
<body>
<nav class="nav-extended" style="background-color: #3f51b5">
<div class="nav-wrapper" style="max-height: 64px">
<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>
&nbsp;&nbsp;Empleados
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
<span id="nombreUsuario" style="min-width: 80px;">
<%= user.getName()%>
</span>
<img src="<%=user.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'})">Cerrar Sesión</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 style="max-height: 62px">
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
<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 class="active"><a class="whiteLink" href="#">Inicio</a></li>
<li><a class="whiteLink" href="./roles">Administración de Usuarios</a></li>
<li><a class="whiteLink" href="./services">Administración de recursos</a></li>
<li><a class="whiteLink" href="./reports">Reportes de Ingresos</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 href="#" 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">Area de Empleados</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="padding: 10px 15px">
<div class="row cards">
<div class="col l9 m9 s8" style="color: white; font-size: large">
<span style="font-size: x-large">Administración de Usuarios</span><br />
<br />
<div>
<a href="./roles">Roles</a><br/>
<a href="./users">Usuarios</a><br/>
<a href="./resources">Recursos</a><br/>
<a href="./access">Accesos</a><br/>
</div>
</div>
<div class="col l3 m3 s4 right-align">
<i class="material-icons" style="font-size: 8rem; color: #3949a3">people</i>
</div>
</div>
<div class="row cards">
<div class="col l9 m9 s8" style="color: white; font-size: large">
<span style="font-size: x-large">Administración de Recursos</span><br />
<br />
<div>
<a href="./services">Servicios</a><br/>
<a href="./employees">Empleados</a><br/>
<a href="./materials">Materiales</a><br/>
</div>
</div>
<div class="col l3 m3 s4 right-align">
<i class="material-icons" style="font-size: 8rem; color: #3949a3">archive</i>
</div>
</div>
<div class="row cards">
<div class="col l9 m9 s8" style="color: white; font-size: large">
<span style="font-size: x-large">Reportes de Ingresos</span><br />
<br />
<div>
<a href="./reports">Finanzas</a><br/>
<a href="./trans">Transacciones</a><br/>
</div>
</div>
<div class="col l3 m3 s4 right-align">
<i class="material-icons" style="font-size: 8rem; color: #3949a3">attach_money</i>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>lab08-20173373</application> <application>hotel-service-210413</application>
<version>2</version> <version>1</version>
<sessions-enabled>true</sessions-enabled> <sessions-enabled>true</sessions-enabled>
<!-- <!--

Some files were not shown because too many files have changed in this diff Show More