Add mock for inpx rescan
This commit is contained in:
parent
443ba9fea9
commit
7f66f20b53
7 changed files with 82 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
postgres/docker-compose.yml
|
postgres/docker-compose.yml
|
||||||
target/
|
target/
|
||||||
|
lib/
|
17
pom.xml
17
pom.xml
|
@ -1,12 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>3.2.1</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath /> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>ru.redrise</groupId>
|
<groupId>ru.redrise</groupId>
|
||||||
<artifactId>marinesco</artifactId>
|
<artifactId>marinesco</artifactId>
|
||||||
|
@ -59,7 +60,8 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity6 -->
|
<!--
|
||||||
|
https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity6 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
||||||
|
@ -71,6 +73,13 @@
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -90,4 +99,4 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
35
src/main/java/ru/redrise/marinesco/library/InpxScanner.java
Normal file
35
src/main/java/ru/redrise/marinesco/library/InpxScanner.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package ru.redrise.marinesco.library;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.core.io.FileSystemResource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "marinesco.library")
|
||||||
|
public class InpxScanner {
|
||||||
|
|
||||||
|
private String filesLocation = "";
|
||||||
|
|
||||||
|
private FileSystemResource inpxFile;
|
||||||
|
|
||||||
|
public void reScan() {
|
||||||
|
inpxFile = new FileSystemResource(filesLocation);
|
||||||
|
|
||||||
|
//todo
|
||||||
|
Stream.of(inpxFile.getFile().listFiles())
|
||||||
|
.forEach(file -> log.info(file.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilesLocation(){
|
||||||
|
return filesLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilesLocation(String location){
|
||||||
|
filesLocation = location;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import ru.redrise.marinesco.library.InpxScanner;
|
||||||
|
|
||||||
//@Slf4j
|
//@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/settings")
|
@RequestMapping("/settings")
|
||||||
|
@ -15,9 +17,12 @@ public class SettingsController {
|
||||||
private KeyValueRepository keyValueRepository;
|
private KeyValueRepository keyValueRepository;
|
||||||
private ApplicationSettings applicationSettings;
|
private ApplicationSettings applicationSettings;
|
||||||
|
|
||||||
public SettingsController(KeyValueRepository keyValueRepository, ApplicationSettings applicationSettings){
|
private InpxScanner inpxScanner;
|
||||||
|
|
||||||
|
public SettingsController(KeyValueRepository keyValueRepository, ApplicationSettings applicationSettings, InpxScanner inpxScanner){
|
||||||
this.keyValueRepository = keyValueRepository;
|
this.keyValueRepository = keyValueRepository;
|
||||||
this.applicationSettings = applicationSettings;
|
this.applicationSettings = applicationSettings;
|
||||||
|
this.inpxScanner = inpxScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
|
@ -39,4 +44,11 @@ public class SettingsController {
|
||||||
|
|
||||||
return "redirect:/settings";
|
return "redirect:/settings";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/rescan")
|
||||||
|
public String rescan(){
|
||||||
|
inpxScanner.reScan();
|
||||||
|
|
||||||
|
return "redirect:/settings";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "marinesco.library.filesLocation",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "All library files location"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -21,3 +21,6 @@ spring:
|
||||||
settings:
|
settings:
|
||||||
web-allow-others: true
|
web-allow-others: true
|
||||||
trace: false
|
trace: false
|
||||||
|
marinesco:
|
||||||
|
library:
|
||||||
|
filesLocation: "./lib"
|
|
@ -4,7 +4,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Marinesco - Application settings</title>
|
<title>Marinesco - Application settings</title>
|
||||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||||
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||||
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -12,8 +12,13 @@
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div th:replace="~{fragments/header :: 'header'}"></div>
|
<div th:replace="~{fragments/header :: 'header'}"></div>
|
||||||
<div class="container base">
|
<div class="container base">
|
||||||
<span th:text="${'New users registration is now ' + (allowRegistration ? 'enabled. ' : 'disabled. ' )}"></span>
|
<span
|
||||||
<a th:href="${'/settings/allow_registration/' + !allowRegistration }" th:text="${'Click here to ' + (allowRegistration ? 'disable' : 'enable' )}"></a>
|
th:text="${'New users registration is now ' + (allowRegistration ? 'enabled. ' : 'disabled. ' )}"></span>
|
||||||
|
<a th:href="${'/settings/allow_registration/' + !allowRegistration }"
|
||||||
|
th:text="${'Click here to ' + (allowRegistration ? 'disable' : 'enable' )}"></a>
|
||||||
|
<p>
|
||||||
|
<a href="/settings/rescan" th:text="Click to rescan library"></a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
||||||
|
|
Loading…
Reference in a new issue