jsharmony 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AppSrv.Report.js CHANGED
@@ -29,7 +29,7 @@ exports.getReport = function (req, res, fullmodelid, Q, P, callback) {
29
29
  var _this = this;
30
30
  if (typeof Q == 'undefined') Q = req.query;
31
31
  if (typeof P == 'undefined') P = req.body;
32
- if (typeof callback == 'undefined') callback = function (err, tmppath, dispose) {
32
+ if (typeof callback == 'undefined') callback = function (err, tmppath, dispose, dbdata) {
33
33
  if(err){ Helper.GenError(req, res, -99999, err.toString()); return; }
34
34
 
35
35
  /* Report Done */
@@ -37,23 +37,34 @@ exports.getReport = function (req, res, fullmodelid, Q, P, callback) {
37
37
  if (err != null) return dispose();
38
38
  var fsize = stat.size;
39
39
  var model = _this.jsh.getModel(req, fullmodelid);
40
- //Send MIME type
41
- if(model.format=='xlsx'){
42
- res.writeHead(200, {
43
- 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
44
- 'Content-Length': fsize,
45
- 'Content-Disposition': 'filename = ' + encodeURIComponent(fullmodelid + '.xlsx')
46
- });
47
- }
48
- else {
49
- res.writeHead(200, {
50
- 'Content-Type': 'application/pdf',
51
- 'Content-Length': fsize,
52
- 'Content-Disposition': 'filename = ' + encodeURIComponent(fullmodelid + '.pdf')
53
- });
54
- }
55
- var rs = fs.createReadStream(tmppath);
56
- rs.pipe(res).on('finish', function () { dispose(); });
40
+ var filename = fullmodelid + (model.format == 'xlsx' ? '.xlsx' : '.pdf');
41
+ Helper.execif(model.ongetfilename,
42
+ function(done){
43
+ model.ongetfilename(function(rslt){
44
+ if(rslt) filename = rslt.toString();
45
+ return done();
46
+ }, model, Q, P, req, dbdata);
47
+ },
48
+ function(){
49
+ //Send MIME type
50
+ if(model.format=='xlsx'){
51
+ res.writeHead(200, {
52
+ 'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
53
+ 'Content-Length': fsize,
54
+ 'Content-Disposition': 'filename = ' + encodeURIComponent(filename)
55
+ });
56
+ }
57
+ else {
58
+ res.writeHead(200, {
59
+ 'Content-Type': 'application/pdf',
60
+ 'Content-Length': fsize,
61
+ 'Content-Disposition': 'filename = ' + encodeURIComponent(filename)
62
+ });
63
+ }
64
+ var rs = fs.createReadStream(tmppath);
65
+ rs.pipe(res).on('finish', function () { dispose(); });
66
+ }
67
+ );
57
68
  });
58
69
  }
59
70
 
package/AppSrvRpt.js CHANGED
@@ -681,7 +681,10 @@ AppSrvRpt.prototype.genReportXlsx = function (req, res, fullmodelid, params, dat
681
681
  //Generate worksheets
682
682
  function(rpt_cb){
683
683
  if(cancelRender) return rpt_cb();
684
- async.eachOfSeries(data, function(rsData, rsName, rs_cb){
684
+ var sheetNames = [];
685
+ if(data) sheetNames = _.keys(data).reverse();
686
+ async.eachSeries(sheetNames, function(rsName, rs_cb){
687
+ var rsData = data[rsName];
685
688
  try{
686
689
  //Create worksheet
687
690
  var worksheet = workbook.addWorksheet(rsName);
@@ -1752,7 +1752,7 @@ exports.ParseEntities = function () {
1752
1752
  }
1753
1753
 
1754
1754
  //Convert mutli-line variables to single string
1755
- ParseMultiLineProperties(model, ['js', 'jslib', 'sqlselect', 'sqldownloadselect', 'sqlinsert', 'sqlinsertencrypt', 'sqlupdate', 'sqldelete', 'sqlexec', 'sqlwhere', 'sqlgetinsertkeys', 'oninit', 'onload', 'onloadimmediate', 'oninsert', 'onvalidate', 'onupdate', 'ondestroy', 'oncommit', 'onchange']);
1755
+ ParseMultiLineProperties(model, ['js', 'jslib', 'sqlselect', 'sqldownloadselect', 'sqlinsert', 'sqlinsertencrypt', 'sqlupdate', 'sqldelete', 'sqlexec', 'sqlwhere', 'sqlgetinsertkeys', 'ongetfilename', 'oninit', 'onload', 'onloadimmediate', 'oninsert', 'onvalidate', 'onupdate', 'ondestroy', 'oncommit', 'onchange']);
1756
1756
  if (model.breadcrumbs) ParseMultiLineProperties(model.breadcrumbs, ['sql']);
1757
1757
  if (model.fields) _.each(model.fields, function (field) {
1758
1758
  ParseMultiLineProperties(field, ['onchange', 'sqlselect', 'sqlupdate', 'sqlinsert', 'sqlwhere', 'sqlsort', 'sqlsearch', 'sqlsearchsound', 'value']);
@@ -1908,6 +1908,8 @@ exports.ParseEntities = function () {
1908
1908
  });
1909
1909
  }
1910
1910
  _this.validateDisplayLayouts(model);
1911
+ if(model.ongetfilename) model.ongetfilename = _this.createFunction(model.ongetfilename, ['callback', 'xmodel', 'Q', 'P', 'req', 'dbdata'], model.id+' model.ongetfilename');
1912
+
1911
1913
 
1912
1914
  //Validate Model and Field Parameters
1913
1915
  var _v_model = [
@@ -1917,7 +1919,7 @@ exports.ParseEntities = function () {
1917
1919
  'hide_system_buttons', 'grid_expand_search', 'grid_rowcount', 'reselectafteredit', 'newrowposition', 'commitlevel', 'validationlevel',
1918
1920
  'grid_require_search', 'default_search', 'grid_static', 'rowstyle', 'rowclass', 'rowlimit', 'disableautoload',
1919
1921
  'oninit', 'oncommit', 'onload', 'oninsert', 'onupdate', 'onvalidate', 'onloadstate', 'ongetstate', 'onrowbind', 'onrowunbind', 'ondestroy', 'onchange', 'getapi', 'onrender', 'onrendered',
1920
- 'js', 'jslib', 'ejs', 'header', 'css', 'dberrors', 'tablestyle', 'tableclass', 'formstyle', 'formclass', 'popup', 'onloadimmediate', 'sqlwhere', 'sqlwhere_disabled_on_insert', 'breadcrumbs', 'tabpos', 'tabs', 'tabpanelstyle',
1922
+ 'js', 'jslib', 'ejs', 'header', 'css', 'dberrors', 'tablestyle', 'tableclass', 'formstyle', 'formclass', 'popup', 'ongetfilename', 'onloadimmediate', 'sqlwhere', 'sqlwhere_disabled_on_insert', 'breadcrumbs', 'tabpos', 'tabs', 'tabpanelstyle',
1921
1923
  'nokey', 'nodatalock', 'unbound', 'duplicate', 'sqlselect', 'sqlupdate', 'sqlinsert', 'sqlgetinsertkeys', 'sqldelete', 'sqlexec', 'sqlexec_comment', 'sqltype', 'onroute', 'tabcode', 'noresultsmessage', 'bindings',
1922
1924
  'path', 'module', 'templates', 'db', 'onecolumn', 'namespace',
1923
1925
  //Report Parameters
@@ -39,6 +39,7 @@ function jsHarmonyServer(serverConfig, jsh){
39
39
  this.serverConfig = serverConfig||{};
40
40
  this.servers = [];
41
41
  if(!('add_default_routes' in serverConfig)) serverConfig.add_default_routes = true;
42
+ this.redirectRouter = null; //Express router for redirect HTTP server
42
43
  /*
43
44
  serverConfig: {
44
45
  add_default_routes: true,
@@ -419,6 +420,8 @@ jsHarmonyServer.prototype.Run = function(cb){
419
420
  if(!http_redirect) start_https_server(cb);
420
421
  else {
421
422
  var redirect_app = express();
423
+ _this.redirectRouter = express.Router();
424
+ redirect_app.use(_this.redirectRouter);
422
425
  redirect_app.get('*', function (req, res) {
423
426
  var hostname = Helper.GetIP(req);
424
427
  if(req.headers && req.headers.host){
package/lib/Helper.js CHANGED
@@ -274,6 +274,9 @@ exports.pushCreate = function(parent, idx, val){
274
274
  parent[idx].push(val);
275
275
  }
276
276
  exports.getFullURL = function (req, url) {
277
+ url = (url||'').toString();
278
+ if(url.toLowerCase().indexOf('http://')==0) return url;
279
+ else if(url.toLowerCase().indexOf('https://')==0) return url;
277
280
  return req.protocol + '://' + req.get('host') + url;
278
281
  };
279
282
  exports.getLine = function(txt, lineno){
@@ -0,0 +1,19 @@
1
+ /*
2
+ Copyright 2022 apHarmony
3
+
4
+ This file is part of jsHarmony.
5
+
6
+ jsHarmony is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ jsHarmony is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with this package. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ exports = module.exports = require('body-parser');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsharmony",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Rapid Application Development (RAD) Platform for Node.js Database Application Development",
5
5
  "main": "index.js",
6
6
  "scripts": {