Compare commits

..

19 Commits

Author SHA1 Message Date
b829f09330 [fix] Reference to view body 2018-08-12 11:36:17 -06:00
b03d152f11 [add] Loading views 2018-08-12 11:32:48 -06:00
0ec20a4c67 [add] Logout uses generic error messages
Refactored some messages from the generic modals
2018-08-12 10:39:44 -06:00
1605b1cea3 Merge pull request #17 from PootisPenserHere/interactionBetweenLoginAndPanel
Interaction between login and panel
2018-08-12 10:08:54 -06:00
d4fadf08bc [add] Logout
Also made general fixes to the css
2018-08-12 10:03:25 -06:00
de84da4482 [add] Mapping enter key 2018-08-12 09:13:00 -06:00
697d0fe769 [mod] getBaseUrl moved to its own file 2018-08-12 09:07:48 -06:00
cb5d30b4e0 [add] Verifying session 2018-08-12 08:51:22 -06:00
6c91cad46c Merge pull request #16 from PootisPenserHere/qualityChangesToDocker
Quality changes to docker
2018-08-11 20:07:07 -06:00
ccd9e10351 Merge pull request #15 from PootisPenserHere/landingPage
Landing page
2018-08-11 20:06:13 -06:00
231e7fe2e6 [add] Access config 2018-08-12 01:43:37 +00:00
f820a22a4f [add] Volumes directory 2018-08-12 01:25:11 +00:00
0cdfd21fa2 [mod] Config files moved to a directory 2018-08-12 01:06:40 +00:00
fee3db486f [add] Composer decoupled from prod build 2018-08-12 00:58:12 +00:00
87181696e1 [add] Looks of the dockerfile 2018-08-12 00:49:03 +00:00
8b22c0db9c [add] Composer compileed in multi stagre 2018-08-12 00:38:39 +00:00
18ee0ad333 [add] Downloading composer dependencies 2018-08-10 06:53:13 +00:00
4928481f72 [add] Empty log file with permisions 2018-08-10 03:51:17 +00:00
Jose Pablo Domingo Aramburo Sanchez
2d11218076 [fix] php volume 2018-08-09 13:42:13 -06:00
18 changed files with 258 additions and 112 deletions

View File

@@ -1 +1,2 @@
Options -Indexes Options -Indexes
Deny from all

View File

@@ -1,10 +1,29 @@
# Stage 1 - the build process
FROM composer:1.7.1 as build-deps
ENV COMPOSER_ALLOW_SUPERUSER 1
WORKDIR /root
COPY . .
RUN composer install
RUN composer test
# Stage 2 - the production environment
FROM ubuntu:16.04 FROM ubuntu:16.04
# Updating
RUN apt-get -y update && apt-get -y upgrade RUN apt-get -y update && apt-get -y upgrade
# Installing php, apache and supplementary software RUN apt-get -y install apache2 \
RUN apt-get -y install apache2 php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip curl git unzip composer php7.0 \
libapache2-mod-php7.0 \
php7.0-cli \
php7.0-common \
php7.0-mbstring \
php7.0-gd \
php7.0-intl \
php7.0-xml \
php7.0-mysql \
php7.0-mcrypt
# Enable apache mods # Enable apache mods
RUN a2enmod php7.0 RUN a2enmod php7.0
@@ -20,24 +39,14 @@ ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2
# Expose apache
EXPOSE 80
# Copy this repo into place.
ADD . /var/www/site
WORKDIR /var/www/site WORKDIR /var/www/site
COPY --from=build-deps /root .
# Testing permisions RUN touch logs/app.log
RUN chmod 777 -R . RUN chmod 777 logs/app.log
# Installing dependencies # Update the default apache site
RUN composer install ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# Unit tests # By default start up apache in the foreground
RUN composer test
# Update the default apache site with the config we created.
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# By default start up apache in the foreground, override with /bin/bash for interative
CMD /usr/sbin/apache2ctl -D FOREGROUND CMD /usr/sbin/apache2ctl -D FOREGROUND

0
api-payroll/logs/app.log Executable file
View File

View File

@@ -1,3 +1,5 @@
allow from all
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine On RewriteEngine On

View File

