backend-plus 2.0.0-beta.1 → 2.0.0-beta.11
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/my-menu.js +1 -1
- package/for-client/my-tables.js +95 -40
- package/for-client/my-things.js +3 -2
- package/lib/backend-plus.d.ts +5 -2
- package/lib/backend-plus.js +18 -9
- package/lib/procedures-table.js +22 -0
- package/lib/table-def-adapt.js +1 -1
- package/lib/tables/table-bitacora.js +3 -1
- package/lib/tables/table-locks.js +1 -0
- package/lib/tables/table-summary.js +2 -0
- package/lib/tables/table-tokens.js +3 -1
- package/package.json +21 -21
package/for-client/my-menu.js
CHANGED
|
@@ -67,7 +67,7 @@ myOwn.wScreens.table = function(addrParams){
|
|
|
67
67
|
myOwn.wScreens.procAux = {
|
|
68
68
|
showParams:function(formDef, main_layout, addrParams, mainAction){
|
|
69
69
|
var autoproced = addrParams.autoproced || false
|
|
70
|
-
addrParams.up=addrParams.up||{};
|
|
70
|
+
addrParams.up=addrParams.up||addrParams.ff||{};
|
|
71
71
|
var params=addrParams.up;
|
|
72
72
|
// var button = html.button(formDef.proceedLabel||my.messages.proceed).create();
|
|
73
73
|
var label = formDef.proceedLabel||my.messages.proceed;
|
package/for-client/my-tables.js
CHANGED
|
@@ -284,6 +284,8 @@ myOwn.getStructuresToRegisterInLdb = function getStructuresToRegisterInLdb(paren
|
|
|
284
284
|
return promiseChain;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
myOwn.skipInFixedFields = Symbol("skipInFixedFields");
|
|
288
|
+
|
|
287
289
|
myOwn.TableConnector = function(context, opts){
|
|
288
290
|
var connector = this;
|
|
289
291
|
for(var attr in context){
|
|
@@ -292,9 +294,13 @@ myOwn.TableConnector = function(context, opts){
|
|
|
292
294
|
connector.opts = opts||{};
|
|
293
295
|
connector.fixedFields = connector.opts.fixedFields || [];
|
|
294
296
|
connector.fixedField = {};
|
|
297
|
+
connector.hideBecauseRelated = {};
|
|
295
298
|
connector.fixedFields.forEach(function(pair){
|
|
296
|
-
if(!pair.range){
|
|
299
|
+
if(!pair.range && pair.value != myOwn.skipInFixedFields){
|
|
297
300
|
connector.fixedField[pair.fieldName] = pair.value;
|
|
301
|
+
if (!pair.show) {
|
|
302
|
+
connector.hideBecauseRelated[pair.fieldName] = true;
|
|
303
|
+
}
|
|
298
304
|
}
|
|
299
305
|
});
|
|
300
306
|
connector.parameterFunctions=connector.opts.parameterFunctions||{};
|
|
@@ -441,9 +447,13 @@ myOwn.TableConnectorLocal = function(context, opts){
|
|
|
441
447
|
connector.opts = opts||{};
|
|
442
448
|
connector.fixedFields = connector.opts.fixedFields || [];
|
|
443
449
|
connector.fixedField = {};
|
|
450
|
+
connector.hideBecauseRelated = {};
|
|
444
451
|
connector.fixedFields.forEach(function(pair){
|
|
445
|
-
if(!pair.range){
|
|
452
|
+
if(!pair.range && pair.value != myOwn.skipInFixedFields){
|
|
446
453
|
connector.fixedField[pair.fieldName] = pair.value;
|
|
454
|
+
if (!pair.show) {
|
|
455
|
+
connector.hideBecauseRelated[pair.fieldName] = true;
|
|
456
|
+
}
|
|
447
457
|
}
|
|
448
458
|
});
|
|
449
459
|
connector.parameterFunctions=connector.opts.parameterFunctions||{};
|
|
@@ -573,7 +583,6 @@ myOwn.setTimeStamp = function setTimeStamp(row){
|
|
|
573
583
|
|
|
574
584
|
myOwn.skipTimeStamp = function skipTimeStamp(row, timeStamp){
|
|
575
585
|
var skip = (row[TIME_STAMP_PROP] || 0) > timeStamp;
|
|
576
|
-
console.log(skip ? 'SKIP' : 'PASS', timeStamp, row[TIME_STAMP_PROP], JSON4all.toUrl(row))
|
|
577
586
|
if (!skip) row[TIME_STAMP_PROP] = timeStamp;
|
|
578
587
|
return skip;
|
|
579
588
|
}
|
|
@@ -601,9 +610,9 @@ myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
|
|
|
601
610
|
}
|
|
602
611
|
})
|
|
603
612
|
}
|
|
604
|
-
grid.refreshAllRows = function(){
|
|
613
|
+
grid.refreshAllRows = async function(force){
|
|
605
614
|
var timeStamp = new Date().getTime();
|
|
606
|
-
grid.connector.my.ajax.table_data({
|
|
615
|
+
await grid.connector.my.ajax.table_data({
|
|
607
616
|
table:grid.connector.tableName,
|
|
608
617
|
fixedFields:grid.connector.fixedFields,
|
|
609
618
|
paramfun:grid.connector.parameterFunctions||{}
|
|
@@ -623,8 +632,43 @@ myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
|
|
|
623
632
|
var primaryKeyValuesForDepotRow = getPrimaryKeyValues(primaryKey, depot.row);
|
|
624
633
|
return sameValue(JSON.stringify(primaryKeyValuesForRow),JSON.stringify(primaryKeyValuesForDepotRow))
|
|
625
634
|
});
|
|
635
|
+
if (!depot) {
|
|
636
|
+
var depot = grid.createDepotFromRow(row);
|
|
637
|
+
var needToAddInGrid = true;
|
|
638
|
+
}
|
|
639
|
+
var needToDisplayDepot = !!grid.filterDepots([depot])[0];
|
|
640
|
+
if (!needToDisplayDepot) return;
|
|
626
641
|
//chequeo que exista depot por las dudas
|
|
627
|
-
if (depot) {
|
|
642
|
+
if ((!depot || !depot.tr || !depot.tr.parentNode) && !thereIsANewRecord && !grid.vertical) {
|
|
643
|
+
var depotsToDisplay = grid.filterDepots(grid.depots);
|
|
644
|
+
if (needToAddInGrid) {
|
|
645
|
+
var depot = grid.createDepotFromRow(row);
|
|
646
|
+
grid.depots.push(depot);
|
|
647
|
+
var depotsToDisplay = grid.filterDepots(grid.depots);
|
|
648
|
+
grid.sortDepotsToDisplay(depotsToDisplay);
|
|
649
|
+
} else if (depot.tr && !depot.tr.parentNode) {
|
|
650
|
+
depot.tr = null
|
|
651
|
+
}
|
|
652
|
+
var iRow = -1;
|
|
653
|
+
var i = 0;
|
|
654
|
+
while (i < depotsToDisplay.length){
|
|
655
|
+
var aDepot = depotsToDisplay[i];
|
|
656
|
+
if (depot == aDepot) break;
|
|
657
|
+
if (aDepot && aDepot.tr && aDepot.tr.parentNode && aDepot.tr.rowIndex != null) {
|
|
658
|
+
iRow = aDepot.tr.sectionRowIndex
|
|
659
|
+
}
|
|
660
|
+
i++;
|
|
661
|
+
}
|
|
662
|
+
grid.createRowElements(iRow + 1, depot);
|
|
663
|
+
grid.updateRowData(depot);
|
|
664
|
+
depot.tick = tick
|
|
665
|
+
if (!force) {
|
|
666
|
+
changeIoStatus(depot,'background-change', depot.row);
|
|
667
|
+
setTimeout(function(){
|
|
668
|
+
changeIoStatus(depot,'ok', depot.row);
|
|
669
|
+
},3000);
|
|
670
|
+
}
|
|
671
|
+
} else if (depot) {
|
|
628
672
|
if (!sameValue(JSON.stringify(row),JSON.stringify(depot.row))) {
|
|
629
673
|
//grid.retrieveRowAndRefresh(depot);
|
|
630
674
|
if(depot.tr){
|
|
@@ -632,31 +676,21 @@ myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
|
|
|
632
676
|
}
|
|
633
677
|
}
|
|
634
678
|
depot.tick = tick
|
|
635
|
-
} else if (!depot && !thereIsANewRecord && !grid.vertical) {
|
|
636
|
-
var depot = grid.createDepotFromRow(row);
|
|
637
|
-
grid.depots.push(depot);
|
|
638
|
-
grid.sortDepotsToDisplay(grid.depots);
|
|
639
|
-
grid.createRowElements(grid.depots.findIndex((myDepot)=>myDepot===depot), depot);
|
|
640
|
-
grid.updateRowData(depot);
|
|
641
|
-
depot.tick = tick
|
|
642
|
-
changeIoStatus(depot,'background-change', depot.row);
|
|
643
|
-
setTimeout(function(){
|
|
644
|
-
changeIoStatus(depot,'ok', depot.row);
|
|
645
|
-
},3000);
|
|
646
679
|
}
|
|
647
680
|
})
|
|
648
681
|
if(!thereIsANewRecord){
|
|
649
682
|
var i = 0;
|
|
650
|
-
var
|
|
683
|
+
var depotsToDisplay = grid.filterDepots(grid.depots);
|
|
684
|
+
var depotsToDelete = depotsToDisplay.filter(depot => depot.tick != tick);
|
|
651
685
|
var depot;
|
|
652
|
-
if (myOwn.config.config['grid-row-retain-moved-or-deleted']) {
|
|
686
|
+
if (myOwn.config.config['grid-row-retain-moved-or-deleted'] && !force) {
|
|
653
687
|
var depotsToRetain = grid.depots.filter(depot => depot.tick == tick);
|
|
654
688
|
for (depot of depotsToRetain) {
|
|
655
|
-
if (depot.tr.getAttribute('not-here')) depot.tr.removeAttribute('not-here')
|
|
689
|
+
if (depot.tr && depot.tr.getAttribute('not-here')) depot.tr.removeAttribute('not-here')
|
|
656
690
|
}
|
|
657
691
|
}
|
|
658
692
|
while (depot = depotsToDelete.pop()) {
|
|
659
|
-
depot.manager.displayAsDeleted(depot, 'unknown');
|
|
693
|
+
depot.manager.displayAsDeleted(depot, force ? 'change-ff' : 'unknown');
|
|
660
694
|
}
|
|
661
695
|
}
|
|
662
696
|
})
|
|
@@ -904,11 +938,11 @@ myOwn.DataColumnGrid.prototype.cellAttributes = function cellAttributes(specific
|
|
|
904
938
|
attr["my-mandatory"]="normal";
|
|
905
939
|
}
|
|
906
940
|
}
|
|
907
|
-
if(grid.connector.
|
|
941
|
+
if(grid.connector.hideBecauseRelated[fieldDef.name] && !fieldDef.alwaysShow){
|
|
908
942
|
attr["inherited-pk-column"]="yes";
|
|
909
943
|
}
|
|
910
944
|
if(fieldDef.referencesField){
|
|
911
|
-
if(grid.connector.
|
|
945
|
+
if(grid.connector.hideBecauseRelated[fieldDef.referencesField] && !fieldDef.alwaysShow){
|
|
912
946
|
attr["inherited-pk-column"]="yes";
|
|
913
947
|
}
|
|
914
948
|
if(grid.def.field[fieldDef.referencesField].isPk){
|
|
@@ -1140,9 +1174,13 @@ myOwn.DetailColumnGrid.prototype.td = function td(depot, iColumn, tr){
|
|
|
1140
1174
|
alt:'DETAIL',
|
|
1141
1175
|
title:detailTableDef.label||my.messages.details
|
|
1142
1176
|
}).create();
|
|
1143
|
-
var menuRef=
|
|
1177
|
+
var menuRef = detailTableDef.table ? {table:detailTableDef.table} : {w:detailTableDef.wScreen, autoproced:true};
|
|
1144
1178
|
var calculateFixedFields = function(){
|
|
1145
|
-
return detailTableDef.fields
|
|
1179
|
+
return detailTableDef.fields
|
|
1180
|
+
.filter(function(pair){
|
|
1181
|
+
return !pair.nullMeansAll || depot.row[pair.source] != null;
|
|
1182
|
+
})
|
|
1183
|
+
.map(function(pair){
|
|
1146
1184
|
var fieldCondition={fieldName: pair.target, value:'value' in pair ? pair.value : depot.row[pair.source]}
|
|
1147
1185
|
if(pair.range){
|
|
1148
1186
|
fieldCondition.range=pair.range;
|
|
@@ -1225,9 +1263,17 @@ myOwn.DetailColumnGrid.prototype.td = function td(depot, iColumn, tr){
|
|
|
1225
1263
|
g.dom.main.addEventListener('deletedRowOk', refresh);
|
|
1226
1264
|
g.dom.main.addEventListener('savedRowOk', refresh);
|
|
1227
1265
|
}
|
|
1228
|
-
detailControl.refreshAllRowsInGrid=function(){
|
|
1229
|
-
if(detailTableDef.refreshFromParent){
|
|
1230
|
-
|
|
1266
|
+
detailControl.refreshAllRowsInGrid=function(force){
|
|
1267
|
+
if(detailTableDef.refreshFromParent || force){
|
|
1268
|
+
if (force) {
|
|
1269
|
+
g.dom.main.style.opacity=0.5;
|
|
1270
|
+
fixedFields = calculateFixedFields()
|
|
1271
|
+
g.connector.fixedFields = fixedFields
|
|
1272
|
+
}
|
|
1273
|
+
setTimeout(async ()=>{
|
|
1274
|
+
await g.refreshAllRows(force);
|
|
1275
|
+
g.dom.main.style.opacity=1;
|
|
1276
|
+
},1)
|
|
1231
1277
|
}
|
|
1232
1278
|
}
|
|
1233
1279
|
return g;
|
|
@@ -2195,7 +2241,7 @@ myOwn.TableGrid.prototype.createRowInsertElements = function createRowInsertElem
|
|
|
2195
2241
|
}
|
|
2196
2242
|
var depotForInsert = grid.createDepotFromRow({$allow:{delete:true, update:true}}, 'new');
|
|
2197
2243
|
grid.connector.fixedFields.forEach(function(pair){
|
|
2198
|
-
if(!pair.range){
|
|
2244
|
+
if(!pair.range && grid.def.field[pair.fieldName].inTable !== false){
|
|
2199
2245
|
depotForInsert.row[pair.fieldName] = pair.value;
|
|
2200
2246
|
depotForInsert.rowPendingForUpdate[pair.fieldName] = pair.value;
|
|
2201
2247
|
}
|
|
@@ -2576,18 +2622,19 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2576
2622
|
}
|
|
2577
2623
|
return depot;
|
|
2578
2624
|
};
|
|
2579
|
-
grid.
|
|
2625
|
+
grid.filterDepots = function filterDepots(depotsToFilter){
|
|
2580
2626
|
var grid = this;
|
|
2581
|
-
var depotsToDisplay;
|
|
2582
2627
|
var filterRows = grid.view.filter;
|
|
2628
|
+
var depotsToDisplay;
|
|
2583
2629
|
if(filterRows && filterRows.length){
|
|
2584
|
-
depotsToDisplay =
|
|
2630
|
+
depotsToDisplay = depotsToFilter.filter(function(depot,i){
|
|
2585
2631
|
var iFilter=0;
|
|
2586
2632
|
while(iFilter<filterRows.length){
|
|
2587
2633
|
var filterData=filterRows[iFilter];
|
|
2588
2634
|
var partialOk=true;
|
|
2589
2635
|
var columnsCompared = 0;
|
|
2590
2636
|
for(var column in depot.row){
|
|
2637
|
+
// var compSymb = filterData.rowSymbols && filterData.rowSymbols[column] || filterData[column].operator;
|
|
2591
2638
|
var compSymb = filterData.rowSymbols[column];
|
|
2592
2639
|
if(compSymb && my.comparator[compSymb] && (my.comparatorParameterNull[compSymb] || filterData.row[column] != null)){
|
|
2593
2640
|
var isSatisfied=my.comparator[compSymb](depot.row[column],filterData.row[column]);
|
|
@@ -2605,8 +2652,13 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2605
2652
|
return false;
|
|
2606
2653
|
});
|
|
2607
2654
|
}else{
|
|
2608
|
-
depotsToDisplay =
|
|
2655
|
+
depotsToDisplay = depotsToFilter;
|
|
2609
2656
|
}
|
|
2657
|
+
return depotsToDisplay;
|
|
2658
|
+
}
|
|
2659
|
+
grid.displayBody=function displayBody(){
|
|
2660
|
+
var grid = this;
|
|
2661
|
+
var depotsToDisplay = grid.filterDepots(grid.depots);
|
|
2610
2662
|
grid.sortDepotsToDisplay = function sortDepotsToDisplay(depotsToDisplay){
|
|
2611
2663
|
if(grid.view.sortColumns.length>0){
|
|
2612
2664
|
return depotsToDisplay.sort(function(depot1, depot2){
|
|
@@ -2701,10 +2753,11 @@ myOwn.TableGrid.prototype.displayGrid = function displayGrid(){
|
|
|
2701
2753
|
|
|
2702
2754
|
myOwn.TableGrid.prototype.displayAsDeleted = function displayAsDeleted(depot, mode){
|
|
2703
2755
|
var grid = this;
|
|
2756
|
+
var fast = mode == 'change-ff'
|
|
2704
2757
|
if (mode == 'unknown' && myOwn.config.config['grid-row-retain-moved-or-deleted']) {
|
|
2705
2758
|
depot.tr.setAttribute('not-here', 'yes');
|
|
2706
2759
|
} else {
|
|
2707
|
-
var position = Math.min(grid.depots.length,Math.max(0,depot.tr.sectionRowIndex));
|
|
2760
|
+
var position = depot.tr ? Math.min(grid.depots.length,Math.max(0,depot.tr.sectionRowIndex)) : 0;
|
|
2708
2761
|
if(grid.depots[position] !== depot){
|
|
2709
2762
|
position = grid.depots.indexOf(depot);
|
|
2710
2763
|
}
|
|
@@ -2729,12 +2782,14 @@ myOwn.TableGrid.prototype.displayAsDeleted = function displayAsDeleted(depot, mo
|
|
|
2729
2782
|
depots[j-1].colNumber = j;
|
|
2730
2783
|
}
|
|
2731
2784
|
}else{
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2785
|
+
if(depot.tr){
|
|
2786
|
+
depot.my.fade(depot.tr, {fast});
|
|
2787
|
+
for(var detailControl in depot.detailControls){
|
|
2788
|
+
if(depot.detailControls[detailControl].tr){
|
|
2789
|
+
depot.my.fade(depot.detailControls[detailControl].tr, {fast});
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2738
2793
|
}
|
|
2739
2794
|
}
|
|
2740
2795
|
grid.updateTotals(grid.depots.length?1:0, grid.depots.length);
|
package/for-client/my-things.js
CHANGED
|
@@ -252,11 +252,12 @@ myOwn.log = function log(severity, message){
|
|
|
252
252
|
};
|
|
253
253
|
|
|
254
254
|
myOwn.fade = function fade(element, options){
|
|
255
|
-
|
|
255
|
+
options=options||{};
|
|
256
|
+
if (!element.parentNode) return
|
|
257
|
+
if(element.tagName.toUpperCase()==='TR' && element.parentNode.replaceChild && !options.fast){
|
|
256
258
|
var parent=element.parentNode;
|
|
257
259
|
var dummyTr=document.createElement(element.tagName);
|
|
258
260
|
dummyTr.className=element.className;
|
|
259
|
-
options=options||{};
|
|
260
261
|
options.smooth=options.smooth||{};
|
|
261
262
|
var spans=options.smooth.spans;
|
|
262
263
|
var sourceRow;
|
package/lib/backend-plus.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export type MenuInfoMenu = {
|
|
|
120
120
|
export type MenuInfoTable = {
|
|
121
121
|
menuType:'table'
|
|
122
122
|
table?:string
|
|
123
|
-
ff?:{fieldName:string, value:any}[]
|
|
123
|
+
ff?:{fieldName:string, value:any, show?:boolean}[]
|
|
124
124
|
fc?:{fieldName:string, operator:string, value:any}[]
|
|
125
125
|
pf?:any
|
|
126
126
|
td?:TableDefinition
|
|
@@ -211,6 +211,7 @@ export type FieldDefinition = EditableDbDefinition & {
|
|
|
211
211
|
table?:string
|
|
212
212
|
inherited?:boolean
|
|
213
213
|
nameForUpsert?:string
|
|
214
|
+
alwaysShow?:boolean /* show when appears in fixed fields */
|
|
214
215
|
} & ({} | {
|
|
215
216
|
sequence:SequenceDefinition
|
|
216
217
|
nullable:true
|
|
@@ -230,7 +231,7 @@ export type EditableDbDefinition = {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
export type FieldsForConnect = (string | {source:string, target:string})[]
|
|
233
|
-
export type FieldsForConnectDetailTable = (string | {source:string, target:string} | {value:any, target:string})[]
|
|
234
|
+
export type FieldsForConnectDetailTable = (string | {source:string, target:string, nullMeansAll?:boolean} | {value:any, target:string})[]
|
|
234
235
|
|
|
235
236
|
export type FkActions = 'no action'|'restrict'|'cascade'|'set null'|'set default';
|
|
236
237
|
export type ForeignKey = {
|
|
@@ -418,6 +419,8 @@ export class AppBackend{
|
|
|
418
419
|
i18n:{
|
|
419
420
|
messages:Record<LangId,Record<string, string>>
|
|
420
421
|
}
|
|
422
|
+
shootDownBackend():Promise<void>
|
|
423
|
+
setLog(opts:{until:string, results?:boolean})
|
|
421
424
|
}
|
|
422
425
|
|
|
423
426
|
}
|
package/lib/backend-plus.js
CHANGED
|
@@ -235,7 +235,8 @@ AppBackend.prototype.i18n.messages.en={
|
|
|
235
235
|
fileUploaded:'file uploaded',
|
|
236
236
|
unkownExt:'unkown file extension'
|
|
237
237
|
},
|
|
238
|
-
server:{
|
|
238
|
+
server:{
|
|
239
|
+
backupNotAvailable: 'Backup not available',
|
|
239
240
|
cantDelete_TLDR:'Can\'t delete. May be rights problems, locked records or internal problems',
|
|
240
241
|
cantInsert_TLDR:'Can\'t insert. May be rights problems, locked records or internal problems',
|
|
241
242
|
cantUpdate_TLDR:'Can\'t update. May be rights problems, locked records or internal problems',
|
|
@@ -314,6 +315,7 @@ AppBackend.prototype.i18n.messages.es={
|
|
|
314
315
|
unkownExt:'extensión de archivo desconocida'
|
|
315
316
|
},
|
|
316
317
|
server:{
|
|
318
|
+
backupNotAvailable: 'Backup no disponible',
|
|
317
319
|
cantDelete_TLDR:'no se pudo eliminar el registro. Podrían haber problemas de persmisos, bloqueo de registros o problemas internos en la definición de la PK',
|
|
318
320
|
cantInsert_TLDR:'no se pudo insertar el registro. Podrían haber problemas de persmisos, bloqueo de registros o problemas internos en la definición de la PK',
|
|
319
321
|
cantUpdate_TLDR:'no se pudo modificar el registro. Podrían haber problemas de persmisos, bloqueo de registros o problemas internos en la definición de la PK',
|
|
@@ -616,6 +618,7 @@ AppBackend.prototype.start = function start(opts){
|
|
|
616
618
|
console.log('*','express server');
|
|
617
619
|
be.server.close(/** @param {Error} err */function(err){
|
|
618
620
|
if(err){
|
|
621
|
+
console.log('*', err)
|
|
619
622
|
reject(err);
|
|
620
623
|
}else{
|
|
621
624
|
resolve();
|
|
@@ -989,21 +992,20 @@ AppBackend.prototype.start = function start(opts){
|
|
|
989
992
|
done(null,false,{message:be.messages.unlogged.login.userOrPassFail});
|
|
990
993
|
}
|
|
991
994
|
}).then(async function(userInfo){
|
|
995
|
+
if (!userInfo) return;
|
|
992
996
|
if (!be.config.login.skipBitacora) {
|
|
993
997
|
var context = be.getContext(req);
|
|
994
|
-
var sessionInfo = client.query(be.generateInsertSQL(be.config.server.bitacoraSchema, be.config.server.bitacoraTableName,{
|
|
998
|
+
var sessionInfo = await client.query(be.generateInsertSQL(be.config.server.bitacoraSchema, be.config.server.bitacoraTableName,{
|
|
995
999
|
procedure_name: '@login',
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1000
|
+
username,
|
|
1001
|
+
machine_id: context.machineId,
|
|
1002
|
+
navigator: context.navigator,
|
|
1003
|
+
init_date: bestGlobals.datetime.now(),
|
|
1004
|
+
parameters: {}
|
|
1002
1005
|
})).fetchUniqueValue();
|
|
1003
1006
|
userInfo.bitacoraId = sessionInfo.value;
|
|
1004
1007
|
}
|
|
1005
1008
|
done(null, userInfo);
|
|
1006
|
-
return userInfo;
|
|
1007
1009
|
}).then(function(){
|
|
1008
1010
|
client.done();
|
|
1009
1011
|
}).catch(function(err){
|
|
@@ -1233,6 +1235,7 @@ AppBackend.prototype.checkDatabaseStructure = async function checkDatabaseStruct
|
|
|
1233
1235
|
alter table his.bitacora alter column id type bigint;
|
|
1234
1236
|
grant usage on schema his to ${be.config.db.user};
|
|
1235
1237
|
grant select, insert, update on his.bitacora to ${be.config.db.user};
|
|
1238
|
+
alter table his.bitacora alter column parameters_definition drop not null;
|
|
1236
1239
|
`;
|
|
1237
1240
|
throw new Error(message);
|
|
1238
1241
|
}
|
|
@@ -1376,6 +1379,7 @@ AppBackend.prototype.addProcedureServices = function addProcedureServices(forUnl
|
|
|
1376
1379
|
var params={};
|
|
1377
1380
|
procedureDef.parameters.forEach(function(paramDef){
|
|
1378
1381
|
var undecodedValue = req[source][paramDef.name];
|
|
1382
|
+
undecodedValue = paramDef.encoding == 'plain' || undecodedValue === undefined ? undecodedValue : undecodedValue + '';
|
|
1379
1383
|
var value = undecodedValue===undefined?undecodedValue:myOwn.encoders[paramDef.encoding].parse(undecodedValue);
|
|
1380
1384
|
if(undecodedValue===undefined){
|
|
1381
1385
|
if(paramDef.defaultSpecial === 'currentYear'){
|
|
@@ -2596,8 +2600,13 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2596
2600
|
var schema=db.quoteIdent(be.config.db.schema);
|
|
2597
2601
|
linesCreate.push("set role to "+owner+";");
|
|
2598
2602
|
linesCreate.push("drop schema if exists "+schema+' cascade;');
|
|
2603
|
+
if (be.config.install.dump["drop-his"]) {
|
|
2604
|
+
linesCreate.push("drop schema if exists his cascade;");
|
|
2605
|
+
}
|
|
2599
2606
|
linesCreate.push("create schema "+schema+';');
|
|
2600
2607
|
linesCreate.push("grant usage on schema "+schema+' to '+user+';');
|
|
2608
|
+
linesCreate.push("create schema if not exists his;");
|
|
2609
|
+
linesCreate.push("grant usage on schema his to "+user+';');
|
|
2601
2610
|
if(be.config.install.dump["admin-can-create-tables"]){
|
|
2602
2611
|
linesCreate.push("grant create on schema "+schema+' to '+user+';');
|
|
2603
2612
|
}
|
package/lib/procedures-table.js
CHANGED
|
@@ -189,6 +189,9 @@ ProcedureTables = [
|
|
|
189
189
|
var updateTarget = {}
|
|
190
190
|
for(var name in parameters.newRow){
|
|
191
191
|
var defField=mainDefTable.field[name];
|
|
192
|
+
if (!defField) {
|
|
193
|
+
throw new Error("field "+name+" does not exist in "+mainDefTable.name);
|
|
194
|
+
}
|
|
192
195
|
if(!defField.allow[action] && (!opts || !opts.forImport) && (
|
|
193
196
|
!defField.isPk ||
|
|
194
197
|
parameters.primaryKeyValues[defField.isPk-1]!=parameters.newRow[name]
|
|
@@ -1202,6 +1205,25 @@ ProcedureTables = [
|
|
|
1202
1205
|
and cha_new_pk = ${context.be.db.quoteLiteral(JSON.stringify(pk))}
|
|
1203
1206
|
order by cha_when desc
|
|
1204
1207
|
`,[parameters.tableName, parameters.fieldName]).fetchAll();
|
|
1208
|
+
return result.rows;
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
action:'download_dump',
|
|
1213
|
+
parameters:[
|
|
1214
|
+
{name:'password' , typeName:'text' },
|
|
1215
|
+
],
|
|
1216
|
+
bitacora:{always: true, error: true},
|
|
1217
|
+
progress:true,
|
|
1218
|
+
coreFunction:async function(context,parameters){
|
|
1219
|
+
var {be,client} = context;
|
|
1220
|
+
if(context.user[be.config.login.rolFieldName] != 'admin'){
|
|
1221
|
+
throw new Error('Forbiden history')
|
|
1222
|
+
}
|
|
1223
|
+
if (!be.config.db['downloadable-backup-path']) {
|
|
1224
|
+
throw new Error(be.messages.server.backupNotAvailable)
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1205
1227
|
return result.rows;
|
|
1206
1228
|
}
|
|
1207
1229
|
}
|
package/lib/table-def-adapt.js
CHANGED
|
@@ -317,7 +317,7 @@ function tableDefAdapt(tableDef, context){
|
|
|
317
317
|
resultFieldDef.referencesFields=fkDef.fields;
|
|
318
318
|
resultFieldDef.skipReferenceLookup=fkDef.skipReferenceLookup || fkTableDef.skipReferenceLookup;
|
|
319
319
|
}catch(err){
|
|
320
|
-
console.log('ERROR',fkDef.fields,'in',resultTableDef.field);
|
|
320
|
+
console.log('ERROR',fkDef.fields,'in',resultTableDef.field.name);
|
|
321
321
|
err.context=(err.context||'')+'referencing '+fkDef.fields[lastPos].source+' in '+resultTableDef.name+' to '+fkDef.references+' \n ';
|
|
322
322
|
throw err;
|
|
323
323
|
}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = function(context){
|
|
4
4
|
const BITACORA_TABLENAME = context.be.config.server.bitacoraTableName;
|
|
5
|
+
const BITACORA_SCHEMA = context.be.config.server.bitacoraSchema;
|
|
5
6
|
return context.be.tableDefAdapt({
|
|
6
7
|
name:'bitacora',
|
|
7
8
|
title:'Bitacora',
|
|
8
9
|
tableName: BITACORA_TABLENAME,
|
|
10
|
+
schema: BITACORA_SCHEMA,
|
|
9
11
|
editable:context.forDump,
|
|
10
12
|
fields:[
|
|
11
13
|
{name:'id' , typeName:'bigint' , nullable:false, sequence:{name: 'secuencia_bitacora', firstValue: 1}},
|
|
12
14
|
{name:'procedure_name' , typeName:'text' , nullable:false },
|
|
13
|
-
{name:'parameters_definition' , typeName:'text' , nullable:false },
|
|
14
15
|
{name:'parameters' , typeName:'text' , nullable:false },
|
|
15
16
|
{name:'username' , typeName:'text' , nullable:false },
|
|
16
17
|
{name:'machine_id' , typeName:'text' , nullable:false },
|
|
@@ -21,6 +22,7 @@ module.exports = function(context){
|
|
|
21
22
|
{name:'end_status' , typeName:'text' },
|
|
22
23
|
],
|
|
23
24
|
primaryKey:['id'],
|
|
25
|
+
sql:{skipEnance:true},
|
|
24
26
|
sortColumns:[{column:'id', order:-1}]
|
|
25
27
|
}, context);
|
|
26
28
|
}
|
|
@@ -4,6 +4,7 @@ module.exports = function(context){
|
|
|
4
4
|
var $1_is_num=`$1 ~ '^\\s*(\\d+(\\.\\d*)?|\\.\\d+)\\s*$'`
|
|
5
5
|
return context.be.tableDefAdapt({
|
|
6
6
|
name:'summary',
|
|
7
|
+
schema:'his',
|
|
7
8
|
editable:context.forDump,
|
|
8
9
|
fields:[
|
|
9
10
|
{name:'table_name' , typeName:'text' , visible:false},
|
|
@@ -32,6 +33,7 @@ module.exports = function(context){
|
|
|
32
33
|
],
|
|
33
34
|
primaryKey:['table_name', 'name'],
|
|
34
35
|
// hiddenColunns:['typeName', 'nullable', 'label', 'title', 'description'],
|
|
36
|
+
sql:{skipEnance:true},
|
|
35
37
|
sortColumns:[{column:'ordinal_position', order:1}]
|
|
36
38
|
}, context);
|
|
37
39
|
}
|
|
@@ -5,6 +5,7 @@ module.exports = function(context){
|
|
|
5
5
|
return context.be.tableDefAdapt({
|
|
6
6
|
name:'tokens',
|
|
7
7
|
elementName:'token',
|
|
8
|
+
schema:'his',
|
|
8
9
|
editable:admin,
|
|
9
10
|
fields:[
|
|
10
11
|
{name:'token' , typeName:'text' , nullable:false },
|
|
@@ -21,7 +22,8 @@ module.exports = function(context){
|
|
|
21
22
|
],
|
|
22
23
|
sql:{
|
|
23
24
|
isTable: true,
|
|
24
|
-
from: `(select * from tokens order by date desc)
|
|
25
|
+
from: `(select * from tokens order by date desc)`,
|
|
26
|
+
skipEnance:true,
|
|
25
27
|
},
|
|
26
28
|
}, context);
|
|
27
29
|
}
|
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-beta.
|
|
4
|
+
"version": "2.0.0-beta.11",
|
|
5
5
|
"author": "Codenautas <codenautas@googlegroups.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "codenautas/backend-plus",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"mini-tools": "^1.12.1",
|
|
55
55
|
"moment": "^2.29.4",
|
|
56
56
|
"multiparty": "^4.2.3",
|
|
57
|
-
"nodemailer": "^6.9.
|
|
57
|
+
"nodemailer": "^6.9.5",
|
|
58
58
|
"numeral": "^2.0.6",
|
|
59
59
|
"pg-promise-strict": "^1.3.3",
|
|
60
60
|
"pikaday": "^1.8.2",
|
|
@@ -67,26 +67,26 @@
|
|
|
67
67
|
"session-file-store": "^1.5.0",
|
|
68
68
|
"sql-tools": "^0.1.2",
|
|
69
69
|
"stack-trace": "^0.0.10",
|
|
70
|
-
"stylus": "0.
|
|
70
|
+
"stylus": "0.60.0",
|
|
71
71
|
"type-store": "^0.4.0",
|
|
72
72
|
"typed-controls": "^0.12.0",
|
|
73
73
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@types/big.js": "^6.
|
|
77
|
-
"@types/expect.js": "~0.3.
|
|
78
|
-
"@types/express": "^4.17.
|
|
79
|
-
"@types/express-useragent": "^1.0.
|
|
80
|
-
"@types/fs-extra": "^11.0.
|
|
81
|
-
"@types/js-yaml": "^4.0.
|
|
82
|
-
"@types/mocha": "^10.0.
|
|
83
|
-
"@types/multiparty": "~0.0.
|
|
84
|
-
"@types/node": "^20.
|
|
85
|
-
"@types/nodemailer": "^6.4.
|
|
86
|
-
"@types/numeral": "~2.0.
|
|
87
|
-
"@types/session-file-store": "^1.2.
|
|
88
|
-
"@types/stack-trace": "~0.0.
|
|
89
|
-
"@types/websql": "~0.0.
|
|
76
|
+
"@types/big.js": "^6.2.0",
|
|
77
|
+
"@types/expect.js": "~0.3.30",
|
|
78
|
+
"@types/express": "^4.17.18",
|
|
79
|
+
"@types/express-useragent": "^1.0.3",
|
|
80
|
+
"@types/fs-extra": "^11.0.2",
|
|
81
|
+
"@types/js-yaml": "^4.0.6",
|
|
82
|
+
"@types/mocha": "^10.0.2",
|
|
83
|
+
"@types/multiparty": "~0.0.34",
|
|
84
|
+
"@types/node": "^20.8.0",
|
|
85
|
+
"@types/nodemailer": "^6.4.11",
|
|
86
|
+
"@types/numeral": "~2.0.3",
|
|
87
|
+
"@types/session-file-store": "^1.2.3",
|
|
88
|
+
"@types/stack-trace": "~0.0.31",
|
|
89
|
+
"@types/websql": "~0.0.28",
|
|
90
90
|
"esprima": "^4.0.1",
|
|
91
91
|
"expect.js": "~0.3.1",
|
|
92
92
|
"karma": "6.4.2",
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
"kill-9": "~0.4.3",
|
|
99
99
|
"mocha": "^10.2.0",
|
|
100
100
|
"nyc": "^15.1.0",
|
|
101
|
-
"puppeteer": "^
|
|
102
|
-
"sinon": "^
|
|
101
|
+
"puppeteer": "^21.3.6",
|
|
102
|
+
"sinon": "^16.0.0",
|
|
103
103
|
"supertest": "^6.3.3",
|
|
104
|
-
"types.d.ts": "~0.6.
|
|
105
|
-
"typescript": "^5.
|
|
104
|
+
"types.d.ts": "~0.6.18",
|
|
105
|
+
"typescript": "^5.2.2",
|
|
106
106
|
"why-is-node-running": "^2.2.2"
|
|
107
107
|
},
|
|
108
108
|
"engines": {
|