From 2e120291c77b067e8649d2776b1a96abeecc04b2 Mon Sep 17 00:00:00 2001 From: verboomp Date: Tue, 3 Feb 2026 14:35:02 +0100 Subject: [PATCH] fix url for https --- .../rest/vo/PictureValue.java | 10 +--- .../rest/CustomerPictureResourceTest.java | 53 ++++++++----------- .../lib/pages/customer/customer_widget.dart | 13 ++++- .../customer/picture_fullscreen_dialog.dart | 10 ++++ .../lib/pages/customer/picture_widget.dart | 10 ++++ 5 files changed, 54 insertions(+), 42 deletions(-) diff --git a/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/rest/vo/PictureValue.java b/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/rest/vo/PictureValue.java index a6feb94..fc56ae8 100644 --- a/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/rest/vo/PictureValue.java +++ b/hartmann-foto-documentation-app/src/main/java/marketing/heyday/hartmann/fotodocumentation/rest/vo/PictureValue.java @@ -2,9 +2,6 @@ package marketing.heyday.hartmann.fotodocumentation.rest.vo; import java.util.Date; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import io.swagger.v3.oas.annotations.media.Schema; import marketing.heyday.hartmann.fotodocumentation.core.model.Picture; @@ -20,19 +17,16 @@ import marketing.heyday.hartmann.fotodocumentation.core.model.Picture; @Schema(name = "Picture") public record PictureValue(Long id, String comment, String category, Date pictureDate, String username, Integer evaluation, String imageUrl, String normalSizeUrl, String thumbnailSizeUrl) { - private static final Log LOG = LogFactory.getLog(PictureValue.class); - + public static PictureValue builder(Picture picture, String baseUrl) { if (picture == null) { return null; } - LOG.error("baseUrl " + baseUrl); String sizeUrl = baseUrl; + // we need to rewrite the url for dev/integ/prod since the Wildfly doesn't know we are running the nginx on https. Without the https the images are not shown if(baseUrl.startsWith("http://") && !baseUrl.startsWith("http://localhost")){ - LOG.error("starts with http:// "); sizeUrl = "https://" + baseUrl.substring(7); - LOG.error("new baseUrl " + sizeUrl); } sizeUrl = sizeUrl + "picture/image/" + picture.getPictureId() + "?size="; diff --git a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java index c799334..1788cdb 100644 --- a/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java +++ b/hartmann-foto-documentation-docker/src/test/java/marketing/heyday/hartmann/fotodocumentation/rest/CustomerPictureResourceTest.java @@ -40,10 +40,10 @@ public class CustomerPictureResourceTest extends AbstractRestTest { @Order(2) public void doAddCustomerPicture() throws IOException { LOG.info("doAddCustomerPicture"); - + assertEquals(3, customerCount()); assertEquals(5, pictureCount()); - + String path = deploymentURL + PATH; Request request = Request.Post(path).addHeader("Accept", "application/json; charset=utf-8") .bodyFile(new File(BASE_UPLOAD + "add.json"), ContentType.APPLICATION_JSON); @@ -51,19 +51,19 @@ public class CustomerPictureResourceTest extends AbstractRestTest { HttpResponse httpResponse = executeRequest(request); int code = httpResponse.getStatusLine().getStatusCode(); assertEquals(200, code); - + assertEquals(3, customerCount()); assertEquals(6, pictureCount()); } - + @Test @Order(3) public void doAddCustomerWithPicture() throws IOException { LOG.info("doAddCustomerWithPicture"); - + assertEquals(3, customerCount()); assertEquals(6, pictureCount()); - + String authorization = getBasicHeader(); LOG.info("authorization: " + authorization); String path = deploymentURL + PATH; @@ -74,16 +74,16 @@ public class CustomerPictureResourceTest extends AbstractRestTest { HttpResponse httpResponse = executeRequest(request); int code = httpResponse.getStatusLine().getStatusCode(); assertEquals(200, code); - + assertEquals(4, customerCount()); assertEquals(7, pictureCount()); } - + @Test @Order(1) public void doAddCustomerPictureWrongJson() throws IOException { LOG.info("doAddCustomerPictureWrongJson"); - + String authorization = getBasicHeader(); LOG.info("authorization: " + authorization); String path = deploymentURL + PATH; @@ -94,55 +94,44 @@ public class CustomerPictureResourceTest extends AbstractRestTest { HttpResponse httpResponse = executeRequest(request); int code = httpResponse.getStatusLine().getStatusCode(); assertEquals(400, code); - + String text = getResponseText(httpResponse, "doGetAll"); System.out.println(text); } - + @Test @Order(2) public void doTest() throws IOException { LOG.info("doAddCustomerPicture"); - + //String authorization = getBasicHeader(); //LOG.info("authorization: " + authorization); String path = deploymentURL + PATH; Request request = Request.Options(path).addHeader("Accept", "application/json; charset=utf-8"); - //.addHeader("Authorization", authorization) - //.bodyFile(new File(BASE_UPLOAD + "add.json"), ContentType.APPLICATION_JSON); + //.addHeader("Authorization", authorization) + //.bodyFile(new File(BASE_UPLOAD + "add.json"), ContentType.APPLICATION_JSON); HttpResponse httpResponse = executeRequest(request); - + var headers = httpResponse.getAllHeaders(); for (var header : headers) { System.out.println(header.getName() + " " + header.getValue()); } - + int code = httpResponse.getStatusLine().getStatusCode(); assertEquals(200, code); - + } - + public static void main(String[] args) throws IOException { - String baseUrl = "http://hartmann-cue.heydevelop.de/api/"; - //String baseUrl = "http://localhost:8080/api/"; - - String sizeUrl = baseUrl; - System.out.println(); - if(baseUrl.startsWith("http://") && !baseUrl.startsWith("http://localhost")){ - System.out.println("starts with http:// "); - sizeUrl = "https://" + baseUrl.substring(7); - System.out.println("new baseUrl " + sizeUrl); - } - -/* + var test = new CustomerPictureResourceTest(); - + test.deploymentURL = "http://localhost:8080/"; test.deploymentURL = "https://hartmann-cue.heydevelop.de/"; test.username = "adm"; test.password = "x1t0e7Pb49"; - test.doTest();*/ + test.doTest(); } } diff --git a/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart index 8b0ad76..0c288c7 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart @@ -224,6 +224,16 @@ class _CustomerWidgetState extends State { headers: {cred.name: cred.value}, pictureDto.thumbnailSizeUrl, fit: BoxFit.contain, + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + : 0, + ), + ); + }, ), ), ), @@ -232,8 +242,7 @@ class _CustomerWidgetState extends State { flex: 3, child: Align( alignment: Alignment.centerLeft, - child: Text(pictureDto.thumbnailSizeUrl), - //FIXME: child: Text(pictureDto.comment ?? "", style: dataStyle), + child: Text(pictureDto.comment ?? "", style: dataStyle), ), ), Expanded( diff --git a/hartmann-foto-documentation-frontend/lib/pages/customer/picture_fullscreen_dialog.dart b/hartmann-foto-documentation-frontend/lib/pages/customer/picture_fullscreen_dialog.dart index 8e862aa..9491e31 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/customer/picture_fullscreen_dialog.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/customer/picture_fullscreen_dialog.dart @@ -54,6 +54,16 @@ class PictureFullscreenDialog extends StatelessWidget { child: Image.network( headers: {cred.name: cred.value}, dto.imageUrl, + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + : 0, + ), + ); + }, ), ), ), diff --git a/hartmann-foto-documentation-frontend/lib/pages/customer/picture_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/customer/picture_widget.dart index f0ef1ab..3e93594 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/customer/picture_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/customer/picture_widget.dart @@ -158,6 +158,16 @@ class _PictureWidgetState extends State { headers: {cred.name: cred.value}, dto.normalSizeUrl, fit: BoxFit.contain, + loadingBuilder: (context, child, loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: CircularProgressIndicator( + value: loadingProgress.expectedTotalBytes != null + ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + : 0, + ), + ); + }, ), ), ),