diff --git a/financer-server/pom.xml b/financer-server/pom.xml index 48a03b1..82315ca 100644 --- a/financer-server/pom.xml +++ b/financer-server/pom.xml @@ -17,7 +17,7 @@ jar - postgres,dev + hsqldb,dev mk diff --git a/financer-web-client/pom.xml b/financer-web-client/pom.xml index 1601ea7..b7b8138 100644 --- a/financer-web-client/pom.xml +++ b/financer-web-client/pom.xml @@ -21,7 +21,7 @@ dev diff --git a/financer-web-client/src/main/java/de/financer/config/FinancerConfig.java b/financer-web-client/src/main/java/de/financer/config/FinancerConfig.java index 7c1bba8..6eec601 100644 --- a/financer-web-client/src/main/java/de/financer/config/FinancerConfig.java +++ b/financer-web-client/src/main/java/de/financer/config/FinancerConfig.java @@ -3,12 +3,14 @@ package de.financer.config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import java.util.Currency; @Configuration @ConfigurationProperties(prefix = "financer") +@ComponentScan("de.pushservice.client") public class FinancerConfig { private static final Logger LOGGER = LoggerFactory.getLogger(FinancerConfig.class); diff --git a/financer-web-client/src/main/java/de/financer/controller/AccountController.java b/financer-web-client/src/main/java/de/financer/controller/AccountController.java index 627b067..fcbad97 100644 --- a/financer-web-client/src/main/java/de/financer/controller/AccountController.java +++ b/financer-web-client/src/main/java/de/financer/controller/AccountController.java @@ -11,6 +11,9 @@ import de.financer.template.*; import de.financer.template.exception.FinancerRestException; import de.financer.util.ControllerUtils; import de.financer.util.TransactionUtils; +import de.pushservice.client.dto.PayloadDto; +import de.pushservice.client.model.Urgency; +import de.pushservice.client.service.SubscriptionService; import org.apache.commons.collections4.IterableUtils; import org.apache.commons.lang3.BooleanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -189,4 +192,30 @@ public class AccountController { return "redirect:/accountOverview"; } + + // --------------------------------------------- + + @Autowired + private SubscriptionService subscriptionService; + private int counter = 0; + + @GetMapping("/sentTestNotification") + public String sentTestNotification() { + if (this.subscriptionService.isInitialized()) { + PayloadDto p = new PayloadDto("Hello from Financer!"); + + p.setTimestamp(System.currentTimeMillis()); + p.setMessage("Test notification " + counter++); + p.setVibration(new int[] {100, 200, 300, 400, 500}); + + try { + this.subscriptionService.notify(p, "FINANCER-TEST", Urgency.NORMAL); + } + catch(Exception e) { + e.printStackTrace(); + } + } + + return "redirect:/accountOverview"; + } } diff --git a/financer-web-client/src/main/resources/config/application-mk.properties b/financer-web-client/src/main/resources/config/application-mk.properties index 1961672..dd36e21 100644 --- a/financer-web-client/src/main/resources/config/application-mk.properties +++ b/financer-web-client/src/main/resources/config/application-mk.properties @@ -1 +1,2 @@ -financer.serverUrl=http://localhost:8080/financer-server-mk/ \ No newline at end of file +financer.serverUrl=http://localhost:8080/financer-server-mk/ +push-service-client.serverUrl=http://localhost:8080/push-service-server-mk/ \ No newline at end of file diff --git a/financer-web-client/src/main/resources/config/application.properties b/financer-web-client/src/main/resources/config/application.properties index 03a2920..21eba0e 100644 --- a/financer-web-client/src/main/resources/config/application.properties +++ b/financer-web-client/src/main/resources/config/application.properties @@ -32,4 +32,7 @@ spring.messages.basename=i18n/message # The currency code to use for displaying money values. Note that the currency is only used for # displaying. # Possible values are ISO-4271 currency codes. -financer.currencyCode=EUR \ No newline at end of file +financer.currencyCode=EUR + +push-service-client.serverUrl=http://localhost:8077/push-service-server/ +logging.level.de.pushservice=DEBUG \ No newline at end of file diff --git a/financer-web-client/src/main/resources/static/javascript/init.js b/financer-web-client/src/main/resources/static/javascript/init.js new file mode 100644 index 0000000..4abd3d0 --- /dev/null +++ b/financer-web-client/src/main/resources/static/javascript/init.js @@ -0,0 +1 @@ +window.onload = registerServiceWorker(); \ No newline at end of file diff --git a/financer-web-client/src/main/resources/templates/account/accountOverview.html b/financer-web-client/src/main/resources/templates/account/accountOverview.html index 83a39eb..5a14b03 100644 --- a/financer-web-client/src/main/resources/templates/account/accountOverview.html +++ b/financer-web-client/src/main/resources/templates/account/accountOverview.html @@ -4,8 +4,10 @@ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <link rel="stylesheet" th:href="@{/css/main.css}"> + <link rel="stylesheet" th:href="@{/css/main.css}" /> <link rel="shortcut icon" th:href="@{/favicon.ico}" /> + <script th:src="@{/javascript/push-service-client-init.js}"></script> + <script th:src="@{/javascript/init.js}"></script> </head> <body> <h1 th:text="#{financer.heading.account-overview}" /> diff --git a/financer-web-client/src/main/resources/templates/includes/footer.html b/financer-web-client/src/main/resources/templates/includes/footer.html index f7d062b..ff66c12 100644 --- a/financer-web-client/src/main/resources/templates/includes/footer.html +++ b/financer-web-client/src/main/resources/templates/includes/footer.html @@ -2,6 +2,6 @@ <hr> <div> <span th:text="'financer v' + ${financerVersion}"/> -  (<a th:href="@{/changelog.txt}">Changelog</a>, <a th:href="@{/readme.txt}">Readme</a>) +  (<a th:href="@{/changelog.txt}">Changelog</a>, <a th:href="@{/readme.txt}">Readme</a>, <a th:href="@{/sentTestNotification}">Test</a>) </div> </div> \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7b37496..c58c36c 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ <!-- Property to define the parallel deployment version. See e.g. https://tomcat.apache.org/tomcat-8.5-doc/config/context.html Should be the same as the project.version but padded with zeros to six digits. --> - <parallelDeploymentVersion>000030</parallelDeploymentVersion> + <parallelDeploymentVersion>000031</parallelDeploymentVersion> </properties> <modules> @@ -87,6 +87,11 @@ <artifactId>financer-common</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>de.77zzcx7.push-service</groupId> + <artifactId>push-service-client-lib</artifactId> + <version>2</version> + </dependency> </dependencies> </dependencyManagement>