Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix - APP + API - Corrección paneles SQL y autorelaciones #151

Merged
merged 223 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
223 commits
Select commit Hold shift + click to select a range
315d90a
sidebar - create dashboard from sidebar
Oct 12, 2023
537ad2f
datasource - allow count/countdistinct text_columns
Oct 15, 2023
4fb90fb
change column type to numeric
Oct 18, 2023
acad7c3
Merge branch 'aa/aggText'
jortilles Oct 19, 2023
dd647aa
Merge remote-tracking branch 'origin/aa/sidebarNewDashboard' into test
jortilles Oct 20, 2023
e208932
Posibilidad de crear un dashboard desde el sidebar
jortilles Oct 30, 2023
e0f4620
Internacionalizar "buscar" en las tablas
jortilles Oct 30, 2023
588ec20
Configuracion de seguridad try catch
jortilles Oct 31, 2023
7541e04
Borrado logs innecesarios
jortilles Oct 31, 2023
da437dc
BugFix - error tipográfico en comprobación de seguridad de grupo
asafJortilles Nov 2, 2023
0e25d61
Bug Multi Value List ==> texto
jortilles Nov 6, 2023
390b3ac
Merge branch 'master' of https://github.com/jortilles/EDA
jortilles Nov 7, 2023
86e061b
Borrado console.log
jortilles Nov 8, 2023
277f875
limpieza console.log
jortilles Nov 8, 2023
1f6a63c
console.log
jortilles Nov 8, 2023
a23944c
Aumento del número de iteraciones
jortilles Nov 8, 2023
0812f7e
registro de control de dashboard y panel en app.log
jortilles Nov 13, 2023
da4bc5a
fixed bug - ocultar repetidos
asafJortilles Nov 17, 2023
ef652fa
chartClick - no refresh data
Apr 17, 2023
0071fd4
rebase conflicts
Nov 22, 2023
57a8463
bugfix - eliminar permisos dinámicos corregido
asafJortilles Nov 27, 2023
985dd20
Bug-Permisos de columna none
jortilles Nov 29, 2023
c5fd94f
Bug visibilidad de datasoures para admin (los tineen que ver)
jortilles Nov 29, 2023
df31ca8
Bug Visibilidad columna usuario
jortilles Nov 30, 2023
a841c63
estetica
jortilles Dec 3, 2023
6e63b08
Priorizar relaciones directas
jortilles Dec 3, 2023
0ff2a10
Control de seguridad noDataAllowed
jortilles Dec 3, 2023
34e6bd2
Merge remote-tracking branch 'SinergiaDA/reporting'
jortilles Dec 3, 2023
a5fb7e8
comm
jortilles Dec 4, 2023
06dc4c5
Error typografico
jortilles Dec 12, 2023
477d0da
Agregació Columnes calculades + Reescritura lógica de consultes
jortilles Dec 19, 2023
ccc933e
update pupperteeer para poder actualizar node
jortilles Dec 21, 2023
f940621
Merge branch 'master' of https://github.com/jortilles/EDA
jortilles Dec 21, 2023
48d2b7e
sidebar new dashboard reload fix
Dec 21, 2023
b04bc26
limpieza de console.log
jortilles Dec 21, 2023
53d6ff3
Consoles log y typo
jortilles Dec 21, 2023
bac48e9
error typografico
jortilles Dec 21, 2023
b27c822
otro typo
jortilles Dec 21, 2023
bd7f44e
TYPO
jortilles Dec 21, 2023
1e681d5
habilitados usuarios anonimos para acceder a consultas publicas hech…
asafJortilles Dec 22, 2023
731d7c7
Merge branch 'master' of https://github.com/jortilles/EDA
asafJortilles Dec 22, 2023
7a22745
1er commit - probado con postgres
asafJortilles Dec 27, 2023
8b2f51d
Error en color coding cuando el nombre de la columna tiene un _
asafJortilles Jan 3, 2024
f333d44
2º commit
asafJortilles Jan 4, 2024
5b5d249
refactor
asafJortilles Jan 4, 2024
d3f2a5e
whatif
Jan 4, 2024
54d1e80
estilos
jortilles Jan 9, 2024
0f30baa
corrección de nomenclatura para clase de codigo de colores
asafJortilles Jan 10, 2024
07fcf56
override decorator
Jan 11, 2024
ef0f5f4
whatIfExpresion qbSystems
Jan 14, 2024
c44db69
whatif i18n
Jan 14, 2024
067a57f
añadido espacio de gracia a la parte superior del gráfico y mejora de…
asafJortilles Jan 15, 2024
761a9d0
Retoques finales
Jan 15, 2024
16fb53d
cambio de or por and para la consecución de filtros
asafJortilles Jan 16, 2024
00b901c
whatif - jsonwebservice
Jan 18, 2024
987970a
whatIf buttons
Jan 20, 2024
a689c53
whatif - modify values on dashboard panel
Jan 20, 2024
2a929ac
Linked dashboard + Click 2 filter en Chart JS
jortilles Jan 22, 2024
f139841
Merge branch 'master' of https://github.com/jortilles/EDA
jortilles Jan 22, 2024
4f7a3e6
Refactor - limpieza
jortilles Jan 22, 2024
11b4c02
Prototipo algoritmo
jortilles Jan 22, 2024
d013847
1er commit: modificación del modelo de datos, añadido label. En caso …
asafJortilles Jan 22, 2024
16f825c
Algoritmo nuevo de rutas
jortilles Jan 22, 2024
d677810
Merge branch 'pg-connection.SSL-selector' of https://github.com/jorti…
jortilles Jan 22, 2024
fbe1203
Literales en minuscula
jortilles Jan 23, 2024
3f3c675
puntero en sidebar new report
jortilles Jan 23, 2024
334e0be
AaAa comentado el getGraph
jortilles Jan 23, 2024
a65388f
corrección conexión mysql
asafJortilles Jan 23, 2024
82e8e36
eliminacion de consele logs
asafJortilles Jan 23, 2024
43cdbae
añadido checkbox en la edicion del modelo de datos
asafJortilles Jan 23, 2024
c4f93bf
Unificación del código
jortilles Jan 24, 2024
514ab6e
typo
jortilles Jan 24, 2024
28bf1e1
switch en modelo de datos, refactoring de true/false
asafJortilles Jan 24, 2024
eb5d80b
Merge branch 'pg-connection.SSL-selector' of https://github.com/jorti…
asafJortilles Jan 24, 2024
603bdda
SDA52 Refactor
jortilles Jan 25, 2024
3d10250
Añadido nuevo tipo de "no numerico"
jortilles Jan 25, 2024
74f5e49
cambio de posición del boton de confirmar
jortilles Jan 25, 2024
2dfb77c
Merge branch 'pg-connection.SSL-selector'
jortilles Jan 25, 2024
d4af98e
Retoques finales para What If
jortilles Jan 25, 2024
948ea2f
Merge branch 'reporting' into SDA#53
Jan 26, 2024
8d18dde
Subida de versión y libreria de mergeo de archivos de traducciones
jortilles Jan 30, 2024
7096234
Quitado acceso anonimo error typografico
jortilles Feb 2, 2024
2ccdba8
Concatenar filtros con Null or => and
Feb 2, 2024
4523a92
Merge branch 'reporting' into SDA#56
jortilles Feb 4, 2024
5e979b2
update Fitlers to String
Feb 4, 2024
e78a152
Qutado consosle.log innecesario
Feb 4, 2024
6abc111
Canvis de hover als grafics de ChartJS
aTorresJortilles Feb 5, 2024
90c1d85
Merge pull request #84 from jortilles/chart.js-OnMouseOver
jortilles Feb 5, 2024
c93adf8
cambio de cadenas vacías o nulas por '-'
asafJortilles Feb 5, 2024
c75f75b
typos
asafJortilles Feb 5, 2024
8755d94
typos
jortilles Feb 6, 2024
fe7a1b3
corrección: rescate de opción de visibilidad del fitro
asafJortilles Feb 5, 2024
e25f57d
Añadida explicación
Feb 4, 2024
2fc6b84
Merge remote-tracking branch 'SinergiaDA/SDA-#59' into Temporal
jortilles Feb 6, 2024
d447b79
Merge branch 'Temporal' of https://github.com/jortilles/EDA into Temp…
jortilles Feb 6, 2024
776ae6a
traducciones
jortilles Feb 6, 2024
695807c
cadenas vacías
asafJortilles Feb 7, 2024
bf90396
reemplazo '' por ' ' en consultas fijas
Feb 7, 2024
9a1bfd1
Comparación con null innecesaria
Feb 7, 2024
7c4aa2f
Merge remote-tracking branch 'SinergiaDA/SDA#58'
jortilles Feb 7, 2024
83972d7
eda query build joins
Feb 8, 2024
382d469
Merge remote-tracking branch 'SinergiaDA/SDA#56'
jortilles Feb 9, 2024
ace7d9e
Car. 1901, funcionalidad de linked dashboards en D3.
aTorresJortilles Feb 9, 2024
2ba6442
Tables bug
jortilles Feb 12, 2024
d663ab6
documentar codi
Feb 12, 2024
044f9b0
Usabilidad
jortilles Feb 13, 2024
b65ee77
Merge branch 'edaquery2' of https://github.com/jortilles/EDA into eda…
jortilles Feb 13, 2024
476b9cf
commit
jortilles Feb 13, 2024
7c28529
Added limit to json data source
jortilles Feb 14, 2024
f844a4e
Primera instancia del centrado de los sufijos en el component KPI. Pe…
aTorresJortilles Feb 14, 2024
cb78641
detallitos
jortilles Feb 15, 2024
adf74bc
fff
jortilles Feb 15, 2024
1619286
noRepetitions correction
asafJortilles Feb 15, 2024
857ece8
2
asafJortilles Feb 15, 2024
d42e550
Merge branch 'master' of https://github.com/jortilles/EDA
jortilles Feb 15, 2024
2480ed3
1er commit, se ajusta el output numérico de las tablas a 2 decimales
asafJortilles Feb 15, 2024
733febc
HOTFIX - ocultar codigo de color si se escoge solo porcentajes
asafJortilles Feb 13, 2024
3d9da9e
Fixed logs
aTorresJortilles Feb 16, 2024
ba81158
Cambio a margen automático del componente KPI
aTorresJortilles Feb 16, 2024
3d633c0
zzz
jortilles Feb 19, 2024
406c0b7
millores
Feb 19, 2024
8aa1726
Mejora KPI
jortilles Feb 19, 2024
7bd40a7
Merge remote-tracking branch 'origin/linked-dashboards/all-d3'
jortilles Feb 19, 2024
1f47b69
Merge remote-tracking branch 'origin/kpi-centered'
jortilles Feb 19, 2024
b1dfea5
SDA51-Literales de totales y icono de locales
jortilles Feb 19, 2024
2f1863b
work in progress
jortilles Feb 21, 2024
3e333ac
joins millores
Feb 23, 2024
fa97520
eda query build joins
Feb 8, 2024
c2c6f5c
Usabilidad
jortilles Feb 13, 2024
37aa957
documentar codi
Feb 12, 2024
b28cbed
commit
jortilles Feb 13, 2024
987e651
detallitos
jortilles Feb 15, 2024
0418137
fff
jortilles Feb 15, 2024
73aa616
millores
Feb 19, 2024
ca51875
work in progress
jortilles Feb 21, 2024
6dad305
joins millores
Feb 23, 2024
bc64595
eda tree joins
Feb 26, 2024
8c41a0d
Merge branch 'edaquery2' of https://github.com/jortilles/EDA into eda…
jortilles Feb 27, 2024
9963e26
multiValueList
Feb 27, 2024
97f5f8d
fix(globalFilter) && fix(closeConsulta)
Mar 1, 2024
618e04d
EDA_RO
jortilles Mar 7, 2024
e70ba65
global-filter-tree
Mar 20, 2024
fc2f347
Syncro
jortilles Mar 20, 2024
eada1c4
Merge branch 'edaquery2' of https://github.com/jortilles/EDA into eda…
jortilles Mar 20, 2024
e71ee8b
globalFilter refactor #1
Mar 21, 2024
0842d78
globalFilter - bugs fixed
Mar 24, 2024
4847fa4
globalFilter - edit & remove
Mar 25, 2024
1b9ce04
globalfilter - bugs
Mar 25, 2024
69c480a
globalFilter - bugs fix
Mar 27, 2024
b6a62ee
globalFilter - panells no relacionats
Apr 2, 2024
5d7c3c9
Merge branch 'reporting' into SDA#53
Apr 4, 2024
4429762
check globalFilter when remove column
Apr 6, 2024
5d103d1
globalFilter - edit fix
Apr 7, 2024
636dcdf
Merge edaquery2 into SDA#53
Apr 8, 2024
01eee15
Merge remote-tracking branch 'EnterpriseDataAnalytics/edaquery2' into…
Apr 8, 2024
7c9142f
Syncro 1
Apr 8, 2024
6d4e3b0
SDA CUSTOM propagation
Apr 8, 2024
7dbaa42
RC 1
Apr 9, 2024
28341bf
Eliminación de tablas bridge
Apr 10, 2024
a25b5d7
label split
asafJortilles Apr 10, 2024
0375152
Etiquetas para cada lado
Apr 10, 2024
38eb36f
Quitadas líneas innecesarias
Apr 17, 2024
5df4cbe
Restaurado MariaDB
Apr 17, 2024
45390da
issues fix
Apr 20, 2024
1d34ffa
showHiddenColumns refactor
Apr 20, 2024
67a17b8
fix valueListSource on filters
Apr 23, 2024
1d736ef
aggregation_type fix
Apr 24, 2024
131d81e
limpiado query utils
Apr 24, 2024
0895291
Refactorización del diálogo de filtros para optimizar pantalla
Apr 24, 2024
4e79cd0
globalFilter - unselect filter
Apr 24, 2024
5cfb0d7
globalFilter fix unselect panel
Apr 24, 2024
f9ade45
reset columns fitlers
Apr 24, 2024
b19cb9f
filterDialog (fix)
Apr 28, 2024
109911e
queryInfo - show columns join path
Apr 28, 2024
524a2d4
int
Apr 28, 2024
6a3bcdc
globalFilter - disable panel table
Apr 28, 2024
8137bac
globalFilterDialog - set default panel path
Apr 28, 2024
36762a9
globalFilterDialog - fix error on update filter
Apr 28, 2024
532cfc6
globalFilter - fix auto set path
Apr 29, 2024
307b5f8
globalFilterDialog - hide panel table && localize
Apr 29, 2024
abb6246
if fix
Apr 30, 2024
79d5328
fix valueList
May 2, 2024
5f36146
fix multivalueListJoins
May 2, 2024
238f58d
removeFilter fix && loadFilterData fix
May 3, 2024
332310a
Filtros con value list.
May 6, 2024
f74f736
globalFilter - add new panel when exists globalFilter
May 12, 2024
75ace1e
globalFilter - date fix
May 12, 2024
dd21b22
globalFilter - onChange column refresh option values
May 12, 2024
2c2cad5
globalFilter - on remove avoid refresh data
May 12, 2024
7c5bb22
localFilters - set joins
May 12, 2024
a693c4f
handle local filter on init
May 12, 2024
4fea2f2
tree - mark node fix
May 12, 2024
8baede3
Merge branch 'reporting' into SDA#53
jortilles May 13, 2024
141cc95
oldDashboard - fix loading issues
May 16, 2024
0503274
display selected filter paths
May 18, 2024
5ee8d26
displayFilters - filter is new
May 19, 2024
736f13e
globalFilter - update items fix
May 19, 2024
2abc8bb
dashboard - set panels queryMode
May 20, 2024
f7199b3
Posicionamiento de selectores en selección del panel
May 20, 2024
c1785d5
tree - remove filter
May 20, 2024
946e860
globalFilter - path label fix
May 20, 2024
a0fcb1c
detalles
May 20, 2024
7838dd1
revert column area
juanSTIC May 21, 2024
9cac85a
queryMode - remove clearOption
May 21, 2024
b2ceb88
fix query mode selector overlay
juanSTIC May 21, 2024
69d16ce
Update selector
May 27, 2024
780bf92
localize messages
juanSTIC May 28, 2024
754b85e
Improving translation
jalbaiges May 28, 2024
e5e2026
Improving translation
jalbaiges May 28, 2024
cb3ae6d
Improving translation
jalbaiges May 28, 2024
a6050d8
Improving translation
jalbaiges May 28, 2024
cf25a38
fix sql panels
May 31, 2024
34d7e66
Merge branch 'reporting' into SDA#53
jortilles Jun 3, 2024
1c6160c
autorelations
Jun 2, 2024
dbaaede
añadido autorelation en updateModel
asafJortilles Jun 3, 2024
c15cc58
Quitado el duplicado de las relaciones para las auto-relaciones. No p…
Jun 4, 2024
b6b1dfa
autorelations #1
Jun 7, 2024
1532634
alias fix
Jun 8, 2024
5a8e9ed
autorelation hide child
Jun 9, 2024
5dddb8b
Merge branch 'reporting' into SDA#53
jortilles Jun 10, 2024
bed7dff
autorelation - fix on quering multiple tables
Jun 10, 2024
b71ef4e
bugs fix
Jun 12, 2024
b089df7
handleCurrentQuery - add autorelation property to columns
Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion eda/eda_api/lib/module/updateModel/updateModel.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class updateModel {
SELECT target_table as source_table, target_column as source_column ,
source_table as target_table , source_column as target_column, label as label , 1 as direccion
FROM sda_def_relationships
where source_table != target_table
union
SELECT source_table , source_column ,
master_table , master_id as target_column, 'xx-bridge|xx-bridge' , 2 as direccion
Expand Down Expand Up @@ -514,7 +515,8 @@ export class updateModel {
"display_name": {
"default": relations[i].direccion === 0 ? relations[i].label.split('|')[0] : relations[i].label.split('|')[1] ,
"localized": []
},
},
"autorelation" : relations[i].source_table === relations[i].target_table ? true : false
}
destRelations.push(rr);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { QueryBuilderService } from './../query-builder.service';
import * as _ from 'lodash';
import { filter, values } from 'lodash';

