Commit 2c4b927e by Pablo Molina

Merge branch 'issue/381' into develop

parents 312d4986 e4f090d4
Showing with 483 additions and 597 deletions
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Temporal files # Temporal files
################ ################
\#.*\# \#.*\#
# BCrypt build #
################
sails/src/node_modules/bcrypt/build/
# Images # # Images #
########## ##########
sails/upload sails/upload
...@@ -24,9 +11,7 @@ sails/src/assets/upload ...@@ -24,9 +11,7 @@ sails/src/assets/upload
# Webapp # # Webapp #
########## ##########
sails/src/assets/app/js/lib/sails.io.js sails/src/logs
sails/src/assets/app/js/config.js
sails/src/assets/app/js/local.js
sails/src/assets/app/bower_components sails/src/assets/app/bower_components
sails/src/assets/app/modules sails/src/assets/app/modules
sails/src/assets/app/css sails/src/assets/app/css
...@@ -34,36 +19,17 @@ sails/src/assets/app/js ...@@ -34,36 +19,17 @@ sails/src/assets/app/js
# Other # # Other #
######### #########
sails/src/config/local.js
sails/src/config/ssl sails/src/config/ssl
sails/src/config/logs
sails/src/node_modules sails/src/node_modules
sails/src/.tmp
sails/.vagrant sails/.vagrant
sails/config/tmp.sql
android/Pictogram/.idea # Android #
###########
.idea .idea
android/Pictogram/.idea
android/Pictogram/app/app.iml android/Pictogram/app/app.iml
android/Pictogram/Pictogrammar.iml android/Pictogram/Pictogrammar.iml
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files # # OS generated files #
###################### ######################
.DS_Store .DS_Store
......
# Servidor de Pictogram e instalación del cliente web # Servidor de Pictogram e instalación del cliente web
En este directorio se encuentra el servidor web ([src](./src)) y la aplicación
web ([src/assets/app](./src/assets/app)). Los distintos ficheros de configuración
utilizados para la inicialización y el testeo de la aplicación se encuentran
en el directorio [conf](./conf).
## Dependencias
- Ubuntu >= 14.04
- Nodejs >= 0.10.37
- Npm >= 3.8.5
- Bower >= 1.4.1
- Sails 0.12.3
## Instalación del servidor y el cliente web ## Instalación del servidor y el cliente web
- Configurar el cliente ssh para poder conectarse a los servidores de Las distintas configuraciones aplicadas a la instalación pueden leerse en los `roles`
pre.yottacode.com (se intentará conectar como el usuario ec2-user). de [ansible][9] creados para ello, pero **no es necesario ejecutarlas a mano**, las opciones
- Ejecutar el script [install.sh](./install.sh) para instalar todas las mostradas más adelante hacen todo el trabajo.
dependencias del servidor y el cliente web.
- Acceder al directorio [conf](./conf) para la instalación de la base de datos. - [Instalación de NodeJS][4]
- [Instalación de MYSQL][5]
- [Importación de la base de datos][6]
- [Dependencias del cliente web][7]
- [Dependencias y ejecución del servidor][8]
### Opción A (producción): ejecución en la máquina local
1. Descargar upload.zip y symbolstx.zip desde el servidor de Yottacode:
```
scp ec2-user@pre.yottacode.com:~/upload.zip .
scp ec2-user@pre.yottacode.com:~/symbolstx.zip .
unzip upload.zip
unzip symbolstx.zip
rm upload.zip
rm symbolstx.zip
```
2. Ejecutar [./install.sh][3].
3. Ejecutar [./bootstrap.sh][19] para lanzar el servidor.
### Opción B (desarrollo): ejecución en una máquina virtual generada automáticamente
1. Descargar upload.zip y symbolstx.zip desde el servidor de Yottacode:
```
scp ec2-user@pre.yottacode.com:~/upload.zip .
scp ec2-user@pre.yottacode.com:~/symbolstx.zip .
unzip upload.zip
unzip symbolstx.zip
rm upload.zip
rm symbolstx.zip
```
2. Instalar [virtualbox][1] y [vagrant][2].
3. Ejecutar `vagrant up` desde este directorio.
> **Importante**: el script utilizado creará un entorno para el servidor desde > **Importante**: el script utilizado creará un entorno para el servidor desde
> cero, por lo que **pueden perderse los datos** almacenados por usuarios. > cero, por lo que **pueden perderse los datos** almacenados por usuarios.
## Desarrollo y pruebas ## Ejecución del servidor
Para ejecutar el servidor como desarrollo se debe acceder al directorio
[conf](./conf) e instalar los datos de la base de datos necesarios.
## Proceso de compilación
Una vez lanzado sails con el servidor comienza con la compilación de la aplicación web mediante Una vez lanzado sails con el servidor comienza con la compilación de la aplicación web mediante
tareas de Grunt, para esta configuración existe, por un lado, un fichero [Gruntfile.js][1] que tareas de Grunt, para esta configuración existe, por un lado, un fichero [Gruntfile.js][11] que
se encarga de cargar las tareas establecidas y ejecutar la especificada (`default` si no se se encarga de cargar las tareas establecidas y ejecutar la especificada (`default` si no se
especifica nada). Por otro lado están las tareas establecidas dentro del directorio [tasks][2], especifica nada). Por otro lado están las tareas establecidas dentro del directorio [tasks][12],
que a su vez se divide en [config][3] y [register][4]. La primera de ellas contiene parámetros que a su vez se divide en [config][13] y [register][14]. La primera de ellas contiene parámetros
de configuración, la segunda la propia ejecución de las tareas. de configuración, la segunda la propia ejecución de las tareas.
> Este proceso se realiza automáticamente, no es necesario realizar ningún paso adicional. Las **Este proceso se realiza automáticamente, sólo hay que lanzar el el servidor con uno de los
> tareas separadas son las siguientes: siguientes comandos**:
>
> - `sails lift`: tarea [default][5]
> - `sails lift --prod`: tarea [prod][6]
> - `sails www`: tarea [build][7]
> - `sails www --prod`: tarea [buildProd][8]
## Ejecución
Para lanzar el servidor hay que acceder al directorio [src](./src) y ejecutar
uno de esos comandos:
- `sails lift`: para un servidor corriente - `sails lift`: tarea [default][15]
- `sails console`: para un servidor con un intérprete de nodejs con las - `sails lift --prod`: tarea [prod][16]
variables de sails expuestas - `sails www`: tarea [build][17]
- `sails www --prod`: tarea [buildProd][18]
> Puede añadirse --prod para ejecutar el servidor en modo producción. > La opción `--prod` indica que sails se ejecutará en modo producción
> El servidor se ejecutará en [localhost:1337/app](http://localhost:1337/app). >
> El servidor se ejecutará en [localhost:1337/app](http://localhost:1337/app)
[1]: ./src/Gruntfile.js
[2]: ./src/tasks [1]: https://www.virtualbox.org/
[3]: ./src/tasks/config [2]: https://www.vagrantup.com/
[4]: ./src/tasks/register [3]: ./install.sh
[5]: ./src/tasks/register/default.js [4]: ./roles/nodejs
[6]: ./src/tasks/register/prod.js [5]: ./roles/mysql
[7]: ./src/tasks/register/build.js [6]: ./roles/database
[8]: ./src/tasks/register/buildProd.js [7]: ./roles/webapp
[8]: ./roles/server
[9]: https://www.ansible.com/
[10]: ./src
[11]: ./src/Gruntfile.js
[12]: ./src/tasks
[13]: ./src/tasks/config
[14]: ./src/tasks/register
[15]: ./src/tasks/register/default.js
[16]: ./src/tasks/register/prod.js
[17]: ./src/tasks/register/build.js
[18]: ./src/tasks/register/buildProd.js
[19]: ./bootstrap.sh
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# "ubuntu/trusty64" for ubuntu environment
# "puphpet/centos65-x64" for AWS similar environment
config.vm.box = "puphpet/centos65-x64"
config.vm.network "forwarded_port", guest: 1337, host: 1337
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
end
config.vm.provision "shell", path: "install.sh"
config.vm.provision "shell", path: "bootstrap.sh", run: "always"
end
#!/bin/bash
echo "-- Running pictogram server"
if [ -e "src/app.js" ]; then
cd src && forever start app.js
elif [ -e "/vagrant/src/app.js" ]; then
cd /vagrant/src && forever start app.js
elif [ -e "/home/vagrant/sync/src/app.js" ]; then
cd /home/vagrant/sync/src && forever start app.js
else
echo "-- app.js not found, cannot run pictogram server"
exit
fi
# Configuración de la base de datos
## Scripts
- [installdb.sh](./installdb.sh) elimina la base de datos existente y realiza
una instalación limpia para producción.
- [installdb-tests.sh](./installdb-test.sh) realiza el mismo proceso
que [installdb.sh](./installdb.sh) pero añadiendo los datos de tests.
- [installdb-autismojaen.sh](./installdb-autismojaen.sh) realiza el mismo
proceso que [installdb.sh](./installdb.sh), pero añadiendo los datos de
autismojaen.
> **Importante**: para no añadir la biblioteca de symbolstix de nuevo
> y conservarla en el caso de que ya esté en la base de datos se puede
> añadir la opción `--ignore-symbolstix` a todos los scripts (por ejemplo
> `installdb.sh --ignore-symbolstix` no importará estos datos).
## Orden de la importación
### Datos necesarios
- [init.sql](./pictodb-init.sql) inicializa el usuario y permisos de la base de
datos.
- _[init-ignoresymbolstix.sql](./sql/init-ignoresymbolstix.sql) realiza el mismo
proceso que [init.sql](./sql/init.sql), pero ignorando a symbolstix._
- [pictodb-schema.sql](./sql/pictodb-schema.sql) contiene el esquema de la base de
datos.
- _[symbolstix-categories.sql](./sql/symbolstix-categories.sql) añade las
categorías de symbolstix._
- _[symbolstix-metadata.sql](./sql/symbolstix-metadata.sql) añade los
metadatos de symbolstix._
- [pictodb-data.sql](./sql/pictodb-data.sql) contiene la información básica que
la aplicación necesita para funcionar.
- [triggers-enrolments-integrity-constraints.sql](./pictodb-triggers-enrolments-integrity-constraints.sql)
añade disparadores para el control de integridad de inscripciones.
- [triggers-sessions-integrity-constraints.sql](./pictodb-triggers-enrolments-integrity-constraints.sql)
añade disparadores para el control de integridad de sesiones.
### Añadido de datos de desarrollo y pruebas
- [test.sql](./sql/test-autismojaen.sql) contiene datos para el desarrollo y
pruebas de la aplicación.
- [test-autismojaen.sql](./sql/test-autismojaen.sql) añade los datos de
autismojaen.
## Notes
### Importación de datos
To import `pictodb-data.sql` into MySQL without foreign key constraints, ensure
that the imported file starts with `SET foreign_key_checks=0;` and then you turn
on it again with `SET foreign_key_checks=1;`
### Eliminando la base de datos completa
```sql
SET foreign_key_checks=0;
DROP TABLE `action`, `device`, `enrolment`, `instruction`, `license`,
`license_activation`, `meta_picto`, `meta_stu`, `method`, `office`,
`official_dev`, `picto`, `picto_acl`, `picto_core`, `picto_core_cat`,
`picto_exp`, `picto_tag`, `picto_tag_sup`, `source`, `student`, `stu_picto`,
`stu_sup`, `stu_sup_dev`, `supervisor`, `try`, `working_session`;
SET foreign_key_checks=1;
```
#!/bin/bash
ROOT_PASSWD=passwd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
execute_db ./sql/pictodb-data.sql
execute_db ./sql/test-autismojaen.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
#!/bin/bash
ROOT_PASSWD=passwdd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
execute_db ./sql/pictodb-data.sql
execute_db ./sql/test.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
#!/bin/bash
ROOT_PASSWD=passwd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
execute_db ./sql/pictodb-data.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
/// template file for sails/src/assets/app/js/config.js
'use strict';
/* Configuration constants */
angular.module('dashboardConfig', [])
.constant('config', {
'backend': 'https://sinai-fernando.ujaen.es:9944'
// 'backend': 'http://localhost:1337',
// 'backend': 'https://dev.yottacode.com',
// // 'backend': 'https://test.yottacode.com',
// // 'backend_ws': 'ws://localhost:1337',
// 'version': 0.1
});
//// template file for sails/src/config/local.js
/**
* Local environment settings
*
* Use this file to specify configuration settings for use while developing
* the app on your personal system: for example, this would be a good place
* to store database or email passwords that apply only to you, and shouldn't
* be shared with others in your organization.
*
* These settings take precedence over all other config files, including those
* in the env/ subfolder.
*
* PLEASE NOTE:
* local.js is included in your .gitignore, so if you're using git
* as a version control solution for your Sails app, keep in mind that
* this file won't be committed to your repository!
*
* Good news is, that means you can specify configuration for your local
* machine in this file without inadvertently committing personal information
* (like database passwords) to the repo. Plus, this prevents other members
* of your team from commiting their local configuration changes on top of yours.
*
* In a production environment, you probably want to leave this file out
* entirely and leave all your settings in env/production.js
*
*
* For more information, check out:
* http://sailsjs.org/#!/documentation/anatomy/myApp/config/local.js.html
*/
module.exports = {
/***************************************************************************
* Your SSL certificate and key, if you want to be able to serve HTTP *
* responses over https:// and/or use websockets over the wss:// protocol *
* (recommended for HTTP, strongly encouraged for WebSockets) *
* *
* In this example, we'll assume you created a folder in your project, *
* `config/ssl` and dumped your certificate/key files there: *
***************************************************************************/
ssl: {
ca: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.bundle.crt'),
key: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.key'),
cert: require('fs').readFileSync(__dirname + '/ssl/goddady/gd.yottacode.com.crt')
},
/***************************************************************************
* The `port` setting determines which TCP port your app will be *
* deployed on. *
* *
* Ports are a transport-layer concept designed to allow many different *
* networking applications run at the same time on a single computer. *
* More about ports: *
* http://en.wikipedia.org/wiki/Port_(computer_networking) *
* *
* By default, if it's set, Sails uses the `PORT` environment variable. *
* Otherwise it falls back to port 1337. *
* *
* In env/production.js, you'll probably want to change this setting *
* to 80 (http://) or 443 (https://) if you have an SSL certificate *
***************************************************************************/
port: process.env.PORT || 1337,
/***************************************************************************
* The runtime "environment" of your Sails app is either typically *
* 'development' or 'production'. *
* *
* In development, your Sails app will go out of its way to help you *
* (for instance you will receive more descriptive error and *
* debugging output) *
* *
* In production, Sails configures itself (and its dependencies) to *
* optimize performance. You should always put your app in production mode *
* before you deploy it to a server. This helps ensure that your Sails *
* app remains stable, performant, and scalable. *
* *
* By default, Sails sets its environment using the `NODE_ENV` environment *
* variable. If NODE_ENV is not set, Sails will run in the *
* 'development' environment. *
***************************************************************************/
// environment: process.env.NODE_ENV || 'development'
};
#!/bin/bash #!/bin/bash
# Nodejs install echo "-- Installing ansible"
sudo apt-get update if [ -e "/usr/bin/apt-get" ]; then
sudo apt-get install -y python-software-properties python g++ make echo "-- Installing using apt-get"
sudo add-apt-repository -y ppa:chris-lea/node.js sudo apt-get install -y software-properties-common
sudo apt-get update sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get install -y nodejs sudo apt-get update -y
sudo npm install -g npm sudo apt-get install -y ansible
elif [ -e "/usr/bin/yum" ]; then
# Sails install echo "-- Installing using yum"
sudo npm install -g sails@0.12.3 sudo yum -y install epel-release
sudo yum -y install ansible
# Sails log file else
mkdir -p ./src/logs echo "XX Cannot install ansible"
touch ./src/logs/my_log_file.log exit
fi
# Sails upload folder
mkdir -p ./upload echo "-- Running ansible playbook"
function runAnsiblePlaybook {
# Server dependencies installation echo "-- Running playbook from $(pwd)"
pushd ./src ansible-playbook playbook.yml --extra-vars="server_path=$(pwd)"
npm install }
popd if [ -e "playbook.yml" ]; then
runAnsiblePlaybook
# Copy sails.io.js elif [ -e "/vagrant/playbook.yml" ]; then
pushd /tmp cd /vagrant && runAnsiblePlaybook
rm -rf sailstempapp elif [ -e "/home/vagrant/sync/playbook.yml" ]; then
sails new sailstempapp cd /home/vagrant/sync && runAnsiblePlaybook
popd else
mkdir -p ./src/assets/app/js/lib/ echo "XX Playbook not found, provision not finished"
cp /tmp/sailstempapp/assets/js/dependencies/sails.io.js ./src/assets/app/js/lib/ exit
rm -rf /tmp/sailstempapp fi
# Link configuration file
ln ./conf/js/config.js ./src/assets/app/js/config.js
ln ./conf/js/local.js ./src/assets/app/js/local.js
# Download project assets
scp ec2-user@pre.yottacode.com:~/symbolstx.zip .
scp ec2-user@pre.yottacode.com:~/upload.zip .
unzip symbolstx
unzip upload
rm symbolstx.zip
rm upload.zip
# Client dependencies installation
sudo npm install -g bower
pushd ./src/assets/app
bower install
popd
---
- hosts: localhost
become: yes
connection: local
roles:
- webapp
- server
# Rol de configuración de la base de datos para pictogram
Elimina toda la información escrita en la base de datos para generar una nueva con los esquemas
necesarios. En el caso de establecer la variable `database_ignore_symbolstix` a `True`, los datos
de las bases de datos de symbolstx quedarán intactos y no serán reimportados.
Los ficheros SQL que importará este rol son los siguientes:
- [init][1] inicializa el usuario y permisos de la base de datos.
- [init-ignoresymbolstix][2] realiza el mismo proceso que [init][1], pero manteniendo
los datos almacenados por symbolstx.
- [pictodb-schema][3] contiene el esquema de la base de datos.
- [pictodb-data][4] contiene la información básica que la aplicación necesita para funcionar.
- [symbolstx-categories][5] añade las categorías de symbolstx.
- [symbolstix-metadata][6] añade traducciones para symbolstx.
- [triggers-enrolments-integrity-constraints][7] añade disparadores para el control de
integridad de inscripciones.
- [triggers-sessions-integrity-constraints][8] añade disparadores para el control de integridad
de sesiones.
- [test-caja][9] contiene datos para el test de CAJA.
- [test-autismojaen][10] añade los datos para el test de autismojaen.
[1]: ./files/init.sql
[2]: ./files/init-ignoresymbolstix.sql
[3]: ./files/pictodb-schema.sql
[4]: ./files/pictodb-data.sql
[5]: ./files/symbolstx-categories.sql
[6]: ./files/symbolstx-metadata.sql
[7]: ./files/triggers-enrolments-integrity-constraints.sql
[8]: ./files/triggers-sessions-integrity-constraints.sql
[9]: ./files/test-autismojaen.sql
[10]: ./files/test-caja.sql
...@@ -2,15 +2,25 @@ GRANT USAGE ON *.* TO 'pictodbuser'@'localhost'; ...@@ -2,15 +2,25 @@ GRANT USAGE ON *.* TO 'pictodbuser'@'localhost';
DROP USER 'pictodbuser'@'localhost'; DROP USER 'pictodbuser'@'localhost';
CREATE USER 'pictodbuser'@'localhost' identified by 'p1KT015'; CREATE USER 'pictodbuser'@'localhost' identified by 'p1KT015';
CREATE DATABASE symbolstixdb; DROP DATABASE IF EXISTS symbolstixdb;
CREATE DATABASE IF NOT EXISTS symbolstixdb;
CREATE DATABASE IF NOT EXISTS pictodb;
CREATE TABLE IF NOT EXISTS pictodb.picto (c CHAR(1));
CREATE TABLE IF NOT EXISTS pictodb.pictocat (c CHAR(1));
CREATE TABLE IF NOT EXISTS pictodb.catexp (c CHAR(1));
CREATE TABLE IF NOT EXISTS pictodb.picto_exp (c CHAR(1));
alter table pictodb.picto rename symbolstixdb.picto; alter table pictodb.picto rename symbolstixdb.picto;
alter table pictodb.pictocat rename symbolstixdb.pictocat; alter table pictodb.pictocat rename symbolstixdb.pictocat;
alter table pictodb.catexp rename symbolstixdb.catexp; alter table pictodb.catexp rename symbolstixdb.catexp;
alter table pictodb.picto_exp rename symbolstixdb.picto_exp; alter table pictodb.picto_exp rename symbolstixdb.picto_exp;
SET foreign_key_checks=0; SET foreign_key_checks=0;
DROP DATABASE pictodb; DROP DATABASE IF EXISTS pictodb;
CREATE DATABASE IF NOT EXISTS pictodb;
SET foreign_key_checks=1; SET foreign_key_checks=1;
CREATE DATABASE pictodb;
alter table symbolstixdb.picto rename pictodb.picto; alter table symbolstixdb.picto rename pictodb.picto;
alter table symbolstixdb.pictocat rename pictodb.pictocat; alter table symbolstixdb.pictocat rename pictodb.pictocat;
alter table symbolstixdb.catexp rename pictodb.catexp; alter table symbolstixdb.catexp rename pictodb.catexp;
...@@ -18,5 +28,4 @@ alter table symbolstixdb.picto_exp rename pictodb.picto_exp; ...@@ -18,5 +28,4 @@ alter table symbolstixdb.picto_exp rename pictodb.picto_exp;
grant all privileges on pictodb.* to pictodbuser; grant all privileges on pictodb.* to pictodbuser;
flush privileges; flush privileges;
DROP DATABASE IF EXISTS symbolstixdb;
DROP DATABASE symbolstixdb;
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00"; SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
...@@ -389,7 +388,7 @@ CREATE TABLE IF NOT EXISTS `stu_picto` ( ...@@ -389,7 +388,7 @@ CREATE TABLE IF NOT EXISTS `stu_picto` (
`attributes` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'JSON object describing the properties of the picto according to the properties defined in meta_picto', `attributes` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'JSON object describing the properties of the picto according to the properties defined in meta_picto',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `fk_picto` (`id_pic`), KEY `fk_picto` (`id_pic`),
KEY `id_stu` (`id_stu`), KEY `id_stu` (`id_stu`),
UNIQUE `uq_stupicto` (`id_stu`,`id_pic`) UNIQUE `uq_stupicto` (`id_stu`,`id_pic`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
...@@ -472,7 +471,7 @@ CREATE TABLE IF NOT EXISTS `try` ( ...@@ -472,7 +471,7 @@ CREATE TABLE IF NOT EXISTS `try` (
-- --
-- Estructura de tabla para la tabla `working_session` -- Estructura de tabla para la tabla `working_session`
-- --
-- NOTA: current es un atributo derivado que es necesario porque MySQL 5.1 -- NOTA: current es un atributo derivado que es necesario porque MySQL 5.1
-- no soporta correctamente indices con valor unico donde un campo es NULL -- no soporta correctamente indices con valor unico donde un campo es NULL
-- Trabaja en combinación al índice unico (id_sup,current) (idx_ws_supcur) -- Trabaja en combinación al índice unico (id_sup,current) (idx_ws_supcur)
-- --
...@@ -526,7 +525,7 @@ ALTER TABLE `meta_instruction` ...@@ -526,7 +525,7 @@ ALTER TABLE `meta_instruction`
-- --
ALTER TABLE `meta_method` ALTER TABLE `meta_method`
ADD CONSTRAINT `fk_met_sup` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`); ADD CONSTRAINT `fk_met_sup` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`);
-- --
-- Filtros para la tabla `office` -- Filtros para la tabla `office`
...@@ -630,29 +629,29 @@ ALTER TABLE `working_session` ...@@ -630,29 +629,29 @@ ALTER TABLE `working_session`
-- --
CREATE ALGORITHM=UNDEFINED CREATE ALGORITHM=UNDEFINED
VIEW `v_stu_last_ws_time` AS VIEW `v_stu_last_ws_time` AS
SELECT M.`id_stu`AS id_stu, SELECT M.`id_stu`AS id_stu,
MAX(WS.begin) AS time MAX(WS.begin) AS time
FROM FROM
`working_session` AS WS join `working_session` AS WS join
`instruction` AS I join `instruction` AS I join
`method` AS M `method` AS M
WHERE WHERE
WS.`id_ins` =I.`id` WS.`id_ins` =I.`id`
and I.`id_met` = M.`id` and I.`id_met` = M.`id`
group by M.`id_stu`; group by M.`id_stu`;
CREATE ALGORITHM=UNDEFINED CREATE ALGORITHM=UNDEFINED
VIEW `v_stu_last_instruction` AS VIEW `v_stu_last_instruction` AS
select select
WS.`id` AS `id_ws`, WS.`id` AS `id_ws`,
WS.`begin` AS `ws_begin`, WS.`begin` AS `ws_begin`,
WS.`end` AS `ws_end`, WS.`end` AS `ws_end`,
WS.`description` AS `ws_description`, WS.`description` AS `ws_description`,
I.`name` AS `ins_name`, I.`name` AS `ins_name`,
M.`name` AS `met_name`, M.`name` AS `met_name`,
M.`id_stu` AS `id_stu` M.`id_stu` AS `id_stu`
FROM FROM
`working_session` AS WS join `working_session` AS WS join
`instruction` AS I join `instruction` AS I join
...@@ -682,7 +681,6 @@ VIEW `v_stu_last_instruction` AS ...@@ -682,7 +681,6 @@ VIEW `v_stu_last_instruction` AS
-- KEY `id_ins` (`id_ins`) -- KEY `id_ins` (`id_ins`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; -- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
...@@ -11,16 +11,17 @@ FOR EACH ROW ...@@ -11,16 +11,17 @@ FOR EACH ROW
BEGIN BEGIN
DECLARE max_enr,curr_enr INT; DECLARE max_enr,curr_enr INT;
IF new.id_off IS NOT NULL THEN IF new.id_off IS NOT NULL THEN
SELECT SELECT
max_students, current_students INTO max_enr, curr_enr max_students, current_students INTO max_enr, curr_enr
FROM FROM
office office
WHERE WHERE
office.id=new.id_off; office.id=new.id_off;
IF curr_enr>=max_enr THEN IF curr_enr>=max_enr THEN
SIGNAL SQLSTATE '20001' -- Needed hack for mysql 5.1
SET MESSAGE_TEXT = 'Max number of enrolments reached'; -- http://stackoverflow.com/questions/10617136/why-is-signal-keyword-not-working-in-mysql-5-1-48
CALL raise_error_max_number_of_enrolments_reached;
END IF; END IF;
END IF; END IF;
END;; END;;
...@@ -31,41 +32,41 @@ AFTER INSERT ON student ...@@ -31,41 +32,41 @@ AFTER INSERT ON student
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
UPDATE UPDATE
office office
SET SET
current_students=current_students+1 current_students=current_students+1
WHERE WHERE
office.id=new.id_off; office.id=new.id_off;
END;; END;;
-- Integrity rule 3: office.current_enrolments and supervisor assigments updating. -- Integrity rule 3: office.current_enrolments and supervisor assigments updating.
CREATE TRIGGER TRG_MODIFY_STUDENT_ENROLMENTS CREATE TRIGGER TRG_MODIFY_STUDENT_ENROLMENTS
AFTER UPDATE ON student AFTER UPDATE ON student
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF NOT (old.id_off<=>new.id_off) THEN IF NOT (old.id_off<=>new.id_off) THEN
IF (old.id_off IS NOT NULL) THEN IF (old.id_off IS NOT NULL) THEN
UPDATE UPDATE
office office
SET SET
current_students=current_students-1 current_students=current_students-1
WHERE WHERE
office.id=old.id_off; office.id=old.id_off;
DELETE DELETE
stu_sup stu_sup
FROM FROM
stu_sup INNER JOIN supervisor ON (stu_sup.id_sup=supervisor.id) stu_sup INNER JOIN supervisor ON (stu_sup.id_sup=supervisor.id)
WHERE WHERE
id_stu=new.id AND old.id_off=supervisor.id_off; id_stu=new.id AND old.id_off=supervisor.id_off;
END IF; END IF;
IF (new.id_off IS NOT NULL) THEN IF (new.id_off IS NOT NULL) THEN
UPDATE UPDATE
office office
SET SET
current_students=current_students+1 current_students=current_students+1
WHERE WHERE
office.id=new.id_off; office.id=new.id_off;
END IF; END IF;
END IF; END IF;
END;; END;;
...@@ -74,14 +75,14 @@ END;; ...@@ -74,14 +75,14 @@ END;;
CREATE TRIGGER TRG_DELETE_STUDENT_ENROLMENTS CREATE TRIGGER TRG_DELETE_STUDENT_ENROLMENTS
AFTER DELETE ON student AFTER DELETE ON student
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
IF old.id_off IS NULL THEN IF old.id_off IS NULL THEN
UPDATE UPDATE
office office
SET SET
current_students=current_students-1 current_students=current_students-1
WHERE WHERE
office.id=old.id_off; office.id=old.id_off;
END IF; END IF;
END;; END;;
DELIMITER ; DELIMITER ;
\ No newline at end of file
---
dependencies:
- { role: mysql }
---
- name: Creates the database
mysql_db:
login_user: root
login_password: "{{ database_root_passwd }}"
name: all
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/init.sql"
when: database_ignore_symbolstix == False
- name: Creates the database without removing symbolstx
mysql_db:
login_user: root
login_password: "{{ database_root_passwd }}"
name: all
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/init-ignoresymbolstix.sql"
when: database_ignore_symbolstix == True
- name: Imports the schema and basic data
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/{{ item }}.sql"
with_items:
- pictodb-schema
- pictodb-data
- name: Imports selected tests
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/test-{{ item }}.sql"
with_items: "{{ database_tests }}"
- name: Imports symbolstx categories and metadata
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/symbolstx-{{ item }}.sql"
with_items:
- categories
- metadata
when: database_ignore_symbolstix == False
- name: Creates triggers
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/triggers-{{ item }}.sql"
with_items:
- enrolments-integrity-constraints
- sessions-integrity-constraints
---
database_files_relative_path: 'roles/database/files'
database_root_passwd: root
database_name: pictodb
database_user: pictodbuser
database_user_passwd: p1KT015
database_ignore_symbolstix: False
database_tests: [caja, autismojaen] # can be empty
# Rol de configuración de MYSQL
Este rol instala y arranca MYSQL, configurando una contraseña por defecto para el usuario root
---
- name: Set mysql root password
debconf:
name: mysql-server
question: "mysql-server/{{ item }}"
value: "{{ mysql_root_passwd | quote }}"
vtype: password
with_items:
- root_password
- root_password_again
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Update apt-get cache
apt:
update-cache: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install mysql packages
apt:
name: "{{ item }}"
state: present
with_items:
- mysql-server
- mysql-client
- python-mysqldb # required by ansible
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install mysql packages
yum:
name: "{{ item }}"
state: present
with_items:
- mysql-server
- MySQL-python # required by ansible
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Enable and start mysql service
service:
name: mysql
state: restarted
enabled: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Enable and start mysql service
service:
name: mysqld
state: restarted
enabled: yes
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Set mysql root password
shell: "/usr/bin/mysqladmin -u root password {{ mysql_root_passwd | quote }}"
ignore_errors: yes
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
---
mysql_root_passwd: root
# Rol de instalación de NodeJS
Instala NodeJS (versión 4 o 5) como dependencia global
---
- name: Install HTTPS transport
apt:
name: apt-transport-https
state: installed
update_cache: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Import the NodeSource key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
state: present
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Add NodeSource repositories
apt_repository:
repo: "{{ item }} https://deb.nodesource.com/node_{{ nodejs_major_version }}.x {{ ansible_distribution_release }} main"
state: present
with_items:
- deb
- deb-src
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Add Nodesource repositories
yum:
name: "https://rpm.nodesource.com/pub_{{ nodejs_major_version }}.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm"
state: present
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Update apt-get cache
apt:
update_cache: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install NodeJS
apt:
name: nodejs
state: present
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install NodeJS
yum:
name: nodejs
state: present
enablerepo: 'epel,nodesource'
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
---
nodejs_major_version: 4 # or 5
# Rol de configuración del servidor de pictogram
Instala las dependencias necesarias para el servidor y lo ejecuta utilizando forever.js
---
dependencies:
- { role: nodejs }
- { role: database }
---
- name: Install NPM dependencies
npm:
path: "{{ server_path }}/{{ server_relative_path }}"
- name: Create log directory
file:
path: "{{ server_path }}/{{ server_relative_path }}/logs"
state: directory
- name: Create log file
file:
path: "{{ server_path }}/{{ server_relative_path }}/logs/my_log_file.log"
state: touch
- name: Install sails globaly
npm:
name: sails
global: yes
state: present
version: 0.12.3
- name: Install forever
npm:
name: forever
state: present
global: yes
---
server_relative_path: 'src'
server_relative_webapp_path: 'src/assets/app'
# Rol de configuración del cliente web de pictogram
Instala todas las dependencias necesarias para que la aplicación web funcione
---
dependencies:
- { role: nodejs }
---
- name: Install git
package:
name: git
state: present
- name: Install bower
npm:
name: bower
state: present
global: yes
- name: Install bower dependencies
bower: path="{{ webapp_path }}"
---
webapp_path: '/vagrant/src/assets/app'
**/.tmp/**
**/views/**
\ No newline at end of file
//// template file for sails/src/config/local.js
/**
* Local environment settings
*
* Use this file to specify configuration settings for use while developing
* the app on your personal system: for example, this would be a good place
* to store database or email passwords that apply only to you, and shouldn't
* be shared with others in your organization.
*
* These settings take precedence over all other config files, including those
* in the env/ subfolder.
*
* PLEASE NOTE:
* local.js is included in your .gitignore, so if you're using git
* as a version control solution for your Sails app, keep in mind that
* this file won't be committed to your repository!
*
* Good news is, that means you can specify configuration for your local
* machine in this file without inadvertently committing personal information
* (like database passwords) to the repo. Plus, this prevents other members
* of your team from commiting their local configuration changes on top of yours.
*
* In a production environment, you probably want to leave this file out
* entirely and leave all your settings in env/production.js
*
*
* For more information, check out:
* http://sailsjs.org/#!/documentation/anatomy/myApp/config/local.js.html
*/
module.exports = {
/***************************************************************************
* Your SSL certificate and key, if you want to be able to serve HTTP *
* responses over https:// and/or use websockets over the wss:// protocol *
* (recommended for HTTP, strongly encouraged for WebSockets) *
* *
* In this example, we'll assume you created a folder in your project, *
* `config/ssl` and dumped your certificate/key files there: *
***************************************************************************/
ssl: {
ca: require('fs').readFileSync(__dirname + '/ssl/godaddy/gd.yottacode.com.bundle.crt'),
key: require('fs').readFileSync(__dirname + '/ssl/godaddy/gd.yottacode.com.key'),
cert: require('fs').readFileSync(__dirname + '/ssl/godaddy/gd.yottacode.com.crt')
},
/***************************************************************************
* The `port` setting determines which TCP port your app will be *
* deployed on. *
* *
* Ports are a transport-layer concept designed to allow many different *
* networking applications run at the same time on a single computer. *
* More about ports: *
* http://en.wikipedia.org/wiki/Port_(computer_networking) *
* *
* By default, if it's set, Sails uses the `PORT` environment variable. *
* Otherwise it falls back to port 1337. *
* *
* In env/production.js, you'll probably want to change this setting *
* to 80 (http://) or 443 (https://) if you have an SSL certificate *
***************************************************************************/
port: process.env.PORT || 1337,
/***************************************************************************
* The runtime "environment" of your Sails app is either typically *
* 'development' or 'production'. *
* *
* In development, your Sails app will go out of its way to help you *
* (for instance you will receive more descriptive error and *
* debugging output) *
* *
* In production, Sails configures itself (and its dependencies) to *
* optimize performance. You should always put your app in production mode *
* before you deploy it to a server. This helps ensure that your Sails *
* app remains stable, performant, and scalable. *
* *
* By default, Sails sets its environment using the `NODE_ENV` environment *
* variable. If NODE_ENV is not set, Sails will run in the *
* 'development' environment. *
***************************************************************************/
// environment: process.env.NODE_ENV || 'development'
};
...@@ -9,6 +9,13 @@ ...@@ -9,6 +9,13 @@
"connect-redis": "3.0.2", "connect-redis": "3.0.2",
"ejs": "^0.8.8", "ejs": "^0.8.8",
"forever": "^0.14.1", "forever": "^0.14.1",
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^1.0.1",
"grunt-contrib-less": "^1.3.0",
"grunt-contrib-uglify": "^1.0.1",
"include-all": "~0.1.3", "include-all": "~0.1.3",
"jsonwebtoken": "~0.4.0", "jsonwebtoken": "~0.4.0",
"lodash": "^3.10.1", "lodash": "^3.10.1",
...@@ -37,8 +44,6 @@ ...@@ -37,8 +44,6 @@
"devDependencies": { "devDependencies": {
"eslint": "^2.8.0", "eslint": "^2.8.0",
"eslint-config-airbnb": "^7.0.0", "eslint-config-airbnb": "^7.0.0",
"eslint-plugin-jsx-a11y": "^1.0.1",
"eslint-plugin-react": "^5.0.1",
"node-inspector": "^0.12.8" "node-inspector": "^0.12.8"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment