mirror of
https://github.com/JasonHHouse/gaps.git
synced 2026-02-11 21:28:37 -06:00
trying to fix checkbox issues
This commit is contained in:
@@ -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<PlexLibrary> plexLibraries = plexQuery.getLibraries(plexSearch);
|
||||
gapsService.getPlexSearch().getLibraries().addAll(plexLibraries);
|
||||
|
||||
LOGGER.info(gapsService.getPlexSearch().toString());
|
||||
setPlexSearch();
|
||||
//List<PlexLibrary> 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<PlexLibrary> plexLibraries;
|
||||
try {
|
||||
plexLibraries = Arrays.asList(objectMapper.readValue(json, PlexLibrary[].class));
|
||||
gapsService.getPlexSearch().getLibraries().addAll(plexLibraries);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Long> 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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -51,10 +51,10 @@
|
||||
|
||||
<form class="needs-validation" method="POST" action="/plexMovieList" novalidate th:object="${plexSearch}">
|
||||
<fieldset th:each="library,status : *{libraries}" class="form-group form-check">
|
||||
<input type="checkbox" class="form-check-input" th:field="*{libraries[__${status.index}__].selected}" th:value="*{libraries[__${status.index}__].key}">
|
||||
<label class="form-check-label" th:for="${library}" th:text="${library.title}"></label>
|
||||
<input id="key" name="plexSearch" th:field="*{libraries[__${status.index}__].key}" type="hidden"/>
|
||||
<input id="title" name="plexSearch" th:field="*{libraries[__${status.index}__].title}" type="hidden"/>
|
||||
<input type="checkbox" class="form-check-input" th:field="*{libraries[__${status.index}__].key}" th:value="*{libraries[__${status.index}__].key}" />
|
||||
<label class="form-check-label" th:for="${#ids.prev('libraries')}" th:text="${library.title}"></label>
|
||||
<!--<input id="key" name="plexSearch" th:field="*{libraries[__${status.index}__].key}" type="hidden"/>
|
||||
<input id="title" name="plexSearch" th:field="*{libraries[__${status.index}__].title}" type="hidden"/>-->
|
||||
</fieldset>
|
||||
|
||||
<button type="button" class="btn btn-secondary" onclick="back()">Back</button>
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user