@@ -1,24 +1,13 @@
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*/ #newViewBody{
.size{
color: black;
}
.calendar{
background: #fff;
}
#cuerpo{
top:17%; top:17%;
left:1%; left:1%;
width:98%; width:98%;
@@ -34,34 +23,34 @@ body {
} }
#cuerpo .modal-body{ #newViewBody .modal-body{
color: #000; color: #000;
border:none; border:none;
} }
#cuerpo .panel-default{ #newViewBody .panel-default{
border: 3px solid #4A89A5; border: 3px solid #4A89A5;
border-radius: 5px; border-radius: 5px;
} }
#cuerpo .panel > .panel-heading { #newViewBody .panel > .panel-heading {
background-image: none; background-image: none;
background-color: #4A89A5; background-color: #4A89A5;
color: white; color: white;
border-radius: 0; border-radius: 0;
} }
#cuerpo .btn-default{ #newViewBody .btn-default{
border: 2px solid #62655F; border: 2px solid #62655F;
background: #F9DFAF; background: #F9DFAF;
} }
#cuerpo .btn-default:hover{ #newViewBody .btn-default:hover{
border: 2px solid #62655F; border: 2px solid #62655F;
background: #F9DFAF; background: #F9DFAF;
} }
#cuerpo .alert-success{ #newViewBody .alert-success{
background: #C6E97C; background: #C6E97C;
} }
@@ -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

