Skip to content
Snippets Groups Projects
Commit 0a926cea authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#696 - perform update search without page reload

parent 84812fb7
No related branches found
No related tags found
No related merge requests found
...@@ -491,15 +491,21 @@ public class SettingsController extends BaseController ...@@ -491,15 +491,21 @@ public class SettingsController extends BaseController
} }
@GetMapping("/updateSearch") @GetMapping("/updateSearch")
public String updateSearch(WebRequest request) @ResponseBody
public String updateSearch()
{ {
budgetMasterUpdateService.getUpdateService().fetchCurrentVersion(); budgetMasterUpdateService.getUpdateService().fetchCurrentVersion();
if(budgetMasterUpdateService.isUpdateAvailable()) 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") @GetMapping("/update")
......
...@@ -178,6 +178,7 @@ notification.settings.transactions.error=Fehler beim Speichern der Buchungseinst ...@@ -178,6 +178,7 @@ notification.settings.transactions.error=Fehler beim Speichern der Buchungseinst
notification.settings.update.saved=Updateeinstellungen gespeichert notification.settings.update.saved=Updateeinstellungen gespeichert
notification.settings.update.error=Fehler beim Speichern der Updateeinstellungen notification.settings.update.error=Fehler beim Speichern der Updateeinstellungen
notification.settings.update.available=BudgetMaster Update "{0}" verfügbar 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.database.delete.success=Datenbank erfolgreich gelöscht
notification.settings.backup.run.success=Backup erfolgreich notification.settings.backup.run.success=Backup erfolgreich
notification.settings.backup.run.error=Backup fehlgeschlagen notification.settings.backup.run.error=Backup fehlgeschlagen
......
...@@ -179,6 +179,7 @@ notification.settings.transactions.error=Error saving transactions settings ...@@ -179,6 +179,7 @@ notification.settings.transactions.error=Error saving transactions settings
notification.settings.update.saved=Update settings saved notification.settings.update.saved=Update settings saved
notification.settings.update.error=Error saving update settings notification.settings.update.error=Error saving update settings
notification.settings.update.available=BudgetMaster update "{0}" available 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.database.delete.success=Successfully deleted database
notification.settings.backup.run.success=Backup successful notification.settings.backup.run.success=Backup successful
notification.settings.backup.run.error=Backup failed notification.settings.backup.run.error=Backup failed
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</div> </div>
<div class="table-cell table-cell-valign"> <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> </div>
</div> </div>
...@@ -77,6 +77,35 @@ ...@@ -77,6 +77,35 @@
<@header.buttonSubmit name='action' icon='save' localizationKey='save' color='background-green' formaction='/settings/save/update'/> <@header.buttonSubmit name='action' icon='save' localizationKey='save' color='background-green' formaction='/settings/save/update'/>
</div> </div>
</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> </@settingsContainerMacros.settingsContainer>
</#macro> </#macro>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment