Skip to content

Commit

Permalink
millores
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Alloza committed Feb 24, 2024
1 parent 0418137 commit 73aa616
Show file tree
Hide file tree
Showing 10 changed files with 540 additions and 438 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ export class EdaBlankPanelComponent implements OnInit {
public queryLimit: number;
public joinType: string = 'inner';

public modeSQL: boolean;
public queryModes: any[] = [
{ label: 'EDA Query', value: 'EDA' },
{ label: 'SQL Query', value: 'SQL' },
{ label: 'EDA Joins Query', value: 'EDA2' }
];
public selectedQueryMode: string = 'EDA';

// Depreacted use selectedQueryMode instead of
// public modeSQL: boolean;
public sqlOriginTables: {}[];
public sqlOriginTable: any;

Expand Down Expand Up @@ -191,27 +199,31 @@ export class EdaBlankPanelComponent implements OnInit {

ngOnInit(): void {
this.index = 0;
this.modeSQL = false;
// this.modeSQL = false;

this.setTablesData();

/**If panel comes from server */
if (this.panel.content) {
try{
const query = this.panel.content.query;

if (query.query.modeSQL) {
this.modeSQL = true;
const modeSQL = query.query.modeSQL;
const queryMode = query.query.queryMode;

if (queryMode) {
this.selectedQueryMode = queryMode;
}

if (modeSQL || queryMode=='SQL') {
this.currentSQLQuery = query.query.SQLexpression;
this.sqlOriginTable = this.tables.filter(t => t.table_name === query.query.fields[0].table_id)
.map(table => {
return { label: table.display_name.default, value: table.table_name }
})[0];
.map(table => ({ label: table.display_name.default, value: table.table_name }))[0];
}

this.loadChartsData(this.panel.content);
}catch(e){
} catch(e){
console.error('Error loading panen conent.....');
throw e;
}
}

Expand All @@ -231,8 +243,6 @@ export class EdaBlankPanelComponent implements OnInit {
* @param event selected node. Can be rootNode (table_id) or childNode (child_id).
*/
public tableNodeSelect(event: any): void {
console.log('tableNodeSelect');
console.log(event);
const node = event?.node;
if (node) {
if (node.table_id) {
Expand All @@ -253,8 +263,6 @@ export class EdaBlankPanelComponent implements OnInit {
* @param event node to expand. Empty for nodes without more paths.
*/
public tableNodeExpand(event: any): void {
console.log('tableNodeExpand');
console.log(event);
this.loadingNodes = true;

const node = event?.node;
Expand All @@ -266,6 +274,14 @@ export class EdaBlankPanelComponent implements OnInit {
this.loadingNodes = false;
}

public checkNodeSelected(node: any) {
if (node?.child_id) {
return this.currentQuery.some((query: any) => query.table_id == node.child_id.split('.')[0]);
} else {
return false;
}
}

getEditMode() {
const user = sessionStorage.getItem('user');
const userName = JSON.parse(user).name;
Expand Down Expand Up @@ -388,7 +404,10 @@ export class EdaBlankPanelComponent implements OnInit {
*/

public buildGlobalconfiguration(panelContent: any) {
if (!panelContent.query.query.modeSQL) {
const modeSQL = panelContent.query.query.modeSQL;
const queryMode = panelContent.query.query.queryMode;

if ((queryMode && queryMode != 'SQL') || !modeSQL) {
try{
const queryTables = [...new Set(panelContent.query.query.fields.map((field: any) => field.table_id))];

Expand Down Expand Up @@ -467,13 +486,13 @@ export class EdaBlankPanelComponent implements OnInit {
public savePanel() {

this.panel.title = this.pdialog.getTitle();


if (!_.isEmpty(this.graficos) || this.modeSQL) {
this.panel.content.query.query.queryMode = this.selectedQueryMode;
if (!_.isEmpty(this.graficos) || this.selectedQueryMode == 'SQL') {

this.display_v.saved_panel = true;

const query = this.initObjectQuery(this.modeSQL);
const query = this.initObjectQuery();
const chart = this.chartForm.value.chart.value ? this.chartForm.value.chart.value : this.chartForm.value.chart;
const edaChart = this.panelChart.props.edaChart;

Expand All @@ -495,8 +514,8 @@ export class EdaBlankPanelComponent implements OnInit {

}

public initObjectQuery(modeSQL: boolean) {
if (modeSQL) {
public initObjectQuery() {
if (this.selectedQueryMode == 'SQL') {
return QueryUtils.initSqlQuery(this);
} else {
return QueryUtils.initEdaQuery(this)
Expand Down Expand Up @@ -645,7 +664,8 @@ export class EdaBlankPanelComponent implements OnInit {
c.aggregation_type.forEach( e=> e.selected = false);
c.aggregation_type.map( e=> e.value == 'none'? e.selected = true:true );
}catch(e){
console.log('no llego')
console.error(e)
throw e;
}

}
Expand Down Expand Up @@ -793,14 +813,19 @@ export class EdaBlankPanelComponent implements OnInit {
this.filtredColumns = [];
//Reassing sqlQuery -if exists
this.currentSQLQuery = this.panelDeepCopy.query.query.SQLexpression;
this.modeSQL = this.panelDeepCopy.query.query.modeSQL;

const queryMode = this.panelDeepCopy.query.query.queryMode;
const modeSQL = this.panelDeepCopy.query.query.modeSQL;

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

// this.modeSQL = this.panelDeepCopy.query.query.modeSQL;
}

this.loadChartsData(this.panelDeepCopy);
this.userSelectedTable = undefined;
this.tablesToShow = this.tables;
this.display_v.chart = '';
// this.index = this.modeSQL ? 1 : 0;
this.display_v.page_dialog = false;
}

Expand Down Expand Up @@ -1040,7 +1065,7 @@ export class EdaBlankPanelComponent implements OnInit {
}

public switchAndBuildQuery() {
if (!this.modeSQL) return QueryUtils.initEdaQuery(this);
if (this.selectedQueryMode != 'SQL') return QueryUtils.initEdaQuery(this);
else return QueryUtils.initSqlQuery(this);
}

Expand Down Expand Up @@ -1095,23 +1120,22 @@ export class EdaBlankPanelComponent implements OnInit {
this.queryFromServer = '';
this.currentQuery = [];
this.filtredColumns = [];
this.modeSQL = true;
this.selectedQueryMode = 'SQL';
}

public async changeQueryMode(): Promise<void> {

public changeQueryMode(): void {
this.index = 0;
this.currentSQLQuery = '';
this.currentQuery = [];
this.filtredColumns = [];
this.display_v.btnSave = true;
}

public accopen(e){
public accopen(e) { }

}
/** This funciton return the display name for a given table. Its used for the query resumen */
public getNiceTableName( table ){
return this.tables.find( t => t.table_name === table).display_name.default;
public getNiceTableName(table: any){
return this.tables.find( t => t.table_name === table).display_name.default;
}

public onWhatIfDialog(): void {
Expand All @@ -1122,4 +1146,20 @@ export class EdaBlankPanelComponent implements OnInit {
this.display_v.whatIf_dialog = false;
}

public disableRunQuery(): boolean {
let disable = false;

if (this.selectedQueryMode !== 'SQL') {
if (this.currentQuery.length === 0 && this.index === 0) {
disable = true;
}
} else {
if (_.isNil(this.sqlOriginTables)) {
disable = true;
}
}

return disable;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- CASE chart + edaquery -->

<div class="grid"
*ngIf="controller.params.charttype !== 'table' && controller.params.charttype !== 'parallelSets' && !controller.params.modeSQL">
*ngIf="controller.params.charttype !== 'table' && controller.params.charttype !== 'parallelSets' && controller.params.queryMode != 'SQL'">
<div class="col-6">
<h6 class="col-12" i18n="@@csvField" class="custom-border-b1">
Campo
Expand All @@ -33,7 +33,7 @@ <h6 class="col-12" i18n="@@LinkDashboardSelectedDashboard" class="custom-border-
<!-- CASE table + edaquery -->

<div class="grid"
*ngIf="(controller.params.charttype === 'table' || controller.params.charttype === 'parallelSets') && !controller.params.modeSQL">
*ngIf="(controller.params.charttype === 'table' || controller.params.charttype === 'parallelSets') && controller.params.queryMode != 'SQL'">
<div class="col-6">
<h6 class="col-12" i18n="@@csvField" class="custom-border-b1">
Campo
Expand All @@ -56,7 +56,7 @@ <h6 class="col-12" i18n="@@LinkDashboardSelectedDashboard" class="custom-border-
</div>

<!-- CASE chart + sqlquery -->
<div *ngIf="controller.params.modeSQL" class="grid">
<div *ngIf="controller.params.queryMode == 'SQL'" class="grid">
<div class="col-12">
<h6 class="col-12" i18n="@@csvField" class="custom-border-b1">
Campo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export class LinkDashboardsComponent extends EdaDialogAbstract {
onShow(): void {
this.oldLinked = this.controller.params.linkedDashboard ? this.controller.params.linkedDashboard.dashboardName : null;

if ((this.controller.params.charttype === 'parallelSets') && !this.controller.params.modeSQL) {
if ((this.controller.params.charttype === 'parallelSets') && this.controller.params.queryMode != 'SQL') {

this.columns = this.controller.params.query.filter(col => (col.column_type === 'text' || col.column_type === 'date'))
.map(col => {
return { col: col.column_name, table: col.table_id, colname: col.display_name.default }
});
}

else if ((this.controller.params.charttype === 'treeMap') && !this.controller.params.modeSQL) {
else if ((this.controller.params.charttype === 'treeMap') && this.controller.params.queryMode != 'SQL') {
this.columns = this.controller.params.query.filter(col => (col.column_type === 'text' || col.column_type === 'date'))
.map(col => {
return { col: col.column_name, table: col.table_id, colname: col.display_name.default }
Expand All @@ -100,7 +100,7 @@ export class LinkDashboardsComponent extends EdaDialogAbstract {

}

else if (this.controller.params.charttype !== 'table' && !this.controller.params.modeSQL) {
else if (this.controller.params.charttype !== 'table' && this.controller.params.queryMode != 'SQL') {
let column = this.controller.params.query
.map((col, i) => { return { col: col.column_name, table: col.table_id, colname: col.display_name.default, index:i, column_type:col.column_type } })
.filter(col => (col.column_type === 'text' || col.column_type === 'date'))[0];
Expand All @@ -112,15 +112,15 @@ export class LinkDashboardsComponent extends EdaDialogAbstract {

}

else if (this.controller.params.charttype === 'table' && !this.controller.params.modeSQL) {
else if (this.controller.params.charttype === 'table' && this.controller.params.queryMode != 'SQL') {
this.columns = this.controller.params.query.filter(col => (col.column_type === 'text' || col.column_type === 'date'))
.map(col => {
return { col: col.column_name, table: col.table_id, colname: col.display_name.default }
});

}

else if (this.controller.params.modeSQL) {
else if (this.controller.params.queryMode == 'SQL') {
this.columns = this.controller.params.query.filter(col => (col.column_type === 'text' || col.column_type === 'date'))
.map(col => {
return { col: col.column_name, table: col.table_id, colname: col.display_name.default }
Expand All @@ -139,10 +139,8 @@ export class LinkDashboardsComponent extends EdaDialogAbstract {
}

public handleTargetColumn() {

this.targetColumn = this.selectedFilter.colname;
this.targetTable = this.selectedFilter.table;

}

public async initDashboards(column: any): Promise<any> {
Expand Down Expand Up @@ -174,7 +172,7 @@ export class LinkDashboardsComponent extends EdaDialogAbstract {

let disable = true;

if (!this.controller.params.modeSQL) {
if (this.controller.params.queryMode != 'SQL') {
res.dashboard.config.filters.forEach(filter => {

if (filter.column.value.column_name === column.col && filter.table.value === column.table) {
Expand Down
Loading

0 comments on commit 73aa616

Please sign in to comment.