/*SDA CUSTOM*/ import * as custom from '../../custom/custom';

Expand Down Expand Up @@ -35,8 +34,6 @@ export class MySqlBuilderService extends QueryBuilderService {
joinString = this.getJoins(joinTree, dest, tables, joinType, valueListJoins, schema);
}



joinString.forEach(x => {
myQuery = myQuery + '\n' + x;
});
Expand Down Expand Up @@ -209,21 +206,35 @@ export class MySqlBuilderService extends QueryBuilderService {
if (!joinExists.has(`${sourceJoin}=${targetJoin}`)) {
joinExists.add(`${sourceJoin}=${targetJoin}`);


let aliasSource;
if (sourceJoin.split('.')[0] == targetJoin.split('.')[0]) {
aliasSource = `\`${sourceTable}.${sourceColumn}\``;
}

// Construcción de los alias
const alias = `\`${targetTable}.${targetColumn}\``;
let alias = `\`${targetTable}.${targetColumn}.${sourceColumn}\``;

if (aliasSource) {
alias = aliasSource;
}

aliasTables[alias] = targetTable;
// aliasTables[sourceJoin] = targetTable;

let aliasTargetTable: string;
// targetTable and sourceTable can be the same table (autorelation)
if (targetTableJoin.includes(targetTable) || targetTable == sourceTable) {
aliasTargetTable = `${targetTable}${targetTableJoin.indexOf(targetTable)}`;
// aliasTargetTable = `${targetTable}${targetTableJoin.indexOf(targetTable)}`;
aliasTargetTable = `${targetTable}${sourceColumn}`;
aliasTables[alias] = aliasTargetTable;
}

let joinStr: string;

joinType = valueListJoins.includes(targetTable) ? 'LEFT' : joinType;


if (aliasTargetTable) {
targetJoin = `\`${aliasTargetTable}\`.\`${targetColumn}\``;
joinStr = `${joinType} JOIN \`${targetTable}\` \`${aliasTargetTable}\` ON ${sourceJoin} = ${targetJoin} `;
Expand Down Expand Up @@ -261,7 +272,12 @@ export class MySqlBuilderService extends QueryBuilderService {
this.queryTODO.fields.forEach(el => {
el.order !== 0 && el.table_id !== origin && !dest.includes(el.table_id) ? dest.push(el.table_id) : false;

const table_column = `\`${el.table_id}\`.\`${el.column_name}\``;
let table_column;
if (el.autorelation && !el.valueListSource) {
table_column = `\`${el.joins[el.joins.length-1][0]}\`.\`${el.column_name}\``;
} else {
table_column = `\`${el.table_id}\`.\`${el.column_name}\``;
}

let whatIfExpression = '';
if (el.whatif_column) whatIfExpression = `${el.whatif.operator} ${el.whatif.value}`;
Expand Down
15 changes: 11 additions & 4 deletions eda/eda_api/lib/services/query-builder/query-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ export abstract class QueryBuilderService {
}
});
}


/** SEPAREM ENTRE AGGREGATION COLUMNS/GROUPING COLUMNS */
let separedCols = this.getSeparedColumns(origin, dest);
let columns = separedCols[0];
let grouping = separedCols[1];


let joinTree = [];
let tree = [];
Expand Down Expand Up @@ -208,10 +207,18 @@ export abstract class QueryBuilderService {

field.valueListSource.source_column = field.column_name?field.column_name:field.filter_column;
// field.valueListSource.source_table = field.table_id?field.table_id.split('.')[0]:field.filter_table.split('.')[0];
field.valueListSource.source_table = field.table_id?field.table_id:field.filter_table;

const sourceTable = (field.table_id||field.filter_table)
// const sourceTable = table.substring(0, table.lastIndexOf('.'));
field.valueListSource.source_table = sourceTable;

field.table_id = field.valueListSource.target_table;
field.column_name = field.valueListSource.target_description_column;

if (field.autorelation) {
field.valueListSource.source_table = field.joins[field.joins.length-1][0]; //, join[0].substring(sourceLastDotInx + 1)];
}


if (field.valueListSource.bridge_table?.length > 0) {
const j = {
Expand Down Expand Up @@ -251,7 +258,7 @@ export abstract class QueryBuilderService {
}
}
valueListJoins = [...new Set(valueListJoins.map((value) => value.target_table))];

tree = [...new Set(tree)];
joinTree = tree;
this.queryTODO.joined = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class EdaBlankPanelComponent implements OnInit {
public filterValue: any = {};

public loadingNodes: boolean = false;
public rootTreeTable: any;
public rootTable: any;
public tableNodes: any = [];
public selectedTableNode: any;
public nodeJoins: any[] = [];
Expand Down Expand Up @@ -226,10 +226,9 @@ export class EdaBlankPanelComponent implements OnInit {
this.selectedQueryMode = queryMode;

if (queryMode == 'EDA2') {
this.rootTreeTable = contentQuery.query.rootTreeTable;
this.rootTable = contentQuery.query.rootTable;
}


if (modeSQL || queryMode=='SQL') {
this.currentSQLQuery = contentQuery.query.SQLexpression;

Expand Down Expand Up @@ -265,7 +264,7 @@ export class EdaBlankPanelComponent implements OnInit {

if (this.currentQuery.length == 0) {
this.nodeJoins = [];
this.rootTreeTable = undefined;
this.rootTable = undefined;
}

const node = event?.node;
Expand Down Expand Up @@ -446,6 +445,7 @@ export class EdaBlankPanelComponent implements OnInit {

try {
if (queryMode == 'EDA2') {
this.rootTable = this.tables.find((t) => t.table_name == this.rootTable);
// Assert Relation Tables
const currentQuery = panelContent.query.query.fields;
for (const column of currentQuery) {
Expand Down Expand Up @@ -489,7 +489,7 @@ export class EdaBlankPanelComponent implements OnInit {

if (this.panel?.content) {
this.panel.content.query.query.queryMode = this.selectedQueryMode;
this.panel.content.query.query.rootTreeTable = this.rootTreeTable;
this.panel.content.query.query.rootTable = this.rootTable;
}

if (!_.isEmpty(this.graficos) || this.selectedQueryMode == 'SQL') {
Expand Down Expand Up @@ -699,7 +699,7 @@ export class EdaBlankPanelComponent implements OnInit {
public openColumnDialog(column: Column, isFilter?: boolean): void {
this.disableBtnSave();

if (column.table_id !== this.rootTreeTable?.table_name) {
if (column.table_id !== this.rootTable?.table_name) {
column.joins = (column.joins||[]).length == 0 ? this.nodeJoins[this.nodeJoins.length-1] : column.joins;
}

Expand Down Expand Up @@ -845,7 +845,7 @@ export class EdaBlankPanelComponent implements OnInit {
const modeSQL = this.panelDeepCopy.query.query.modeSQL;

this.selectedQueryMode = _.isNil(queryMode) ? (modeSQL ? 'SQL' : 'EDA') : queryMode;
this.rootTreeTable = this.panelDeepCopy.rootTreeTable;
this.rootTable = this.panelDeepCopy.rootTable;
}

this.loadChartsData(this.panelDeepCopy);
Expand Down Expand Up @@ -1156,7 +1156,7 @@ export class EdaBlankPanelComponent implements OnInit {
this.currentQuery = [];
this.filtredColumns = [];
this.display_v.btnSave = true;
this.rootTreeTable = undefined;
this.rootTable = undefined;
this.action.emit({ code: 'QUERYMODE', data: { queryMode: this.selectedQueryMode, panel: this.panel } })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export const PanelInteractionUtils = {
loadTableNodes: (ebp: EdaBlankPanelComponent) => {
if (ebp.currentQuery.length > 0) {
const idTables = [...new Set(ebp.currentQuery.map((q) => q.table_id))];
const rootTable = idTables.find((idTable: string) => ebp.rootTreeTable?.table_name == idTable);
const rootTable = idTables.find((idTable: string) => ebp.rootTable?.table_name == idTable);

if (rootTable) {
const dataSource = ebp.inject.dataSource.model.tables;

Expand Down Expand Up @@ -105,7 +106,7 @@ export const PanelInteractionUtils = {
const rootTable = (rootJoin[0]||'').split('.')[0];
const sourceTable = ebp.tables.find((table: any) => table.table_name == rootTable);

const relation = sourceTable?.relations.find((rel) => `${rel.target_table}.${rel.target_column[0]}` == column.table_id);
const relation = sourceTable?.relations.find((rel) => `${rel.target_table}.${rel.target_column[0]}.${rel.source_column[0]}` == column.table_id);
if (relation) {
let assertTable = _.cloneDeep(ebp.tables.find((t) => t.table_name == relation.target_table));

Expand Down Expand Up @@ -155,7 +156,7 @@ export const PanelInteractionUtils = {
table.relations = table.relations.filter(f=>f.bridge==false );
for (const relation of table.relations) {
// Init child_id
const child_id = relation.target_table+'.'+relation.target_column[0];
const child_id = `${relation.target_table}.${relation.target_column[0]}.${relation.source_column[0]}`;

/** Checks if the current child_node is included before.
* This prevents duplicated paths. */
Expand All @@ -168,7 +169,8 @@ export const PanelInteractionUtils = {
/** This creates the path to relate this node with the previous tables.
* It will be used later to generate the query. */
let sourceJoin = relation.source_table+'.'+relation.source_column[0];
let joins = expandNode.joins ? [].concat(expandNode.joins, [[sourceJoin, child_id]]) : [[sourceJoin, child_id]];
const joinChildId = child_id.substring(0, child_id.lastIndexOf('.'));
let joins = expandNode.joins ? [].concat(expandNode.joins, [[sourceJoin, joinChildId]]) : [[sourceJoin, joinChildId]];

if (!ebp.tables.some((t) => t.table_name == child_id)) {
let assertTable = _.cloneDeep(ebp.tables.find((t) => t.table_name == relation.target_table))
Expand Down Expand Up @@ -197,7 +199,7 @@ export const PanelInteractionUtils = {
});

// If it's expandable, we add properties to expand the node.
if (isexpandible) {
if (isexpandible && !relation.autorelation) {
childNode.expandedIcon = "pi pi-folder-open";
childNode.collapsedIcon = "pi pi-folder";
childNode.children = [{}];
Expand Down Expand Up @@ -326,8 +328,8 @@ export const PanelInteractionUtils = {
const table = ebp.tables.find((table) => table.table_name == contentColumn.table_id);

if (table && table?.columns) {
if (!ebp.rootTreeTable && contentColumn.joins.length == 0) {
ebp.rootTreeTable = table;
if (!ebp.rootTable && contentColumn.joins.length == 0) {
ebp.rootTable = table;
}

const columns = table.columns;
Expand Down Expand Up @@ -359,6 +361,7 @@ export const PanelInteractionUtils = {
duplicatedColumn.whatif_column = contentColumn.whatif_column || false;
duplicatedColumn.whatif = contentColumn.whatif || {};
duplicatedColumn.joins = contentColumn.joins || [];
duplicatedColumn.autorelation = contentColumn.autorelation || false;
PanelInteractionUtils.handleAggregationType4DuplicatedColumns(ebp, duplicatedColumn);
// Moc la columna directament perque es una duplicada.... o no....
ebp.currentQuery.push(duplicatedColumn);
Expand All @@ -375,7 +378,8 @@ export const PanelInteractionUtils = {
handleColumn.whatif = contentColumn.whatif || {};
handleColumn.joins = contentColumn.joins || [];
handleColumn.ordenation_type = contentColumn.ordenation_type;

handleColumn.autorelation = contentColumn.autorelation || false;

const existsAgg = handleColumn.aggregation_type.find((agg) => agg.value === contentColumn.aggregation_type);
if (existsAgg) existsAgg.selected = true;

Expand Down Expand Up @@ -593,11 +597,11 @@ export const PanelInteractionUtils = {
if (match) match.isdeleted = true; // Marco la columna com a borrada


if (!ebp.rootTreeTable) {
ebp.rootTreeTable = ebp.tables.find((table) => table.table_name == c.table_id);
if (!ebp.rootTable) {
ebp.rootTable = ebp.tables.find((table) => table.table_name == c.table_id);
}

if (c.table_id !== ebp.rootTreeTable?.table_name) {
if (c.table_id !== ebp.rootTable?.table_name) {
c.joins = (c.joins||[]).length == 0 ? ebp.nodeJoins[ebp.nodeJoins.length-1] : c.joins;
}

Expand Down Expand Up @@ -693,7 +697,7 @@ export const PanelInteractionUtils = {
if (list === 'select') {
if (ebp.selectedQueryMode == 'EDA2') {

const rootTable = ebp.rootTreeTable.table_name;
const rootTable = ebp.rootTable.table_name;

// Remove column is from rootTable then check currentQuery columns to allow or not.
if (c.table_id === rootTable) {
Expand All @@ -706,7 +710,7 @@ export const PanelInteractionUtils = {
}
}

if (ebp.rootTreeTable && ebp.rootTreeTable.column_name == c.column_name && rootTable == c.table_id) {
if (ebp.rootTable && ebp.rootTable.column_name == c.column_name && rootTable == c.table_id) {
// ebp.selectedQueryMode = 'EDA';
ebp.currentQuery.forEach((query) => query.table_id = query.table_id.split('.')[0]);
ebp.reloadTablesData();
Expand All @@ -729,7 +733,7 @@ export const PanelInteractionUtils = {

// Buscar relacións per tornar a mostrar totes les taules
if (ebp.currentQuery.length === 0 && ebp.filtredColumns.length === 0) {
ebp.rootTreeTable = undefined;
ebp.rootTable = undefined;
ebp.tablesToShow = ebp.tables;

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const PanelOptions = {
/* SDA CUSTOM */ panelComponent.showHiddenColumn = false;
panelComponent.panelDeepCopy = _.cloneDeep(panelComponent.panel.content, true);
if (panelComponent.selectedQueryMode == 'EDA2') {
panelComponent.panelDeepCopy.rootTreeTable = _.cloneDeep(panelComponent.rootTreeTable);
panelComponent.panelDeepCopy.rootTable = _.cloneDeep(panelComponent.rootTable);
}
panelComponent.display_v.disablePreview = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export const QueryUtils = {
break;
}
}

ebp.currentQuery = [];
types.forEach((type, i) => {
ebp.currentQuery.push(QueryUtils.createColumn(response[0][i], type, ebp.sqlOriginTable));
});
return response;
}
} catch (err) {
console.log(err);
throw err;
}
},
Expand Down Expand Up @@ -229,7 +229,7 @@ export const QueryUtils = {
config: config.getConfig(),
queryLimit: ebp.queryLimit,
joinType: ebp.joinType,
rootTable: ebp.rootTreeTable?.table_name,
rootTable: ebp.rootTable?.table_name,
};
return ebp.queryBuilder.normalQuery(ebp.currentQuery, params, ebp.selectedQueryMode);
},
Expand Down
Loading