Merge pull request #102 from JasonHHouse/improvement/tallguydirk

Improvement/tallguydirk
This commit is contained in:
JasonHHouse
2020-01-09 10:19:37 +09:00
committed by GitHub
17 changed files with 121 additions and 44 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.1.3</version>
<version>0.1.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -26,9 +26,9 @@ public interface GapsService {
/**
* Updates PlexLibrary's to add them if not added and set them selected or unselected if added
*
* @param plexLibraries The libraries to add or update
* @param selectedLibraries The libraries to update
*/
void updateLibrarySelections(@NotNull List<PlexLibrary> plexLibraries);
void updateLibrarySelections(@NotNull List<String> selectedLibraries);
/**
* Updates the plex search object itself to the singleton object

View File

@@ -12,6 +12,6 @@ RUN mkdir -p /usr/app
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.1.3.jar /usr/app/
COPY GapsWeb/target/GapsWeb-0.1.4.jar /usr/app/
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=no-ssl", "GapsWeb-0.1.3.jar"]
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=no-ssl", "GapsWeb-0.1.4.jar"]

View File

@@ -12,6 +12,6 @@ RUN mkdir -p /usr/app
WORKDIR /usr/app
COPY GapsWeb/target/GapsWeb-0.1.3.jar /usr/app/
COPY GapsWeb/target/GapsWeb-0.1.4.jar /usr/app/
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=ssl", "GapsWeb-0.1.3.jar"]
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=ssl", "GapsWeb-0.1.4.jar"]

View File

@@ -2,8 +2,8 @@
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>console</headerType>
<jar>C:\Users\jh597\Code\Gaps\GapsWeb\target\GapsWeb-0.1.3.jar</jar>
<outfile>C:\Users\jh597\Desktop\Gaps-v0.1.3.exe</outfile>
<jar>C:\Users\jh597\Code\Gaps\GapsWeb\target\GapsWeb-0.1.4.jar</jar>
<outfile>C:\Users\jh597\Desktop\Gaps-v0.1.4.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
@@ -28,16 +28,16 @@
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>0.1.3.0</fileVersion>
<fileVersion>0.1.4.0</fileVersion>
<txtFileVersion>Free Form</txtFileVersion>
<fileDescription>Gaps</fileDescription>
<copyright>2019</copyright>
<productVersion>0.1.3.0</productVersion>
<productVersion>0.1.4.0</productVersion>
<txtProductVersion>Free Form</txtProductVersion>
<productName>Gaps</productName>
<companyName></companyName>
<internalName>Gaps</internalName>
<originalFilename>Gaps-v0.1.3.exe</originalFilename>
<originalFilename>Gaps-v0.1.4.exe</originalFilename>
<trademarks></trademarks>
<language>ENGLISH_US</language>
</versionInfo>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.1.3</version>
<version>0.1.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -19,7 +19,7 @@
<dependency>
<groupId>com.jasonhhouse</groupId>
<artifactId>Core</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
</dependency>
<dependency>

View File

@@ -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;
@@ -72,8 +76,6 @@ public class PlexLibrariesController {
List<PlexLibrary> plexLibraries = plexQuery.getLibraries(plexSearch);
gapsService.getPlexSearch().getLibraries().addAll(plexLibraries);
LOGGER.info(gapsService.getPlexSearch().toString());
ModelAndView modelAndView = new ModelAndView("plexLibraries");
modelAndView.addObject("plexSearch", gapsService.getPlexSearch());
return modelAndView;
@@ -94,4 +96,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();
}
}
}

View File

@@ -17,8 +17,10 @@ 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.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,17 +51,15 @@ 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(@RequestParam ArrayList<String> selectedLibraries) {
LOGGER.info("postPlexMovieList( " + selectedLibraries + " )");
if (bindingErrorsService.hasBindingErrors(bindingResult)) {
if(CollectionUtils.isEmpty(selectedLibraries)) {
return bindingErrorsService.getErrorPage();
}
gapsService.updateLibrarySelections(plexSearch.getLibraries());
gapsService.updatePlexSearch(plexSearch);
gapsService.updateLibrarySelections(selectedLibraries);
ModelAndView modelAndView = new ModelAndView("plexMovieList");
LOGGER.info(gapsService.getPlexSearch().toString());

View File

@@ -14,6 +14,7 @@ import com.jasonhhouse.gaps.GapsService;
import com.jasonhhouse.gaps.PlexLibrary;
import com.jasonhhouse.gaps.PlexSearch;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
@@ -39,16 +40,17 @@ public class GapsServiceImpl implements GapsService {
}
@Override
public void updateLibrarySelections(@NotNull List<PlexLibrary> plexLibraries) {
LOGGER.info("updateLibrarySelections( " + plexLibraries + " )");
public void updateLibrarySelections(@NotNull List<String> selectedLibraries) {
LOGGER.info("updateLibrarySelections( " + selectedLibraries + " )");
LOGGER.info("BEFORE:" + getPlexSearch().getLibraries().toString());
for (PlexLibrary plexLibrary : plexLibraries) {
int index = getPlexSearch().getLibraries().indexOf(plexLibrary);
LOGGER.info("Index of plexLibrary: " + index + " - " + plexLibrary);
if (index == -1) {
getPlexSearch().getLibraries().add(plexLibrary);
for (String selectedLibrary : selectedLibraries) {
Optional<PlexLibrary> library = getPlexSearch().getLibraries().stream().filter(plexLibrary -> plexLibrary.getKey().equals(Integer.valueOf(selectedLibrary))).findFirst();
if (!library.isPresent()) {
LOGGER.warn("Can't find library");
} else {
getPlexSearch().getLibraries().get(index).setSelected(plexLibrary.getSelected());
library.get().setSelected(true);
}
}

View File

@@ -47,7 +47,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.1.3
version: 0.1.4
---
spring:
@@ -79,5 +79,5 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.1.3
version: 0.1.4

View File

@@ -155,7 +155,7 @@
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">Gaps v0.1.3</h5>
<h5 class="white-text">Gaps v0.1.4</h5>
</div>
</div>
</div>

View File

@@ -39,7 +39,7 @@
<div class="container">
<h2 class="top-margin">Welcome to Gaps</h2>
<h4 class="top-margin">v0.1.3</h4>
<h4 class="top-margin">v0.1.4</h4>
<p>Gaps searches through your Plex Server. It then queries
for known

View File

@@ -49,12 +49,10 @@
<p>These are the movie libraries we found in your Plex
Server. Select any and all you would like to look for gaps in.</p>
<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"/>
<form class="needs-validation" method="POST" action="/plexMovieList" novalidate enctype="multipart/form-data">
<fieldset th:each="library,status : *{plexSearch.libraries}" class="form-group form-check">
<input type="checkbox" name="selectedLibraries" class="form-check-input" th:value="*{plexSearch.libraries[__${status.index}__].key}" />
<label class="form-check-label" th:text="${library.title}"></label>
</fieldset>
<button type="button" class="btn btn-secondary" onclick="back()">Back</button>

View File

@@ -29,7 +29,7 @@ public class GapsServiceTest implements GapsService {
}
@Override
public void updateLibrarySelections(@NotNull List<PlexLibrary> plexLibraries) {
public void updateLibrarySelections(@NotNull List<String> plexLibraries) {
}

View File

@@ -1,5 +1,5 @@
#!/bin/bash
VERSION=0.1.3
VERSION=0.1.4
DOCKER_SSL_LATEST="housewrecker/gaps:latest"
DOCKER_NO_SSL_LATEST="housewrecker/gaps:latest-no-ssl"
JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"

View File

@@ -1,5 +1,5 @@
#!/bin/bash
VERSION=0.1.3
VERSION="-v0.1.4"
DOCKER_SSL_VERSION="housewrecker/gaps:v$VERSION"
DOCKER_NO_SSL_VERSION="housewrecker/gaps:v$VERSION-no-ssl"
JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"

View File

@@ -15,7 +15,7 @@
</parent>
<groupId>com.jasonhhouse</groupId>
<artifactId>Gaps</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<name>Gaps</name>
<description>Demo project for Spring Boot</description>