Merge pull request #183 from muff1nman/settings-fixes

Fixes #179 and Fixes #181
master
Tom Powell 8 years ago committed by GitHub
commit 51de74b7c5
  1. 15
      libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java
  2. 14
      libresonic-main/src/main/java/org/libresonic/player/command/GeneralSettingsCommand.java
  3. 9
      libresonic-main/src/main/java/org/libresonic/player/command/MusicFolderSettingsCommand.java
  4. 9
      libresonic-main/src/main/java/org/libresonic/player/command/NetworkSettingsCommand.java
  5. 9
      libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java
  6. 5
      libresonic-main/src/main/java/org/libresonic/player/command/PlayerSettingsCommand.java
  7. 8
      libresonic-main/src/main/java/org/libresonic/player/command/PodcastSettingsCommand.java
  8. 18
      libresonic-main/src/main/java/org/libresonic/player/command/UserSettingsCommand.java
  9. 10
      libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java
  10. 51
      libresonic-main/src/main/java/org/libresonic/player/controller/DLNASettingsController.java
  11. 17
      libresonic-main/src/main/java/org/libresonic/player/controller/GeneralSettingsController.java
  12. 54
      libresonic-main/src/main/java/org/libresonic/player/controller/InternetRadioSettingsController.java
  13. 9
      libresonic-main/src/main/java/org/libresonic/player/controller/MusicFolderSettingsController.java
  14. 9
      libresonic-main/src/main/java/org/libresonic/player/controller/NetworkSettingsController.java
  15. 10
      libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java
  16. 7
      libresonic-main/src/main/java/org/libresonic/player/controller/PlayerSettingsController.java
  17. 9
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastSettingsController.java
  18. 82
      libresonic-main/src/main/java/org/libresonic/player/controller/ShareSettingsController.java
  19. 62
      libresonic-main/src/main/java/org/libresonic/player/controller/SonosSettingsController.java
  20. 77
      libresonic-main/src/main/java/org/libresonic/player/controller/TranscodingSettingsController.java
  21. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/UserSettingsController.java
  22. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp
  23. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/dlnaSettings.jsp
  24. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/generalSettings.jsp
  25. 8
      libresonic-main/src/main/webapp/WEB-INF/jsp/internetRadioSettings.jsp
  26. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/musicFolderSettings.jsp
  27. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/networkSettings.jsp
  28. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/passwordSettings.jsp
  29. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp
  30. 4
      libresonic-main/src/main/webapp/WEB-INF/jsp/playerSettings.jsp
  31. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/podcastSettings.jsp
  32. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/premiumSettings.jsp
  33. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/shareSettings.jsp
  34. 2
      libresonic-main/src/main/webapp/WEB-INF/jsp/sonosSettings.jsp
  35. 16
      libresonic-main/src/main/webapp/WEB-INF/jsp/transcodingSettings.jsp
  36. 13
      libresonic-main/src/main/webapp/WEB-INF/jsp/userSettings.jsp
  37. 32
      libresonic-main/src/main/webapp/WEB-INF/libresonic-servlet.xml

