diff --git a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java index 58db87e..8805b18 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java @@ -10,4 +10,6 @@ public interface GapsService { Set getPlexLibraries(); void copyInLibraries(@NotNull Set plexLibraries); + + void updatePlexSearch(PlexSearch plexSearch); } diff --git a/Core/src/main/java/com/jasonhhouse/gaps/PlexSearch.java b/Core/src/main/java/com/jasonhhouse/gaps/PlexSearch.java index d8511dc..55877e5 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/PlexSearch.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/PlexSearch.java @@ -2,67 +2,60 @@ package com.jasonhhouse.gaps; import java.util.HashMap; import java.util.Map; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public final class PlexSearch { - @Nullable private String movieDbApiKey; - @Nullable private String plexToken; - @Nullable private String address; - @Nullable - private int port; + private Integer port; - @NotNull private final Map libraries; public PlexSearch() { libraries = new HashMap<>(); } - public void setLibrary(@NotNull String library, @NotNull Boolean selected) { + public void setLibrary(String library, Boolean selected) { libraries.put(library, selected); } - public @NotNull Map getLibraries() { + public Map getLibraries() { return libraries; } - public @Nullable String getMovieDbApiKey() { + public String getMovieDbApiKey() { return movieDbApiKey; } - public void setMovieDbApiKey(@NotNull String movieDbApiKey) { + public void setMovieDbApiKey(String movieDbApiKey) { this.movieDbApiKey = movieDbApiKey; } - public @Nullable String getPlexToken() { + public String getPlexToken() { return plexToken; } - public void setPlexToken(@NotNull String plexToken) { + public void setPlexToken(String plexToken) { this.plexToken = plexToken; } - public @Nullable String getAddress() { + public String getAddress() { return address; } - public void setAddress(@NotNull String address) { + public void setAddress(String address) { this.address = address; } - public int getPort() { + public Integer getPort() { return port; } - public void setPort(int port) { + public void setPort(Integer port) { this.port = port; } @@ -72,7 +65,8 @@ public final class PlexSearch { "movieDbApiKey='" + movieDbApiKey + '\'' + ", plexToken='" + plexToken + '\'' + ", address='" + address + '\'' + - ", port='" + port + '\'' + + ", port=" + port + + ", libraries=" + libraries + '}'; } } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexConfigurationController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexConfigurationController.java index af51263..b2a53ce 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexConfigurationController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexConfigurationController.java @@ -1,9 +1,11 @@ package com.jasonhhouse.gaps.controller; +import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.PlexSearch; import com.jasonhhouse.gaps.service.BindingErrorsService; 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; @@ -18,23 +20,28 @@ public class PlexConfigurationController { private final Logger logger = LoggerFactory.getLogger(PlexConfigurationController.class); private final BindingErrorsService bindingErrorsService; + private final GapsService gapsService; - public PlexConfigurationController(BindingErrorsService bindingErrorsService) { + @Autowired + public PlexConfigurationController(BindingErrorsService bindingErrorsService, GapsService gapsService) { this.bindingErrorsService = bindingErrorsService; + this.gapsService = gapsService; } @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView postPlexConfiguration(PlexSearch plexSearch, BindingResult bindingResult) { + public ModelAndView postPlexConfiguration(PlexSearch plexSearch, BindingResult bindingResult) { logger.info("postPlexConfiguration( " + plexSearch + " )"); if (bindingErrorsService.hasBindingErrors(bindingResult)) { return bindingErrorsService.getErrorPage(); } + gapsService.updatePlexSearch(plexSearch); + ModelAndView modelAndView = new ModelAndView("plexConfiguration"); - modelAndView.addObject("plexSearch", plexSearch); + modelAndView.addObject("plexSearch", gapsService.getPlexSearch()); return modelAndView; } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java index 9eae4a9..e495d9c 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java @@ -1,5 +1,6 @@ package com.jasonhhouse.gaps.controller; +import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.PlexLibrary; import com.jasonhhouse.gaps.PlexSearch; import com.jasonhhouse.gaps.PlexService; @@ -7,6 +8,7 @@ import com.jasonhhouse.gaps.service.BindingErrorsService; import java.util.Set; 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; @@ -21,10 +23,13 @@ public class PlexLibrariesController { private final BindingErrorsService bindingErrorsService; private final PlexService plexService; + private final GapsService gapsService; - public PlexLibrariesController(BindingErrorsService bindingErrorsService, PlexService plexService) { + @Autowired + public PlexLibrariesController(BindingErrorsService bindingErrorsService, PlexService plexService, GapsService gapsService) { this.bindingErrorsService = bindingErrorsService; this.plexService = plexService; + this.gapsService = gapsService; } @RequestMapping(method = RequestMethod.POST, @@ -37,14 +42,15 @@ public class PlexLibrariesController { return bindingErrorsService.getErrorPage(); } + gapsService.updatePlexSearch(plexSearch); + Set plexLibraries = plexService.getPlexLibraries(plexSearch); + gapsService.copyInLibraries(plexLibraries); - - //ToDo - //Make the search for plex libs and copy that in here + logger.info(plexSearch.toString()); ModelAndView modelAndView = new ModelAndView("plexLibraries"); - modelAndView.addObject("plexSearch", plexSearch); + modelAndView.addObject("plexSearch", gapsService.getPlexSearch()); return modelAndView; } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java index f922aee..baa7df0 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java @@ -35,14 +35,14 @@ public class PlexMovieListController { @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView postPlexMovieList(PlexSearch plexSearch, BindingResult bindingResult) { + public ModelAndView postPlexMovieList(String plexSearch, BindingResult bindingResult) { logger.info("postPlexLibraries( " + plexSearch + " )"); if (bindingErrorsService.hasBindingErrors(bindingResult)) { return bindingErrorsService.getErrorPage(); } - Set plexLibraries = plexService.getPlexLibraries(plexSearch); + Set plexLibraries = plexService.getPlexLibraries(gapsService.getPlexSearch()); gapsService.copyInLibraries(plexLibraries); //ToDo diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java index 2e76de8..4ff9013 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java @@ -5,11 +5,13 @@ import com.jasonhhouse.gaps.PlexLibrary; import com.jasonhhouse.gaps.PlexSearch; import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; @Service public class GapsServiceImpl implements GapsService { + @NotNull private final PlexSearch plexSearch; @@ -44,4 +46,23 @@ public class GapsServiceImpl implements GapsService { plexLibraries.forEach(plexLibrary -> plexSearch.setLibrary(plexLibrary.getTitle(), false)); this.plexLibraries.addAll(plexLibraries); } + + @Override + public void updatePlexSearch(PlexSearch plexSearch) { + if (StringUtils.isEmpty(plexSearch.getAddress())) { + this.plexSearch.setAddress(plexSearch.getAddress()); + } + + if (plexSearch.getPort() != null) { + this.plexSearch.setPort(plexSearch.getPort()); + } + + if (StringUtils.isEmpty(plexSearch.getPlexToken())) { + this.plexSearch.setPlexToken(plexSearch.getPlexToken()); + } + + if (StringUtils.isEmpty(plexSearch.getMovieDbApiKey())) { + this.plexSearch.setMovieDbApiKey(plexSearch.getMovieDbApiKey()); + } + } } diff --git a/GapsWeb/src/main/resources/static/js/plex_configuration.js b/GapsWeb/src/main/resources/static/js/plexConfiguration.js similarity index 100% rename from GapsWeb/src/main/resources/static/js/plex_configuration.js rename to GapsWeb/src/main/resources/static/js/plexConfiguration.js diff --git a/GapsWeb/src/main/resources/static/js/plex_configuration.min.js b/GapsWeb/src/main/resources/static/js/plexConfiguration.min.js similarity index 100% rename from GapsWeb/src/main/resources/static/js/plex_configuration.min.js rename to GapsWeb/src/main/resources/static/js/plexConfiguration.min.js diff --git a/GapsWeb/src/main/resources/static/js/plex_libraries.js b/GapsWeb/src/main/resources/static/js/plexLibraries.js similarity index 54% rename from GapsWeb/src/main/resources/static/js/plex_libraries.js rename to GapsWeb/src/main/resources/static/js/plexLibraries.js index fff2948..c62700a 100644 --- a/GapsWeb/src/main/resources/static/js/plex_libraries.js +++ b/GapsWeb/src/main/resources/static/js/plexLibraries.js @@ -10,50 +10,8 @@ "use strict"; -let allLibraries; - function onStart() { $("#back").click(function () { location.assign("plexConfiguration.html"); }); -/* - $("#search").click(function () { - if (Cookies.get('dialogDontShowAgain')) { - if (validateInput()) { - $("#warningModal").modal("open"); - - } - } else { - if (validateInput()) { - updatedSelectedLibraries(); - location.assign("plexMovieList.html"); - } - } - });*/ - } -/* -function validateInput() { - let selectedLibraries = findSelectedLibraries(); - - if (selectedLibraries === undefined || selectedLibraries.length === 0) { - M.toast({html: "Must select at least one library"}); - return false; - } - return true; -} - -function updatedSelectedLibraries() { - Cookies.set('libraries', JSON.stringify(findSelectedLibraries())); -} - -function findSelectedLibraries() { - let selectedLibraries = []; - for (let library of allLibraries) { - if ($("#" + library.key).is(":checked")) { - selectedLibraries.push(library); - } - } - - return selectedLibraries; -}*/ diff --git a/GapsWeb/src/main/resources/static/js/plexLibraries.min.js b/GapsWeb/src/main/resources/static/js/plexLibraries.min.js new file mode 100644 index 0000000..d2a7857 --- /dev/null +++ b/GapsWeb/src/main/resources/static/js/plexLibraries.min.js @@ -0,0 +1 @@ +"use strict";function onStart(){$("#back").click(function(){location.assign("plexConfiguration.html")})} \ No newline at end of file diff --git a/GapsWeb/src/main/resources/static/js/plex_movie_list.js b/GapsWeb/src/main/resources/static/js/plexMovieList.js similarity index 100% rename from GapsWeb/src/main/resources/static/js/plex_movie_list.js rename to GapsWeb/src/main/resources/static/js/plexMovieList.js diff --git a/GapsWeb/src/main/resources/static/js/plex_movie_list.min.js b/GapsWeb/src/main/resources/static/js/plexMovieList.min.js similarity index 100% rename from GapsWeb/src/main/resources/static/js/plex_movie_list.min.js rename to GapsWeb/src/main/resources/static/js/plexMovieList.min.js diff --git a/GapsWeb/src/main/resources/static/js/plex_libraries.min.js b/GapsWeb/src/main/resources/static/js/plex_libraries.min.js deleted file mode 100644 index 1f36db1..0000000 --- a/GapsWeb/src/main/resources/static/js/plex_libraries.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";let allLibraries;function onStart(){$("#back").click(function(){location.assign("plexConfiguration.html")})} \ No newline at end of file diff --git a/GapsWeb/src/main/resources/templates/error.html b/GapsWeb/src/main/resources/templates/error.html index d194ac8..94d790b 100644 --- a/GapsWeb/src/main/resources/templates/error.html +++ b/GapsWeb/src/main/resources/templates/error.html @@ -8,7 +8,7 @@ - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - + Gaps diff --git a/GapsWeb/src/main/resources/templates/plexConfiguration.html b/GapsWeb/src/main/resources/templates/plexConfiguration.html index c7e6d01..c1306d3 100644 --- a/GapsWeb/src/main/resources/templates/plexConfiguration.html +++ b/GapsWeb/src/main/resources/templates/plexConfiguration.html @@ -68,6 +68,6 @@ - + \ No newline at end of file diff --git a/GapsWeb/src/main/resources/templates/plexLibraries.html b/GapsWeb/src/main/resources/templates/plexLibraries.html index 5ff1c93..27f7b7e 100644 --- a/GapsWeb/src/main/resources/templates/plexLibraries.html +++ b/GapsWeb/src/main/resources/templates/plexLibraries.html @@ -8,7 +8,7 @@ - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - + Gaps @@ -40,14 +40,14 @@
-
- - -
-
- - + +
+
+ + +
+ @@ -60,6 +60,6 @@ - + \ No newline at end of file diff --git a/GapsWeb/src/main/resources/templates/plexMovieList.html b/GapsWeb/src/main/resources/templates/plexMovieList.html index 75afe19..346c767 100644 --- a/GapsWeb/src/main/resources/templates/plexMovieList.html +++ b/GapsWeb/src/main/resources/templates/plexMovieList.html @@ -8,7 +8,7 @@ - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> - + Gaps @@ -36,37 +36,36 @@

Searching for Movies

-

+

+
-
- -
-
-
+
+
+
-
- +<!– Modal Structure –> +-->
@@ -76,6 +75,6 @@ - + \ No newline at end of file