IDEMPIERE-5607 - Dashboard Process Tenant data rendered in System (#1707)

* IDEMPIERE-5607 - Dashboard Process Tenant data rendered in System

* IDEMPIERE-5607 - do not render DPPerformance if it is empty
This commit is contained in:
Peter Takács 2023-03-10 04:36:27 +01:00 committed by GitHub
parent a55a1bfbcf
commit f0532b214a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 79 additions and 48 deletions

View File

@ -104,4 +104,9 @@ public class DPPerformance extends DashboardPanel {
public boolean isLazy() {
return true;
}
@Override
public boolean isEmpty() {
return performanceData.length <= 0;
}
}

View File

@ -55,4 +55,12 @@ public abstract class DashboardPanel extends Window implements IDashboardPanel {
public boolean isLazy() {
return false;
}
/**
* Empty Dashboard Panels are not rendered on the Dashboard
* @return true if the panel is empty
*/
public boolean isEmpty() {
return false;
}
}

View File

@ -71,6 +71,7 @@ import org.compiere.model.MProcess;
import org.compiere.model.MProcessPara;
import org.compiere.model.MStatusLine;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.print.ReportEngine;
import org.compiere.process.ProcessInfo;
@ -445,6 +446,12 @@ public class DashboardController implements EventListener<Event> {
if (dpanel.isLazy()) {
try {
dpanel.refresh(spt);
if(dpanel.isEmpty()) {
spt.executeAsync(() -> {
panel.detach();
panel.setAttribute(PANEL_EMPTY_ATTRIBUTE, Boolean.TRUE);
});
}
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
@ -746,7 +753,17 @@ public class DashboardController implements EventListener<Event> {
int AD_Process_ID = dashboardContent.getAD_Process_ID();
if(AD_Process_ID > 0)
{
String sql = "SELECT AD_MENU_ID FROM AD_MENU WHERE AD_Process_ID=?";
boolean systemAccess = false;
MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID);
String accessLevel = process.getAccessLevel();
if ( MTable.ACCESSLEVEL_All.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemOnly.equals(accessLevel)
|| MTable.ACCESSLEVEL_SystemPlusClient.equals(accessLevel)) {
systemAccess = true;
}
int thisClientId = Env.getAD_Client_ID(Env.getCtx());
if((thisClientId == 0 && systemAccess) || thisClientId != 0) {
String sql = "SELECT AD_Menu_ID FROM AD_Menu WHERE AD_Process_ID=?";
int AD_Menu_ID = DB.getSQLValueEx(null, sql, AD_Process_ID);
ToolBarButton btn = new ToolBarButton();
MMenu menu = new MMenu(Env.getCtx(), AD_Menu_ID, null);
@ -798,6 +815,7 @@ public class DashboardController implements EventListener<Event> {
components.add(btn);
}
}
}
// Goal
int PA_Goal_ID = dashboardContent.getPA_Goal_ID();