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