Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
dbab7fdd1f
@ -1,15 +1,73 @@
|
|||||||
package controller.resources;
|
package controller.resources;
|
||||||
|
|
||||||
|
import javax.jdo.JDOObjectNotFoundException;
|
||||||
|
import javax.jdo.PersistenceManager;
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ResourcesControllerAdd extends HttpServlet {
|
public class ResourcesControllerAdd extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
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"));
|
||||||
|
|
||||||
|
Resource resource = new Resource(url,status);
|
||||||
|
|
||||||
|
try{
|
||||||
|
pm.makePersistent(resource);
|
||||||
|
} finally {
|
||||||
|
System.out.println("Recurso creado");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 resource = pm.getObjectById(Resource.class, a);
|
||||||
|
|
||||||
|
resource.setName(request.getParameter("url"));
|
||||||
|
resource.setStatus(Boolean.parseBoolean(request.getParameter("status")));
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.close();
|
||||||
|
try{
|
||||||
|
response.sendRedirect("/resource");
|
||||||
|
}
|
||||||
|
//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 {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -1,15 +1,40 @@
|
|||||||
package controller.resources;
|
package controller.resources;
|
||||||
|
|
||||||
|
import com.google.appengine.api.datastore.Key;
|
||||||
|
import com.google.appengine.api.datastore.KeyFactory;
|
||||||
|
import model.Resource;
|
||||||
|
|
||||||
|
import javax.jdo.JDOObjectNotFoundException;
|
||||||
|
import javax.jdo.PersistenceManager;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ResourcesControllerDelete extends HttpServlet {
|
public class ResourcesControllerDelete extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
|
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Key k = KeyFactory.stringToKey(request.getParameter("key"));
|
||||||
|
try{
|
||||||
|
pm.deletePersistent(pm.getObjectById(Role.class, k));
|
||||||
|
} catch (JDOObjectNotFoundException e){
|
||||||
|
System.err.println("Exception catched -> " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
System.err.println("Exception captured -> " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
response.sendRedirect("/resource");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -1,15 +1,41 @@
|
|||||||
package controller.resources;
|
package controller.resources;
|
||||||
|
|
||||||
|
import controller.users.UsersControllerView;
|
||||||
|
import model.User;
|
||||||
|
|
||||||
|
import javax.jdo.PersistenceManager;
|
||||||
|
import javax.servlet.RequestDispatcher;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ResourcesControllerIndex extends HttpServlet {
|
public class ResourcesControllerIndex extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
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",RolesControllerView.getAllRoles());
|
||||||
|
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/View/Resource/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 {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
@ -1,18 +1,94 @@
|
|||||||
package controller.resources;
|
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.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ResourcesControllerView extends HttpServlet {
|
public class ResourcesControllerView extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
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/Resource/view.jsp");
|
||||||
|
request.setAttribute("Resource",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/Resource/view.jsp");
|
||||||
|
request.setAttribute("Resource",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 {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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> getAllRoles(){
|
||||||
|
PersistenceManager pm = controller.PMF.get().getPersistenceManager();
|
||||||
|
List<Resource> users = (List<Resource>) pm.newQuery("select from " + Resource.class.getName()).execute();
|
||||||
|
pm.close();
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,59 @@
|
|||||||
package model;
|
package model;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.jdo.annotations.IdGeneratorStrategy;
|
||||||
|
import javax.jdo.annotations.PersistenceCapable;
|
||||||
|
import javax.jdo.annotations.Persistent;
|
||||||
|
import javax.jdo.annotations.PrimaryKey;
|
||||||
|
|
||||||
|
import com.google.appengine.api.datastore.Key;
|
||||||
|
import com.google.appengine.api.datastore.KeyFactory;
|
||||||
public class Resource {
|
public class Resource {
|
||||||
|
|
||||||
|
|
||||||
|
@PrimaryKey
|
||||||
|
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
|
||||||
|
private Key key;
|
||||||
|
|
||||||
|
//URL del recurso
|
||||||
|
@Persistent
|
||||||
|
private String Url;
|
||||||
|
|
||||||
|
//Estado del recurso
|
||||||
|
@Persistent
|
||||||
|
private boolean status;
|
||||||
|
|
||||||
|
//Fecha de creacion del recurso
|
||||||
|
@Persistent
|
||||||
|
private String created;
|
||||||
|
|
||||||
|
//Constructor
|
||||||
|
public Resource(String url,boolean status){
|
||||||
|
this.Url=url;
|
||||||
|
this.status=status;
|
||||||
|
DateFormat df = new SimpleDateFormat("HH:mm:ss dd/MM/yy");
|
||||||
|
created = df.format(Calendar.getInstance().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return KeyFactory.keyToString(key);
|
||||||
|
}
|
||||||
|
public void setUrl(String url){
|
||||||
|
this.Url=url;
|
||||||
|
}
|
||||||
|
public String getUrl(){
|
||||||
|
return this.Url;
|
||||||
|
}
|
||||||
|
public void setStatus(boolean status){
|
||||||
|
this.status=status;
|
||||||
|
}
|
||||||
|
public boolean getStatus(){
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
public String toString(){
|
||||||
|
return "Recurso url: " + Url +"\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,159 @@
|
|||||||
|
<%@ page import="model.User" %>
|
||||||
|
<%@ page import="java.util.List" %>
|
||||||
<%--
|
<%--
|
||||||
Created by IntelliJ IDEA.
|
Created by IntelliJ IDEA.
|
||||||
User: Fernando
|
User: Jose
|
||||||
Date: 07/06/2018
|
Date: 07/06/2018
|
||||||
Time: 16:39
|
Time: 16:39
|
||||||
To change this template use File | Settings | File Templates.
|
To change this template use File | Settings | File Templates.
|
||||||
--%>
|
--%>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
<html>
|
<% User user = (User) request.getAttribute("User"); %>
|
||||||
<head>
|
<html lang="es">
|
||||||
<title>Title</title>
|
<head>
|
||||||
|
<title>Add a Resource - Hotel Services</title>
|
||||||
|
|
||||||
|
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||||
|
|
||||||
|
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.postLink{
|
||||||
|
color: blue;
|
||||||
|
font-size: large;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 250ms ease-in;
|
||||||
|
}
|
||||||
|
.postLink:hover{
|
||||||
|
color: green;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: white;
|
||||||
|
font-family: Roboto, serif;
|
||||||
|
}
|
||||||
|
.whiteLink{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.whiteLink:hover{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<nav style="background-color: #67c9b3">
|
||||||
|
<div class="nav-wrapper">
|
||||||
|
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||||
|
|
||||||
|
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||||
|
<%= user.getName()%>
|
||||||
|
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||||
|
<i class="material-icons right">arrow_drop_down</i>
|
||||||
|
|
||||||
|
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||||
|
<ul style="color: black">
|
||||||
|
|
||||||
|
<li style="padding: 0 5px;">
|
||||||
|
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||||
|
<i class="small material-icons">arrow_drop_up</i>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul id="nav-mobile" class="right">
|
||||||
|
<li class="active"><a class="whiteLink" href="">Users</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./resources')">Resources</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<br />
|
||||||
|
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Add a Resource</span>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<form method="post" action="./add">
|
||||||
|
<input name="action" value="create" type="hidden">
|
||||||
|
|
||||||
|
Url of the Resource:<br />
|
||||||
|
<input name="url" placeholder="Url of the Role" required><br />
|
||||||
|
Status of the Resource:<br />
|
||||||
|
<select name="status" class="browser-default" required>
|
||||||
|
<option value="" disabled selected>Choose a status</option>
|
||||||
|
<option value="true">true</option>
|
||||||
|
<option value="false">false</option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||||
|
<i class="material-icons right">send</i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<hr />
|
||||||
|
<br />
|
||||||
|
<a href="../resources" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var sourceImg = document.getElementById("sourceImg");
|
||||||
|
function cambiarImg(input) {
|
||||||
|
sourceImg.src = input.value;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
var userOptions = document.getElementById("userOptions");
|
||||||
|
var isUserOptionsEnable = true;
|
||||||
|
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||||
|
function changeUserOptions() {
|
||||||
|
if (isUserOptionsEnable){
|
||||||
|
userOptions.style.display = "none";
|
||||||
|
} else {
|
||||||
|
userOptions.style.display = "block";
|
||||||
|
}
|
||||||
|
isUserOptionsEnable = !isUserOptionsEnable;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function postRedirect(url, postData){
|
||||||
|
var postForm = document.createElement("form");
|
||||||
|
postForm.action = url;
|
||||||
|
postForm.method = "POST";
|
||||||
|
postForm.style.display = "none";
|
||||||
|
for (var key in postData){
|
||||||
|
if (postData.hasOwnProperty(key)){
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.type = "hidden";
|
||||||
|
input.name = key;
|
||||||
|
input.value = postData[key];
|
||||||
|
postForm.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.body.appendChild(postForm);
|
||||||
|
postForm.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,16 +1,175 @@
|
|||||||
|
<%@ page import="model.Resource" %>
|
||||||
|
<%@ page import="model.User" %>
|
||||||
|
<%@ page import="java.util.List" %>
|
||||||
<%--
|
<%--
|
||||||
Created by IntelliJ IDEA.
|
Created by IntelliJ IDEA.
|
||||||
User: Fernando
|
User: Jose
|
||||||
Date: 07/06/2018
|
Date: 07/06/2018
|
||||||
Time: 16:39
|
Time: 16:39
|
||||||
To change this template use File | Settings | File Templates.
|
To change this template use File | Settings | File Templates.
|
||||||
--%>
|
--%>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
<html>
|
<% User usuario = (User) request.getAttribute("User"); %>
|
||||||
|
<% List<Resource> resourceList = (List<Resource>) request.getAttribute("ResourceList");%>
|
||||||
|
<html lang="es">
|
||||||
<head>
|
<head>
|
||||||
<title>Title</title>
|
<title>Resources - Hotel Services</title>
|
||||||
|
|
||||||
|
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||||
|
|
||||||
|
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/css/Diseno.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="/css/materialize.min.css">
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.postLink{
|
||||||
|
color: blue;
|
||||||
|
font-size: large;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 250ms ease-in;
|
||||||
|
}
|
||||||
|
.postLink:hover{
|
||||||
|
color: green;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: white;
|
||||||
|
font-family: Roboto, serif;
|
||||||
|
}
|
||||||
|
.whiteLink{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.whiteLink:hover{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<nav style="background-color: #67c9b3">
|
||||||
|
<div class="nav-wrapper">
|
||||||
|
<a class="whiteLink hide-on-med-and-down" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||||
|
|
||||||
|
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||||
|
<%= usuario.getName()%>
|
||||||
|
<img src="<%=usuario.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||||
|
<i class="material-icons right">arrow_drop_down</i>
|
||||||
|
|
||||||
|
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||||
|
<ul style="color: black">
|
||||||
|
|
||||||
|
<li style="padding: 0 5px;">
|
||||||
|
<a style="color: black" onclick="postRedirect('./users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||||
|
<i class="small material-icons">arrow_drop_up</i>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul id="nav-mobile" class="right">
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||||
|
<li class="active"><a class="whiteLink" href="">Resources</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<br />
|
||||||
|
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">Roles</span>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<a class="waves-effect waves-light btn whiteLink" onclick="postRedirect('/resources/add',{action:'redirect'})"><i class="material-icons left">add</i>Create</a>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<table class="striped responsive-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>URL</td>
|
||||||
|
<td>Status</td>
|
||||||
|
<td>Date created</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
<% for (int i = 0; i < recourseList.size(); i++) {%>
|
||||||
|
<% Recourse recourse = recourseList.get(i); %>
|
||||||
|
<% String key = recourse.getKey();
|
||||||
|
String[] arr = key.split("");
|
||||||
|
key = "";
|
||||||
|
for (String a : arr) {
|
||||||
|
if (a.equals("\"")){
|
||||||
|
key += """;
|
||||||
|
} else{
|
||||||
|
key += a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<tr>
|
||||||
|
<td><%= recourse.getName()%></td>
|
||||||
|
<td><%= recourse.getStatus()%></td>
|
||||||
|
<td><%= recourse.getCreateDate()%></td>
|
||||||
|
<td>
|
||||||
|
<a class="postLink" onclick="postRedirect('recourses/view',{action:'viewRedirect',key:'<%=key%>'})">View</a>
|
||||||
|
| <a class="postLink" onclick="postRedirect('recourses/view',{action:'editRedirect',key:'<%=key%>'})">Edit</a>
|
||||||
|
| <a class="postLink" onclick="postRedirect('recourses/delete',{key:'<%=key%>'})">Delete</a></td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var userOptions = document.getElementById("userOptions");
|
||||||
|
var isUserOptionsEnable = true;
|
||||||
|
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||||
|
function changeUserOptions() {
|
||||||
|
if (isUserOptionsEnable){
|
||||||
|
userOptions.style.display = "none";
|
||||||
|
} else {
|
||||||
|
userOptions.style.display = "block";
|
||||||
|
}
|
||||||
|
isUserOptionsEnable = !isUserOptionsEnable;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function postRedirect(url, postData){
|
||||||
|
var postForm = document.createElement("form");
|
||||||
|
postForm.action = url;
|
||||||
|
postForm.method = "POST";
|
||||||
|
postForm.style.display = "none";
|
||||||
|
for (var key in postData){
|
||||||
|
if (postData.hasOwnProperty(key)){
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.type = "hidden";
|
||||||
|
input.name = key;
|
||||||
|
input.value = postData[key];
|
||||||
|
postForm.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.body.appendChild(postForm);
|
||||||
|
postForm.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,16 +1,171 @@
|
|||||||
|
<%@ page import="model.User" %>
|
||||||
|
<%@ page import="model.Resource" %>
|
||||||
<%--
|
<%--
|
||||||
Created by IntelliJ IDEA.
|
Created by IntelliJ IDEA.
|
||||||
User: Fernando
|
User: Jose
|
||||||
Date: 07/06/2018
|
Date: 07/06/2018
|
||||||
Time: 16:39
|
Time: 16:39
|
||||||
To change this template use File | Settings | File Templates.
|
To change this template use File | Settings | File Templates.
|
||||||
--%>
|
--%>
|
||||||
|
<% Resource = (Resource) request.getAttribute("Resource");
|
||||||
|
User userLogged = (User) request.getAttribute("UserLogged");
|
||||||
|
boolean editAllowed = (Boolean) request.getAttribute("editAllowed");
|
||||||
|
String action = (String) request.getAttribute("action");
|
||||||
|
%>
|
||||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Title</title>
|
<title><%=action%> a User - Hotel Services</title>
|
||||||
|
|
||||||
|
<meta name="google-signin-client_id" content="746890482047-c734fgap3p3vb6bdoquufn60bsh2p8l9.apps.googleusercontent.com">
|
||||||
|
|
||||||
|
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="../css/Diseno.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../css/materialize.min.css">
|
||||||
|
|
||||||
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.postLink{
|
||||||
|
color: blue;
|
||||||
|
font-size: large;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 250ms ease-in;
|
||||||
|
}
|
||||||
|
.postLink:hover{
|
||||||
|
color: green;
|
||||||
|
font-size: larger;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: white;
|
||||||
|
font-family: Roboto, serif;
|
||||||
|
}
|
||||||
|
.whiteLink{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.whiteLink:hover{
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
<nav style="background-color: #67c9b3">
|
||||||
|
<div class="nav-wrapper">
|
||||||
|
<a class="whiteLink" href="../" style="padding: 0 0 0 20px; font-family: 'Product Sans', Roboto, serif; font-size: xx-large">Hotel Services</a>
|
||||||
|
|
||||||
|
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer;" onclick="changeUserOptions()">
|
||||||
|
<%= userLogged.getName()%>
|
||||||
|
<img src="<%=userLogged.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
||||||
|
<i class="material-icons right">arrow_drop_down</i>
|
||||||
|
|
||||||
|
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute; width: auto; display: none;">
|
||||||
|
<ul style="color: black">
|
||||||
|
|
||||||
|
<li style="padding: 0 5px;">
|
||||||
|
<a style="color: black" onclick="postRedirect('/users/view',{action:'closeSession'})">Cerrar Sesion</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
||||||
|
<i class="small material-icons">arrow_drop_up</i>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul id="nav-mobile" class="right">
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./users')">Users</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./roles')">Roles</a></li>
|
||||||
|
<li><a class="whiteLink" onclick="postRedirect('./access')">Access</a></li>
|
||||||
|
<li class="active"><a class="whiteLink" href="">Resources</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<br />
|
||||||
|
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif"><%=action%> a User</span>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<% if (editAllowed) {%>
|
||||||
|
|
||||||
|
<form action="./add" method="post">
|
||||||
|
|
||||||
|
<input name="key" value="<%=resource.getKey()%>" type="hidden">
|
||||||
|
<input name="action" value="update" type="hidden">
|
||||||
|
|
||||||
|
Name:<br />
|
||||||
|
<input name="url" value="<%=resource.getName()%>" placeholder="url" required><br/>
|
||||||
|
<br/>
|
||||||
|
Status:<br />
|
||||||
|
<select name="status" class="browser-default" required>
|
||||||
|
<option value="" disabled selected>Choose a status</option>
|
||||||
|
<option value="true">true</option>
|
||||||
|
<option value="false">false</option>
|
||||||
|
</select>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<button class="btn waves-effect waves-light" type="submit" name="action">Submit
|
||||||
|
<i class="material-icons right">send</i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<% } else {%>
|
||||||
|
|
||||||
|
|
||||||
|
<div style="font-size: x-large">
|
||||||
|
Url: <%=resource.getUrl()%><br />
|
||||||
|
Email: <%=resource.getStatus()%><br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
<br />
|
||||||
|
<a href="../resources" class="waves-effect waves-light btn whiteLink"><i class="material-icons left">arrow_back</i>Go Back</a>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var userOptions = document.getElementById("userOptions");
|
||||||
|
var isUserOptionsEnable = true;
|
||||||
|
document.getElementById("cerrar").addEventListener("click", changeUserOptions());
|
||||||
|
function changeUserOptions() {
|
||||||
|
if (isUserOptionsEnable){
|
||||||
|
userOptions.style.display = "none";
|
||||||
|
} else {
|
||||||
|
userOptions.style.display = "block";
|
||||||
|
}
|
||||||
|
isUserOptionsEnable = !isUserOptionsEnable;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
function postRedirect(url, postData){
|
||||||
|
var postForm = document.createElement("form");
|
||||||
|
postForm.action = url;
|
||||||
|
postForm.method = "POST";
|
||||||
|
postForm.style.display = "none";
|
||||||
|
for (var key in postData){
|
||||||
|
if (postData.hasOwnProperty(key)){
|
||||||
|
var input = document.createElement("input");
|
||||||
|
input.type = "hidden";
|
||||||
|
input.name = key;
|
||||||
|
input.value = postData[key];
|
||||||
|
postForm.appendChild(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.body.appendChild(postForm);
|
||||||
|
postForm.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user