Continuing bootstrap work

Also splitting docker builds
This commit is contained in:
Jason House
2019-12-14 20:41:45 +09:00
parent 2020d0edf0
commit 8d02154bd0
17 changed files with 93 additions and 106 deletions

View File

@@ -10,4 +10,6 @@ public interface GapsService {
Set<PlexLibrary> getPlexLibraries();
void copyInLibraries(@NotNull Set<PlexLibrary> plexLibraries);
void updatePlexSearch(PlexSearch plexSearch);
}

View File

@@ -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<String, Boolean> 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<String, Boolean> getLibraries() {
public Map<String, Boolean> 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 +
'}';
}
}

View File

@@ -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;
}

View File

@@ -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<PlexLibrary> 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;
}

View File

@@ -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<PlexLibrary> plexLibraries = plexService.getPlexLibraries(plexSearch);
Set<PlexLibrary> plexLibraries = plexService.getPlexLibraries(gapsService.getPlexSearch());
gapsService.copyInLibraries(plexLibraries);
//ToDo

View File

@@ -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());
}
}
}

View File

@@ -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;
}*/

View File

@@ -0,0 +1 @@
"use strict";function onStart(){$("#back").click(function(){location.assign("plexConfiguration.html")})}

View File

@@ -1 +0,0 @@
"use strict";let allLibraries;function onStart(){$("#back").click(function(){location.assign("plexConfiguration.html")})}

View File

@@ -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.
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Gaps</title>

View File

@@ -68,6 +68,6 @@
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="js/js.cookie.min.js"></script>
<script type="text/javascript" src="js/plex_configuration.js"></script>
<script type="text/javascript" src="js/plexConfiguration.js"></script>
</body>
</html>

View File

@@ -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.
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Gaps</title>
@@ -40,14 +40,14 @@
<form id="plexMovieList" class="needs-validation" method="POST" action="/plexMovieList" novalidate
th:object="${plexSearch}">
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Movies HD</label>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck2">
<label class="form-check-label" for="exampleCheck2">Movies SD</label>
<div th:each="library : *{libraries.keySet()}" 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>
</div>
</div>
<button class="btn btn-secondary" onclick="back()">Back</button>
<button type="submit" class="btn btn-primary">Next</button>
</form>
@@ -60,6 +60,6 @@
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="js/js.cookie.min.js"></script>
<script type="text/javascript" src="../static/js/plex_libraries.min.js"></script>
<script type="text/javascript" src="../static/js/plexLibraries.min.js"></script>
</body>
</html>

View File

@@ -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.
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title>Gaps</title>
@@ -36,37 +36,36 @@
<h2 class="top-margin">Searching for Movies</h2>
<p id="searchDescription" class="col s12 grey-text text-lighten-4"></p>
<p id="searchDescription" class="col s12 grey-text text-lighten-4"></p>
<button class="btn btn-secondary" id="cancel">Cancel</button>
<button class="btn btn-secondary" id="viewRss">View RSS</button>
<button class="btn btn-secondary" id="copyToClipboard">Copy to clipboard</button>
<div id="searchPosition" class="col s12 grey-text text-lighten-4"></div>
<div id="searchPosition" class="col s12 grey-text text-lighten-4"></div>
<div id="progressContainer" class="progress">
<div class="indeterminate"></div>
</div>
<div id="progressContainer" class="progress">
<div class="indeterminate"></div>
</div>
<div id="searchResults" class="col s12 grey-text text-lighten-4"></div>
<!--
<div id="searchResults" class="col s12 grey-text text-lighten-4"></div>
<!--
&lt;!&ndash; Modal Structure &ndash;&gt;
<div id="warningModal" class="modal">
<div class="modal-content">
<h4 id="searchModelTitle">Cancel Search</h4>
<div id="body">
<p>Are you sure you want to cancel searching?</p>
</div>
</div>
<div class="modal-footer">
<a id="agree" href="#!" class="modal-close waves-effect waves-green btn-flat teal-text">Cancel
Search</a>
</div>
</div>-->
&lt;!&ndash; Modal Structure &ndash;&gt;
<div id="warningModal" class="modal">
<div class="modal-content">
<h4 id="searchModelTitle">Cancel Search</h4>
<div id="body">
<p>Are you sure you want to cancel searching?</p>
</div>
</div>
<div class="modal-footer">
<a id="agree" href="#!" class="modal-close waves-effect waves-green btn-flat teal-text">Cancel
Search</a>
</div>
</div>-->
</div>
@@ -76,6 +75,6 @@
<script type="text/javascript" src="../static/js/js.cookie.min.js"></script>
<script type="text/javascript" src="../static/js/sockjs-1.4.0.min.js"></script>
<script type="text/javascript" src="../static/js/stomp-2.3.3.min.js"></script>
<script type="text/javascript" src="../static/js/plex_movie_list.js"></script>
<script type="text/javascript" src="../static/js/plexMovieList.js"></script>
</body>
</html>