ADD basic video player with Hilla
This commit is contained in:
36
src/main/frontend/views/@index.tsx
Normal file
36
src/main/frontend/views/@index.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import {useState} from "react";
|
||||||
|
import {UploadService} from "Frontend/generated/endpoints";
|
||||||
|
|
||||||
|
export default function main() {
|
||||||
|
const [uuid, setUuid] = useState<String | undefined> (undefined);
|
||||||
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
|
||||||
|
function press() {
|
||||||
|
if (file) {
|
||||||
|
UploadService.upload(file)
|
||||||
|
.then(uuid => setUuid(uuid))
|
||||||
|
.catch(e => console.error(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
<video width={640} height={480} controls>
|
||||||
|
{ (uuid) &&
|
||||||
|
<source src={`/download/input/${uuid}`} />
|
||||||
|
}
|
||||||
|
</video>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
onChange={(e) => {
|
||||||
|
const selected = e.target.files?.[0] ?? null;
|
||||||
|
setFile(selected);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<button onClick={() => press()}>Upload</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import com.ddf.vodsystem.entities.JobStatus;
|
|||||||
import com.ddf.vodsystem.exceptions.JobNotFinished;
|
import com.ddf.vodsystem.exceptions.JobNotFinished;
|
||||||
import com.ddf.vodsystem.exceptions.JobNotFound;
|
import com.ddf.vodsystem.exceptions.JobNotFound;
|
||||||
import com.ddf.vodsystem.entities.Job;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@@ -12,6 +14,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Endpoint
|
||||||
|
@AnonymousAllowed
|
||||||
public class DownloadService {
|
public class DownloadService {
|
||||||
|
|
||||||
private final JobService jobService;
|
private final JobService jobService;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ddf.vodsystem.services;
|
package com.ddf.vodsystem.services;
|
||||||
|
|
||||||
import com.ddf.vodsystem.entities.Job;
|
import com.ddf.vodsystem.entities.Job;
|
||||||
|
import com.vaadin.flow.server.auth.AnonymousAllowed;
|
||||||
|
import com.vaadin.hilla.Endpoint;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -21,6 +23,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Endpoint
|
||||||
|
@AnonymousAllowed
|
||||||
public class UploadService {
|
public class UploadService {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(UploadService.class);
|
private static final Logger logger = LoggerFactory.getLogger(UploadService.class);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user