FIxed checkboxes not showing up for movies

This commit is contained in:
Jason House
2019-12-16 22:07:11 +09:00
parent 8d02154bd0
commit d8a400ca93
7 changed files with 28 additions and 24 deletions

View File

@@ -5,6 +5,6 @@ import org.jetbrains.annotations.NotNull;
public interface PlexService {
@NotNull Set<PlexLibrary> getPlexLibraries(@NotNull PlexSearch plexSearch);
@NotNull Set<PlexLibrary> queryPlexLibraries(@NotNull PlexSearch plexSearch);
}

View File

@@ -49,6 +49,8 @@ public class PlexConfigurationController {
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getPlexConfiguration() {
logger.info("getPlexConfiguration()");
return new ModelAndView("plexConfiguration");
ModelAndView modelAndView = new ModelAndView("plexConfiguration");
modelAndView.addObject("plexSearch", gapsService.getPlexSearch());
return modelAndView;
}
}

View File

@@ -44,10 +44,10 @@ public class PlexLibrariesController {
gapsService.updatePlexSearch(plexSearch);
Set<PlexLibrary> plexLibraries = plexService.getPlexLibraries(plexSearch);
Set<PlexLibrary> plexLibraries = plexService.queryPlexLibraries(plexSearch);
gapsService.copyInLibraries(plexLibraries);
logger.info(plexSearch.toString());
logger.info(gapsService.getPlexSearch().toString());
ModelAndView modelAndView = new ModelAndView("plexLibraries");
modelAndView.addObject("plexSearch", gapsService.getPlexSearch());
@@ -57,7 +57,9 @@ public class PlexLibrariesController {
@RequestMapping(method = RequestMethod.GET,
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getPlexLibraries() {
logger.info("getPlexLibraries( )");
return new ModelAndView("plexLibraries");
logger.info("getPlexLibraries()");
ModelAndView modelAndView = new ModelAndView("plexLibraries");
modelAndView.addObject("plexSearch", gapsService.getPlexSearch());
return modelAndView;
}
}

View File

@@ -6,12 +6,14 @@ import com.jasonhhouse.gaps.PlexSearch;
import com.jasonhhouse.gaps.PlexService;
import com.jasonhhouse.gaps.service.BindingErrorsService;
import java.util.Set;
import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
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.ModelAndView;
@@ -35,28 +37,26 @@ public class PlexMovieListController {
@RequestMapping(method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView postPlexMovieList(String plexSearch, BindingResult bindingResult) {
logger.info("postPlexLibraries( " + plexSearch + " )");
public ModelAndView postPlexMovieList(@Valid @ModelAttribute("plexSearch") PlexSearch plexSearch, BindingResult bindingResult) {
logger.info("postPlexMovieList( " + plexSearch + " )");
if (bindingErrorsService.hasBindingErrors(bindingResult)) {
return bindingErrorsService.getErrorPage();
}
Set<PlexLibrary> plexLibraries = plexService.getPlexLibraries(gapsService.getPlexSearch());
Set<PlexLibrary> plexLibraries = plexService.queryPlexLibraries(gapsService.getPlexSearch());
gapsService.copyInLibraries(plexLibraries);
//ToDo
//Make the search for plex libs and copy that in here
gapsService.updatePlexSearch(plexSearch);
ModelAndView modelAndView = new ModelAndView("plexMovieList");
modelAndView.addObject("plexSearch", plexSearch);
modelAndView.addObject("plexSearch", gapsService.getPlexSearch());
return modelAndView;
}
@RequestMapping(method = RequestMethod.GET,
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView postPlexMovieList() {
logger.info("getPlexLibraries()");
return new ModelAndView("plexLibraries");
public ModelAndView getPlexMovieList() {
logger.info("getPlexMovieList()");
return new ModelAndView("plexMovieList");
}
}

View File

@@ -49,7 +49,7 @@ public class GapsServiceImpl implements GapsService {
@Override
public void updatePlexSearch(PlexSearch plexSearch) {
if (StringUtils.isEmpty(plexSearch.getAddress())) {
if (StringUtils.isNotEmpty(plexSearch.getAddress())) {
this.plexSearch.setAddress(plexSearch.getAddress());
}
@@ -57,11 +57,11 @@ public class GapsServiceImpl implements GapsService {
this.plexSearch.setPort(plexSearch.getPort());
}
if (StringUtils.isEmpty(plexSearch.getPlexToken())) {
if (StringUtils.isNotEmpty(plexSearch.getPlexToken())) {
this.plexSearch.setPlexToken(plexSearch.getPlexToken());
}
if (StringUtils.isEmpty(plexSearch.getMovieDbApiKey())) {
if (StringUtils.isNotEmpty(plexSearch.getMovieDbApiKey())) {
this.plexSearch.setMovieDbApiKey(plexSearch.getMovieDbApiKey());
}
}

View File

@@ -38,8 +38,8 @@ public class PlexServiceImpl implements PlexService {
private final Logger logger = LoggerFactory.getLogger(PlexServiceImpl.class);
@Override
public @NotNull Set<PlexLibrary> getPlexLibraries(@NotNull PlexSearch plexSearch) {
logger.info("getPlexLibraries()");
public @NotNull Set<PlexLibrary> queryPlexLibraries(@NotNull PlexSearch plexSearch) {
logger.info("queryPlexLibraries()");
HttpUrl url = new HttpUrl.Builder()
.scheme("http")

View File

@@ -41,10 +41,10 @@
<form id="plexMovieList" class="needs-validation" method="POST" action="/plexMovieList" novalidate
th:object="${plexSearch}">
<div th:each="library : *{libraries.keySet()}" th:remove="tag">
<div th:each="library : *{libraries}" th:remove="tag">
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" th:field="${library}">
<label class="form-check-label" th:for="${library}" th:text="${library}"></label>
<input type="checkbox" th:id="${library.key}" class="form-check-input">
<label class="form-check-label" th:for="${library.key}" th:text="${library.key}"></label>
</div>
</div>