backend-plus 2.0.9 → 2.1.2

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.
@@ -436,19 +436,6 @@ myOwn.displayMenu = function displayMenu(layout, menu, addrParams, parents){
436
436
  {underElement:this}
437
437
  );
438
438
  }),
439
- my.light('airplane', function(){
440
- if(my.ldb && my.offline){
441
- if(my.offline.mode && !my.server.connected){
442
- promptPromise("Si desea salir del modo avión puede forzarlo").then(function(texto){
443
- if (texto == 'forzar') {
444
- my.changeOfflineMode();
445
- }
446
- });
447
- }else{
448
- my.changeOfflineMode();
449
- }
450
- }
451
- }, {hidden:true})
452
439
  ]));
453
440
  elements.push(status);
454
441
  }
@@ -501,9 +488,6 @@ myOwn.displayMainMenu = function(addrParams){
501
488
  }
502
489
  }
503
490
  setTimeout(my.doMenuRealigns,10);
504
- setTimeout(function(){
505
- my.offlineModeRefresh();
506
- },10);
507
491
  return menu;
508
492
  };
509
493
 
@@ -547,84 +531,9 @@ myOwn.informDetectedStatus = function informDetectedStatus(statusCode, logged) {
547
531
  }
548
532
  }
549
533
 
550
- myOwn.setOnlineOfflineUrl = function setOnlineOfflineUrl(){
551
- var actualHref=location.href;
552
- var hrefSplit = actualHref.split(my.menuSeparator)
553
- var newHref = my.offline.mode?'ext':my.menuName;
554
- newHref = (hrefSplit.length > 1)?newHref+my.menuSeparator+hrefSplit[1]:newHref;
555
- history.pushState(null, null, newHref);
556
- }
557
-
558
- myOwn.offlineModeRefresh = function offlineModeRefresh(){
559
- var my=this;
560
- /** @type {HTMLImageElement} */
561
- // @ts-ignore
562
- var imgLight = document.getElementById('light-airplane');
563
- if (imgLight != null) {
564
- var skin=((my.config||{}).config||{}).skin;
565
- if(my.offline.mode){
566
- imgLight.src=my.path.img+'airplane-on.png';
567
- }else{
568
- imgLight.src=my.path.img+'airplane-off.png';
569
- }
570
- }
571
- }
572
-
573
- myOwn.changeOfflineMode = function changeOfflineMode(){
574
- my.offline.mode=!my.offline.mode;
575
- my.offlineModeRefresh();
576
- my.setOnlineOfflineUrl();
577
- if(my.offline.mode){
578
- var fkToStoreData = [];
579
- var promiseArray1 = [];
580
- var promiseChain = my.ldb.getAllStructures().then(function(tablesDef){
581
- tablesDef.forEach(function(tableDef){
582
- promiseArray1.push(
583
- my.ldb.isEmpty(tableDef.name).then(function(isEmpty){
584
- if(!isEmpty){
585
- var fkToStoreSearch = tableDef.foreignKeys.filter(function(fk){
586
- return fk.fields.find(function(field){
587
- return !tableDef.primaryKey.includes(field.source)
588
- })
589
- });
590
- fkToStoreData = fkToStoreData.concat(fkToStoreSearch);
591
- }
592
- })
593
- );
594
- });
595
- });
596
- var promiseArray2 = [];
597
- promiseChain = promiseChain.then(function(){
598
- return Promise.all(promiseArray1).then(function(){
599
- return fkToStoreData.forEach(function(fk){
600
- var conn = new my.TableConnector({tableName: fk.references, my:my});
601
- var opts = { registerInLocalDB: false };
602
- conn.getStructure(opts)
603
- promiseArray2.push(
604
- Promise.resolve().then(function(){
605
- return conn.getData().then(function(rows){
606
- return my.ldb.putMany(fk.references, rows)
607
- })
608
- })
609
- );
610
- });
611
- });
612
- });
613
- promiseChain = promiseChain.then(function(){
614
- Promise.all(promiseArray2).then(function(){
615
- location.reload();
616
- })
617
- });
618
- }else{
619
- my.showPage();
620
- location.reload();
621
- }
622
- }
623
-
624
534
  window.addEventListener('popstate', function(){
625
535
  if(!my.config){
626
536
  my.autoSetup().then(function(){
627
- my.setOnlineOfflineUrl();
628
537
  my.showPage();
629
538
  })
630
539
  }else{
@@ -635,13 +544,9 @@ window.addEventListener('popstate', function(){
635
544
  window.addEventListener('load', function(){
636
545
  window.my = myOwn;
637
546
  my.autoSetup().then(function(){
638
- my.setOnlineOfflineUrl();
639
547
  my.showPage();
640
548
  })
641
549
  document.body.appendChild(html.div({id:'cached-images'},[
642
- html.img({src:my.path.img+'airplane-on.png'}),
643
- html.img({src:my.path.img+'airplane-off.png'}),
644
- html.img({src:my.path.img+'airplane.png'}),
645
550
  html.img({src:my.path.img+'server.png'}),
646
551
  html.img({src:my.path.img+'network-signal.png'}),
647
552
  html.img({src:my.path.img+'server-error.png'}),
@@ -367,6 +367,7 @@ export interface OptsClientPage {
367
367
  extraFiles?:ClientModuleDefinition[]
368
368
  icon?:string
369
369
  icons?:Record<string,string>
370
+ baseUrlForRelativePaths?:boolean
370
371
  }
371
372
 
372
373
  export type DumpOptions={complete?:boolean, skipEnance?:boolean, disableDBFunctions?:boolean}
@@ -479,6 +480,7 @@ export interface AppConfig {
479
480
  delay: number // msec avg random delay in API responses (to emulate slow nets)
480
481
  "cache-content": boolean // if the cache header must be sent to the client (when no devel config the default is true)
481
482
  forceShowAsEditable: boolean // force "editable" behavior in grids
483
+ "tests-can-delete-db": boolean
482
484
  }
483
485
  mailer: { // config to send mails
484
486
  conn: string // connection string
@@ -2240,11 +2240,13 @@ AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
2240
2240
  if(offlineMode){
2241
2241
  cssList.push('css/offline-mode.css');
2242
2242
  }
2243
+ cssList = cssList.concat((opts.extraFiles ?? []).filter((extraFile)=>extraFile.type == 'css').map((extraFile)=>extraFile.file));
2243
2244
  return html.html(attr,[
2244
2245
  html.head([
2245
2246
  html.title(be.config["client-setup"]?.title),
2246
2247
  html.meta({charset:"utf-8"}),
2247
2248
  viewportAttrs?html.meta(viewportAttrs):null,
2249
+ opts.baseUrlForRelativePaths?html.base({href:`${be.config.server["base-url"]}/`}):null,
2248
2250
  html.link({href: opts.icons.iconShortcut , rel: "shortcut icon", type: "image/png"}),
2249
2251
  html.link({href: opts.icons.icon , rel: "icon", type: "image/png"}),
2250
2252
  html.link({href: opts.icons.iconApple , rel: "apple-touch-icon"}),
@@ -2268,7 +2270,9 @@ AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
2268
2270
  html.div(be.messages.unlogged.loading),
2269
2271
  req.useragent.os=='iOS'&&req.useragent.version.split('.')[0]<9?html.div(`La versión del dispositivo ${req.useragent.version} no es compatible`):null
2270
2272
  ]),
2271
- html.div({id: "total-scripts"}, be.clientModules(req,opts).scripts.map(function(scriptDef){
2273
+ html.div({id: "total-scripts"}, be.clientModules(req,opts).scripts.concat(
2274
+ (opts?.extraFiles ?? []).filter((extraFile)=>be.esJavascript(extraFile.type)).map((extraFile)=>({...extraFile,type:null}))
2275
+ ).map(function(scriptDef){
2272
2276
  return html.script(scriptDef);
2273
2277
  }).concat([html.script({src:'client/menu.js'})]))
2274
2278
  ]),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.0.9",
4
+ "version": "2.1.2",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",
@@ -527,7 +527,9 @@ function containsObjectsWithTheSameColumns(o){
527
527
  if (!keys.length) return false;
528
528
  var separator = Math.random();
529
529
  var colNamesFirstObject = Object.keys(o[keys[0]]).join(separator);
530
- return !keys.find(k => o[k] == null || !(o[k] instanceof Object) || Object.keys(o[k]).join(separator) != colNamesFirstObject);
530
+ return !keys.find(k =>
531
+ o[k] == null || !(o[k] instanceof Object) || Object.keys(o[k]).join(separator) != colNamesFirstObject
532
+ );
531
533
  }
532
534
  /* test
533
535
  var cases = [
@@ -550,7 +552,7 @@ function agregar_json(div, o, ubicaciones=agregar_json_default_ubicaciones){
550
552
  return ;
551
553
  }
552
554
  if(typeof o == "object" && !(o instanceof Date) && !o.isRealDateTime){
553
- if((o instanceof Array && o[0] || containsObjectsWithTheSameColumns(o)) && o[0] instanceof Object && !(o[0] instanceof Array) && !(o[0].isRealDateTime)){
555
+ if((o instanceof Array && o[0] && o[0] instanceof Object && !(o[0] instanceof Array) && !(o[0].isRealDateTime) || containsObjectsWithTheSameColumns(o)) ){
554
556
  var table = document.createElement('table');
555
557
  div.appendChild(table);
556
558
  var titleRow = table.insertRow(-1);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file