2018-06-17 16:26:01 +00:00
|
|
|
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
|
|
|
|
|
pageEncoding="ISO-8859-1"%>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<%@ page import="model.*"%>
|
2018-06-17 16:26:01 +00:00
|
|
|
|
<%@ page import="java.util.List"%>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<% User user = (User) request.getAttribute("User"); %>
|
2018-06-17 16:26:01 +00:00
|
|
|
|
<%
|
|
|
|
|
List<Role> roles = (List<Role>)request.getAttribute("roles");
|
|
|
|
|
List<Resource> resourses = (List<Resource>)request.getAttribute("resources");
|
|
|
|
|
%>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
2018-06-07 21:50:55 +00:00
|
|
|
|
<head>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<title>A<>adir un Acceso - Hotel Services</title>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<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"/>
|
|
|
|
|
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<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">
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
|
|
|
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
|
|
|
|
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<script src="../../js/GlobalJs.js" async defer></script>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
2018-06-07 21:50:55 +00:00
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<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>
|
|
|
|
|
Empleados
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<div class="right valign-wrapper" style="padding: 0 0 0 10px; cursor: pointer; min-width: 180px;" onclick="changeUserOptions()">
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
2018-07-15 22:16:35 +00:00
|
|
|
|
<span id="nombreUsuario" style="min-width: 80px;">
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<%= user.getName()%>
|
|
|
|
|
</span>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<img src="<%=user.getImgUrl()%>" alt="" class="circle responsive-img" style="padding: 5px" width="50px">
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<i class="material-icons">arrow_drop_down</i>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<div id="userOptions" style="background-color: white; border:solid 2px #67c9b3; position: absolute;
|
|
|
|
|
width: auto; display: none;">
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<ul style="color: black">
|
|
|
|
|
|
|
|
|
|
<li style="padding: 0 5px;">
|
2018-07-15 20:28:04 +00:00
|
|
|
|
<a style="color: black" onclick="postRedirect('../users/view',{action:'closeSession'})">Cerrar Sesi<73>n</a>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li id="cerrar" style="padding: 0 5px; cursor: pointer">
|
|
|
|
|
<i class="small material-icons">arrow_drop_up</i>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
|
|
|
|
<li style="max-height: 62px">
|
2018-07-14 22:38:27 +00:00
|
|
|
|
<a href="https://github.com/Grupo-PW2/Web-Hostal" target="_blank" style="max-height: 62px">
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<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>
|
2018-07-15 20:28:04 +00:00
|
|
|
|
<li><a class="whiteLink" href="../">Inicio</a></li>
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<li class="active"><a class="whiteLink active" href="../roles">Administraci<63>n de Usuarios</a></li>
|
|
|
|
|
<li><a class="whiteLink" href="../services">Administraci<63>n de recursos</a></li>
|
|
|
|
|
<li><a class="whiteLink" href="../reports">Reportes de Ingresos</a></li>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<li>|</li>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
</ul>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<!--<div class="dropdown hide-on-large-only" style="padding: 0 10px; font-weight: bold" onclick="toggleDropdown()">Show Services</div>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<div id="dropdownContent">
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<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>-->
|
2018-06-25 00:38:59 +00:00
|
|
|
|
|
2018-06-21 16:39:35 +00:00
|
|
|
|
</div>
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<div class="nav-content" style="background-color: #3949a3">
|
|
|
|
|
<ul class="tabs tabs-transparent">
|
|
|
|
|
<li class="tab"><a href="../roles">Roles</a></li>
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<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>
|
2018-07-14 15:29:59 +00:00
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<div class="container">
|
|
|
|
|
<br />
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<span style="font-size: xx-large; font-family: 'Product Sans',Roboto,serif">A<>adir un Acceso</span>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<br />
|
|
|
|
|
<br />
|
|
|
|
|
|
2018-06-25 00:38:59 +00:00
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<div style="float: left; display: inline;">
|
2018-07-14 15:29:59 +00:00
|
|
|
|
<i class="material-icons large" style=" color: #3f51b5">info_outline</i>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
</div>
|
2018-06-25 02:16:54 +00:00
|
|
|
|
<div style="font-size: x-large; clear: right; min-height: 87px;">
|
2018-07-15 16:34:28 +00:00
|
|
|
|
El "admin" tiene acceso total.
|
2018-06-25 00:38:59 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<br />
|
|
|
|
|
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<script>
|
|
|
|
|
var buttonDisabled = false;
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<form id="mainForm" name="post" method="post" action="add" onsubmit="return safeSend()">
|
|
|
|
|
|
|
|
|
|
<input type="hidden" name="info" value="agregar"/>
|
|
|
|
|
|
2018-07-15 16:34:28 +00:00
|
|
|
|
Rol:
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<% if(roles.size() > 0) {%>
|
|
|
|
|
<select id="formRole" name="rolesl" class="browser-default" required oninput="accessExists()">
|
|
|
|
|
<option value="!" disabled selected>Choose a Role</option>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
<% for (Role r: roles) { %>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<option value="<%= r.getKey() %>"><%= r.getName() %></option>
|
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
<% } else {%>
|
|
|
|
|
<br />
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<span style="color: darkorange; font-size: x-large">No hay Roles registrados.</span>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<script>buttonDisabled = true</script>
|
|
|
|
|
<% } %>
|
|
|
|
|
<br />
|
|
|
|
|
|
2018-07-15 16:34:28 +00:00
|
|
|
|
Recurso:
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
<% if (resourses.size() > 0) { %>
|
|
|
|
|
<select id="formResource" name="resourcesl" class="browser-default" required oninput="accessExists()">
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<option value="!" disabled selected>Escoja un Recurso.</option>
|
2018-06-25 00:38:59 +00:00
|
|
|
|
|
|
|
|
|
<% for (Resource res: resourses) { %>
|
|
|
|
|
<option value="<%= res.getKey() %>"><%= res.getUrl() %></option>
|
|
|
|
|
<% } %>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
<% } else { %>
|
|
|
|
|
<br />
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<span style="color: darkorange; font-size: x-large">No hay Recursos disponibles.</span>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<script>buttonDisabled = true</script>
|
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
|
|
<br />
|
2018-07-15 22:16:35 +00:00
|
|
|
|
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 />
|
|
|
|
|
|
|
|
|
|
<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>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<button id="sendButton" class="btn waves-effect waves-light indigo darken-1" type="submit" name="action">Crear
|
2018-06-21 16:39:35 +00:00
|
|
|
|
<i class="material-icons right">send</i>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
<br />
|
2018-07-15 16:34:28 +00:00
|
|
|
|
<a href="../access" class="waves-effect waves-light btn whiteLink indigo darken-1"><i class="material-icons left">arrow_back</i>Volver</a>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
var sourceImg = document.getElementById("sourceImg");
|
|
|
|
|
function cambiarImg(input) {
|
|
|
|
|
sourceImg.src = input.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (buttonDisabled)
|
|
|
|
|
document.getElementById("sendButton").disabled = "disabled";
|
|
|
|
|
|
|
|
|
|
var safeToSend = false;
|
|
|
|
|
|
|
|
|
|
function accessExists() {
|
|
|
|
|
|
2018-06-25 00:38:59 +00:00
|
|
|
|
var roleKey = document.forms["mainForm"]["formRole"].value;
|
2018-06-21 16:39:35 +00:00
|
|
|
|
var resource = document.forms["mainForm"]["formResource"].value;
|
|
|
|
|
|
|
|
|
|
var req = new XMLHttpRequest();
|
|
|
|
|
|
|
|
|
|
req.onreadystatechange = function () {
|
|
|
|
|
|
|
|
|
|
if (req.readyState === 4 && req.status === 200){
|
|
|
|
|
if (req.responseText === "true") {
|
|
|
|
|
safeToSend = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
safeToSend = true;
|
|
|
|
|
console.log("isSafe? -> " + safeToSend);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-25 00:38:59 +00:00
|
|
|
|
req.open("get", "/access/add?info=check&rolesl=" + roleKey + "&resourcesl=" + resource);
|
2018-06-21 16:39:35 +00:00
|
|
|
|
req.send();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function safeSend() {
|
|
|
|
|
if (!safeToSend){
|
|
|
|
|
alert("This Access already exists");
|
|
|
|
|
return false;
|
|
|
|
|
} else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
2018-06-07 21:50:55 +00:00
|
|
|
|
</body>
|
2018-06-21 16:39:35 +00:00
|
|
|
|
|
2018-06-17 16:26:01 +00:00
|
|
|
|
</html>
|