Interaction between login and panel #17

Merged
PootisPenserHere merged 4 commits from interactionBetweenLoginAndPanel into master 2018-08-12 16:08:55 +00:00
8 changed files with 84 additions and 38 deletions

View File

@ -1,23 +1,12 @@
body { body {
background-color: #e3e3e3; background-color: #e3e3e3;
/* Se agrego color blanco a letra en panel en general*/
color: #000; color: #000;
} }
/*Cambia el color del date picker a negro para permitir su visibilidad*/
.datepicker{ .datepicker{
color: black; color: black;
} }
/*El color con el que se muestra el peso del archivo en la carga masiva se imagenes*/
.size{
color: black;
}
.calendar{
background: #fff;
}
#cuerpo{ #cuerpo{
top:17%; top:17%;
left:1%; left:1%;
@ -78,7 +67,6 @@ body {
} }
/* botoner<65>a panel principal */
.metro{ .metro{
width:auto; width:auto;
height:auto; height:auto;
@ -199,7 +187,7 @@ body {
} }
} }
/* FORMATO PARA TEXTO CUSTOM */
.formato_texto_custom{ .formato_texto_custom{
width: 97%; width: 97%;
float: left; float: left;

View File

@ -18,7 +18,7 @@ body {
padding: 20px; padding: 20px;
background: #fff; background: #fff;
border-radius: 5px; border-radius: 5px;
border-top: 5px solid #bdb035; border-top: 5px solid #5bc0de;
margin: 0 auto; margin: 0 auto;
} }
.login-block h1 { .login-block h1 {
@ -58,15 +58,15 @@ body {
background-size: 16px 80px; background-size: 16px 80px;
} }
.login-block input:active, .login-block input:focus { .login-block input:active, .login-block input:focus {
border: 1px solid #bdb035; border: 1px solid #5bc0de;
} }
.login-block #loginButon { .login-block #loginButon {
width: 100%; width: 100%;
height: 40px; height: 40px;
background: #bdb035; background: #009bad;
box-sizing: border-box; box-sizing: border-box;
border-radius: 5px; border-radius: 5px;
border: 1px solid #6d661c; border: 1px solid #000;
color: #fff; color: #fff;
font-weight: bold; font-weight: bold;
text-transform: uppercase; text-transform: uppercase;
@ -75,7 +75,7 @@ body {
outline: none; outline: none;
cursor: pointer; cursor: pointer;
} }
.login-block button:hover {
background: #c7b935; #modalLoginErrorHeader{
border: 1px solid #6d661c; background-color: #d9534f;
} }

View File

@ -1,3 +1,12 @@
<?php
session_start();
if(!isset($_SESSION['userName'])){
header("Location: ./login.php");
exit();
}
?>
<!-- Latest compiled and minified CSS --> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/bootstrap.min.css">
@ -38,7 +47,7 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li> <li>
<a href="../logout.php"><span class="fa fa-fw fa-power-off"></span> Cerrar Sesión</a> <a href="#" onclick="logout();"><span class="fa fa-fw fa-power-off"></span> Cerrar Sesión</a>
</li> </li>
</ul> </ul>
@ -229,4 +238,6 @@
</div> </div>
</body> </body>
<link href="../css/panel.css" rel="stylesheet"> <script src="../js/getBaseUrl.js"></script>
<script src="../js/landing.js"></script>
<link href="../css/landing.css" rel="stylesheet">

View File

@ -1,3 +1,12 @@
<?php
session_start();
if(isset($_SESSION['userName'])){
header("Location: ./landing.php");
exit();
}
?>
<!-- Latest compiled and minified CSS --> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/bootstrap.min.css">
@ -41,4 +50,5 @@
</div> </div>
<script src="../js/login.js"></script> <script src="../js/login.js"></script>
<script src="../js/getBaseUrl.js"></script>
<link href="../css/login.css" rel="stylesheet"> <link href="../css/login.css" rel="stylesheet">

View File

@ -0,0 +1,10 @@
/**
* Returns the entry point url for the system, this url will be used
* to access both the api and the static resources
*
* @returns {string}
*/
function getbaseUrl(){
var url = window.location.href;
return url.substring(0, url.indexOf('/html/'));
}

View File

@ -0,0 +1,18 @@
function logout() {
var baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/api/session/logout',
type: 'GET',
dataType: 'json',
success:function(data){
window.location.replace(baseUrl + '/html/login.php');
},
error:function(x) {
if (x.status==500){
$('#modalLoginError').modal('show');
document.getElementById('modalLoginErrorBody').innerHTML = "The user or password didnt match, please try again";
}
},
});
}

View File

@ -1,25 +1,38 @@
function getbaseUrl(uriPath){ /**
var url = window.location.href; * Maps the enter key to the login action
return url.substring(0, url.indexOf(uriPath)); */
} $(document).keypress(function(e) {
if(e.which == 13) {
processLogin();
}
});
/**
* Takes the input from the username and password fields and send theem to the backend
* to be validated
*
* The response from the api will contain a status that will determine if the login was
* successful or not and a message that will contain feedback which can be used to
* display errors to the user
*/
function processLogin() { function processLogin() {
var baseUrl = getbaseUrl('/html/'); var baseUrl = getbaseUrl();
var parametros = { var parameters = {
"userName":$('#userName').val(), "userName":$('#userName').val(),
"password":$('#password').val() "password":$('#password').val()
}; };
$.ajax({ $.ajax({
url: baseUrl + '/index.php/api/session/login', url: baseUrl + '/api/session/login',
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: parametros, data: parameters,
success:function(data){ success:function(data){
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
if(data["status"] == "success"){ if(data["status"] == "success"){
redirect(baseUrl + '/html/landing.php'); window.location.replace(baseUrl + '/html/landing.php');
}else if(data["status"] == "success" || (data["status"] === undefined)){ }else if(data["status"] == "success" || (data["status"] === undefined)){
$('#modalLoginError').modal('show'); $('#modalLoginError').modal('show');
document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page."; document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page.";
@ -32,8 +45,4 @@ function processLogin() {
} }
}, },
}); });
}
function redirect(url){
window.location.replace(url);
} }

View File

@ -117,12 +117,12 @@ class SessionApplication{
} }
/** /**
* @return string * @return array
*/ */
function destroySession(){ function destroySession(){
session_destroy(); session_destroy();
return "Sucessfully logged out."; return array('status' => 'success', 'message' => 'Successfully logged out.');
} }
} }
?> ?>