Skip to content

Commit

Permalink
merge with changes from master
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggiWuerze committed Dec 8, 2023
2 parents 22ae562 + 9d35d0d commit 589ebb6
Show file tree
Hide file tree
Showing 31 changed files with 449 additions and 163 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ HELP.md
/target/
!.mvn/wrapper/maven-wrapper.jar

.DS_Store

### STS ###
.apt_generated
.classpath
Expand All @@ -28,3 +30,7 @@ HELP.md
### VS Code ###
.vscode/
/.gradle/

### Node.js ###
node_modules
xdcc
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:17.0
WORKDIR /
ADD xdccloader.jar xdccloader.jar
EXPOSE 8080
CMD java -jar xdccloader.jar
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# xddcwebloader
# XDCCWebloader
Web based Download Manager for xdcc file transfer with ReactJS in the frontend and Spring Data REST in the backend

# Releases
Releases and executables can be found here:
[Releases](https://github.com/MaggiWuerze/xddcwebloader/releases)

# Screenshots

### The Main Download View
![image](https://user-images.githubusercontent.com/9729962/184309789-07bce483-73ec-4159-aaac-4b8e75598cef.png)

### Configuring Bots for different Servers and Channels
<img src="https://user-images.githubusercontent.com/9729962/184310278-6973ae76-a08e-43f4-93d4-0776c8d0a078.png" width="15%"></img> <img src="https://user-images.githubusercontent.com/9729962/184310219-024bc28c-7226-4aa0-bb75-1be2e3efec65.png" width="15%"></img> <img src="https://user-images.githubusercontent.com/9729962/184310113-8230d5ec-4824-4e36-83a0-0ec65a902819.png" width="15%"></img>

### Settings page
![image](https://user-images.githubusercontent.com/9729962/184346810-f5fb1803-664d-43dc-9b40-1c684ffc290e.png)

# Running The App
### Locally
The simplest way to run it is to simply execute the jar from the [releases](https://github.com/MaggiWuerze/xddcwebloader/releases) section. it packs everything except a java runtime, so as long as you have java you can run it and start right away.
### Docker
The next best option is to use the Dockerfiles found in the repository to build and run the app through your docker installation.
### From The IDE
This option is mainly meant for people looking into the code or trying to make a PR/Fork for it. Open the project in your favourite Java IDE and execute the XdccloaderApplication class.

I'd recommend IntelliJ. For this approach also see the building section.

--

After starting the app (shouldn't take more than a couple of seconds) you can open it in your browser at either [localhost:8080](localhost:8080) or hostname/ip:8080 if you try to access it from another machine.

# Building
Building the app (and running it from your IDE) requires you to install the following requirements:
- Node.js (17+)
- JDK (17+)


# Documentation (soon)
https://maggiwuerze.de/XDCC-Webloader
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.3'
services:
run:
container_name: xdcc
ports:
- '9999:8080'
environment:
- XDCC_DB_TYPE=org.hibernate.dialect.PostgreSQLDialect
- XDCC_DB_URL=postgresql://mediaserver:49153/postgres
- XDCC_DB_USER=sa
- XDCC_DB_PASSWORD=sa
image: xdcc

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package de.maggiwuerze.xdccloader.controller;

import de.maggiwuerze.xdccloader.model.entity.Bot;
import de.maggiwuerze.xdccloader.model.entity.Server;
import de.maggiwuerze.xdccloader.model.forms.ServerForm;
import de.maggiwuerze.xdccloader.model.transport.ChannelTO;
import de.maggiwuerze.xdccloader.model.transport.ServerTO;
import de.maggiwuerze.xdccloader.service.ServerService;
import java.security.Principal;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -24,14 +33,38 @@ class ServerController {
* @return a list of all servers
*/
@GetMapping("/servers/")
public ResponseEntity<List<Server>> getAllServers() {
List<Server> servers = serverService.list();
public ResponseEntity<List<ServerTO>> getAllServers() {
List<ServerTO> servers = serverService.list().stream().map(ServerTO::new).collect(Collectors.toList());;
return new ResponseEntity(servers, HttpStatus.OK);
}

@PostMapping("/servers/")
public ResponseEntity<?> addServer(@RequestBody ServerForm serverForm) {
Server server = serverService.save(new Server(serverForm.getName(), serverForm.getServerUrl()));
return new ResponseEntity("Download added succcessfully. id=[" + server.getId() + "]", HttpStatus.OK);
try {
Server server = serverService.save(new Server(serverForm.getName(), serverForm.getServerUrl()));
return new ResponseEntity("Download added successfully. id=[" + server.getId() + "]", HttpStatus.OK);
} catch (ConstraintViolationException e) {
log.error(e.getMessage());
String errormessage = e.getConstraintViolations().stream().map(ConstraintViolation::getMessage).collect(Collectors.joining("\n"));
return new ResponseEntity(errormessage, HttpStatus.BAD_REQUEST);
}
}

/**
* @return an example server object to populate the attributes for server creation popover
*/
@GetMapping("/servers/example")
public ResponseEntity<List<Server>> getExampleServer(Principal principal) {
return new ResponseEntity(List.of(new Server()), HttpStatus.OK);
}

@DeleteMapping("/servers/")
public ResponseEntity<?> delete( Long serverId) {
try {
serverService.delete(serverId);
return new ResponseEntity("Server deleted successfully.", HttpStatus.OK);
}catch (Exception e) {
return new ResponseEntity("Server could not be deleted", HttpStatus.CONFLICT);
}
}
}
6 changes: 6 additions & 0 deletions src/main/java/de/maggiwuerze/xdccloader/model/entity/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.NoArgsConstructor;

Expand All @@ -28,15 +30,19 @@ public class Bot {
@JoinColumn(name = "SERVER_ID")
Server server;

@Size(min=1, message = "Bot name must be at least 1 character long")
@Column(nullable = false)
String name;

@Size(min=1, message = "Bot pattern must be at least 1 character long")
@Column(nullable = false)
String pattern;

@Column(nullable = false)
LocalDateTime creationDate = LocalDateTime.now();


@Min(1L)
@Column(nullable = false)
Long maxParallelDownloads = 3L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public class UserSettingsForm {
DownloadSort downloadSortBy;

Long sessionTimeout;

String downloadPath;
}
40 changes: 40 additions & 0 deletions src/main/java/de/maggiwuerze/xdccloader/model/transport/BotTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.maggiwuerze.xdccloader.model.transport;

import de.maggiwuerze.xdccloader.model.entity.Bot;
import de.maggiwuerze.xdccloader.model.entity.Channel;
import de.maggiwuerze.xdccloader.model.entity.Server;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import lombok.Data;
import lombok.Value;

@Value
public class BotTO {

Long id;

String channel;

String server;

String name;

String pattern;

Long maxParallelDownloads;

public BotTO(Bot bot) {
this.id = bot.getId();
this.name = bot.getName();
this.pattern = bot.getPattern();
this.server = bot.getServer().getName();
this.channel = bot.getChannel().getName();
this.maxParallelDownloads = bot.getMaxParallelDownloads();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.maggiwuerze.xdccloader.model.transport;

import de.maggiwuerze.xdccloader.model.entity.Channel;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.Value;

@Value
public class ChannelTO {

Long id;

String name;

public ChannelTO (Channel channel) {
this.id = channel.getId();
this.name = channel.getName();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.maggiwuerze.xdccloader.model.transport;

import de.maggiwuerze.xdccloader.model.entity.Channel;
import de.maggiwuerze.xdccloader.model.entity.Server;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.Value;

@Value
public class ServerTO {

Long id;

String name;

String serverUrl;

public ServerTO (Server server) {
this.id = server.getId();
this.name = server.getName();
this.serverUrl = server.getServerUrl();
}

}
Loading

0 comments on commit 589ebb6

Please sign in to comment.