From 9e7ab40945bf4c5c0b344d636547a10b50158d0a Mon Sep 17 00:00:00 2001 From: khituras Date: Mon, 15 Jul 2024 17:44:39 +0200 Subject: [PATCH] Fixes #274. --- .../gepi/webapp/components/GepiWidgetLayout.java | 9 +++++++-- .../main/java/de/julielab/gepi/webapp/pages/Index.java | 8 +++++--- .../java/de/julielab/gepi/webapp/services/AppModule.java | 6 +----- .../META-INF/modules/gepi/components/widgetManager.js | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/components/GepiWidgetLayout.java b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/components/GepiWidgetLayout.java index c2549859..a1c3d4e1 100644 --- a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/components/GepiWidgetLayout.java +++ b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/components/GepiWidgetLayout.java @@ -10,10 +10,12 @@ import de.julielab.gepi.webapp.pages.Index; import org.apache.tapestry5.BindingConstants; import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.SymbolConstants; import org.apache.tapestry5.annotations.*; import org.apache.tapestry5.corelib.components.Zone; import org.apache.tapestry5.http.Link; import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.ioc.annotations.Symbol; import org.apache.tapestry5.json.JSONObject; import org.apache.tapestry5.services.ajax.AjaxResponseRenderer; import org.apache.tapestry5.services.javascript.JavaScriptSupport; @@ -82,6 +84,9 @@ final public class GepiWidgetLayout { private String viewMode; @InjectPage private Index index; + @Inject + @Symbol(SymbolConstants.PRODUCTION_MODE) + private boolean productionMode; void setupRender() { if (getEsResult() == null) @@ -142,8 +147,8 @@ public JSONObject getWidgetSettings() { widgetSettings.put("handleId", getResizeHandleId()); widgetSettings.put("widgetId", clientId); widgetSettings.put("viewMode", "small"); - widgetSettings.put("toggleViewModeUrl", toggleViewModeEventLink.toAbsoluteURI().replace(":80", "")); - widgetSettings.put("refreshContentsUrl", refreshContentEventLink.toAbsoluteURI().replace(":80", "")); + widgetSettings.put("toggleViewModeUrl", toggleViewModeEventLink.toAbsoluteURI(productionMode)); + widgetSettings.put("refreshContentsUrl", refreshContentEventLink.toAbsoluteURI(productionMode)); widgetSettings.put("zoneElementId", widgetZone.getClientId()); widgetSettings.put("useTapestryZoneUpdates", useTapestryZoneUpdates); widgetSettings.put("dataSessionId", requestData.getDataSessionId()); diff --git a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/pages/Index.java b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/pages/Index.java index fa844091..e47e495b 100644 --- a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/pages/Index.java +++ b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/pages/Index.java @@ -173,7 +173,7 @@ public Future getUnrolledResult4download() { void afterRender() { javaScriptSupport.require("gepi/base").invoke("setuptooltips"); - javaScriptSupport.require("gepi/charts/data").invoke("setDataUrl").with(resources.createEventLink("loadDataToClient").toAbsoluteURI().replace(":80", "")); + javaScriptSupport.require("gepi/charts/data").invoke("setDataUrl").with(resources.createEventLink("loadDataToClient").toAbsoluteURI(productionMode)); javaScriptSupport.require("gepi/pages/index").invoke("setupDownloadUrlCopyButton"); if (isResultPresent()) { // If there already is data at loading the page, the input panel is already hidden (see #getShowInputClass) @@ -466,12 +466,14 @@ private boolean isBList() { return requestData.getInputMode().contains(InputMode.AB); } - + @Inject + @Symbol(SymbolConstants.PRODUCTION_MODE) + private boolean productionMode; @Inject private PageRenderLinkSource pageRenderLS; public String getResultFileDownloadLink() { - return pageRenderLS.createPageRenderLinkWithContext(ResultDownload.class, dataSessionId).toAbsoluteURI().replace(":80", ""); + return pageRenderLS.createPageRenderLinkWithContext(ResultDownload.class, dataSessionId).toAbsoluteURI(productionMode); } } diff --git a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/services/AppModule.java b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/services/AppModule.java index 02125be0..cd3fdebe 100644 --- a/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/services/AppModule.java +++ b/gepi/gepi-webapp/src/main/java/de/julielab/gepi/webapp/services/AppModule.java @@ -75,11 +75,7 @@ public static void contributeFactoryDefaults( // This is something that should be removed when going to production, but is useful // in the early stages of development. - configuration.override(SymbolConstants.PRODUCTION_MODE, true); - -// configuration.override(SymbolConstants.CORS_ENABLED, true); -// configuration.override(SymbolConstants.CORS_ALLOWED_ORIGINS, "*"); - configuration.add(SymbolConstants.CORS_MAX_AGE, "5"); + configuration.override(SymbolConstants.PRODUCTION_MODE, false); } public static void contributeApplicationDefaults( diff --git a/gepi/gepi-webapp/src/main/resources/META-INF/modules/gepi/components/widgetManager.js b/gepi/gepi-webapp/src/main/resources/META-INF/modules/gepi/components/widgetManager.js index fa2d1227..09834a1f 100644 --- a/gepi/gepi-webapp/src/main/resources/META-INF/modules/gepi/components/widgetManager.js +++ b/gepi/gepi-webapp/src/main/resources/META-INF/modules/gepi/components/widgetManager.js @@ -64,7 +64,7 @@ define(['jquery', 't5/core/zone', 'gepi/pages/index'], function($, zoneManager, Widget.prototype.ajaxRefresh = function() { console.log('[trace] Issueing update of zone with ID ' + this.zoneElementId); - index.getReadySemaphor().done(() => zoneManager.deferredZoneUpdate(this.zoneElementId, this.refreshContentsUrl.replace(":80", ""))); + index.getReadySemaphor().done(() => zoneManager.deferredZoneUpdate(this.zoneElementId, this.refreshContentsUrl)); console.log('[trace] Returned from update of zone with ID ' + this.zoneElementId); };