Search in sources :

Example 6 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class PlayQueueController method handleRequestInternal.

@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    User user = securityService.getCurrentUser(request);
    UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
    Player player = playerService.getPlayer(request, response);
    Map<String, Object> map = new HashMap<>();
    map.put("user", user);
    map.put("player", player);
    map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
    map.put("visibility", userSettings.getPlaylistVisibility());
    map.put("partyMode", userSettings.isPartyModeEnabled());
    map.put("notify", userSettings.isSongNotificationEnabled());
    map.put("autoHide", userSettings.isAutoHidePlayQueue());
    return new ModelAndView("playQueue", "model", map);
}
Also used : Player(org.libresonic.player.domain.Player) User(org.libresonic.player.domain.User) HashMap(java.util.HashMap) UserSettings(org.libresonic.player.domain.UserSettings) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class AvatarController method getLastModified.

public long getLastModified(HttpServletRequest request) {
    Avatar avatar = getAvatar(request);
    long result = avatar == null ? -1L : avatar.getCreatedDate().getTime();
    String username = request.getParameter("username");
    if (username != null) {
        UserSettings userSettings = settingsService.getUserSettings(username);
        result = Math.max(result, userSettings.getChanged().getTime());
    }
    return result;
}
Also used : UserSettings(org.libresonic.player.domain.UserSettings) Avatar(org.libresonic.player.domain.Avatar)

Example 8 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class TopController method handleRequestInternal.

@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
    Map<String, Object> map = new HashMap<>();
    User user = securityService.getCurrentUser(request);
    UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
    map.put("user", user);
    map.put("showSideBar", userSettings.isShowSideBar());
    map.put("showAvatar", userSettings.getAvatarScheme() != AvatarScheme.NONE);
    return new ModelAndView("top", "model", map);
}
Also used : User(org.libresonic.player.domain.User) HashMap(java.util.HashMap) UserSettings(org.libresonic.player.domain.UserSettings) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class UserSettingsController method displayForm.

@RequestMapping(method = RequestMethod.GET)
protected String displayForm(HttpServletRequest request, Model model) throws Exception {
    UserSettingsCommand command;
    if (!model.containsAttribute("command")) {
        command = new UserSettingsCommand();
        User user = getUser(request);
        if (user != null) {
            command.setUser(user);
            command.setEmail(user.getEmail());
            UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
            command.setTranscodeSchemeName(userSettings.getTranscodeScheme().name());
            command.setAllowedMusicFolderIds(Util.toIntArray(getAllowedMusicFolderIds(user)));
        } else {
            command.setNewUser(true);
            command.setStreamRole(true);
            command.setSettingsRole(true);
        }
    } else {
        command = (UserSettingsCommand) model.asMap().get("command");
    }
    command.setAdmin(User.USERNAME_ADMIN.equals(command.getUsername()));
    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());
    model.addAttribute("command", command);
    return "userSettings";
}
Also used : User(org.libresonic.player.domain.User) UserSettings(org.libresonic.player.domain.UserSettings) UserSettingsCommand(org.libresonic.player.command.UserSettingsCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with UserSettings

use of org.libresonic.player.domain.UserSettings in project libresonic by Libresonic.

the class RightController method handleRequestInternal.

@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
    Map<String, Object> map = new HashMap<>();
    ModelAndView result = new ModelAndView("right");
    UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));
    if (userSettings.isFinalVersionNotificationEnabled() && versionService.isNewFinalVersionAvailable()) {
        map.put("newVersionAvailable", true);
        map.put("latestVersion", versionService.getLatestFinalVersion());
    } else if (userSettings.isBetaVersionNotificationEnabled() && versionService.isNewBetaVersionAvailable()) {
        map.put("newVersionAvailable", true);
        map.put("latestVersion", versionService.getLatestBetaVersion());
    }
    map.put("brand", settingsService.getBrand());
    map.put("showNowPlaying", userSettings.isShowNowPlayingEnabled());
    map.put("user", securityService.getCurrentUser(request));
    result.addObject("model", map);
    return result;
}
Also used : HashMap(java.util.HashMap) UserSettings(org.libresonic.player.domain.UserSettings) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

UserSettings (org.libresonic.player.domain.UserSettings)14 User (org.libresonic.player.domain.User)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 HashMap (java.util.HashMap)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 Date (java.util.Date)3 Player (org.libresonic.player.domain.Player)2 Locale (java.util.Locale)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 UserSettingsCommand (org.libresonic.player.command.UserSettingsCommand)1 Avatar (org.libresonic.player.domain.Avatar)1 Playlist (org.libresonic.player.domain.Playlist)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1