Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jortilles/EDA
Browse files Browse the repository at this point in the history
  • Loading branch information
jortilles committed Jan 22, 2024
2 parents 2a929ac + a689c53 commit f139841
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@

<!-- Panel Header -->
<div class="panel-heading d-flex justify-content-between">
<div style="width: 100%;">
<div class="panel-heading d-flex justify-content-between align-items-center">
<div>
<h6 id="p-header" class="panel-title" style="cursor: default">
{{ panel.title || title }}
</h6>
</div>

<div id="edit" [ngClass]="{'edit-blink': lodash.isEmpty(panel.content) }">
<i class="fa fa-ellipsis-v btn" (click)="contextMenu.showContextMenu($event)"></i>
<div class="d-flex align-items-center" style="gap: 15px;">
<ng-container *ngIf="showWhatIfSection()">
<label class="panel-title">What if:</label>
<div *ngFor="let column of getWhatIfColumns()">
<span style="font-weight: bold;">{{column.display_name.default}}</span>
<input type="number" pInputText [(ngModel)]="column.whatif.value"
(keydown.enter)="runWhatIfQuery(column)"
style="margin-left: 5px; width: 50px; padding: 0;">
<button type="button" pButton pRipple icon="pi pi-refresh" class="p-button-outlined" style="width: 20px; padding: 0; border: 0;" (click)="runWhatIfQuery(column)"></button>
</div>
</ng-container>


<div id="edit" [ngClass]="{'edit-blink': lodash.isEmpty(panel.content) }" style="width: 25px;">
<i class="fa fa-ellipsis-v btn" (click)="contextMenu.showContextMenu($event)"></i>
</div>
</div>

</div>

<!-- Body of Panel -->
<div class="panel-body" [ngClass]="{'spinner-panel': display_v.minispinner === true}">
<div *ngIf="display_v.saved_panel" class="p-1" style="height: 100%">
<div class="panel-body" [ngClass]="{'spinner-panel': display_v.minispinner}">
<div *ngIf="display_v.saved_panel && !display_v.minispinner" class="p-1" style="height: 100%">
<panel-chart #PanelChartComponent
[props]="panelChartConfig"
(configUpdated)="setChartProperties()"
Expand All @@ -26,8 +39,8 @@ <h6 id="p-header" class="panel-title" style="cursor: default">

<div class="grid" *ngIf="display_v.minispinner">
<div class="col-12">
<p-progressSpinner [style]="{width: '5vw', height: '5vh'}" strokeWidth="8" class="" fill="#EEEEEE"
animationDuration=".5s"></p-progressSpinner>
<p-progressSpinner [style]="{width: '5vw', height: '5vh'}" strokeWidth="8" class="" fill="#EEEEEE" animationDuration=".5s">
</p-progressSpinner>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,39 @@ export class EdaBlankPanelComponent implements OnInit {
return (userName !== 'edaanonim' && !this.inject.isObserver);
}

public showWhatIfSection(): boolean {
return this.currentQuery.some((query: any) => query.whatif_column);
}

public getWhatIfColumns(): any[] {
return this.currentQuery.filter((query: any) => query.whatif_column);
}

public async runWhatIfQuery(column?: any): Promise<void> {
try {
const updateDisplayName = (col: any) => {
const origin = col.whatif.origin;
if (origin) {
col.display_name.default = `${origin.display_name.default}(${col.whatif.operator}${col.whatif.value})`;
}
};

if (!column) {
for (const col of this.getWhatIfColumns()) {
updateDisplayName(col);
}
} else {
updateDisplayName(column);
}


await this.runQueryFromDashboard(true);
this.panelChart.updateComponent();
} catch (err) {
throw err;
}
}

