0
1
Fork 0

Release beta

This commit is contained in:
Juan Ferrer Toribio 2016-10-14 12:58:35 +02:00
parent cfb3419fd6
commit 858604a736
21 changed files with 96 additions and 69 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.346-deb8) stable; urgency=low hedera-web (1.352-deb8) stable; urgency=low
* Initial Release. * Initial Release.

4
debian/control vendored
View File

@ -1,7 +1,7 @@
Source: hedera-web Source: hedera-web
Priority: optional Priority: optional
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es> Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
Build-Depends: build-essential, debhelper Build-Depends: build-essential, debhelper, nodejs, npm
Standards-Version: 3.9.3 Standards-Version: 3.9.3
Section: misc Section: misc
Homepage: http://www.verdnatura.es Homepage: http://www.verdnatura.es
@ -9,7 +9,7 @@ Vcs-Git: git://www.verdnatura.es/var/git/hedera-web
Package: hedera-web Package: hedera-web
Architecture: all Architecture: all
Depends: apache2, php5-mysql, php5-mcrypt, php5-ssh2, php-vn-lib Depends: apache2, php5-mysql, php5-mcrypt, php5-ssh2, php-vn-lib, nodejs, npm
Suggests: php-text-captcha, php5-imap, vn-image, tinymce Suggests: php-text-captcha, php5-imap, vn-image, tinymce
Section: misc Section: misc
Priority: optional Priority: optional

4
debian/install vendored
View File