@@ -0,0 +1,38 @@
<script src="../js/NewEmployee.js"></script>
<form class="form-horizontal" id="newEmployeeForm">
<div class="col-md-12">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">New employee</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeFirstName">First name</label>
<div class="col-md-5">
<input id="newEmployeeFirstName" name="newEmployeeFirstName" type="text" class="form-control input-md">
</div>
</div>
</div>
<div class="row">
<div class="form-group">
<label class="col-md-4 control-label" for="newEmployeeMiddleName">Middle name</label>
<div class="col-md-5">
<input id="newEmployeeMiddleName" name="newEmployeeMiddleName" type="number" class="form-control input-md">
</div>
</div>
</div>
<div class="col-md-12">
<div class="row">
<div class="form-group">
<a href="#" class="btn btn-lg btn-success" onclick="saveNewEmployee();">Save</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>

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">
@@ -17,28 +26,28 @@
</button> </button>
</div> </div>
<div class="collapse navbar-collapse navbar-menubuilder"> <div class="collapse navbar-collapse navbar-menubuilder">
<ul class="nav navbar-nav navbar-left"> <ul class="nav navbar-nav navbar-left" id="nevatation-options">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> Employees<span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> Employees<span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#" data-nav_accion="views/cliente.php" onclick="vista_crear_nuevo_salon_evento();"> New employee</a></li> <li><a href="#" data-nav_accion="NewEmployee.php"> New employee</a></li>
<li><a href="#" data-nav_accion="views/clientess.php" onclick="vista_crear_nuevo_coach();"> Modify employee</a></li> <li><a href="#" data-nav_accion="EditEmployee.php"> Modify employee</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-tasks"></span> Management</a> <a href="#" onclick="loadView();"><span class="glyphicon glyphicon-tasks"></span> Management</a>
</li> </li>
<li> <li>
<a href="#" onclick="vista_calendario();"><span class="glyphicon glyphicon-wrench"></span> Change password</a> <a href="#" onclick="loadView();"><span class="glyphicon glyphicon-wrench"></span> Change password</a>
</li> </li>
</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> logout</a>
</li> </li>
</ul> </ul>
@@ -46,26 +55,25 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12" id="cuerpo"></div>
<div class="col-md-12" id="newViewBody"></div>
<!-- <!--
================================================================================= =================================================================================
Errores en query de AJAX Modals for errors encountered by ajax
================================================================================= =================================================================================
--> -->
<!-- Fallo en la conexion de internet -->
<div id="modal_error_internet" class="modal fade" role="dialog"> <div id="modal_error_internet" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Por favor revise su conexión a internet.</p> <p>Please verify your internet connection and try again.</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -75,18 +83,16 @@
</div> </div>
</div> </div>
<!-- El recurso solicitado no existe -->
<div id="modal_error_404" class="modal fade" role="dialog"> <div id="modal_error_404" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>El URL del formulario no pudo ser encontrado en el servidor.</p> <p>Unable to find the requested url in the sever.</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -96,18 +102,16 @@
</div> </div>
</div> </div>
<!-- Error interno del servidor donde no es posible detectar la causa especifica -->
<div id="modal_error_500" class="modal fade" role="dialog"> <div id="modal_error_500" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Error interno del servidor.</p> <p>The server has encountered an internal error, please try again later.</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -117,18 +121,16 @@
</div> </div>
</div> </div>
<!-- El servidor respone con un string que no esta en formato JSON o contiene caracteres adicionales al JSON -->
<div id="modal_error_parsererror" class="modal fade" role="dialog"> <div id="modal_error_parsererror" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Fallo al procesar el JSON enviado por el servidor.</p> <p>The response from the sever wasn't a proper JSON format</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -138,18 +140,16 @@
</div> </div>
</div> </div>
<!-- El servidortardo demasiado en responder -->
<div id="modal_error_timeout" class="modal fade" role="dialog"> <div id="modal_error_timeout" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>La petición excedió el limite de tiempo.</p> <p>The request timeout, please try again or verify your connection.</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -159,18 +159,16 @@
</div> </div>
</div> </div>
<!-- Si el request AJAX falla por alguna razon no listada -->
<div id="modal_error_otro" class="modal fade" role="dialog"> <div id="modal_error_otro" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_error"> <div class="modal-header" id="modal_header_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Ha ocurrido un error desconocido.</p> <p>An unknown error occurred.</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -182,22 +180,20 @@
<!-- <!--
================================================================================= =================================================================================
Respuesta del servidor Generic response modals
================================================================================= =================================================================================
--> -->
<!-- Si el request AJAX falla por alguna razon no listada --> <div id="modal_server_response_error" class="modal fade" role="dialog">
<div id="modal_respuesa_servidor_error" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_respuesa_servidor_error"> <div class="modal-header" id="modal_header_server_response_error">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4> <h4 class="modal-title">An error has occurred</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p id="respuesa_servidor_error"></p> <p id="server_response_error"></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -207,18 +203,16 @@
</div> </div>
</div> </div>
<!-- Si el request AJAX recibe un success en la variable pasasa por el servidor --> <div id="modal_server_response_success" class="modal fade" role="dialog">
<div id="modal_respuesa_servidor_success" class="modal fade" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content"> <div class="modal-content">
<div class="modal-header" id="modal_header_respuesa_servidor_success"> <div class="modal-header" id="modal_header_server_response_success">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><center>El almacenado ha sido exitoso</center></h4> <h4 class="modal-title">Success</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p id="respuesa_servidor_success"></p> <p id="server_response_success"></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
@@ -229,4 +223,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,3 @@
function saveNewEmployee(){
console.log('saving...');
}

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,77 @@
/**
* Destorys the session for the current user and redirects
* back to the login form
*/
function logout() {
let 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,e) {
if (x.status==0) {
$('#modal_error_internet').modal('show');
} else if(x.status==404) {
$('#modal_error_404').modal('show');
} else if(x.status==500) {
$('#modal_error_500').modal('show');
} else if(e=='parsererror') {
$('#modal_error_parsererror').modal('show');
} else if(e=='timeout'){
$('#modal_error_timeout').modal('show');
} else {
$('#modal_error_otro').modal('show');
}
},
});
}
/**
* Entry point for loading elements from the navatation var, this functuion
* will filter the junk clicks that have landed in a dropdown menu and pass
* only the ones containing an action to the actual view loader
*/
$('#nevatation-options li a').click(function(){
let view = $(this).data('nav_accion');
if (view != "#" && view != undefined) {
loadView(view);
}
});
/**
* Will fetch the html of the desired view and load it into the landing page
*
* @param requestedView string
*/
function loadView(requestedView){
let baseUrl = getbaseUrl();
$.ajax({
url: baseUrl + '/html/' + requestedView,
type: 'get',
success:function(data){
$("#newViewBody").hide().html(data).show('slow');
},
error:function(x,e) {
if (x.status==0) {
$('#modal_error_internet').modal('show');
} else if(x.status==404) {
$('#modal_error_404').modal('show');
} else if(x.status==500) {
$('#modal_error_500').modal('show');
} else if(e=='parsererror') {
$('#modal_error_parsererror').modal('show');
} else if(e=='timeout'){
$('#modal_error_timeout').modal('show');
} else {
$('#modal_error_otro').modal('show');
}
},
});
}

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.";
@@ -33,7 +46,3 @@ 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.');
} }
} }
?> ?>

View File

@@ -6,7 +6,7 @@ services:
ports: ports:
- "8085:80" - "8085:80"
volumes: volumes:
- api-payroll:/var/www/site - ./volumes/apache-logs:/var/log/apache2
depends_on: depends_on:
- mysql - mysql
mysql: mysql:
@@ -18,11 +18,11 @@ services:
ports: ports:
- "3307:3307" - "3307:3307"
volumes: volumes:
- my-datavolume:/var/lib/mysql - ./volumes/mysql-data:/var/lib/mysql
environment: environment:
MYSQL_ROOT_PASSWORD: '12345678' MYSQL_ROOT_PASSWORD: '12345678'
MYSQL_USER: 'sloth' MYSQL_USER: 'sloth'
MYSQL_PASS: '12345678' MYSQL_PASS: '12345678'
volumes: volumes:
api-payroll: mysql-data:
my-datavolume: apache-logs:

2
volumes/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
mysql-data/
apache-logs/

1
volumes/README.md Normal file
View File

@@ -0,0 +1 @@
# Do not delete this directory, it'll contain the volumes created by the containers