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.

4
debian/control vendored
View File

@ -1,7 +1,7 @@
Source: hedera-web
Priority: optional
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
Build-Depends: build-essential, debhelper
Build-Depends: build-essential, debhelper, nodejs, npm
Standards-Version: 3.9.3
Section: misc
Homepage: http://www.verdnatura.es
@ -9,7 +9,7 @@ Vcs-Git: git://www.verdnatura.es/var/git/hedera-web
Package: hedera-web
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
Section: misc
Priority: optional

4
debian/install vendored
View File

@ -1,5 +1,5 @@
conf/* etc/hedera-web
vn usr/share/php
web usr/share/php/vn
doc/* usr/share/doc/hedera-web
forms usr/share/hedera-web
image usr/share/hedera-web
@ -10,3 +10,5 @@ reports usr/share/hedera-web
rest usr/share/hedera-web
index.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 cron restart
cd /usr/share/hedera-web && npm install --production

7
debian/rules vendored
View File

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

View File

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

View File

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

View File

@ -12,15 +12,7 @@ module.exports = new Class
type: Db.Connection
,set: function (x)
{
this.link ({_conn: x},
{'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 ();
this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange });
}
,get: function ()
{
@ -59,6 +51,15 @@ module.exports = new Class
});
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 ()

View File

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

View File

@ -26,6 +26,8 @@ module.exports = new Class
this.parent (props);
this.builderInitString (Tpl);
this.$('social-bar').conn = this._conn;
var self = this;
this.$('form').onsubmit = function ()
{
@ -174,7 +176,7 @@ module.exports = new Class
,_onPasswordRecovered: function (json, error)
{
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
Htk.Toast.showError (error.message);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
},
"scripts": {
"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;
$service = $this->service;
$recover = ['recover' => TRUE];
$token = $service->createToken ($_REQUEST['user'], FALSE, $recover);
$token = $service->createToken ($_REQUEST['user'], FALSE, TRUE);
$url = $service->getUrl () ."#!form=account/conf&token=$token";
$report = new Vn\Web\Report ($db, 'recover-password', ['url' => $url]);

View File

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

View File

@ -167,13 +167,13 @@ abstract class Service
$user = $jwtPayload['sub'];
/* if (!empty ($jwtPayload['recover']))
if (!empty ($jwtPayload['recover']))
$db->query (
'UPDATE account.user SET password = NULL
'UPDATE account.user SET recoverPass = TRUE
WHERE name = #',
[$user]
);
*/ }
}
else
$user = $db->getValue ('SELECT guest_user FROM config');
@ -226,9 +226,10 @@ abstract class Service
*
* @param {string} $user The user name
* @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
**/
function createToken ($user, $remember = FALSE, $params = NULL)
function createToken ($user, $remember = FALSE, $recover = FALSE)
{
if ($remember)
$tokenLife = WEEK;
@ -240,9 +241,8 @@ abstract class Service
'exp' => time () + $tokenLife
];
if (isset ($params))
foreach ($params as $key => $value)
$payload[$key] = $value;
if (!empty ($recover))
$payload['recover'] = 'TRUE';
$key = $this->db->getValue ('SELECT jwtKey FROM config');
return Jwt::encode ($payload, $key);

View File

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