@ -1,5 +1,5 @@
conf/* etc/hedera-web conf/* etc/hedera-web
vn usr/share/php web usr/share/php/vn
doc/* usr/share/doc/hedera-web doc/* usr/share/doc/hedera-web
forms usr/share/hedera-web forms usr/share/hedera-web
image usr/share/hedera-web image usr/share/hedera-web
@ -10,3 +10,5 @@ reports usr/share/hedera-web
rest usr/share/hedera-web rest usr/share/hedera-web
index.php usr/share/hedera-web index.php usr/share/hedera-web
cli.php usr/share/hedera-web cli.php usr/share/hedera-web
package.json usr/share/hedera-web
build usr/share/hedera-web

2
debian/postinst vendored
View File

@ -4,3 +4,5 @@ a2enconf hedera-web
service apache2 reload service apache2 reload
service cron restart service cron restart
cd /usr/share/hedera-web && npm install --production

7
debian/rules vendored
View File

@ -5,3 +5,10 @@
%: %:
dh $@ dh $@
clean:
npm --production run clean
dh_clean $@
build:
npm --production run build

View File

@ -15,14 +15,14 @@ Hedera.Conf = new Class
this.$('new-password').value = ''; this.$('new-password').value = '';
this.$('repeat-password').value = ''; this.$('repeat-password').value = '';
var hasPassword = this.$('user-form').get ('hasPassword'); var recoverPass = this.$('user-form').get ('recoverPass');
this.$('old-password').style.display = hasPassword ? 'block' : 'none'; this.$('old-password').style.display = recoverPass ? 'none' : 'block';
this.$('change-password').show (); this.$('change-password').show ();
if (hasPassword) if (recoverPass)
this.$('old-password').focus ();
else
this.$('new-password').focus (); this.$('new-password').focus ();
else
this.$('old-password').focus ();
} }
,onPassModifyClick: function () ,onPassModifyClick: function ()
@ -38,8 +38,10 @@ Hedera.Conf = new Class
throw new Error (_('Passwords doesn\'t match')); throw new Error (_('Passwords doesn\'t match'));
var batch = new Sql.Batch (); var batch = new Sql.Batch ();
batch.addValue ('oldPassword', oldPassword); batch.addValues ({
batch.addValue ('newPassword', newPassword); 'oldPassword': oldPassword,
'newPassword': newPassword
});
var query = 'CALL account.userChangePassword (#oldPassword, #newPassword)'; var query = 'CALL account.userChangePassword (#oldPassword, #newPassword)';
this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch); this.conn.execQuery (query, this.onPasswordUpdate.bind (this), batch);
@ -56,6 +58,7 @@ Hedera.Conf = new Class
resultSet.fetchResult (); resultSet.fetchResult ();
this.$('change-password').hide (); this.$('change-password').hide ();
Htk.Toast.showMessage (_('Password changed!')); Htk.Toast.showMessage (_('Password changed!'));
this.$('user-form').refresh ();
} }
catch (e) catch (e)
{ {

View File

@ -11,21 +11,22 @@
<db-form id="user-form"> <db-form id="user-form">
<db-model property="model" id="user-model" updatable="true"> <db-model property="model" id="user-model" updatable="true">
<custom> <custom>
SELECT u.id, u.name, u.hasPassword, SELECT u.id, u.name, u.recoverPass,
c.email, c.mail, c.user_id, c.default_address c.email, c.mail, c.user_id
FROM account.userView u FROM account.userView u
LEFT JOIN customer_view c LEFT JOIN customer_view c
ON u.id = c.user_id ON u.id = c.user_id
</custom> </custom>
</db-model> </db-model>
</db-form> </db-form>
<db-model id="addresses" updatable="true"> <db-model id="addresses" updatable="true">
<custom> <custom>
SELECT a.id, a.consignee, p.name province, a.zip_code, a.city, a.name, a.active, c.Pais country SELECT a.id, a.consignee, p.name province,
a.zip_code, a.city, a.name, a.active, c.Pais country
FROM address_view a FROM address_view a
LEFT JOIN vn2008.province p ON a.province_id = p.province_id LEFT JOIN vn2008.province p ON a.province_id = p.province_id
JOIN vn2008.Paises c ON c.Id = p.Paises_Id JOIN vn2008.Paises c ON c.Id = p.Paises_Id
WHERE active != FALSE WHERE active
</custom> </custom>
</db-model> </db-model>
</vn-group> </vn-group>

View File

@ -55,7 +55,7 @@ module.exports = new Class
this.unref (); this.unref ();
} }
,_onWindowError: function (message, file, line) ,_onWindowError: function (message, file, line, col, err)
{ {
var error = new Error (message); var error = new Error (message);
error.fileName = file; error.fileName = file;

View File

@ -12,15 +12,7 @@ module.exports = new Class
type: Db.Connection type: Db.Connection
,set: function (x) ,set: function (x)
{ {
this.link ({_conn: x}, this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange });
{'loading-changed': this._onConnLoadChange });
var sql = 'SELECT name FROM customer_user;'
+'SELECT default_form, image_dir, image_host FROM config;'
+'SELECT production_domain, test_domain FROM config;';
x.execQuery (sql, this.onMainQueryDone.bind (this));
this.loadMenu ();
} }
,get: function () ,get: function ()
{ {
@ -59,6 +51,15 @@ module.exports = new Class
}); });
this.parent (props); this.parent (props);
this.$('social-bar').conn = this._conn;
var sql = 'SELECT name FROM customer_user;'
+'SELECT default_form, image_dir, image_host FROM config;'
+'SELECT production_domain, test_domain FROM config;';
this._conn.execQuery (sql, this.onMainQueryDone.bind (this));
this.loadMenu ();
} }
,show: function () ,show: function ()

View File

@ -29,7 +29,7 @@
<ul id="main-menu" class="main-menu"></ul> <ul id="main-menu" class="main-menu"></ul>
</div> </div>
<div class="social"> <div class="social">
<!-- <htk-social-bar/> --> <htk-social-bar id="social-bar" priority="2"/>
</div> </div>
</div> </div>
<div class="body"> <div class="body">

View File

@ -26,6 +26,8 @@ module.exports = new Class
this.parent (props); this.parent (props);
this.builderInitString (Tpl); this.builderInitString (Tpl);
this.$('social-bar').conn = this._conn;
var self = this; var self = this;
this.$('form').onsubmit = function () this.$('form').onsubmit = function ()
{ {
@ -174,7 +176,7 @@ module.exports = new Class
,_onPasswordRecovered: function (json, error) ,_onPasswordRecovered: function (json, error)
{ {
if (json) if (json)
Htk.Toast.showMessage (_('A mail has been sent with your new password')); Htk.Toast.showMessage (_('A mail has been sent wich you can recover your password'));
else else
Htk.Toast.showError (error.message); Htk.Toast.showError (error.message);
} }

View File

@ -50,7 +50,7 @@
</a> </a>
</div> </div>
<div class="footer"> <div class="footer">
<!-- <htk-social-bar/> --> <htk-social-bar id="social-bar" priority="1"/>
<div id="social" class="social"/> <div id="social" class="social"/>
<div class="contact"> <div class="contact">
<p><t>Login mail</t></p> <p><t>Login mail</t></p>

View File

@ -11,6 +11,7 @@ module.exports = new Class
,set: function (x) ,set: function (x)
{ {
this._conn = x; this._conn = x;
this._refresh ();
} }
,get: function () ,get: function ()
{ {
@ -23,31 +24,34 @@ module.exports = new Class
,set: function (x) ,set: function (x)
{ {
this._priority = x; this._priority = x;
this._refresh ();
} }
,get: function () ,get: function ()
{ {
return this._priority; return this._priority;
} }
}, }
} }
,_priority: null ,_priority: 0
,initialize: function () ,initialize: function ()
{ {
this.createElement ('div'); var node = this.createElement ('div');
this._node.className = 'htk-social-bar'; node.className = 'htk-social-bar';
} }
,_refresh: function () ,_refresh: function ()
{ {
if (!this._conn || this._priority === null) if (!this._conn || this._priority === null)
return; return;
var batch = new Sql.Batch ();
batch.addValue ('priority', this._priority);
var query = 'SELECT title, link, icon FROM social ' var query = 'SELECT title, link, icon FROM social '
+'WHERE priority ORDER BY priority'; +'WHERE priority >= #priority ORDER BY priority';
this._conn.execQuery (query, this._onQueryDone.bind (this)); this._conn.execQuery (query, this._onQueryDone.bind (this), batch);
} }
,_onQueryDone: function (resultSet) ,_onQueryDone: function (resultSet)

View File

@ -39,7 +39,7 @@ module.exports = new Class
var radio = Vn.Browser.createRadio (''); var radio = Vn.Browser.createRadio ('');
radio.checked = false; radio.checked = false;
radio.addEventListener ('change', this._onChange.bind (this)); radio.addEventListener ('change', this._onChange.bind (this));
this.node = radio; this._node = radio;
this.parent (props); this.parent (props);
} }

View File

@ -27,7 +27,7 @@ module.exports = new Class
,initialize: function (props) ,initialize: function (props)
{ {
this.node = document.createTextNode (''); this._node = document.createTextNode ('');
this.parent (props); this.parent (props);
} }

View File

@ -4,6 +4,14 @@ module.exports = new Class
Extends: Vn.Object Extends: Vn.Object
,Properties: ,Properties:
{ {
node:
{
type: Object
,get: function ()
{
return this._node;
}
},
class: class:
{ {
type: String type: String
@ -14,13 +22,13 @@ module.exports = new Class
} }
,get: function () ,get: function ()
{ {
return this.node.className; return this._node.className;
} }
} }
} }
/** Main HTML node that represents the widget **/ /** Main HTML node that represents the widget **/
,node: null ,_node: null
,builder: null ,builder: null
,builderInit: function (path) ,builderInit: function (path)
@ -42,33 +50,33 @@ module.exports = new Class
,builderResultInit: function (builder) ,builderResultInit: function (builder)
{ {
var res = this.builder = builder.load (); var res = this.builder = builder.load ();
this.node = res.$('main'); this._node = res.$('main');
res.link (); res.link ();
} }
,createElement: function (tagName) ,createElement: function (tagName)
{ {
this.node = document.createElement (tagName); this._node = document.createElement (tagName);
return this.node; return this._node;
} }
,getNode: function () ,getNode: function ()
{ {
if (!this.node) if (!this._node)
{ {
this._createNode (); this._createNode ();
this._refreshClass (); this._refreshClass ();
} }
return this.node; return this._node;
} }
,_createNode: function () {} ,_createNode: function () {}
,_refreshClass: function () ,_refreshClass: function ()
{ {
if (this.node && this._cssClass) if (this._node && this._cssClass)
this.node.className = this._cssClass +' '+ this.node.className; this._node.className = this._cssClass +' '+ this._node.className;
} }
,$: function (id) ,$: function (id)
@ -81,7 +89,7 @@ module.exports = new Class
,remove: function () ,remove: function ()
{ {
Vn.Node.remove (this.node); Vn.Node.remove (this._node);
} }
,_destroy: function () ,_destroy: function ()

