Skip to content

Commit

Permalink
Comenta todo el código hasta desarrollo del hito 3
Browse files Browse the repository at this point in the history
  • Loading branch information
germaaan committed Dec 1, 2015
1 parent 4e6c342 commit aca0e9c
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 3 deletions.
25 changes: 24 additions & 1 deletion database/client.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
/*
Gesco-DatabaseManagement. Módulo para la gestión de la información de la base
de datos de la aplicación Gesco. Copyright (C) 2015 Germán Martínez Maldonado
This file is part of Gesco-DatabaseManagement.
Gesco-DatabaseManagement is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
Gesco-DatabaseManagement is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


// Dependencias
var ActorDB = require('actordb');

// Configuración de acceso a la base de datos
var client = ActorDB.connectSingle({
host: 'gescoDBM.cloudapp.net',
port: 33306,
username: "usuario",
password: "usuario"
});

module.exports = client;
module.exports = client;
21 changes: 21 additions & 0 deletions database/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Gesco-DatabaseManagement. Módulo para la gestión de la información de la base
de datos de la aplicación Gesco. Copyright (C) 2015 Germán Martínez Maldonado
This file is part of Gesco-DatabaseManagement.
Gesco-DatabaseManagement is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
Gesco-DatabaseManagement is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


-- Crea grupo, nodo y usuario root.
use config
insert into groups values ('grp1','cluster')
Expand Down
19 changes: 19 additions & 0 deletions database/installDB.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#!/bin/bash

# Gesco-DatabaseManagement. Módulo para la gestión de la información de la base
# de datos de la aplicación Gesco. Copyright (C) 2015 Germán Martínez Maldonado
#
# This file is part of Gesco-DatabaseManagement.
#
# Gesco-DatabaseManagement is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# Gesco-DatabaseManagement is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


INSTALADO=`dpkg --get-selections | grep actordb | wc -l`

if (( $INSTALADO >= 1 )); then
Expand Down
5 changes: 5 additions & 0 deletions lib/generarInforme.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@ var lxDocument = require('lx-pdf')('lib/template.json');
var moment = require('moment');
var _ = require('underscore');

// Genera el archivo del informe
exports.generar = function(datos) {
// Diferentes campos del documento
var cliente = "CLIENTE: Germán Martínez Maldonado";
var fecha = moment().format("MMMM Do YYYY, h:mm:ss a");
var asunto = "Informe de frecuencias";
var contenido = "";

// Procesa información recuperada de la base de datos
_.each(datos, function(valor) {
contenido += "· " + valor.nombre + ": " + valor.frecuencia + "\n";
});

// Añade la información a distintos campos del documento
lxDocument.addContent('cliente', cliente);
lxDocument.addContent('fecha', fecha);
lxDocument.addContent('asunto', asunto);
lxDocument.addContent('contenido', contenido);

// Genera el documento
lxDocument.save('public/data/gesco.pdf', function(result) {});
};
2 changes: 1 addition & 1 deletion lib/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@
}
}]
}
}
}
3 changes: 2 additions & 1 deletion public/js/generarTabla.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// Añade un tabla al documento con la información recuperada de la base de datos
function filasTabla(data) {
$(document).ready(function() {
$.each(data, function(clave, valor) {
$('#tareas').append('<tr><td>' + valor.nombre + '</td><td>' + valor.frecuencia + '</td></tr>');
});
});
}
}
10 changes: 10 additions & 0 deletions routes/graficos.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
var express = require('express');
var fs = require('fs');
var _ = require('underscore');

var router = express.Router();

var client = require(appRoot + '/database/client');

// GET de la página de gráficos
Expand All @@ -32,15 +34,23 @@ router.get('/', function(req, res) {
title: 'Gesco-DatabaseManagement: Graficos'
});

// Conecta a la base de datos
client.connect(function(err, db) {
// Ejecuta consulta SQL
client.exec_sql("ACTOR consultor(tareas) CREATE; SELECT * FROM tareas;", function(err, datos) {
// Cierra conexión
client.close();

// Crea el documento con el origen de datos para la gráfica
var stream = fs.createWriteStream(appRoot + '/public/data/data.tsv');
stream.write("nombre\tfrecuencia\n");

// Añade al origen de datos la información recuperada de la base de datos
_.each(datos.rows, function(valor) {
stream.write(valor.nombre + "\t" + valor.frecuencia + "\n");
});

// Cierra el flujo al archivo
stream.end();
});
});
Expand Down
5 changes: 5 additions & 0 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Dependencias
var express = require('express');
var router = express.Router();

var client = require(appRoot + '/database/client');

// GET de la página principal
router.get('/', function(req, res) {
// Conecta a la base de datos
client.connect(function(err, db) {
// Ejecuta consulta SQL
client.exec_sql("ACTOR consultor(tareas) CREATE; SELECT * FROM tareas;", function(err, datos) {
// Cierra conexión
client.close();

res.render('index', {
title: 'Gesco-DatabaseManagement: Inicio',
data: datos.rows
Expand Down
5 changes: 5 additions & 0 deletions routes/informes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ router.get('/', function(req, res) {
title: 'Gesco-DatabaseManagement: Informes'
});

// Conecta a la base de datos
client.connect(function(err, db) {
// Ejecuta consulta SQL
client.exec_sql("ACTOR consultor(tareas) CREATE; SELECT * FROM tareas;", function(err, datos) {
// Cierra conexión
client.close();

// Genera el informe con la información recuperada
informe.generar(data.rows);
});
});
Expand Down

0 comments on commit aca0e9c

Please sign in to comment.