|
|
|
@ -23,6 +23,12 @@ import java.util.Locale; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.servlet.mvc.SimpleFormController; |
|
|
|
|
|
|
|
|
|
import org.libresonic.player.command.GeneralSettingsCommand; |
|
|
|
@ -34,11 +40,15 @@ import org.libresonic.player.service.SettingsService; |
|
|
|
|
* |
|
|
|
|
* @author Sindre Mehus |
|
|
|
|
*/ |
|
|
|
|
public class GeneralSettingsController extends SimpleFormController { |
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/generalSettings") |
|
|
|
|
public class GeneralSettingsController { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private SettingsService settingsService; |
|
|
|
|
|
|
|
|
|
protected Object formBackingObject(HttpServletRequest request) throws Exception { |
|
|
|
|
@RequestMapping(method = RequestMethod.GET) |
|
|
|
|
protected String formBackingObject(Model model) throws Exception { |
|
|
|
|
GeneralSettingsCommand command = new GeneralSettingsCommand(); |
|
|
|
|
command.setCoverArtFileTypes(settingsService.getCoverArtFileTypes()); |
|
|
|
|
command.setIgnoredArticles(settingsService.getIgnoredArticles()); |
|
|
|
@ -76,12 +86,12 @@ public class GeneralSettingsController extends SimpleFormController { |
|
|
|
|
} |
|
|
|
|
command.setLocales(localeStrings); |
|
|
|
|
|
|
|
|
|
return command; |
|
|
|
|
|
|
|
|
|
model.addAttribute("command",command); |
|
|
|
|
return "generalSettings"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void doSubmitAction(Object comm) throws Exception { |
|
|
|
|
GeneralSettingsCommand command = (GeneralSettingsCommand) comm; |
|
|
|
|
@RequestMapping(method = RequestMethod.POST) |
|
|
|
|
protected String doSubmitAction(@ModelAttribute GeneralSettingsCommand command, Model model) throws Exception { |
|
|
|
|
|
|
|
|
|
int themeIndex = Integer.parseInt(command.getThemeIndex()); |
|
|
|
|
Theme theme = settingsService.getAvailableThemes()[themeIndex]; |
|
|
|
@ -112,9 +122,8 @@ public class GeneralSettingsController extends SimpleFormController { |
|
|
|
|
settingsService.setThemeId(theme.getId()); |
|
|
|
|
settingsService.setLocale(locale); |
|
|
|
|
settingsService.save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setSettingsService(SettingsService settingsService) { |
|
|
|
|
this.settingsService = settingsService; |
|
|
|
|
return "redirect:generalSettings.view"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|