View File

@ -17,6 +17,7 @@
}, },
"scripts": { "scripts": {
"dev": "webpack-dev-server --progress --colors --inline --hot", "dev": "webpack-dev-server --progress --colors --inline --hot",
"build": "rm build/* ; webpack --progress --colors" "build": "rm -f build/* ; webpack --progress --colors",
"clean": "rm -rf build/"
} }
} }

View File

@ -20,8 +20,7 @@ class RecoverPassword extends Vn\Web\JsonRequest
return TRUE; return TRUE;
$service = $this->service; $service = $this->service;
$recover = ['recover' => TRUE]; $token = $service->createToken ($_REQUEST['user'], FALSE, TRUE);
$token = $service->createToken ($_REQUEST['user'], FALSE, $recover);
$url = $service->getUrl () ."#!form=account/conf&token=$token"; $url = $service->getUrl () ."#!form=account/conf&token=$token";
$report = new Vn\Web\Report ($db, 'recover-password', ['url' => $url]); $report = new Vn\Web\Report ($db, 'recover-password', ['url' => $url]);

View File

@ -38,12 +38,9 @@ class HtmlService extends Service
if (!isset ($_GET['skipBrowser']) if (!isset ($_GET['skipBrowser'])
&& ($browser = get_browser ($_SERVER['HTTP_USER_AGENT']))) && ($browser = get_browser ($_SERVER['HTTP_USER_AGENT'])))
{ {
$browserVersion = $browser->version; $browserVersion = (double) $browser->version;
set_type ($browserVersion, TYPE_DOUBLE);
$minVersion = $db->getValue ( $minVersion = $db->getValue (
'SELECT version FROM browser WHERE name = #', [$browser->browser]); 'SELECT version FROM browser WHERE name = #', [$browser->browser]);
$updateBrowser = $browserVersion > 0 $updateBrowser = $browserVersion > 0
&& isset ($minVersion) && $browserVersion < $minVersion; && isset ($minVersion) && $browserVersion < $minVersion;
} }
@ -78,14 +75,14 @@ class HtmlService extends Service
{ {
Locale::addPath ($basePath); Locale::addPath ($basePath);
$phpFile = "$basePath/$page.php"; $phpFile = "./$basePath/$page.php";
if (file_exists ($phpFile)) if (file_exists ($phpFile))
require ($phpFile); require ($phpFile);
$this->printHeader (); $this->printHeader ();
$dir = $basePath; $dir = $basePath;
include ("$basePath/html.php"); include ("./$basePath/html.php");
} }
else else
header ('Location: ./'); header ('Location: ./');

