backend-plus 2.0.0-rc.14 → 2.0.0-rc.16
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/for-client/css/my-menu.styl +4 -0
- package/lib/backend-plus.d.ts +4 -1
- package/lib/backend-plus.js +17 -8
- package/package.json +6 -6
- package/unlogged/my-ajax.js +52 -33
package/lib/backend-plus.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export interface ContextForDump extends Context {
|
|
|
76
76
|
forDump?:boolean
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export type InformProgressFunction=(opts:Error|{data:any}|{start:any}|{message:string}|{message?:string, lengthComputable:boolean, loaded:number, total:number, force?:boolean})=>void
|
|
79
|
+
export type InformProgressFunction=(opts:Error|{data:any}|{start:any}|{message:string}|{idGroup?:string, message?:string, lengthComputable:boolean, loaded:number, total:number, force?:boolean})=>void
|
|
80
80
|
|
|
81
81
|
export interface ProcedureContext extends Context{
|
|
82
82
|
client:Client
|
|
@@ -370,6 +370,9 @@ export interface AppConfigBin { // executable
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
export interface AppConfig {
|
|
373
|
+
package: {
|
|
374
|
+
version: string
|
|
375
|
+
}
|
|
373
376
|
server: {
|
|
374
377
|
"base-url": string // rool path in the url
|
|
375
378
|
port: number // port of the API services
|
package/lib/backend-plus.js
CHANGED
|
@@ -461,7 +461,13 @@ AppBackend.prototype.setStaticConfig = function setStaticConfig(defConfigYamlStr
|
|
|
461
461
|
}
|
|
462
462
|
|
|
463
463
|
AppBackend.prototype.configList = function configList(){
|
|
464
|
-
var list=[
|
|
464
|
+
var list=[
|
|
465
|
+
{
|
|
466
|
+
package:{
|
|
467
|
+
version: packagejson.version
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
this.staticConfig];
|
|
465
471
|
if(!this.staticConfig["client-setup"]?.title && fs.existsSync(this.rootPath+'/def-config.yaml')){
|
|
466
472
|
console.log('DEPRECATED!!!!!!')
|
|
467
473
|
console.error('ERROR el def-config hay que ponerlo dentro de staticConfig');
|
|
@@ -1546,17 +1552,17 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1546
1552
|
});
|
|
1547
1553
|
}else{
|
|
1548
1554
|
if(progressInfo.lengthComputable){
|
|
1549
|
-
if
|
|
1550
|
-
context.lastMessageSended=
|
|
1555
|
+
if (!context.lastMessageSended) {
|
|
1556
|
+
context.lastMessageSended = {}
|
|
1557
|
+
}
|
|
1558
|
+
if(new Date()-(context.lastMessageSended[progressInfo.idGroup]||0) > 500 || progressInfo.force){
|
|
1559
|
+
context.lastMessageSended[progressInfo.idGroup]=new Date();
|
|
1551
1560
|
res.write(JSON.stringify({progress:progressInfo})+"\n");
|
|
1552
1561
|
if(progressInfo.total){
|
|
1553
1562
|
var rate100=Math.floor(progressInfo.loaded*100/progressInfo.total);
|
|
1554
1563
|
var rate1000=Math.floor(progressInfo.loaded*1000/progressInfo.total);
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
}else{
|
|
1558
|
-
progress2send={message:rate100+'%', ephemeral:true};
|
|
1559
|
-
}
|
|
1564
|
+
var message = rate100<1 && progressInfo.loaded>0 ? '('+(rate1000||'½')+'‰)' : rate100+'%';
|
|
1565
|
+
progress2send={message, ephemeral:true, idGroup:progressInfo.idGroup};
|
|
1560
1566
|
}
|
|
1561
1567
|
}else{
|
|
1562
1568
|
progress2send=null;
|
|
@@ -1929,6 +1935,9 @@ AppBackend.prototype.addUnloggedServices = function addUnloggedServices(mainApp,
|
|
|
1929
1935
|
// http://localhost:3033/img/login-logo-icon.png
|
|
1930
1936
|
mainApp.get(Path.posix.join(baseUrl,'/img/login-logo-icon.png'), async function(req,res,next){
|
|
1931
1937
|
var buscar = [
|
|
1938
|
+
'unlogged/img/login-logo-icon.svg',
|
|
1939
|
+
'dist/unlogged/img/login-logo-icon.svg',
|
|
1940
|
+
'dist/client/unlogged/img/login-logo-icon.svg',
|
|
1932
1941
|
'unlogged/img/login-logo-icon.png',
|
|
1933
1942
|
'dist/unlogged/img/login-logo-icon.png',
|
|
1934
1943
|
'dist/client/unlogged/img/login-logo-icon.png',
|
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.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.16",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"js-yaml": "^4.1.0",
|
|
50
50
|
"json4all": "^1.3.0-beta.1",
|
|
51
51
|
"lazy-some": "^0.1.0",
|
|
52
|
-
"like-ar": "^0.4.
|
|
52
|
+
"like-ar": "^0.4.1",
|
|
53
53
|
"login-plus": "^1.7.1",
|
|
54
54
|
"memorystore": "^1.6.7",
|
|
55
55
|
"mini-tools": "^1.12.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"numeral": "^2.0.6",
|
|
60
60
|
"pg-promise-strict": "^1.4.0",
|
|
61
61
|
"pikaday": "^1.8.2",
|
|
62
|
-
"pug": "^3.0.
|
|
62
|
+
"pug": "^3.0.3",
|
|
63
63
|
"read-yaml-promise": "^1.0.2",
|
|
64
64
|
"regexplicit": "^0.1.3",
|
|
65
65
|
"require-bro": "^0.3.1",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/js-yaml": "^4.0.9",
|
|
83
83
|
"@types/mocha": "^10.0.6",
|
|
84
84
|
"@types/multiparty": "~0.0.36",
|
|
85
|
-
"@types/node": "^20.
|
|
85
|
+
"@types/node": "^20.13.0",
|
|
86
86
|
"@types/nodemailer": "^6.4.15",
|
|
87
87
|
"@types/numeral": "~2.0.5",
|
|
88
88
|
"@types/session-file-store": "^1.2.5",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"kill-9": "~0.4.3",
|
|
100
100
|
"mocha": "^10.4.0",
|
|
101
101
|
"nyc": "^15.1.0",
|
|
102
|
-
"puppeteer": "^22.
|
|
103
|
-
"sinon": "^
|
|
102
|
+
"puppeteer": "^22.10.0",
|
|
103
|
+
"sinon": "^18.0.0",
|
|
104
104
|
"supertest": "^7.0.0",
|
|
105
105
|
"types.d.ts": "~0.6.21",
|
|
106
106
|
"typescript": "^5.4.5",
|
package/unlogged/my-ajax.js
CHANGED
|
@@ -193,14 +193,17 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
193
193
|
}
|
|
194
194
|
var result=[];
|
|
195
195
|
var progress=procedureDef.progress!==false;
|
|
196
|
+
/** @type {Record<string,{ divBar, progressBar, progresIndicator, divBarLabel }>} */
|
|
197
|
+
var progressStruct = {}
|
|
196
198
|
var divProgress;
|
|
197
|
-
var divBarProgress;
|
|
198
|
-
var progressBar;
|
|
199
|
-
var progressIndicator;
|
|
200
|
-
var divBarProgressLabel;
|
|
199
|
+
// var divBarProgress = {};
|
|
200
|
+
// var progressBar;
|
|
201
|
+
// var progressIndicator;
|
|
202
|
+
// var divBarProgressLabel = {};
|
|
201
203
|
var onClose=function(){}
|
|
202
204
|
var defaultInformProgress = function defaultInformProgress(progressInfo){
|
|
203
205
|
if(progressInfo.message || progressInfo.end || progressInfo.start || progressInfo.loaded){
|
|
206
|
+
// progressInfo.idGroup
|
|
204
207
|
if(!divProgress){
|
|
205
208
|
var idAutoClose='id-auto-close-'+Math.random();
|
|
206
209
|
var checkAutoClose=html.input({type:'checkbox', id:idAutoClose, checked:myAjax.ajaxPromise.autoClose}).create();
|
|
@@ -235,8 +238,12 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
235
238
|
}
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
|
-
if(progressInfo.
|
|
239
|
-
|
|
241
|
+
if (progressStruct[progressInfo.idGroup] == null) {
|
|
242
|
+
progressStruct[progressInfo.idGroup] = {}
|
|
243
|
+
}
|
|
244
|
+
var ps = progressStruct[progressInfo.idGroup];
|
|
245
|
+
if(progressInfo.ephemeral && ps.divBarLabel){
|
|
246
|
+
ps.divBarLabel.textContent = progressInfo.message;
|
|
240
247
|
}else if(progressInfo.message || progressInfo.end){
|
|
241
248
|
var now=bestGlobals.datetime.now();
|
|
242
249
|
var elapsed = now.sub(tickTime);
|
|
@@ -265,23 +272,23 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
265
272
|
);
|
|
266
273
|
}
|
|
267
274
|
}
|
|
268
|
-
if(progressInfo.loaded){
|
|
269
|
-
if(!
|
|
270
|
-
|
|
271
|
-
progressIndicator=html.div({class:'indicator'},' ').create();
|
|
272
|
-
progressBar=html.div({class:'progress-bar', style:'width:400px; height:8px;'},[progressIndicator]).create();
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
progressBar
|
|
275
|
+
if(progressInfo.loaded != null){
|
|
276
|
+
if(!ps.divBar){
|
|
277
|
+
ps.divBarLabel = html.div().create();
|
|
278
|
+
ps.progressIndicator=html.div({class:'indicator'},' ').create();
|
|
279
|
+
ps.progressBar=html.div({class:'progress-bar', style:'width:400px; height:8px;'},[ps.progressIndicator]).create();
|
|
280
|
+
ps.divBar = html.div([
|
|
281
|
+
ps.divBarLabel,
|
|
282
|
+
ps.progressBar
|
|
276
283
|
]).create();
|
|
277
|
-
divProgress.parentNode.insertBefore(
|
|
284
|
+
divProgress.parentNode.insertBefore(ps.divBar, divProgress);
|
|
278
285
|
}
|
|
279
286
|
if(progressInfo.lengthComputable){
|
|
280
|
-
progressIndicator.style.width=progressInfo.loaded*100/progressInfo.total+'%';
|
|
281
|
-
progressIndicator.title=Math.round(progressInfo.loaded*100/progressInfo.total)+'%';
|
|
287
|
+
ps.progressIndicator.style.width=progressInfo.loaded*100/progressInfo.total+'%';
|
|
288
|
+
ps.progressIndicator.title=Math.round(progressInfo.loaded*100/progressInfo.total)+'%';
|
|
282
289
|
}else{
|
|
283
|
-
progressIndicator.style.backgroundColor='#D4D';
|
|
284
|
-
progressIndicator.title='N/D %';
|
|
290
|
+
ps.progressIndicator.style.backgroundColor='#D4D';
|
|
291
|
+
ps.progressIndicator.title='N/D %';
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
}
|
|
@@ -304,7 +311,6 @@ myAjax.ajaxPromise = function ajaxPromise(procedureDef,data,opts){
|
|
|
304
311
|
}
|
|
305
312
|
var controlLoggedIn = function controlLoggedIn(result, informNotLoggedIn){
|
|
306
313
|
if(informNotLoggedIn || result && result[0]=="<" && result.match(/login/m)){
|
|
307
|
-
console.log('xxxxxxxxxxx',procedureDef.action)
|
|
308
314
|
my.informDetectedStatus('notLogged');
|
|
309
315
|
throw bestGlobals.changing(new Error(my.messages.notLogged),{displayed:true, isNotLoggedError:true});
|
|
310
316
|
}
|
|
@@ -495,13 +501,27 @@ function agregar_json_default_ubicaciones(div, o, a){
|
|
|
495
501
|
var table = div2.laTabla;
|
|
496
502
|
var row = table.insertRow(-1);
|
|
497
503
|
var cellName = row.insertCell(-1);
|
|
498
|
-
cellName
|
|
499
|
-
cellName.textContent = a;
|
|
504
|
+
agregar_class_textInDiv(cellName, 'attr-name', a)
|
|
500
505
|
var cell = row.insertCell(-1);
|
|
501
506
|
cell.colSpan=99;
|
|
502
507
|
return {title:cellName, data:cell, skip:o[a] == null}
|
|
503
508
|
}
|
|
504
509
|
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* @param {HTMLTableDataElement} td
|
|
513
|
+
* @param {string|number} text
|
|
514
|
+
* @param {string} className
|
|
515
|
+
*/
|
|
516
|
+
function agregar_class_textInDiv(td, className, text){
|
|
517
|
+
var div = document.createElement('div');
|
|
518
|
+
td.className = className;
|
|
519
|
+
div.className = 'json-container';
|
|
520
|
+
div.textContent = text;
|
|
521
|
+
td.innerHTML = '';
|
|
522
|
+
td.appendChild(div);
|
|
523
|
+
}
|
|
524
|
+
|
|
505
525
|
/**
|
|
506
526
|
*
|
|
507
527
|
* @param {HTMLElement} div
|
|
@@ -524,9 +544,7 @@ function agregar_json(div, o, ubicaciones=agregar_json_default_ubicaciones){
|
|
|
524
544
|
if(o[a]!=null){
|
|
525
545
|
var row = table.insertRow(-1);
|
|
526
546
|
var cellName = row.insertCell(-1);
|
|
527
|
-
cellName
|
|
528
|
-
// @ts-ignore numero y texto
|
|
529
|
-
cellName.textContent = isNaN(a)?a:Number(a)+1;
|
|
547
|
+
agregar_class_textInDiv(cellName, 'row-num', isNaN(a)?a:Number(a)+1);
|
|
530
548
|
agregar_json(row, o[a], function(div, _o, a){
|
|
531
549
|
// @ts-ignore sé que es Row
|
|
532
550
|
/** @type {HTMLTableRowElement} */
|
|
@@ -554,11 +572,9 @@ function agregar_json(div, o, ubicaciones=agregar_json_default_ubicaciones){
|
|
|
554
572
|
if(!cells.skip){
|
|
555
573
|
if(cells.title){
|
|
556
574
|
if(o instanceof Array && !isNaN(a)){
|
|
557
|
-
cells.title
|
|
558
|
-
cells.title.textContent = Number(a) + 1;
|
|
575
|
+
agregar_class_textInDiv(cells.title, 'row-num', Number(a) + 1);
|
|
559
576
|
}else{
|
|
560
|
-
cells.title
|
|
561
|
-
cells.title.textContent = a;
|
|
577
|
+
agregar_class_textInDiv(cells.title, 'attr-name', a);
|
|
562
578
|
}
|
|
563
579
|
}
|
|
564
580
|
agregar_json(cells.data, o[a]);
|
|
@@ -566,13 +582,16 @@ function agregar_json(div, o, ubicaciones=agregar_json_default_ubicaciones){
|
|
|
566
582
|
}
|
|
567
583
|
}
|
|
568
584
|
}else{
|
|
569
|
-
|
|
585
|
+
var textContent;
|
|
570
586
|
if(typeof o == "boolean"){
|
|
571
|
-
|
|
587
|
+
textContent = o ? 'Sí' : 'No'
|
|
572
588
|
}else if(o && o instanceof Date && o.isRealDate){
|
|
573
|
-
|
|
589
|
+
textContent = o.toDmy();
|
|
574
590
|
}else{
|
|
575
|
-
|
|
591
|
+
textContent = o.toLocaleString();
|
|
592
|
+
}
|
|
593
|
+
if (textContent) {
|
|
594
|
+
agregar_class_textInDiv(div, 'plain-content', textContent)
|
|
576
595
|
}
|
|
577
596
|
}
|
|
578
597
|
}
|