diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java index 520b7e0faca636b0ab95f2858b22de45692f5063..93c03add156efaef4eb6a5c1b6d95895a08ca49e 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java @@ -491,15 +491,21 @@ public class SettingsController extends BaseController } @GetMapping("/updateSearch") - public String updateSearch(WebRequest request) + @ResponseBody + public String updateSearch() { budgetMasterUpdateService.getUpdateService().fetchCurrentVersion(); if(budgetMasterUpdateService.isUpdateAvailable()) { - WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.settings.update.available", budgetMasterUpdateService.getAvailableVersionString()), NotificationType.INFO)); + final JsonObject toastContent = new JsonObject(); + toastContent.addProperty("localizedMessage", Localization.getString("notification.settings.update.available", budgetMasterUpdateService.getAvailableVersionString())); + toastContent.addProperty("classes", getToastClasses(NotificationType.INFO)); + return toastContent.toString(); } - return ReturnValues.REDIRECT_ALL_ENTITIES; + + final JsonObject toastContent = getToastContent("notification.settings.update.not.available", NotificationType.INFO); + return toastContent.toString(); } @GetMapping("/update") diff --git a/BudgetMasterServer/src/main/resources/languages/base_de.properties b/BudgetMasterServer/src/main/resources/languages/base_de.properties index ef77b4acb606c13f02c63b8ab61d262b16c0c9fb..94e40a891a21176d41a8a81642a2ad2f0dafc4da 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_de.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_de.properties @@ -178,6 +178,7 @@ notification.settings.transactions.error=Fehler beim Speichern der Buchungseinst notification.settings.update.saved=Updateeinstellungen gespeichert notification.settings.update.error=Fehler beim Speichern der Updateeinstellungen notification.settings.update.available=BudgetMaster Update "{0}" verfügbar +notification.settings.update.not.available=Kein Update verfügbar notification.settings.database.delete.success=Datenbank erfolgreich gelöscht notification.settings.backup.run.success=Backup erfolgreich notification.settings.backup.run.error=Backup fehlgeschlagen diff --git a/BudgetMasterServer/src/main/resources/languages/base_en.properties b/BudgetMasterServer/src/main/resources/languages/base_en.properties index 56735f3d086cb747e90f9b63c59fd5b45128cef1..11177b52d1b345a9ebb6dae5eeb443d4b702673b 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_en.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_en.properties @@ -179,6 +179,7 @@ notification.settings.transactions.error=Error saving transactions settings notification.settings.update.saved=Update settings saved notification.settings.update.error=Error saving update settings notification.settings.update.available=BudgetMaster update "{0}" available +notification.settings.update.not.available=No update available notification.settings.database.delete.success=Successfully deleted database notification.settings.backup.run.success=Backup successful notification.settings.backup.run.error=Backup failed diff --git a/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsUpdate.ftl b/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsUpdate.ftl index 0f157e768c1c3740552a40e156b6bb3da7892bf2..cf31e0a611a28327570577984654ea2639f55a5e 100644 --- a/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsUpdate.ftl +++ b/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsUpdate.ftl @@ -46,7 +46,7 @@ </div> <div class="table-cell table-cell-valign"> - <@header.buttonLink url='/settings/updateSearch' icon='refresh' localizationKey='settings.updates.search'/> + <@header.buttonLink url='/settings/updateSearch' icon='refresh' localizationKey='settings.updates.search' isDataUrl=true id='button-update-search'/> </div> </div> </div> @@ -77,6 +77,35 @@ <@header.buttonSubmit name='action' icon='save' localizationKey='save' color='background-green' formaction='/settings/save/update'/> </div> </div> + + <script> + $('#button-update-search').click(function() + { + $.ajax({ + type: 'GET', + url: $(this).attr('data-url'), + data: {}, + success: function(response) + { + M.Toast.dismissAll(); + + let parsedData = JSON.parse(response); + M.toast({ + html: parsedData['localizedMessage'], + classes: parsedData['classes'] + }); + }, + error: function(response) + { + M.toast({ + html: "Error searching for updates", + classes: 'red' + }); + console.error(response); + } + }); + }); + </script> </@settingsContainerMacros.settingsContainer> </#macro>