@ -37,8 +37,6 @@ public class AdvancedSettingsCommand {
private String ldapManagerPassword; private String ldapManagerPassword;
private boolean ldapAutoShadowing; private boolean ldapAutoShadowing;
private String brand; private String brand;
private boolean isReloadNeeded;
private boolean toast;
private String smtpServer; private String smtpServer;
private String smtpEncryption; private String smtpEncryption;
@ -120,19 +118,6 @@ public class AdvancedSettingsCommand {
} }
public void setReloadNeeded(boolean reloadNeeded) { public void setReloadNeeded(boolean reloadNeeded) {
isReloadNeeded = reloadNeeded;
}
public boolean isReloadNeeded() {
return isReloadNeeded;
}
public boolean isToast() {
return toast;
}
public void setToast(boolean toast) {
this.toast = toast;
} }
public String getSmtpServer() { public String getSmtpServer() {

@ -46,8 +46,6 @@ public class GeneralSettingsCommand {
private String[] locales; private String[] locales;
private String themeIndex; private String themeIndex;
private Theme[] themes; private Theme[] themes;
private boolean isReloadNeeded;
private boolean toast;
public String getPlaylistFolder() { public String getPlaylistFolder() {
return playlistFolder; return playlistFolder;
@ -169,12 +167,7 @@ public class GeneralSettingsCommand {
this.themes = themes; this.themes = themes;
} }
public boolean isReloadNeeded() {
return isReloadNeeded;
}
public void setReloadNeeded(boolean reloadNeeded) { public void setReloadNeeded(boolean reloadNeeded) {
isReloadNeeded = reloadNeeded;
} }
public boolean isSortAlbumsByYear() { public boolean isSortAlbumsByYear() {
@ -193,11 +186,4 @@ public class GeneralSettingsCommand {
this.gettingStartedEnabled = gettingStartedEnabled; this.gettingStartedEnabled = gettingStartedEnabled;
} }
public boolean isToast() {
return toast;
}
public void setToast(boolean toast) {
this.toast = toast;
}
} }

@ -41,7 +41,6 @@ public class MusicFolderSettingsCommand {
private boolean organizeByFolderStructure; private boolean organizeByFolderStructure;
private List<MusicFolderInfo> musicFolders; private List<MusicFolderInfo> musicFolders;
private MusicFolderInfo newMusicFolder; private MusicFolderInfo newMusicFolder;
private boolean reload;
public String getInterval() { public String getInterval() {
return interval; return interval;
@ -91,14 +90,6 @@ public class MusicFolderSettingsCommand {
this.newMusicFolder = newMusicFolder; this.newMusicFolder = newMusicFolder;
} }
public void setReload(boolean reload) {
this.reload = reload;
}
public boolean isReload() {
return reload;
}
public boolean isOrganizeByFolderStructure() { public boolean isOrganizeByFolderStructure() {
return organizeByFolderStructure; return organizeByFolderStructure;
} }

@ -33,7 +33,6 @@ public class NetworkSettingsCommand {
private String urlRedirectCustomUrl; private String urlRedirectCustomUrl;
private String urlRedirectType; private String urlRedirectType;
private int port; private int port;
private boolean toast;
private LicenseInfo licenseInfo; private LicenseInfo licenseInfo;
public void setPortForwardingEnabled(boolean portForwardingEnabled) { public void setPortForwardingEnabled(boolean portForwardingEnabled) {
@ -75,14 +74,6 @@ public class NetworkSettingsCommand {
this.port = port; this.port = port;
} }
public boolean isToast() {
return toast;
}
public void setToast(boolean toast) {
this.toast = toast;
}
public void setLicenseInfo(LicenseInfo licenseInfo) { public void setLicenseInfo(LicenseInfo licenseInfo) {
this.licenseInfo = licenseInfo; this.licenseInfo = licenseInfo;
} }

@ -61,7 +61,6 @@ public class PersonalSettingsCommand {
private int listReloadDelay; private int listReloadDelay;
private String lastFmUsername; private String lastFmUsername;
private String lastFmPassword; private String lastFmPassword;
private boolean isReloadNeeded;
public User getUser() { public User getUser() {
return user; return user;
@ -271,14 +270,6 @@ public class PersonalSettingsCommand {
this.lastFmPassword = lastFmPassword; this.lastFmPassword = lastFmPassword;
} }
public boolean isReloadNeeded() {
return isReloadNeeded;
}
public void setReloadNeeded(boolean reloadNeeded) {
isReloadNeeded = reloadNeeded;
}
public boolean isQueueFollowingSongs() { public boolean isQueueFollowingSongs() {
return queueFollowingSongs; return queueFollowingSongs;
} }

@ -52,7 +52,6 @@ public class PlayerSettingsCommand {
private EnumHolder[] transcodeSchemeHolders; private EnumHolder[] transcodeSchemeHolders;
private Player[] players; private Player[] players;
private boolean isAdmin; private boolean isAdmin;
private boolean isReloadNeeded;
public String getPlayerId() { public String getPlayerId() {
return playerId; return playerId;
@ -206,12 +205,8 @@ public class PlayerSettingsCommand {
isAdmin = admin; isAdmin = admin;
} }
public boolean isReloadNeeded() {
return isReloadNeeded;
}
public void setReloadNeeded(boolean reloadNeeded) { public void setReloadNeeded(boolean reloadNeeded) {
isReloadNeeded = reloadNeeded;
} }
/** /**

@ -32,7 +32,6 @@ public class PodcastSettingsCommand {
private String folder; private String folder;
private String episodeRetentionCount; private String episodeRetentionCount;
private String episodeDownloadCount; private String episodeDownloadCount;
private boolean toast;
public String getInterval() { public String getInterval() {
return interval; return interval;
@ -66,11 +65,4 @@ public class PodcastSettingsCommand {
this.episodeDownloadCount = episodeDownloadCount; this.episodeDownloadCount = episodeDownloadCount;
} }
public boolean isToast() {
return toast;
}
public void setToast(boolean toast) {
this.toast = toast;
}
} }

@ -61,8 +61,6 @@ public class UserSettingsCommand {
private EnumHolder[] transcodeSchemeHolders; private EnumHolder[] transcodeSchemeHolders;
private boolean transcodingSupported; private boolean transcodingSupported;
private String transcodeDirectory; private String transcodeDirectory;
private boolean toast;
private boolean reload;
public String getUsername() { public String getUsername() {
return username; return username;
@ -297,21 +295,7 @@ public class UserSettingsCommand {
isSettingsRole = user != null && user.isSettingsRole(); isSettingsRole = user != null && user.isSettingsRole();
isShareRole = user != null && user.isShareRole(); isShareRole = user != null && user.isShareRole();
isLdapAuthenticated = user != null && user.isLdapAuthenticated(); isLdapAuthenticated = user != null && user.isLdapAuthenticated();
setNewUser(false);
} }
public void setToast(boolean toast) {
this.toast = toast;
}
public boolean isToast() {
return toast;
}
public boolean isReload() {
return reload;
}
public void setReload(boolean reload) {
this.reload = reload;
}
} }

@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/** /**
* Controller for the page used to administrate advanced settings. * Controller for the page used to administrate advanced settings.
@ -67,10 +68,10 @@ public class AdvancedSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute AdvancedSettingsCommand command,Model model) throws Exception { protected String doSubmitAction(@ModelAttribute AdvancedSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
command.setToast(true); redirectAttributes.addFlashAttribute("settings_reload", false);
command.setReloadNeeded(false); redirectAttributes.addFlashAttribute("settings_toast", true);
try { try {
settingsService.setDownloadBitrateLimit(Long.parseLong(command.getDownloadLimit())); settingsService.setDownloadBitrateLimit(Long.parseLong(command.getDownloadLimit()));
@ -99,8 +100,7 @@ public class AdvancedSettingsController {
settingsService.setSmtpPassword(command.getSmtpPassword()); settingsService.setSmtpPassword(command.getSmtpPassword());
} }
model.addAttribute("command", command); return "redirect:advancedSettings.view";
return "advancedSettings";
} }
} }

@ -22,53 +22,52 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestUtils; import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.ParameterizableViewController; import org.springframework.web.bind.annotation.RequestMethod;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.UPnPService; import org.libresonic.player.service.UPnPService;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/** /**
* Controller for the page used to administrate the UPnP/DLNA server settings. * Controller for the page used to administrate the UPnP/DLNA server settings.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class DLNASettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/dlnaSettings")
public class DLNASettingsController {
@Autowired
private UPnPService upnpService; private UPnPService upnpService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { public String handleGet(Model model) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
if (isFormSubmission(request)) {
handleParameters(request);
map.put("toast", true);
}
ModelAndView result = super.handleRequestInternal(request, response);
map.put("dlnaEnabled", settingsService.isDlnaEnabled()); map.put("dlnaEnabled", settingsService.isDlnaEnabled());
map.put("dlnaServerName", settingsService.getDlnaServerName()); map.put("dlnaServerName", settingsService.getDlnaServerName());
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); model.addAttribute("model", map);
return result; return "dlnaSettings";
} }
/** @RequestMapping(method = RequestMethod.POST)
* Determine if the given request represents a form submission. public String handlePost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
* handleParameters(request);
* @param request current HTTP request redirectAttributes.addFlashAttribute("settings_toast", true);
* @return if the request represents a form submission return "redirect:dlnaSettings.view";
*/
private boolean isFormSubmission(HttpServletRequest request) {
return "POST".equals(request.getMethod());
} }
private void handleParameters(HttpServletRequest request) { private void handleParameters(HttpServletRequest request) {
@ -84,12 +83,4 @@ public class DLNASettingsController extends ParameterizableViewController {
settingsService.save(); settingsService.save();
upnpService.setMediaServerEnabled(dlnaEnabled); upnpService.setMediaServerEnabled(dlnaEnabled);
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setUpnpService(UPnPService upnpService) {
this.upnpService = upnpService;
}
} }

@ -28,6 +28,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.Locale; import java.util.Locale;
@ -91,7 +92,7 @@ public class GeneralSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") GeneralSettingsCommand command, Model model) throws Exception { protected String doSubmitAction(@ModelAttribute("command") GeneralSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
int themeIndex = Integer.parseInt(command.getThemeIndex()); int themeIndex = Integer.parseInt(command.getThemeIndex());
Theme theme = settingsService.getAvailableThemes()[themeIndex]; Theme theme = settingsService.getAvailableThemes()[themeIndex];
@ -99,12 +100,14 @@ public class GeneralSettingsController {
int localeIndex = Integer.parseInt(command.getLocaleIndex()); int localeIndex = Integer.parseInt(command.getLocaleIndex());
Locale locale = settingsService.getAvailableLocales()[localeIndex]; Locale locale = settingsService.getAvailableLocales()[localeIndex];
command.setToast(true); redirectAttributes.addFlashAttribute("settings_toast", true);
command.setReloadNeeded(!settingsService.getIndexString().equals(command.getIndex()) || redirectAttributes.addFlashAttribute(
!settingsService.getIgnoredArticles().equals(command.getIgnoredArticles()) || "settings_reload",
!settingsService.getShortcuts().equals(command.getShortcuts()) || !settingsService.getIndexString().equals(command.getIndex())
!settingsService.getThemeId().equals(theme.getId()) || || !settingsService.getIgnoredArticles().equals(command.getIgnoredArticles())
!settingsService.getLocale().equals(locale)); || !settingsService.getShortcuts().equals(command.getShortcuts())
|| !settingsService.getThemeId().equals(theme.getId())
|| !settingsService.getLocale().equals(locale));
settingsService.setIndexString(command.getIndex()); settingsService.setIndexString(command.getIndex());
settingsService.setIgnoredArticles(command.getIgnoredArticles()); settingsService.setIgnoredArticles(command.getIgnoredArticles());

@ -22,11 +22,18 @@ package org.libresonic.player.controller;
import org.libresonic.player.domain.InternetRadio; import org.libresonic.player.domain.InternetRadio;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController; import org.springframework.web.servlet.mvc.ParameterizableViewController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -37,38 +44,35 @@ import java.util.Map;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class InternetRadioSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/internetRadioSettings")
public class InternetRadioSettingsController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { public String doGet(Model model) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
if (isFormSubmission(request)) { Map<String, Object> map = new HashMap<>();
String error = handleParameters(request);
map.put("error", error);
if (error == null) {
map.put("reload", true);
}
}
ModelAndView result = super.handleRequestInternal(request, response);
map.put("internetRadios", settingsService.getAllInternetRadios(true)); map.put("internetRadios", settingsService.getAllInternetRadios(true));
result.addObject("model", map); model.addAttribute("model", map);
return result; return "internetRadioSettings";
} }
/** @RequestMapping(method = RequestMethod.POST)
* Determine if the given request represents a form submission. public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
*
* @param request current HTTP request String error = handleParameters(request);
* @return if the request represents a form submission Map<String, Object> map = new HashMap<>();
*/ if(error == null) {
private boolean isFormSubmission(HttpServletRequest request) { redirectAttributes.addFlashAttribute("settings_toast", true);
return "POST".equals(request.getMethod()); redirectAttributes.addFlashAttribute("settings_reload", true);
}
redirectAttributes.addFlashAttribute("error", error);
return "redirect:internetRadioSettings.view";
} }
private String handleParameters(HttpServletRequest request) { private String handleParameters(HttpServletRequest request) {
@ -116,8 +120,4 @@ public class InternetRadioSettingsController extends ParameterizableViewControll
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]")); return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
} }

@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -65,7 +66,6 @@ public class MusicFolderSettingsController {
@ModelAttribute @ModelAttribute
protected void formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow, protected void formBackingObject(@RequestParam(value = "scanNow",required = false) String scanNow,
@RequestParam(value = "expunge",required = false) String expunge, @RequestParam(value = "expunge",required = false) String expunge,
@RequestParam(value = "reload",required = false) String reload,
Model model) throws Exception { Model model) throws Exception {
MusicFolderSettingsCommand command = new MusicFolderSettingsCommand(); MusicFolderSettingsCommand command = new MusicFolderSettingsCommand();
@ -84,7 +84,6 @@ public class MusicFolderSettingsController {
command.setScanning(mediaScannerService.isScanning()); command.setScanning(mediaScannerService.isScanning());
command.setMusicFolders(wrap(settingsService.getAllMusicFolders(true, true))); command.setMusicFolders(wrap(settingsService.getAllMusicFolders(true, true)));
command.setNewMusicFolder(new MusicFolderSettingsCommand.MusicFolderInfo()); command.setNewMusicFolder(new MusicFolderSettingsCommand.MusicFolderInfo());
command.setReload(reload != null || scanNow != null);
model.addAttribute("command",command); model.addAttribute("command",command);
} }
@ -105,7 +104,7 @@ public class MusicFolderSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, Model model) throws Exception { protected String onSubmit(@ModelAttribute("command") MusicFolderSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) { for (MusicFolderSettingsCommand.MusicFolderInfo musicFolderInfo : command.getMusicFolders()) {
if (musicFolderInfo.isDelete()) { if (musicFolderInfo.isDelete()) {
@ -129,6 +128,10 @@ public class MusicFolderSettingsController {
settingsService.setOrganizeByFolderStructure(command.isOrganizeByFolderStructure()); settingsService.setOrganizeByFolderStructure(command.isOrganizeByFolderStructure());
settingsService.save(); settingsService.save();
redirectAttributes.addFlashAttribute("settings_toast", true);
redirectAttributes.addFlashAttribute("settings_reload", true);
mediaScannerService.schedule(); mediaScannerService.schedule();
return "redirect:musicFolderSettings.view"; return "redirect:musicFolderSettings.view";
} }

@ -30,6 +30,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.Random; import java.util.Random;
@ -66,8 +67,7 @@ public class NetworkSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, Model model) throws Exception { protected String doSubmitAction(@ModelAttribute("command") NetworkSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
command.setToast(true);
settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled()); settingsService.setPortForwardingEnabled(command.isPortForwardingEnabled());
settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled()); settingsService.setUrlRedirectionEnabled(command.isUrlRedirectionEnabled());
@ -83,7 +83,10 @@ public class NetworkSettingsController {
settingsService.save(); settingsService.save();
networkService.initPortForwarding(0); networkService.initPortForwarding(0);
networkService.initUrlRedirection(true); networkService.initUrlRedirection(true);
return "networkSettings";
redirectAttributes.addFlashAttribute("settings_toast", true);
return "redirect:networkSettings.view";
} }
} }

@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
@ -112,7 +114,7 @@ public class PersonalSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command,Model model) throws Exception { protected String doSubmitAction(@ModelAttribute("command") PersonalSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
int localeIndex = Integer.parseInt(command.getLocaleIndex()); int localeIndex = Integer.parseInt(command.getLocaleIndex());
Locale locale = null; Locale locale = null;
@ -158,10 +160,10 @@ public class PersonalSettingsController {
settings.setChanged(new Date()); settings.setChanged(new Date());
settingsService.updateUserSettings(settings); settingsService.updateUserSettings(settings);
command.setReloadNeeded(true); redirectAttributes.addFlashAttribute("settings_reload", true);
redirectAttributes.addFlashAttribute("settings_toast", true);
model.addAttribute("command",command); return "redirect:personalSettings.view";
return "personalSettings";
} }
private int getAvatarId(UserSettings userSettings) { private int getAvatarId(UserSettings userSettings) {

@ -33,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -104,7 +106,7 @@ public class PlayerSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, Model model) throws Exception { protected String doSubmitAction(@ModelAttribute("command") PlayerSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
Player player = playerService.getPlayerById(command.getPlayerId()); Player player = playerService.getPlayerById(command.getPlayerId());
player.setAutoControlEnabled(command.isAutoControlEnabled()); player.setAutoControlEnabled(command.isAutoControlEnabled());
@ -117,7 +119,8 @@ public class PlayerSettingsController {
playerService.updatePlayer(player); playerService.updatePlayer(player);
transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds()); transcodingService.setTranscodingsForPlayer(player, command.getActiveTranscodingIds());
command.setReloadNeeded(true); redirectAttributes.addFlashAttribute("settings_reload", true);
redirectAttributes.addFlashAttribute("settings_toast", true);
return "redirect:playerSettings.view"; return "redirect:playerSettings.view";
} }

@ -28,6 +28,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/** /**
* Controller for the page used to administrate the Podcast receiver. * Controller for the page used to administrate the Podcast receiver.
@ -57,9 +58,7 @@ public class PodcastSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, Model model) throws Exception { protected String doSubmitAction(@ModelAttribute PodcastSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
command.setToast(true);
settingsService.setPodcastUpdateInterval(Integer.parseInt(command.getInterval())); settingsService.setPodcastUpdateInterval(Integer.parseInt(command.getInterval()));
settingsService.setPodcastEpisodeRetentionCount(Integer.parseInt(command.getEpisodeRetentionCount())); settingsService.setPodcastEpisodeRetentionCount(Integer.parseInt(command.getEpisodeRetentionCount()));
settingsService.setPodcastEpisodeDownloadCount(Integer.parseInt(command.getEpisodeDownloadCount())); settingsService.setPodcastEpisodeDownloadCount(Integer.parseInt(command.getEpisodeDownloadCount()));
@ -67,8 +66,8 @@ public class PodcastSettingsController {
settingsService.save(); settingsService.save();
podcastService.schedule(); podcastService.schedule();
model.addAttribute("command",command); redirectAttributes.addFlashAttribute("settings_toast", true);
return "podcastSettings"; return "redirect:podcastSettings.view";
} }
} }

@ -19,21 +19,8 @@
*/ */
package org.libresonic.player.controller; package org.libresonic.player.controller;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.domain.MediaFile; import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder; import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.Share; import org.libresonic.player.domain.Share;
@ -42,47 +29,60 @@ import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.SecurityService; import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.ShareService; import org.libresonic.player.service.ShareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Controller for the page used to administrate the set of shared media. * Controller for the page used to administrate the set of shared media.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class ShareSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/shareSettings")
public class ShareSettingsController {
@Autowired
private ShareService shareService; private ShareService shareService;
@Autowired
private SecurityService securityService; private SecurityService securityService;
@Autowired
private MediaFileService mediaFileService; private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
if (isFormSubmission(request)) { @RequestMapping(method = RequestMethod.GET)
handleParameters(request); public String doGet(HttpServletRequest request, Model model) throws Exception {
map.put("toast", true);
}
ModelAndView result = super.handleRequestInternal(request, response); Map<String, Object> map = new HashMap<String, Object>();
map.put("shareBaseUrl", shareService.getShareBaseUrl()); map.put("shareBaseUrl", shareService.getShareBaseUrl());
map.put("shareInfos", getShareInfos(request)); map.put("shareInfos", getShareInfos(request));
map.put("user", securityService.getCurrentUser(request)); map.put("user", securityService.getCurrentUser(request));
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); model.addAttribute("model", map);
return result; return "shareSettings";
} }
/** @RequestMapping(method = RequestMethod.POST)
* Determine if the given request represents a form submission. public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
* handleParameters(request);
* @param request current HTTP request
* @return if the request represents a form submission redirectAttributes.addFlashAttribute("settings_toast", true);
*/
private boolean isFormSubmission(HttpServletRequest request) { return "redirect:shareSettings.view";
return "POST".equals(request.getMethod());
} }
private void handleParameters(HttpServletRequest request) { private void handleParameters(HttpServletRequest request) {
@ -148,22 +148,6 @@ public class ShareSettingsController extends ParameterizableViewController {
return calendar.getTime(); return calendar.getTime();
} }
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setShareService(ShareService shareService) {
this.shareService = shareService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public static class ShareInfo { public static class ShareInfo {
private final Share share; private final Share share;
private final MediaFile dir; private final MediaFile dir;

@ -18,57 +18,55 @@
*/ */
package org.libresonic.player.controller; package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
import org.libresonic.player.service.SonosService; import org.libresonic.player.service.SonosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.HashMap;
import java.util.Map;
/** /**
* Controller for the page used to administrate the Sonos music service settings. * Controller for the page used to administrate the Sonos music service settings.
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class SonosSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/sonosSettings")
public class SonosSettingsController {
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Autowired
private SonosService sonosService; private SonosService sonosService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { public String doGet(Model model) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
if (isFormSubmission(request)) {
handleParameters(request);
map.put("toast", true);
}
ModelAndView result = super.handleRequestInternal(request, response);
map.put("sonosEnabled", settingsService.isSonosEnabled()); map.put("sonosEnabled", settingsService.isSonosEnabled());
map.put("sonosServiceName", settingsService.getSonosServiceName()); map.put("sonosServiceName", settingsService.getSonosServiceName());
map.put("licenseInfo", settingsService.getLicenseInfo()); map.put("licenseInfo", settingsService.getLicenseInfo());
result.addObject("model", map); model.addAttribute("model", map);
return result; return "sonosSettings";
} }
/** @RequestMapping(method = RequestMethod.POST)
* Determine if the given request represents a form submission. public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
* handleParameters(request);
* @param request current HTTP request
* @return if the request represents a form submission redirectAttributes.addFlashAttribute("settings_toast", true);
*/
private boolean isFormSubmission(HttpServletRequest request) { return "redirect:sonosSettings.view";
return "POST".equals(request.getMethod());
} }
private void handleParameters(HttpServletRequest request) { private void handleParameters(HttpServletRequest request) {
@ -85,12 +83,4 @@ public class SonosSettingsController extends ParameterizableViewController {
sonosService.setMusicServiceEnabled(false); sonosService.setMusicServiceEnabled(false);
sonosService.setMusicServiceEnabled(sonosEnabled); sonosService.setMusicServiceEnabled(sonosEnabled);
} }
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSonosService(SonosService sonosService) {
this.sonosService = sonosService;
}
} }

@ -23,11 +23,17 @@ import org.libresonic.player.domain.Transcoding;
import org.libresonic.player.service.TranscodingService; import org.libresonic.player.service.TranscodingService;
import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.SettingsService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -36,43 +42,41 @@ import java.util.Map;
* *
* @author Sindre Mehus * @author Sindre Mehus
*/ */
public class TranscodingSettingsController extends ParameterizableViewController { @Controller
@RequestMapping("/transcodingSettings")
public class TranscodingSettingsController {
@Autowired
private TranscodingService transcodingService; private TranscodingService transcodingService;
@Autowired
private SettingsService settingsService; private SettingsService settingsService;
@Override @RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { public String doGet(Model model) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
if (isFormSubmission(request)) {
handleParameters(request, map);
map.put("toast", true);
}
ModelAndView result = super.handleRequestInternal(request, response);
map.put("transcodings", transcodingService.getAllTranscodings()); map.put("transcodings", transcodingService.getAllTranscodings());
map.put("transcodeDirectory", transcodingService.getTranscodeDirectory()); map.put("transcodeDirectory", transcodingService.getTranscodeDirectory());
map.put("downsampleCommand", settingsService.getDownsamplingCommand()); map.put("downsampleCommand", settingsService.getDownsamplingCommand());
map.put("hlsCommand", settingsService.getHlsCommand()); map.put("hlsCommand", settingsService.getHlsCommand());
map.put("brand", settingsService.getBrand()); map.put("brand", settingsService.getBrand());
result.addObject("model", map); model.addAttribute("model", map);
return result; return "transcodingSettings";
} }
/** @RequestMapping(method = RequestMethod.POST)
* Determine if the given request represents a form submission. public String doPost(HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
* String error = handleParameters(request, redirectAttributes);
* @param request current HTTP request if(error != null) {
* @return if the request represents a form submission redirectAttributes.addFlashAttribute("settings_toast", true);
*/ }
private boolean isFormSubmission(HttpServletRequest request) { redirectAttributes.addFlashAttribute("error", error);
return "POST".equals(request.getMethod()); return "redirect:transcodingSettings.view";
} }
private void handleParameters(HttpServletRequest request, Map<String, Object> map) { private String handleParameters(HttpServletRequest request, RedirectAttributes redirectAttributes) {
for (Transcoding transcoding : transcodingService.getAllTranscodings()) { for (Transcoding transcoding : transcodingService.getAllTranscodings()) {
Integer id = transcoding.getId(); Integer id = transcoding.getId();
@ -86,13 +90,13 @@ public class TranscodingSettingsController extends ParameterizableViewController
if (delete) { if (delete) {
transcodingService.deleteTranscoding(id); transcodingService.deleteTranscoding(id);
} else if (name == null) { } else if (name == null) {
map.put("error", "transcodingsettings.noname"); return "transcodingsettings.noname";
} else if (sourceFormats == null) { } else if (sourceFormats == null) {
map.put("error", "transcodingsettings.nosourceformat"); return "transcodingsettings.nosourceformat";
} else if (targetFormat == null) { } else if (targetFormat == null) {
map.put("error", "transcodingsettings.notargetformat"); return "transcodingsettings.notargetformat";
} else if (step1 == null) { } else if (step1 == null) {
map.put("error", "transcodingsettings.nostep1"); return "transcodingsettings.nostep1";
} else { } else {
transcoding.setName(name); transcoding.setName(name);
transcoding.setSourceFormats(sourceFormats); transcoding.setSourceFormats(sourceFormats);
@ -112,35 +116,30 @@ public class TranscodingSettingsController extends ParameterizableViewController
if (name != null || sourceFormats != null || targetFormat != null || step1 != null || step2 != null) { if (name != null || sourceFormats != null || targetFormat != null || step1 != null || step2 != null) {
Transcoding transcoding = new Transcoding(null, name, sourceFormats, targetFormat, step1, step2, null, defaultActive); Transcoding transcoding = new Transcoding(null, name, sourceFormats, targetFormat, step1, step2, null, defaultActive);
String error = null;
if (name == null) { if (name == null) {
map.put("error", "transcodingsettings.noname"); error = "transcodingsettings.noname";
} else if (sourceFormats == null) { } else if (sourceFormats == null) {
map.put("error", "transcodingsettings.nosourceformat"); error = "transcodingsettings.nosourceformat";
} else if (targetFormat == null) { } else if (targetFormat == null) {
map.put("error", "transcodingsettings.notargetformat"); error = "transcodingsettings.notargetformat";
} else if (step1 == null) { } else if (step1 == null) {
map.put("error", "transcodingsettings.nostep1"); error = "transcodingsettings.nostep1";
} else { } else {
transcodingService.createTranscoding(transcoding); transcodingService.createTranscoding(transcoding);
} }
if (map.containsKey("error")) { if(error != null) {
map.put("newTranscoding", transcoding); redirectAttributes.addAttribute("newTranscoding", transcoding);
return error;
} }
} }
settingsService.setDownsamplingCommand(StringUtils.trim(request.getParameter("downsampleCommand"))); settingsService.setDownsamplingCommand(StringUtils.trim(request.getParameter("downsampleCommand")));
settingsService.setHlsCommand(StringUtils.trim(request.getParameter("hlsCommand"))); settingsService.setHlsCommand(StringUtils.trim(request.getParameter("hlsCommand")));
settingsService.save(); settingsService.save();
return null;
} }
private String getParameter(HttpServletRequest request, String name, Integer id) { private String getParameter(HttpServletRequest request, String name, Integer id) {
return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]")); return StringUtils.trimToNull(request.getParameter(name + "[" + id + "]"));
} }
public void setTranscodingService(TranscodingService transcodingService) {
this.transcodingService = transcodingService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
} }

@ -40,6 +40,8 @@ import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -51,7 +53,6 @@ import java.util.List;
*/ */
@Controller @Controller
@RequestMapping("/userSettings") @RequestMapping("/userSettings")
@SessionAttributes(value = "command")
public class UserSettingsController { public class UserSettingsController {
@Autowired @Autowired
@ -69,14 +70,15 @@ public class UserSettingsController {
} }
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
protected String displayForm() throws Exception { protected String displayForm(HttpServletRequest request, Model model) throws Exception {
return "userSettings";
}
@ModelAttribute
protected void formBackingObject(HttpServletRequest request,Model model) throws Exception {
UserSettingsCommand command = new UserSettingsCommand(); UserSettingsCommand command = new UserSettingsCommand();
command.setUsers(securityService.getAllUsers());
command.setTranscodingSupported(transcodingService.isDownsamplingSupported(null));
command.setTranscodeDirectory(transcodingService.getTranscodeDirectory().getPath());
command.setTranscodeSchemes(TranscodeScheme.values());
command.setLdapEnabled(settingsService.isLdapEnabled());
command.setAllMusicFolders(settingsService.getAllMusicFolders());
User user = getUser(request); User user = getUser(request);
if (user != null) { if (user != null) {
command.setUser(user); command.setUser(user);
@ -84,22 +86,15 @@ public class UserSettingsController {
command.setAdmin(User.USERNAME_ADMIN.equals(user.getUsername())); command.setAdmin(User.USERNAME_ADMIN.equals(user.getUsername()));
UserSettings userSettings = settingsService.getUserSettings(user.getUsername()); UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name()); command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name());
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
} else { } else {
command.setNewUser(true); command.setNewUser(true);
command.setStreamRole(true); command.setStreamRole(true);
command.setSettingsRole(true); command.setSettingsRole(true);
} }
command.setUsers(securityService.getAllUsers());
command.setTranscodingSupported(transcodingService.isDownsamplingSupported(null));
command.setTranscodeDirectory(transcodingService.getTranscodeDirectory().getPath());
command.setTranscodeSchemes(TranscodeScheme.values());
command.setLdapEnabled(settingsService.isLdapEnabled());
command.setAllMusicFolders(settingsService.getAllMusicFolders());
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
model.addAttribute("command",command); model.addAttribute("command",command);
return "userSettings";
} }
private User getUser(HttpServletRequest request) throws ServletRequestBindingException { private User getUser(HttpServletRequest request) throws ServletRequestBindingException {
@ -126,7 +121,7 @@ public class UserSettingsController {
} }
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command) throws Exception { protected String doSubmitAction(@ModelAttribute("command") @Validated UserSettingsCommand command, RedirectAttributes redirectAttributes) throws Exception {
if (command.isDeleteUser()) { if (command.isDeleteUser()) {
deleteUser(command); deleteUser(command);
@ -135,9 +130,10 @@ public class UserSettingsController {
} else { } else {
updateUser(command); updateUser(command);
} }
resetCommand(command); redirectAttributes.addFlashAttribute("settings_reload", true);
redirectAttributes.addFlashAttribute("settings_toast", true);
return "userSettings"; return "redirect:userSettings.view";
} }
private void deleteUser(UserSettingsCommand command) { private void deleteUser(UserSettingsCommand command) {
@ -181,22 +177,4 @@ public class UserSettingsController {
settingsService.setMusicFoldersForUser(command.getUsername(), allowedMusicFolderIds); settingsService.setMusicFoldersForUser(command.getUsername(), allowedMusicFolderIds);
} }
private void resetCommand(UserSettingsCommand command) {
command.setUser(null);
command.setUsers(securityService.getAllUsers());
command.setDeleteUser(false);
command.setPasswordChange(false);
command.setNewUser(true);
command.setStreamRole(true);
command.setSettingsRole(true);
command.setPassword(null);
command.setConfirmPassword(null);
command.setEmail(null);
command.setTranscodeSchemeName(null);
command.setAllMusicFolders(settingsService.getAllMusicFolders());
command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(null)));
command.setToast(true);
command.setReload(true);
}
} }

@ -18,7 +18,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="advanced"/> <c:param name="cat" value="advanced"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form:form method="post" action="advancedSettings.view" commandName="command"> <form:form method="post" action="advancedSettings.view" commandName="command">
@ -143,7 +143,7 @@
</form:form> </form:form>
<c:if test="${command.reloadNeeded}"> <c:if test="${settings_reload}">
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
parent.frames.left.location.href="left.view?"; parent.frames.left.location.href="left.view?";
parent.frames.playQueue.location.href="playQueue.view?"; parent.frames.playQueue.location.href="playQueue.view?";

@ -30,7 +30,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="dlna"/> <c:param name="cat" value="dlna"/>
<c:param name="toast" value="${model.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form method="post" action="dlnaSettings.view"> <form method="post" action="dlnaSettings.view">

@ -13,7 +13,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="general"/> <c:param name="cat" value="general"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form:form method="post" action="generalSettings.view" commandName="command"> <form:form method="post" action="generalSettings.view" commandName="command">
@ -165,7 +165,7 @@
</table> </table>
</form:form> </form:form>
<c:if test="${command.reloadNeeded}"> <c:if test="${settings_reload}">
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
parent.frames.left.location.href="left.view?"; parent.frames.left.location.href="left.view?";
parent.frames.playQueue.location.href="playQueue.view?"; parent.frames.playQueue.location.href="playQueue.view?";

@ -8,7 +8,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="internetRadio"/> <c:param name="cat" value="internetRadio"/>
<c:param name="toast" value="${model.reload}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form method="post" action="internetRadioSettings.view"> <form method="post" action="internetRadioSettings.view">
@ -55,11 +55,11 @@
</form> </form>
<c:if test="${not empty model.error}"> <c:if test="${not empty error}">
<p class="warning"><fmt:message key="${model.error}"/></p> <p class="warning"><fmt:message key="${error}"/></p>
</c:if> </c:if>
<c:if test="${model.reload}"> <c:if test="${settings_reload}">
<script language="javascript" type="text/javascript">parent.frames.left.location.href="left.view?"</script> <script language="javascript" type="text/javascript">parent.frames.left.location.href="left.view?"</script>
</c:if> </c:if>

@ -10,7 +10,7 @@
$("#newMusicFolderName").attr("placeholder", "<fmt:message key="musicfoldersettings.name"/>"); $("#newMusicFolderName").attr("placeholder", "<fmt:message key="musicfoldersettings.name"/>");
$("#newMusicFolderPath").attr("placeholder", "<fmt:message key="musicfoldersettings.path"/>"); $("#newMusicFolderPath").attr("placeholder", "<fmt:message key="musicfoldersettings.path"/>");
<c:if test="${command.reload}"> <c:if test="${settings_reload}">
parent.frames.upper.location.href="top.view?"; parent.frames.upper.location.href="top.view?";
parent.frames.left.location.href="left.view?"; parent.frames.left.location.href="left.view?";
parent.frames.right.location.href="right.view?"; parent.frames.right.location.href="right.view?";
@ -22,7 +22,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="musicFolder"/> <c:param name="cat" value="musicFolder"/>
<c:param name="toast" value="${command.reload}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form:form commandName="command" action="musicFolderSettings.view" method="post"> <form:form commandName="command" action="musicFolderSettings.view" method="post">

@ -43,7 +43,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="network"/> <c:param name="cat" value="network"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<p style="padding-top:1em"><fmt:message key="networksettings.text"/></p> <p style="padding-top:1em"><fmt:message key="networksettings.text"/></p>

@ -9,7 +9,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="password"/> <c:param name="cat" value="password"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
<c:param name="restricted" value="true"/> <c:param name="restricted" value="true"/>
</c:import> </c:import>

@ -20,7 +20,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="personal"/> <c:param name="cat" value="personal"/>
<c:param name="restricted" value="${not command.user.adminRole}"/> <c:param name="restricted" value="${not command.user.adminRole}"/>
<c:param name="toast" value="${command.reloadNeeded}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<fmt:message key="personalsettings.title" var="title"><fmt:param>${command.user.username}</fmt:param></fmt:message> <fmt:message key="personalsettings.title" var="title"><fmt:param>${command.user.username}</fmt:param></fmt:message>
@ -254,7 +254,7 @@
<fmt:message key="personalsettings.avatar.courtesy"/> <fmt:message key="personalsettings.avatar.courtesy"/>
</p> </p>
<c:if test="${command.reloadNeeded}"> <c:if test="${settings_reload}">
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
parent.location.href="index.view?"; parent.location.href="index.view?";
</script> </script>

@ -12,7 +12,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="player"/> <c:param name="cat" value="player"/>
<c:param name="toast" value="${command.reloadNeeded}"/> <c:param name="toast" value="${settings_toast}"/>
<c:param name="restricted" value="${not command.admin}"/> <c:param name="restricted" value="${not command.admin}"/>
</c:import> </c:import>
@ -163,7 +163,7 @@
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<c:if test="${command.reloadNeeded}"> <c:if test="${settings_reload}">
<script language="javascript" type="text/javascript">parent.frames.playQueue.location.href="playQueue.view?"</script> <script language="javascript" type="text/javascript">parent.frames.playQueue.location.href="playQueue.view?"</script>
</c:if> </c:if>

@ -9,7 +9,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="podcast"/> <c:param name="cat" value="podcast"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form:form commandName="command" action="podcastSettings.view" method="post"> <form:form commandName="command" action="podcastSettings.view" method="post">

@ -10,7 +10,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="premium"/> <c:param name="cat" value="premium"/>
<c:param name="restricted" value="${not command.user.adminRole}"/> <c:param name="restricted" value="${not command.user.adminRole}"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<c:if test="${not empty command.path}"> <c:if test="${not empty command.path}">

@ -9,7 +9,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="share"/> <c:param name="cat" value="share"/>
<c:param name="toast" value="${model.toast}"/> <c:param name="toast" value="${settings_toast}"/>
<c:param name="restricted" value="${not model.user.adminRole}"/> <c:param name="restricted" value="${not model.user.adminRole}"/>
</c:import> </c:import>

@ -30,7 +30,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="sonos"/> <c:param name="cat" value="sonos"/>
<c:param name="toast" value="${model.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form method="post" action="sonosSettings.view"> <form method="post" action="sonosSettings.view">

@ -10,7 +10,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="transcoding"/> <c:param name="cat" value="transcoding"/>
<c:param name="toast" value="${model.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<form method="post" action="transcodingSettings.view"> <form method="post" action="transcodingSettings.view">
@ -40,11 +40,11 @@
</tr> </tr>
<tr> <tr>
<td><input style="font-family:monospace" type="text" name="name" size="10" placeholder="<fmt:message key="transcodingsettings.name"/>" value="${model.newTranscoding.name}"/></td> <td><input style="font-family:monospace" type="text" name="name" size="10" placeholder="<fmt:message key="transcodingsettings.name"/>" value="${newTranscoding.name}"/></td>
<td><input style="font-family:monospace" type="text" name="sourceFormats" size="36" placeholder="<fmt:message key="transcodingsettings.sourceformat"/>" value="${model.newTranscoding.sourceFormats}"/></td> <td><input style="font-family:monospace" type="text" name="sourceFormats" size="36" placeholder="<fmt:message key="transcodingsettings.sourceformat"/>" value="${newTranscoding.sourceFormats}"/></td>
<td><input style="font-family:monospace" type="text" name="targetFormat" size="10" placeholder="<fmt:message key="transcodingsettings.targetformat"/>" value="${model.newTranscoding.targetFormat}"/></td> <td><input style="font-family:monospace" type="text" name="targetFormat" size="10" placeholder="<fmt:message key="transcodingsettings.targetformat"/>" value="${newTranscoding.targetFormat}"/></td>
<td><input style="font-family:monospace" type="text" name="step1" size="60" placeholder="<fmt:message key="transcodingsettings.step1"/>" value="${model.newTranscoding.step1}"/></td> <td><input style="font-family:monospace" type="text" name="step1" size="60" placeholder="<fmt:message key="transcodingsettings.step1"/>" value="${newTranscoding.step1}"/></td>
<td><input style="font-family:monospace" type="text" name="step2" size="22" placeholder="<fmt:message key="transcodingsettings.step2"/>" value="${model.newTranscoding.step2}"/></td> <td><input style="font-family:monospace" type="text" name="step2" size="22" placeholder="<fmt:message key="transcodingsettings.step2"/>" value="${newTranscoding.step2}"/></td>
<td/> <td/>
</tr> </tr>
@ -87,8 +87,8 @@
</form> </form>
<c:if test="${not empty model.error}"> <c:if test="${not empty error}">
<p class="warning"><fmt:message key="${model.error}"/></p> <p class="warning"><fmt:message key="${error}"/></p>
</c:if> </c:if>
<div style="width:60%"> <div style="width:60%">

@ -8,7 +8,7 @@
<script type="text/javascript"> <script type="text/javascript">
function init() { function init() {
enablePasswordChangeFields(); enablePasswordChangeFields();
<c:if test="${command.reload}"> <c:if test="${settings_reload}">
parent.frames.left.location.href="left.view?"; parent.frames.left.location.href="left.view?";
</c:if> </c:if>
} }
@ -41,7 +41,7 @@
<c:import url="settingsHeader.jsp"> <c:import url="settingsHeader.jsp">
<c:param name="cat" value="user"/> <c:param name="cat" value="user"/>
<c:param name="toast" value="${command.toast}"/> <c:param name="toast" value="${settings_toast}"/>
</c:import> </c:import>
<table class="indent"> <table class="indent">
@ -61,9 +61,8 @@
<p/> <p/>
<form:form method="post" action="userSettings.view" commandName="command"> <form:form method="post" action="userSettings.view" modelAttribute="command">
<c:if test="${not command.admin}"> <table style="${command.admin ? 'display:none' : ''}">
<table>
<tr> <tr>
<td><form:checkbox path="adminRole" id="admin" cssClass="checkbox"/></td> <td><form:checkbox path="adminRole" id="admin" cssClass="checkbox"/></td>
<td><label for="admin"><fmt:message key="usersettings.admin"/></label></td> <td><label for="admin"><fmt:message key="usersettings.admin"/></label></td>
@ -105,7 +104,6 @@
<td><label for="podcast"><fmt:message key="usersettings.podcast"/></label></td> <td><label for="podcast"><fmt:message key="usersettings.podcast"/></label></td>
</tr> </tr>
</table> </table>
</c:if>
<c:if test="${not empty command.allMusicFolders}"> <c:if test="${not empty command.allMusicFolders}">
<h2><fmt:message key="usersettings.folderaccess"/></h2> <h2><fmt:message key="usersettings.folderaccess"/></h2>
@ -158,7 +156,7 @@
<c:choose> <c:choose>
<c:when test="${command.newUser}"> <c:when test="${command.newUser}">
<div style="display:none"><form:input path="newUser" /></div>
<table class="indent"> <table class="indent">
<tr> <tr>
<td><fmt:message key="usersettings.username"/></td> <td><fmt:message key="usersettings.username"/></td>
@ -184,6 +182,7 @@
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<div style="display:none"><form:input path="username"/></div>
<table id="passwordChangeCheckboxTable"> <table id="passwordChangeCheckboxTable">
<tr> <tr>
<td><form:checkbox path="passwordChange" id="passwordChange" onclick="enablePasswordChangeFields();" cssClass="checkbox"/></td> <td><form:checkbox path="passwordChange" id="passwordChange" onclick="enablePasswordChangeFields();" cssClass="checkbox"/></td>

@ -145,33 +145,6 @@
<bean id="settingsController" class="org.libresonic.player.controller.SettingsController"> <bean id="settingsController" class="org.libresonic.player.controller.SettingsController">
<property name="securityService" ref="securityService"/> <property name="securityService" ref="securityService"/>
</bean> </bean>
<bean id="dlnaSettingsController" class="org.libresonic.player.controller.DLNASettingsController">
<property name="viewName" value="dlnaSettings"/>
<property name="upnpService" ref="upnpService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="sonosSettingsController" class="org.libresonic.player.controller.SonosSettingsController">
<property name="viewName" value="sonosSettings"/>
<property name="sonosService" ref="sonosService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="shareSettingsController" class="org.libresonic.player.controller.ShareSettingsController">
<property name="viewName" value="shareSettings"/>
<property name="shareService" ref="shareService"/>
<property name="securityService" ref="securityService"/>
<property name="mediaFileService" ref="mediaFileService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="transcodingSettingsController" class="org.libresonic.player.controller.TranscodingSettingsController">
<property name="viewName" value="transcodingSettings"/>
<property name="transcodingService" ref="transcodingService"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="internetRadioSettingsController"
class="org.libresonic.player.controller.InternetRadioSettingsController">
<property name="viewName" value="internetRadioSettings"/>
<property name="settingsService" ref="settingsService"/>
</bean>
<bean id="avatarUploadController" class="org.libresonic.player.controller.AvatarUploadController"> <bean id="avatarUploadController" class="org.libresonic.player.controller.AvatarUploadController">
<property name="viewName" value="avatarUploadResult"/> <property name="viewName" value="avatarUploadResult"/>
<property name="settingsService" ref="settingsService"/> <property name="settingsService" ref="settingsService"/>
@ -344,11 +317,6 @@
<prop key="/nowPlaying.view">nowPlayingController</prop> <prop key="/nowPlaying.view">nowPlayingController</prop>
<prop key="/starred.view">starredController</prop> <prop key="/starred.view">starredController</prop>
<prop key="/settings.view">settingsController</prop> <prop key="/settings.view">settingsController</prop>
<prop key="/dlnaSettings.view">dlnaSettingsController</prop>
<prop key="/sonosSettings.view">sonosSettingsController</prop>
<prop key="/shareSettings.view">shareSettingsController</prop>
<prop key="/transcodingSettings.view">transcodingSettingsController</prop>
<prop key="/internetRadioSettings.view">internetRadioSettingsController</prop>
<prop key="/avatarUpload.view">avatarUploadController</prop> <prop key="/avatarUpload.view">avatarUploadController</prop>
<prop key="/allmusic.view">allmusicController</prop> <prop key="/allmusic.view">allmusicController</prop>
<prop key="/home.view">homeController</prop> <prop key="/home.view">homeController</prop>

Loading…
Cancel
Save