From 2ff54d4dc5f61aa06564a6d86fe478748cc5b1a6 Mon Sep 17 00:00:00 2001 From: jhouse Date: Wed, 8 Jan 2020 16:32:04 +0900 Subject: [PATCH] trying to fix checkbox issues --- .../controller/PlexLibrariesController.java | 86 ++++++++++++++++++- .../controller/PlexMovieListController.java | 18 ++-- GapsWeb/src/main/resources/application.yaml | 2 +- .../resources/templates/plexLibraries.html | 8 +- buildVersion.sh | 2 +- 5 files changed, 98 insertions(+), 18 deletions(-) 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 06066b6..e76e141 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java @@ -10,6 +10,8 @@ package com.jasonhhouse.gaps.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.PlexLibrary; import com.jasonhhouse.gaps.PlexQuery; @@ -19,6 +21,8 @@ import com.jasonhhouse.gaps.service.BindingErrorsService; import com.jasonhhouse.gaps.service.IoService; import com.jasonhhouse.gaps.validator.PlexPropertiesValidator; import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.validation.Valid; import org.slf4j.Logger; @@ -69,10 +73,9 @@ public class PlexLibrariesController { LOGGER.warn("Could not write gaps properties.", e); } - List plexLibraries = plexQuery.getLibraries(plexSearch); - gapsService.getPlexSearch().getLibraries().addAll(plexLibraries); - - LOGGER.info(gapsService.getPlexSearch().toString()); + setPlexSearch(); + //List plexLibraries = plexQuery.getLibraries(plexSearch); + //gapsService.getPlexSearch().getLibraries().addAll(plexLibraries); ModelAndView modelAndView = new ModelAndView("plexLibraries"); modelAndView.addObject("plexSearch", gapsService.getPlexSearch()); @@ -94,4 +97,79 @@ public class PlexLibrariesController { binder.addCustomFormatter(new PlexSearchFormatter(), "plexSearch"); binder.setValidator(new PlexPropertiesValidator()); } + + private void setPlexSearch() { + String json = "[\n" + + " {\n" + + " \"key\": 23,\n" + + " \"title\": \"BM\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 22,\n" + + " \"title\": \"Family Videos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 13,\n" + + " \"title\": \"Grandad Movies\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 2,\n" + + " \"title\": \"Movies\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 14,\n" + + " \"title\": \"Movies - 3D\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 11,\n" + + " \"title\": \"Movies - 4K\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 16,\n" + + " \"title\": \"Stand Up Comedy\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 6,\n" + + " \"title\": \"Workout Videos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 9,\n" + + " \"title\": \"Bassnectar\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 10,\n" + + " \"title\": \"Halloween\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 20,\n" + + " \"title\": \"Home Theater Demos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 19,\n" + + " \"title\": \"Pre-Rolls\",\n" + + " \"selected\": false\n" + + " }\n" + + "]"; + + ObjectMapper objectMapper = new ObjectMapper(); + List plexLibraries; + try { + plexLibraries = Arrays.asList(objectMapper.readValue(json, PlexLibrary[].class)); + gapsService.getPlexSearch().getLibraries().addAll(plexLibraries); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + } } 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 ef25df6..146abe0 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java @@ -17,6 +17,7 @@ import com.jasonhhouse.gaps.PlexSearch; import com.jasonhhouse.gaps.PlexSearchFormatter; import com.jasonhhouse.gaps.service.BindingErrorsService; import com.jasonhhouse.gaps.validator.PlexLibrariesValidator; +import java.util.ArrayList; import java.util.List; import javax.validation.Valid; import org.slf4j.Logger; @@ -49,21 +50,22 @@ public class PlexMovieListController { } @RequestMapping(method = RequestMethod.POST, - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView postPlexMovieList(@Valid PlexSearch plexSearch, BindingResult bindingResult) { - LOGGER.info("postPlexMovieList( " + plexSearch + " )"); - + public ModelAndView postPlexMovieList( + @ModelAttribute PlexSearch plexSearch, + @ModelAttribute ArrayList libraries, BindingResult bindingResult , Model model) { + LOGGER.info("postPlexMovieList( " + plexSearch + ", " + libraries + " )"); +/* if (bindingErrorsService.hasBindingErrors(bindingResult)) { return bindingErrorsService.getErrorPage(); } gapsService.updateLibrarySelections(plexSearch.getLibraries()); - gapsService.updatePlexSearch(plexSearch); + gapsService.updatePlexSearch(plexSearch);*/ ModelAndView modelAndView = new ModelAndView("plexMovieList"); - LOGGER.info(gapsService.getPlexSearch().toString()); - modelAndView.addObject("plexSearch", gapsService.getPlexSearch()); + /*LOGGER.info(gapsService.getPlexSearch().toString()); + modelAndView.addObject("plexSearch", gapsService.getPlexSearch());*/ return modelAndView; } @@ -78,6 +80,6 @@ public class PlexMovieListController { public void initBinder(WebDataBinder binder) { LOGGER.info("initBinder()"); binder.addCustomFormatter(new PlexSearchFormatter(), "plexSearch"); - binder.setValidator(new PlexLibrariesValidator()); + //binder.setValidator(new PlexLibrariesValidator()); } } diff --git a/GapsWeb/src/main/resources/application.yaml b/GapsWeb/src/main/resources/application.yaml index bf9aa0e..745dadb 100644 --- a/GapsWeb/src/main/resources/application.yaml +++ b/GapsWeb/src/main/resources/application.yaml @@ -26,7 +26,7 @@ logging: level: root: INFO server: - port: 8484 + port: 8443 compression: enabled: true mime-types: text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json diff --git a/GapsWeb/src/main/resources/templates/plexLibraries.html b/GapsWeb/src/main/resources/templates/plexLibraries.html index f9f4b66..d9a7949 100644 --- a/GapsWeb/src/main/resources/templates/plexLibraries.html +++ b/GapsWeb/src/main/resources/templates/plexLibraries.html @@ -51,10 +51,10 @@
- - - - + + +
diff --git a/buildVersion.sh b/buildVersion.sh index 3c7ae14..d9b3f0c 100755 --- a/buildVersion.sh +++ b/buildVersion.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=0.1.3 +VERSION="-v0.1.3" DOCKER_SSL_VERSION="housewrecker/gaps:v$VERSION" DOCKER_NO_SSL_VERSION="housewrecker/gaps:v$VERSION-no-ssl" JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"