Skip to content

Commit 2c7c8e4

Browse files
committed
Merge remote-tracking branch 'origin/EDA_3_KPIISSUE'
# Conflicts: # eda/eda_app/src/app/module/pages/dashboard/dashboard.page.ts
2 parents 201cdeb + 73cd47a commit 2c7c8e4

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

eda/eda_app/src/app/module/components/eda-kpi/eda-kpi.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Component, OnInit, Input, EventEmitter, Output, ViewChild, ElementRef }
22
import { StyleProviderService } from '@eda/services/service.index';
33
import { registerLocaleData } from '@angular/common';
44
import { EdaKpi } from './eda-kpi';
5-
import { EdaChart } from '../eda-chart/eda-chart';
65
import es from '@angular/common/locales/es';
76
import { EdaChartComponent } from '../eda-chart/eda-chart.component';
87

@@ -125,6 +124,10 @@ export class EdaKpiComponent implements OnInit {
125124
if (this.inject.showChart) {
126125
resultSize = resultSize / 1.8;
127126
}
127+
const isMobile = window.innerWidth < 640;
128+
if(isMobile) {
129+
resultSize = 40;
130+
}
128131
return resultSize.toFixed().toString() + 'px';
129132
}
130133

@@ -134,4 +137,4 @@ export class EdaKpiComponent implements OnInit {
134137
}
135138
}
136139

137-
}
140+
}

eda/eda_app/src/app/module/pages/dashboard/dashboard.page.ts

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ export class DashboardPage implements OnInit {
266266
}
267267
this.gridsterOptions.fixedRowHeight = cellSize;
268268
}
269-
this.gridsterOptions.api?.optionsChanged();
269+
this.sortPanelsForMobile();
270+
this.gridsterOptions.api?.optionsChanged();
270271
}
271272

272273
public async loadDashboard() {
@@ -283,6 +284,7 @@ export class DashboardPage implements OnInit {
283284
this.globalFilter?.initOrderDependentFilters(dashboard.config.orderDependentFilters || []); // Filtros dependientes
284285
this.globalFilter?.initGlobalFilters(dashboard.config.filters || []);// Filtres del dashboard
285286
this.initPanels(dashboard);
287+
this.sortPanelsForMobile();
286288
this.styles = dashboard.config.styles || this.stylesProviderService.generateDefaultStyles();
287289
this.getUrlParams();
288290
this.globalFilter.findGlobalFilterByUrlParams(this.queryParams);
@@ -497,7 +499,8 @@ export class DashboardPage implements OnInit {
497499
}
498500

499501
let valor = this.getBottomMostItem();
500-
this.height = valor !== undefined ? (valor.y + valor.rows + 4) * 50 : 750;
502+
const rowHeight = this.gridsterOptions.fixedRowHeight || 150;
503+
this.height = valor !== undefined ? (valor.y + valor.rows + 4) * rowHeight + 150 : 750;
501504
this.cdr.detectChanges();
502505
this.stylesProviderService.loadedPanels--;
503506
}
@@ -1242,10 +1245,16 @@ public startCountdown(seconds: number) {
12421245
// Función que cambia el valor de la altura del gridster cada vez que hay un cambio en el elemento
12431246
onItemChange(item: GridsterItem): void {
12441247
if (this.panels) {
1245-
let valor = this.getBottomMostItem();
1246-
this.height = ((valor.y + valor.rows + 4 ) * 50);
1247-
this.cdr.detectChanges();
1248-
}
1248+
const rowHeight = this.gridsterOptions.fixedRowHeight || 150;
1249+
const isMobile = window.innerWidth < (this.gridsterOptions.mobileBreakpoint || 640);
1250+
if (isMobile) {
1251+
this.updateMobileHeight();
1252+
} else {
1253+
let valor = this.getBottomMostItem();
1254+
this.height = ((valor.y + valor.rows + 4) * rowHeight) + 250;
1255+
this.cdr.detectChanges();
1256+
}
1257+
}
12491258
}
12501259

12511260

@@ -1305,4 +1314,28 @@ public startCountdown(seconds: number) {
13051314
}
13061315
return tableMatch && columnMatch && labelMatch;
13071316
}
1317+
1318+
// Funciones auxiliares para mobile
1319+
private updateMobileHeight(): void {
1320+
const interval = setInterval(() => {
1321+
if (this.stylesProviderService.loadedPanels <= 0) {
1322+
clearInterval(interval);
1323+
const gridsterEl = document.querySelector('gridster') as HTMLElement;
1324+
if (gridsterEl) {
1325+
this.height = gridsterEl.offsetHeight + 50;
1326+
this.cdr.detectChanges();
1327+
}
1328+
}
1329+
}, 100);
1330+
setTimeout(() => clearInterval(interval), 15000);
1331+
}
1332+
1333+
private sortPanelsForMobile(): void {
1334+
if (!this.panels?.length) return;
1335+
const isMobile = window.innerWidth < (this.gridsterOptions.mobileBreakpoint || 640);
1336+
if (isMobile) {
1337+
this.panels.sort((a, b) => Math.floor(a.y / 10) - Math.floor(b.y / 10) || Math.floor(a.x / 10) - Math.floor(b.x / 10));
1338+
this.updateMobileHeight();
1339+
}
1340+
}
13081341
}

0 commit comments

Comments
 (0)