diff --git a/src/main/frontend/views/@index.tsx b/src/main/frontend/views/@index.tsx new file mode 100644 index 0000000..db6312a --- /dev/null +++ b/src/main/frontend/views/@index.tsx @@ -0,0 +1,36 @@ +import {useState} from "react"; +import {UploadService} from "Frontend/generated/endpoints"; + +export default function main() { + const [uuid, setUuid] = useState (undefined); + const [file, setFile] = useState(null); + + function press() { + if (file) { + UploadService.upload(file) + .then(uuid => setUuid(uuid)) + .catch(e => console.error(e)); + } + } + + return ( +
+ + + + { + const selected = e.target.files?.[0] ?? null; + setFile(selected); + }} + /> + + +
+ ) +} \ No newline at end of file diff --git a/src/main/java/com/ddf/vodsystem/services/DownloadService.java b/src/main/java/com/ddf/vodsystem/services/DownloadService.java index 8d35875..008c409 100644 --- a/src/main/java/com/ddf/vodsystem/services/DownloadService.java +++ b/src/main/java/com/ddf/vodsystem/services/DownloadService.java @@ -4,6 +4,8 @@ import com.ddf.vodsystem.entities.JobStatus; import com.ddf.vodsystem.exceptions.JobNotFinished; import com.ddf.vodsystem.exceptions.JobNotFound; import com.ddf.vodsystem.entities.Job; +import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.hilla.Endpoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; @@ -12,6 +14,8 @@ import org.springframework.stereotype.Service; import java.io.File; @Service +@Endpoint +@AnonymousAllowed public class DownloadService { private final JobService jobService; diff --git a/src/main/java/com/ddf/vodsystem/services/UploadService.java b/src/main/java/com/ddf/vodsystem/services/UploadService.java index 3447d25..798efee 100644 --- a/src/main/java/com/ddf/vodsystem/services/UploadService.java +++ b/src/main/java/com/ddf/vodsystem/services/UploadService.java @@ -1,6 +1,8 @@ package com.ddf.vodsystem.services; import com.ddf.vodsystem.entities.Job; +import com.vaadin.flow.server.auth.AnonymousAllowed; +import com.vaadin.hilla.Endpoint; import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -21,6 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Service +@Endpoint +@AnonymousAllowed public class UploadService { private static final Logger logger = LoggerFactory.getLogger(UploadService.class);