private initializeBlankPanelUtils(): void {

this.chartForm = this.formBuilder.group({ chart: [null, Validators.required] });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<eda-dialog2 [display]="display"
header="What If" width="50vw" height= "50vh"
[disableApply]="disableApply()"
(apply)="onApplyWhatIfDialog()"
(close)="onCloseWhatIfDialog()">

<div content>
Expand All @@ -25,9 +27,6 @@
<button type="button" pButton pRipple icon="pi pi-refresh" class="p-button-info" title="Generate alias" (click)="generateAlias()"></button>
</div>
</div>
<div class="col-2 d-flex align-items-end">
<button pButton icon="fa fa-check" class="p-button-info p-button-outlined button-add" label="Añadir" i18n-label="@@addBtn" (click)="addWhatIfColumn()" [disabled]="!whatIf.column || !whatIf.operator || !whatIf.value || !whatIf.display_name"></button>
</div>
</div>

<div class="col-12 mt-3">
Expand All @@ -45,4 +44,6 @@

</eda-dialog2>

<p-confirmDialog [style]="{width: '30vw'}" header="Confirmation" icon="pi pi-exclamation-triangle" appendTo="body"></p-confirmDialog>
<p-confirmDialog [style]="{width: '30vw'}" header="Confirmation" icon="pi pi-exclamation-triangle" appendTo="body"></p-confirmDialog>

<!-- <button pButton icon="fa fa-check" class="p-button-info p-button-outlined button-add" label="Añadir" i18n-label="@@addBtn" (click)="addWhatIfColumn()" [disabled]="!whatIf.column || !whatIf.operator || !whatIf.value || !whatIf.display_name"></button> -->
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,34 @@ export class WhatIfDialogComponent implements OnInit {
}
}

public onCloseWhatIfDialog(): void {
if (this.whatIf.column && this.whatIf.operator && this.whatIf.value) {
this.confirmationService.confirm({
header: 'Warning',
message: `No ha añadido la condicion "WhatIf" a la consulta.<br> ¿Desea continuar sin ser añadida?`,
acceptLabel: 'Si',
rejectLabel: 'No',
accept: () => {
this.display = false;
this.close.emit();
},
rejectButtonStyleClass: 'p-button-danger'
})
} else {
public disableApply(): boolean {
return !this.whatIf.column || !this.whatIf.operator || !this.whatIf.value || !this.whatIf.display_name;
}

public onApplyWhatIfDialog(): void {
if (this.whatIf.column && this.whatIf.operator && this.whatIf.value && this.whatIf.display_name) {
const whatIfColumn = _.cloneDeep(this.whatIf.column);
whatIfColumn.whatif_column = true;
whatIfColumn.whatif = {
operator: this.whatIf.operator,
value: this.whatIf.value,
origin: this.whatIf.column
};

whatIfColumn.display_name.default = this.whatIf.display_name;


this.currentQuery.push(whatIfColumn);
this.whatIf = {};
this.display = false;
this.close.emit();
}
}

public onCloseWhatIfDialog(): void {
this.whatIf = {};
this.display = false;
this.close.emit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ng-template pTemplate="footer">
<hr>
<ng-content select="[footer]"></ng-content>
<button *ngIf="ifShowApply " pButton icon="fa fa-check" class="p-button-raised p-button-success" label="Confirmar" i18n-label="@@guardarBtn" (click)="onApply()"></button>
<button *ngIf="ifShowApply" [disabled]="disableApply" pButton icon="fa fa-check" class="p-button-raised p-button-success" label="Confirmar" i18n-label="@@guardarBtn" (click)="onApply()"></button>
<button *ngIf="ifShowClose" pButton icon="fa fa-times" class="p-button-raised p-button-danger" label="Cerrar" i18n-label="@@cerrarBtn" (click)="onClose()"></button>
</ng-template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export abstract class EdaDialog2 {

@Input() showApply: boolean = true;
@Input() showClose: boolean = true;
@Input() disableApply: boolean = false;

constructor() { }

Expand Down
6 changes: 4 additions & 2 deletions eda/eda_app/src/assets/sass/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ body .ui-tree {
/* Primeng Components css */

.panel-heading .pi {
color: #000!important;
font-size: 1.70em!important;
/* color: var(--header-bg-color)!important; */
color: #455A64!important;

/* font-size: 1.70em; */
}

.ui-paginator-bottom .pi {
Expand Down

0 comments on commit f139841

Please sign in to comment.