Commit e18a8568 by Arturo Montejo Ráez

Merge branch 'develop' of http://gitlab.ujaen.es/yotta/pictogram into develop

parents 7456cee4 fc4e3268
...@@ -21,7 +21,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh] ...@@ -21,7 +21,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh]
3. Descargar Pictogram del repositorio e iniciar instalación 3. Descargar Pictogram del repositorio e iniciar instalación
``` ```
$ git clone http://scm.ujaen.es/softuno/pictogram.git $ git clone http://gitlab.ujaen.es/yotta/pictogram.git
$ cd pictogram/sails $ cd pictogram/sails
$ sudo ./install.sh $ sudo ./install.sh
``` ```
......
#!/bin/bash #!/bin/bash
#
# - Encoding and locale for virtual machine
# - Build-essentials and g++
# - Ansible install
# - Run ansible playbook
#
# keymap and system encoding # keymap and system encoding
echo "-- Configuring encoding and locale" echo "-- Configuring encoding and locale"
sudo localectl set-keymap es sudo localectl set-keymap es
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8 export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
echo "-- Installing build-essentials and g++" echo "-- Installing build-essentials and g++"
sudo apt-get update sudo apt-get update -y
sudo apt-get install -y build-essential g++ sudo apt-get install -y build-essential g++
# installing ansible # installing ansible
...@@ -42,3 +53,6 @@ else ...@@ -42,3 +53,6 @@ else
echo "XX Playbook not found, provision not finished" echo "XX Playbook not found, provision not finished"
exit exit
fi fi
# overwrite sails-mysql
yes | sudo cp -rf /vagrant/src/node_modules_overwrite/sails-mysql/* /vagrant/src/node_modules/sails-mysql/
#!/bin/bash #!/bin/bash
#
# Install core pictos (symbolstx and upload)
#
cd /vagrant/ cd /vagrant/
echo "--Descargando coleccion de pictogramas" echo "--Descargando coleccion de pictogramas"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "angular-pictogram", "name": "angular-pictogram",
"description": "Client side dashboard in AngularJS", "description": "Client side dashboard in AngularJS",
"version": "0.0.0", "version": "0.0.0",
"homepage": "http://scm.ujaen.es/softuno/pictogram.git", "homepage": "http://gitlab.ujaen.es/yotta/pictogram.git",
"license": "Private", "license": "Private",
"private": true, "private": true,
"dependencies": { "dependencies": {
......
...@@ -85,13 +85,11 @@ function LoginCtrl( ...@@ -85,13 +85,11 @@ function LoginCtrl(
$scope.submitted = false; $scope.submitted = false;
delete $window.sessionStorage.token; delete $window.sessionStorage.token;
if (err.search("without students") > 0) { if (err.search("without students") > 0) {
$translate('no_students_for_user').then(function (translation) { ngToast.warning($translate.instant('no_students_for_user'));
ngToast.warning({ content: translation });
});
} else if (err.search("not been activated") > 0) { } else if (err.search("not been activated") > 0) {
$translate('inactive_account').then(function (translation) { ngToast.danger($translate.instant('inactive_account'));
ngToast.danger({ content: translation }); } else {
}); ngToast.danger($translate.instant("login_fail"));
} }
}); });
}; };
......
<!-- Office image --> <!-- Office image -->
<div class="row"> <div class="header-image">
<div class="col-md-12 text-center"> <div class="row">
<!-- Logo Pictogram <div class="col-md-12 text-center">
<p>
<img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" />
</p>
-->
<p>&nbsp;</p>
<p class="text-center">
<img ng-src="{{office.logoUrl}}" alt="{{office.name}}" title="{{office.name}}"> <img ng-src="{{office.logoUrl}}" alt="{{office.name}}" title="{{office.name}}">
</p> </div>
</div> </div>
</div> </div>
<!--/. Office image --> <!--/. Office image -->
<!-- Main row --> <br>
<div class="row">
<!-- Form column and offset --> <div id="main-content" class="container">
<div class="col-md-4 col-md-offset-2"> <div class="row">
<div id="login">
<!-- Formulario --> <!-- Form column and offset -->
<!-- LoginCtrl controls here, see app.js --> <div class="col-md-4 col-md-offset-2">
<form name="loginForm" ng-submit="login()" novalidate> <div id="login">
<!-- Email --> <!-- Formulario -->
<div class="form-group"> <!-- LoginCtrl controls here, see app.js -->
<label translate>email</label>: <form name="loginForm" ng-submit="login()" novalidate>
<input type="email" class="form-control" id="login_email" placeholder="{{ 'your_email' | translate}}" required ng-model="credentials.email" /> <!-- Email -->
</div> <div class="form-group">
<!-- Password --> <label translate>email</label>:
<div class="form-group"> <input type="email" class="form-control" id="login_email" placeholder="{{ 'your_email' | translate}}" required ng-model="credentials.email" />
<label translate>password</label>: </div>
<input type="password" class="form-control" id="login_password" placeholder="{{ 'your_password' | translate}}" required ng-model="credentials.password" /> <!-- Password -->
</div> <div class="form-group">
<!-- Remember --> <label translate>password</label>:
<div class="checkbox"> <input type="password" class="form-control" id="login_password" placeholder="{{ 'your_password' | translate}}" required ng-model="credentials.password" />
<label> </div>
<input type="checkbox" id="login_savepassword" ng-model="credentials.savepassword" />{{ 'remember' | translate }} <div class="row">
</label> <div class="col-xs-6">
</div> <!-- Login -->
<div class="row"> <div class="pull-left">
<div class="col-md-12"> <button type="submit" class="btn btn-primary" translate>login</button>
<!-- Login --> </div>
<div class="pull-left"> <!-- Spinner -->
<button type="submit" class="btn btn-primary" translate>login</button> <div class="pull-left">
</div> <i ng-class="{'fa fa-spinner fa-spin fa-2x fa-fw margin-bottom': true, 'spin_disabled': !submitted}"></i>
<!-- Spinner --> </div>
<div class="pull-left">
<i ng-class="{'fa fa-spinner fa-spin fa-2x fa-fw margin-bottom': true, 'spin_disabled': !submitted}"></i>
</div> </div>
<!-- Create account --> <div class="col-xs-6 margin-top7">
<div class="pull-right margin-top7"> <!-- Remember -->
<a href="/app/#/signin" translate>create_an_account</a> <div class="checkbox">
<label>
<input type="checkbox" id="login_savepassword" ng-model="credentials.savepassword" />{{ 'remember' | translate }}
</label>
</div>
</div> </div>
</div> </div>
</div>
<!-- Remember password -->
<div class="text-center margin-top15">
<br> <br>
<a href="/app/#/changepass" translate>password_forgotten</a>
</div> <!-- Remember password -->
</form> <div class="row text-center">
<a href="/app/#/changepass" translate>password_forgotten</a>
</div>
<!-- Create account -->
<div class="row text-center">
<a href="/app/#/signin" translate>create_an_account</a>
</div>
</form>
</div>
<!--/. login -->
</div> </div>
<!--/. login --> <!--/. form column -->
</div>
<!--/. form column -->
<!-- Image column --> <!-- Image column -->
<div class="col-md-4"> <div class="col-xs-12 col-md-4 text-center">
<img src="img/login.png" alt="Pictogram" title="Pictogram" /> <img src="img/login.png" alt="Pictogram" title="Pictogram" />
</div> </div>
<!--/. image column --> <!--/. image column -->
</div>
</div> </div>
<!--/. main row -->
<footer-translate></footer-translate> <footer-translate></footer-translate>
...@@ -325,7 +325,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -325,7 +325,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
if(!pictoId) if(!pictoId)
return; return;
// Send the picto to the server
$http.put(config.backend + '/stu/' + $scope.studentData.id + '/cat', { $http.put(config.backend + '/stu/' + $scope.studentData.id + '/cat', {
prev_id_stu_pic: picto_cat.id, prev_id_stu_pic: picto_cat.id,
new_id_pic: pictoId new_id_pic: pictoId
......
Files contained here are intented to overwrite dependencies code, because of a enhacement or a bug not included in official distributions and done by us.
/**
* Utility Functions
*/
// Dependencies
var mysql = require('mysql');
var _ = require('lodash');
var url = require('url');
// Module Exports
var utils = module.exports = {};
/**
* Parse URL string from config
*
* Parse URL string into connection config parameters
*/
utils.parseUrl = function (config) {
if(!_.isString(config.url)) {
return config;
}
var obj = url.parse(config.url);
config.host = obj.hostname || config.host;
config.port = obj.port || config.port;
if(_.isString(obj.pathname)) {
config.database = obj.pathname.split('/')[1] || config.database;
}
if(_.isString(obj.auth)) {
config.user = obj.auth.split(':')[0] || config.user;
config.password = obj.auth.split(':')[1] || config.password;
}
return config;
};
/**
* Prepare values
*
* Transform a JS date to SQL date and functions
* to strings.
*/
utils.prepareValue = function(value) {
if(_.isUndefined(value) || value === null) {
return value;
}
// Cast functions to strings
if (_.isFunction(value)) {
value = value.toString();
}
// Store Arrays and Objects as strings
if (_.isArray(value) || value.constructor && value.constructor.name === 'Object') {
try {
value = JSON.stringify(value);
} catch (e) {
// just keep the value and let the db handle an error
value = value;
}
}
// Cast dates to SQL
if (_.isDate(value)) {
value = utils.toSqlDate(value);
}
return mysql.escape(value);
};
/**
* Builds a Select statement determining if Aggeregate options are needed.
*/
utils.buildSelectStatement = function(criteria, table, schemaDefs) {
var query = '';
if(criteria.groupBy || criteria.sum || criteria.average || criteria.min || criteria.max) {
query = 'SELECT ';
// Append groupBy columns to select statement
if(criteria.groupBy) {
if(_.isArray(criteria.groupBy)) {
_.each(criteria.groupBy, function(opt){
query += opt + ', ';
});
} else {
query += criteria.groupBy + ', ';
}
}
// Handle SUM
if (criteria.sum) {
if(_.isArray(criteria.sum)) {
_.each(criteria.sum, function(opt){
query += 'SUM(' + opt + ') AS ' + opt + ', ';
});
} else {
query += 'SUM(' + criteria.sum + ') AS ' + criteria.sum + ', ';
}
}
// Handle AVG (casting to float to fix percision with trailing zeros)
if (criteria.average) {
if(_.isArray(criteria.average)) {
_.each(criteria.average, function(opt){
query += 'AVG(' + opt + ') AS ' + opt + ', ';
});
} else {
query += 'AVG(' + criteria.average + ') AS ' + criteria.average + ', ';
}
}
// Handle MAX
if (criteria.max) {
if(_.isArray(criteria.max)) {
_.each(criteria.max, function(opt){
query += 'MAX(' + opt + ') AS ' + opt + ', ';
});
} else {
query += 'MAX(' + criteria.max + ') AS ' + criteria.max + ', ';
}
}
// Handle MIN
if (criteria.min) {
if(_.isArray(criteria.min)) {
_.each(criteria.min, function(opt){
query += 'MIN(' + opt + ') AS ' + opt + ', ';
});
} else {
query += 'MIN(' + criteria.min + ') AS ' + criteria.min + ', ';
}
}
// trim trailing comma
query = query.slice(0, -2) + ' ';
// Add FROM clause
return query += 'FROM `' + table + '` ';
}
/**
* If no aggregate options lets just build a normal query
*/
// Add all keys to the select statement for this table
query += 'SELECT ';
var selectKeys = [],
joinSelectKeys = [];
if ( !schemaDefs[table] ) {
throw new Error('Schema definition missing for table: `'+table+'`');
}
_.each(schemaDefs[table], function(schemaDef, key) {
selectKeys.push({ table: table, key: key });
});
// Check for joins
if(criteria.joins || criteria.join) {
var joins = criteria.joins || criteria.join;
_.each(joins, function(join) {
if(!join.select) {
return;
}
_.each(_.keys(schemaDefs[join.child.toLowerCase()]), function(key) {
var _join = _.cloneDeep(join);
_join.key = key;
joinSelectKeys.push(_join);
});
// Remove the foreign key for this join from the selectKeys array
selectKeys = selectKeys.filter(function(select) {
var keep = true;
if(select.key === join.parentKey && join.removeParentKey) {
keep = false;
}
return keep;
});
});
}
// Add all the columns to be selected that are not joins
_.each(selectKeys, function(select) {
query += '`' + select.table + '`.`' + select.key + '`, ';
});
// Add all the columns from the joined tables
_.each(joinSelectKeys, function(select) {
// Create an alias by prepending the child table with the alias of the join
var alias = select.alias.toLowerCase() + '_' + select.child.toLowerCase();
// If this is a belongs_to relationship, keep the foreign key name from the AS part
// of the query. This will result in a selected column like: "user"."id" AS "user_id__id"
if(select.model) {
return query += mysql.escapeId(alias) + '.' + mysql.escapeId(select.key) + ' AS ' +
mysql.escapeId(select.parentKey + '__' + select.key) + ', ';
}
// If a junctionTable is used, the child value should be used in the AS part of the
// select query.
if(select.junctionTable) {
return query += mysql.escapeId(alias) + '.' + mysql.escapeId(select.key) + ' AS ' +
mysql.escapeId(select.alias + '__' + select.key) + ', ';
}
// Else if a hasMany attribute is being selected, use the alias plus the child
return query += mysql.escapeId(alias) + '.' + mysql.escapeId(select.key) + ' AS ' +
mysql.escapeId(select.alias + '__' + select.key) + ', ';
});
// Remove the last comma
query = query.slice(0, -2) + ' FROM `' + table + '` ';
return query;
};
utils.toSqlDate = function toSqlDate(date) {
date = date.getFullYear() + '-' +
('00' + (date.getMonth()+1)).slice(-2) + '-' +
('00' + date.getDate()).slice(-2) + ' ' +
('00' + date.getHours()).slice(-2) + ':' +
('00' + date.getMinutes()).slice(-2) + ':' +
('00' + date.getSeconds()).slice(-2) + "." +
('00' + date.getMilliseconds()).slice(-3);
return date;
};
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"main": "app.js", "main": "app.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "http://scm.ujaen.es/softuno/pictogram.git" "url": "http://gitlab.ujaen.es/yotta/pictogram.git"
}, },
"author": "Yottacode", "author": "Yottacode",
"license": "", "license": "",
......
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