View File

@ -167,13 +167,13 @@ abstract class Service
$user = $jwtPayload['sub']; $user = $jwtPayload['sub'];
/* if (!empty ($jwtPayload['recover'])) if (!empty ($jwtPayload['recover']))
$db->query ( $db->query (
'UPDATE account.user SET password = NULL 'UPDATE account.user SET recoverPass = TRUE
WHERE name = #', WHERE name = #',
[$user] [$user]
); );
*/ } }
else else
$user = $db->getValue ('SELECT guest_user FROM config'); $user = $db->getValue ('SELECT guest_user FROM config');
@ -226,9 +226,10 @@ abstract class Service
* *
* @param {string} $user The user name * @param {string} $user The user name
* @param {boolean} $remember Wether to create long live token * @param {boolean} $remember Wether to create long live token
* @param {boolean} $recover Wether to enable recovery mode on login
* @return {string} The JWT generated token * @return {string} The JWT generated token
**/ **/
function createToken ($user, $remember = FALSE, $params = NULL) function createToken ($user, $remember = FALSE, $recover = FALSE)
{ {
if ($remember) if ($remember)
$tokenLife = WEEK; $tokenLife = WEEK;
@ -240,9 +241,8 @@ abstract class Service
'exp' => time () + $tokenLife 'exp' => time () + $tokenLife
]; ];
if (isset ($params)) if (!empty ($recover))
foreach ($params as $key => $value) $payload['recover'] = 'TRUE';
$payload[$key] = $value;
$key = $this->db->getValue ('SELECT jwtKey FROM config'); $key = $this->db->getValue ('SELECT jwtKey FROM config');
return Jwt::encode ($payload, $key); return Jwt::encode ($payload, $key);

View File

@ -2,7 +2,7 @@
var webpack = require ('webpack'); var webpack = require ('webpack');
var path = require ('path'); var path = require ('path');
var devMode = true; var devMode = process.env.NODE_ENV !== 'production';
module.exports = module.exports =
{ {