IDEMPIERE-4787 : Dashboard / Report : add Refresh button (#685)

* IDEMPIERE-4787 : Dashboard / Report : add Refresh button

* IDEMPIERE-4787 : Dashboard / Report : add Refresh button - applying hengsin's advices

Co-authored-by: hengsin <152246+hengsin@users.noreply.github.com>
This commit is contained in:
Nicolas Micoud 2021-05-17 14:06:15 +02:00 committed by GitHub
parent 3b4d371fb6
commit ca556b52ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 12 deletions

View File

@ -422,8 +422,12 @@ public class DashboardController implements EventListener<Event> {
if (dc.isEmbedReportContent())
{
String processParameters = dc.getProcessParameters();
embedReport(content, AD_Process_ID, processParameters);
Iframe iframe = new Iframe();
iframe.setSclass("dashboard-report-iframe");
content.appendChild(iframe);
iframe.setContent(generateReport(AD_Process_ID, processParameters));
Toolbar toolbar = new Toolbar();
content.appendChild(toolbar);
btn.setLabel(Msg.getMsg(Env.getCtx(), "OpenRunDialog"));
@ -436,6 +440,17 @@ public class DashboardController implements EventListener<Event> {
btn.setLabel(Msg.getMsg(Env.getCtx(), "ViewReportInNewTab"));
toolbar.appendChild(new Separator("vertical"));
toolbar.appendChild(btn);
btn = new ToolBarButton();
if (ThemeManager.isUseFontIconForImage()) {
btn.setIconSclass("z-icon-Refresh");
btn.setSclass("trash-toolbarbutton");
}
else
btn.setImage(ThemeManager.getThemeResource("images/Refresh16.png"));
btn.addEventListener(Events.ON_CLICK, e -> iframe.setContent(generateReport(AD_Process_ID, processParameters)));
toolbar.appendChild(btn);
}
else
{
@ -861,21 +876,17 @@ public class DashboardController implements EventListener<Event> {
+ " - " + process.getName());
return re;
}
public void embedReport(Component parent, int AD_Process_ID, String parameters) throws Exception {
}
public AMedia generateReport(int AD_Process_ID, String parameters) throws Exception {
ReportEngine re = runReport(AD_Process_ID, parameters);
Iframe iframe = new Iframe();
iframe.setSclass("dashboard-report-iframe");
File file = File.createTempFile(re.getName(), ".html");
re.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp",
SessionManager.getAppDesktop().getComponent().getUuid()));
AMedia media = new AMedia(re.getName(), "html", "text/html", file, false);
iframe.setContent(media);
parent.appendChild(iframe);
return new AMedia(re.getName(), "html", "text/html", file, false);
}
protected void openReportInViewer(int AD_Process_ID, String parameters) {
ReportEngine re = runReport(AD_Process_ID, parameters);
new ZkReportViewerProvider().openViewer(re);