diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hints/HintController.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hints/HintController.java index 6153f2f8676902bf7612b8686558768a8bae610e..cc4d92aa6689cac345eb9bd2be7d11192ede4204 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hints/HintController.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hints/HintController.java @@ -2,10 +2,6 @@ package de.deadlocker8.budgetmaster.hints; import de.deadlocker8.budgetmaster.controller.BaseController; import de.deadlocker8.budgetmaster.utils.Mappings; -import de.deadlocker8.budgetmaster.utils.WebRequestUtils; -import de.deadlocker8.budgetmaster.utils.notification.Notification; -import de.deadlocker8.budgetmaster.utils.notification.NotificationType; -import de.thecodelabs.utils.util.Localization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; @@ -13,7 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.context.request.WebRequest; @Controller @@ -34,13 +29,4 @@ public class HintController extends BaseController { hintService.dismiss(ID); } - - @GetMapping("/resetAll") - public String resetAll(WebRequest request) - { - hintService.resetAll(); - - WebRequestUtils.putNotification(request, new Notification(Localization.getString("notification.hints.reset"), NotificationType.SUCCESS)); - return "redirect:/settings"; - } } \ No newline at end of file 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 93c03add156efaef4eb6a5c1b6d95895a08ca49e..cb2297b240858daeb5c2f19b6f3db94dc482e6f7 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/settings/SettingsController.java @@ -9,6 +9,7 @@ import de.deadlocker8.budgetmaster.database.DatabaseParser; import de.deadlocker8.budgetmaster.database.DatabaseService; import de.deadlocker8.budgetmaster.database.InternalDatabase; import de.deadlocker8.budgetmaster.database.model.BackupDatabase; +import de.deadlocker8.budgetmaster.hints.HintService; import de.deadlocker8.budgetmaster.services.ImportResultItem; import de.deadlocker8.budgetmaster.services.ImportService; import de.deadlocker8.budgetmaster.settings.containers.PersonalizationSettingsContainer; @@ -83,6 +84,7 @@ public class SettingsController extends BaseController public static final String CONTAINER_PERSONALIZATION = "settings/containers/settingsPersonalization"; public static final String CONTAINER_TRANSACTIONS = "settings/containers/settingsTransactions"; public static final String CONTAINER_UPDATE = "settings/containers/settingsUpdate"; + public static final String CONTAINER_MISC = "settings/containers/settingsMisc"; } private static class RequestAttributeNames @@ -100,11 +102,12 @@ public class SettingsController extends BaseController private final ImportService importService; private final BudgetMasterUpdateService budgetMasterUpdateService; private final BackupService backupService; + private final HintService hintService; private final List<Integer> SEARCH_RESULTS_PER_PAGE_OPTIONS = Arrays.asList(10, 20, 25, 30, 50, 100); @Autowired - public SettingsController(SettingsService settingsService, DatabaseService databaseService, CategoryService categoryService, ImportService importService, BudgetMasterUpdateService budgetMasterUpdateService, BackupService backupService) + public SettingsController(SettingsService settingsService, DatabaseService databaseService, CategoryService categoryService, ImportService importService, BudgetMasterUpdateService budgetMasterUpdateService, BackupService backupService, HintService hintService) { this.settingsService = settingsService; this.databaseService = databaseService; @@ -112,6 +115,7 @@ public class SettingsController extends BaseController this.importService = importService; this.budgetMasterUpdateService = budgetMasterUpdateService; this.backupService = backupService; + this.hintService = hintService; } @GetMapping @@ -255,6 +259,16 @@ public class SettingsController extends BaseController return ReturnValues.CONTAINER_UPDATE; } + @PostMapping(value = "/save/misc") + public String saveContainerMisc(Model model) + { + hintService.resetAll(); + + final JsonObject toastContent = getToastContent("notification.settings.hints.reset", NotificationType.SUCCESS); + model.addAttribute(ModelAttributes.TOAST_CONTENT, toastContent); + return ReturnValues.CONTAINER_MISC; + } + private JsonObject getToastContent(String localizationKey, NotificationType notificationType) { final JsonObject toastContent = new JsonObject(); diff --git a/BudgetMasterServer/src/main/resources/languages/base_de.properties b/BudgetMasterServer/src/main/resources/languages/base_de.properties index 94e40a891a21176d41a8a81642a2ad2f0dafc4da..37ebada83dac9f271c82f891989033159ab5bd60 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_de.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_de.properties @@ -179,6 +179,7 @@ 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.hints.reset=Alle Tipps zurückgesetzt notification.settings.database.delete.success=Datenbank erfolgreich gelöscht notification.settings.backup.run.success=Backup erfolgreich notification.settings.backup.run.error=Backup fehlgeschlagen @@ -320,6 +321,7 @@ settings.category.circle.style.activated=Kreise settings.personalization=Personalisierung settings.personalization.reload.page=Zum Anwenden visueller Änderungen <a href="">Seite neu laden</a> settings.transactions=Buchungen +settings.misc=Sonstiges settings.database.import=Importieren settings.database.export=Exportieren diff --git a/BudgetMasterServer/src/main/resources/languages/base_en.properties b/BudgetMasterServer/src/main/resources/languages/base_en.properties index 11177b52d1b345a9ebb6dae5eeb443d4b702673b..7f2077ed942674a327d9ae9df6be2618b7aa3f5d 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_en.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_en.properties @@ -178,6 +178,7 @@ notification.settings.transactions.saved=Transactions settings saved 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.hints.reset=All hints reset notification.settings.update.available=BudgetMaster update "{0}" available notification.settings.update.not.available=No update available notification.settings.database.delete.success=Successfully deleted database @@ -321,6 +322,7 @@ settings.category.circle.style.activated=Circles settings.personalization=Personalization settings.personalization.reload.page=<a href="">Reload</a> page to apply visual changes settings.transactions=Transactions +settings.misc=Misc settings.database.import=Import settings.database.export=Export diff --git a/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsMisc.ftl b/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsMisc.ftl new file mode 100644 index 0000000000000000000000000000000000000000..8722a6adccfc31cc0ab0770a4a93c79d6d117ae7 --- /dev/null +++ b/BudgetMasterServer/src/main/resources/templates/settings/containers/settingsMisc.ftl @@ -0,0 +1,19 @@ +<#import "/spring.ftl" as s> +<#import "../../helpers/validation.ftl" as validation> +<#import "../../helpers/header.ftl" as header> +<@header.globals/> + +<#import "settingsContainer.ftl" as settingsContainerMacros> +<#import "../settingsMacros.ftl" as settingsMacros> + +<#macro miscSettingsContainer importScripts> + <@settingsContainerMacros.settingsContainer 'MiscSettingsContainer' 'miscSettingsContainer' importScripts> + <div class="row no-margin-bottom"> + <div class="col s12 center-align"> + <@header.buttonSubmit name='action' icon='restore' localizationKey='button.hints.reset' color='background-blue' formaction='/settings/save/misc'/> + </div> + </div> + </@settingsContainerMacros.settingsContainer> +</#macro> + +<@miscSettingsContainer importScripts=true/> diff --git a/BudgetMasterServer/src/main/resources/templates/settings/settings.ftl b/BudgetMasterServer/src/main/resources/templates/settings/settings.ftl index a626b77a5bd219bf77e18b2d9e30f6f4eb6d02a4..8246e214d908224e54c48019d33fe4bde1f16743 100644 --- a/BudgetMasterServer/src/main/resources/templates/settings/settings.ftl +++ b/BudgetMasterServer/src/main/resources/templates/settings/settings.ftl @@ -17,7 +17,8 @@ <#import "containers/settingsSecurity.ftl" as settingsSecurityMacros> <#import "containers/settingsPersonalization.ftl" as settingsPersonalizationMacros> <#import "containers/settingsTransactions.ftl" as settingsTransactionsMacros> - <#import "containers/settingsUpdate.ftl" as settingsUpdatenMacros> + <#import "containers/settingsUpdate.ftl" as settingsUpdateMacros> + <#import "containers/settingsMisc.ftl" as settingsMiscMacros> <!-- Scripts--> <#import "../helpers/scripts.ftl" as scripts> @@ -86,15 +87,11 @@ </@settingsMacros.settingsCollapsibleItem> <@settingsMacros.settingsCollapsibleItem "updateSettingsContainer" "system_update" locale.getString("settings.updates")> - <@settingsUpdatenMacros.updateSettingsContainer importScripts=false settings=settings/> + <@settingsUpdateMacros.updateSettingsContainer importScripts=false settings=settings/> </@settingsMacros.settingsCollapsibleItem> - <@settingsMacros.settingsCollapsibleItem "" "miscellaneous_services" "Misc"> - <div class="row no-margin-bottom"> - <div class="col s12 center-align"> - <@header.buttonLink url='/hints/resetAll' icon='restore' localizationKey='button.hints.reset'/> - </div> - </div> + <@settingsMacros.settingsCollapsibleItem "miscSettingsContainer" "miscellaneous_services" locale.getString("settings.misc")> + <@settingsMiscMacros.miscSettingsContainer importScripts=false/> </@settingsMacros.settingsCollapsibleItem> <@settingsMacros.settingsCollapsibleItem "" "fas fa-database" locale.getString("menu.settings.database") true> @@ -105,8 +102,6 @@ </div> </div> - - <form name="Settings" action="<@s.url '/settings/save'/>" method="post" onsubmit="return validateForm()"> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" id="token"/> <input type="hidden" name="ID" value="${settings.getID()?c}"> @@ -150,6 +145,7 @@ initSettingsContainer('PersonalizationSettingsContainer', 'personalizationSettingsContainer'); initSettingsContainer('TransactionsSettingsContainer', 'transactionsSettingsContainer'); initSettingsContainer('UpdateSettingsContainer', 'updateSettingsContainer'); + initSettingsContainer('MiscSettingsContainer', 'miscSettingsContainer'); </script> </@header.body> </html>