Compare commits
1 Commits
feat/user-
...
c388271ffd
| Author | SHA1 | Date | |
|---|---|---|---|
| c388271ffd |
@@ -4,7 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: gitea.defaoite.dev
|
REGISTRY: gitea.vodsystem.ddns.net
|
||||||
IMAGE_PREFIX: dylan/vod-system
|
IMAGE_PREFIX: dylan/vod-system
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ services:
|
|||||||
context: ./nginx
|
context: ./nginx
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: vod_rtmp
|
container_name: vod_rtmp
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- WEB_SERVER_URL=http://host.docker.internal:8080
|
- WEB_SERVER_URL=http://host.docker.internal:8080
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
image: gitea.defaoite.dev/dylan/vod-system-backend:latest
|
image: gitea.vodsystem.ddns.net/dylan/vod-system-backend:latest
|
||||||
container_name: vod_backend
|
container_name: vod_backend
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
@@ -29,7 +29,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
image: gitea.defaoite.dev/dylan/vod-system-frontend:latest
|
image: gitea.vodsystem.ddns.net/dylan/vod-system-frontend:latest
|
||||||
container_name: vod_frontend
|
container_name: vod_frontend
|
||||||
environment:
|
environment:
|
||||||
VITE_API_URL: ${BACKEND_URL}
|
VITE_API_URL: ${BACKEND_URL}
|
||||||
@@ -38,11 +38,11 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
ports:
|
ports:
|
||||||
- "5173:80"
|
- "5173:5173"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
rtmp:
|
rtmp:
|
||||||
image: gitea.defaoite.dev/dylan/vod-system-rtmp:latest
|
image: gitea.vodsystem.ddns.net/dylan/vod-system-rtmp:latest
|
||||||
container_name: vod_rtmp
|
container_name: vod_rtmp
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
ports:
|
ports:
|
||||||
- "5173:80"
|
- "5173:5173"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
rtmp:
|
rtmp:
|
||||||
|
|||||||
@@ -1,19 +1,9 @@
|
|||||||
# --- Build stage ---
|
FROM node:20-alpine
|
||||||
FROM node:20-alpine AS build
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN --mount=type=cache,target=/root/.npm npm ci
|
RUN --mount=type=cache,target=/root/.npm npm ci
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build
|
EXPOSE 5173
|
||||||
|
CMD ["npm", "run", "dev"]
|
||||||
# --- Production stage ---
|
|
||||||
FROM nginx:1.27-alpine AS prod
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
|
||||||
COPY frontend_nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
# Inject envs at runtime
|
|
||||||
COPY env.sh /docker-entrypoint.d/40-env.sh
|
|
||||||
RUN chmod +x /docker-entrypoint.d/40-env.sh
|
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
|
||||||
54
frontend/README.md
Normal file
54
frontend/README.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# React + TypeScript + Vite
|
||||||
|
|
||||||
|
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||||
|
|
||||||
|
Currently, two official plugins are available:
|
||||||
|
|
||||||
|
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||||
|
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||||
|
|
||||||
|
## Expanding the ESLint configuration
|
||||||
|
|
||||||
|
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default tseslint.config({
|
||||||
|
extends: [
|
||||||
|
// Remove ...tseslint.configs.recommended and replace with this
|
||||||
|
...tseslint.configs.recommendedTypeChecked,
|
||||||
|
// Alternatively, use this for stricter rules
|
||||||
|
...tseslint.configs.strictTypeChecked,
|
||||||
|
// Optionally, add this for stylistic rules
|
||||||
|
...tseslint.configs.stylisticTypeChecked,
|
||||||
|
],
|
||||||
|
languageOptions: {
|
||||||
|
// other options...
|
||||||
|
parserOptions: {
|
||||||
|
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// eslint.config.js
|
||||||
|
import reactX from 'eslint-plugin-react-x'
|
||||||
|
import reactDom from 'eslint-plugin-react-dom'
|
||||||
|
|
||||||
|
export default tseslint.config({
|
||||||
|
plugins: {
|
||||||
|
// Add the react-x and react-dom plugins
|
||||||
|
'react-x': reactX,
|
||||||
|
'react-dom': reactDom,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// other rules...
|
||||||
|
// Enable its recommended typescript rules
|
||||||
|
...reactX.configs['recommended-typescript'].rules,
|
||||||
|
...reactDom.configs.recommended.rules,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
```
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
cat <<EOF > /usr/share/nginx/html/env-config.js
|
|
||||||
window._env_ = {
|
|
||||||
VITE_API_URL: "${VITE_API_URL:-}",
|
|
||||||
VITE_FRONTEND_URL: "${VITE_FRONTEND_URL:-}",
|
|
||||||
VITE_GOOGLE_CLIENT_ID: "${VITE_GOOGLE_CLIENT_ID:-}"
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
server_name _;
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,28 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/png" href="/small_icon.png" />
|
<link rel="icon" type="image/png" href="/small_icon.png" />
|
||||||
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Newsreader:wght@100;200;300;400;500;600;700&family=IBM+Plex+Sans:wght@100;200;300;400;500;600;700&family=IBM+Plex+Mono:wght@100;200;300;400;500;600;700&display=swap" rel="stylesheet">
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script>
|
<title>Vite + React + TS</title>
|
||||||
// Apply the stored theme before first paint so a dark session never
|
|
||||||
// flashes light. Mirrors the logic in src/theme/ThemeProvider.tsx.
|
|
||||||
(function () {
|
|
||||||
try {
|
|
||||||
var stored = localStorage.getItem("theme");
|
|
||||||
var dark = stored === "dark" ||
|
|
||||||
(stored !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
||||||
document.documentElement.dataset.theme = dark ? "dark" : "light";
|
|
||||||
} catch (e) {
|
|
||||||
document.documentElement.dataset.theme = "light";
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<script src="/env-config.js"></script>
|
|
||||||
<title>The VoD System</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
665
frontend/package-lock.json
generated
665
frontend/package-lock.json
generated
@@ -7,9 +7,11 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-oauth/google": "^0.12.2",
|
"@react-oauth/google": "^0.12.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"flowbite-react": "^0.11.8",
|
||||||
"lucide-react": "^0.511.0",
|
"lucide-react": "^0.511.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
@@ -914,6 +916,68 @@
|
|||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@floating-ui/core": {
|
||||||
|
"version": "1.6.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.9.tgz",
|
||||||
|
"integrity": "sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/utils": "^0.2.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@floating-ui/dom": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/core": "^1.8.0",
|
||||||
|
"@floating-ui/utils": "^0.2.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@floating-ui/dom/node_modules/@floating-ui/core": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/utils": "^0.2.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@floating-ui/react": {
|
||||||
|
"version": "0.27.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.27.3.tgz",
|
||||||
|
"integrity": "sha512-CLHnes3ixIFFKVQDdICjel8muhFLOBdQH7fgtHNPY8UbCNqbeKZ262G7K66lGQOUQWWnYocf7ZbUsLJgGfsLHg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/react-dom": "^2.1.2",
|
||||||
|
"@floating-ui/utils": "^0.2.9",
|
||||||
|
"tabbable": "^6.0.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=17.0.0",
|
||||||
|
"react-dom": ">=17.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@floating-ui/react-dom": {
|
||||||
|
"version": "2.1.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.9.tgz",
|
||||||
|
"integrity": "sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/dom": "^1.8.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.0",
|
||||||
|
"react-dom": ">=16.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@floating-ui/utils": {
|
||||||
|
"version": "0.2.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz",
|
||||||
|
"integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@humanfs/core": {
|
"node_modules/@humanfs/core": {
|
||||||
"version": "0.19.2",
|
"version": "0.19.2",
|
||||||
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",
|
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz",
|
||||||
@@ -980,6 +1044,12 @@
|
|||||||
"url": "https://github.com/sponsors/nzakas"
|
"url": "https://github.com/sponsors/nzakas"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@iarna/toml": {
|
||||||
|
"version": "2.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz",
|
||||||
|
"integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
"node_modules/@jridgewell/gen-mapping": {
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
"version": "0.3.13",
|
"version": "0.3.13",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||||
@@ -1030,6 +1100,41 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
|
"version": "2.1.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
|
"integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@nodelib/fs.stat": "2.0.5",
|
||||||
|
"run-parallel": "^1.1.9"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@nodelib/fs.stat": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@nodelib/fs.walk": {
|
||||||
|
"version": "1.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz",
|
||||||
|
"integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@nodelib/fs.scandir": "2.1.5",
|
||||||
|
"fastq": "^1.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-oauth/google": {
|
"node_modules/@react-oauth/google": {
|
||||||
"version": "0.12.2",
|
"version": "0.12.2",
|
||||||
"resolved": "https://registry.npmjs.org/@react-oauth/google/-/google-0.12.2.tgz",
|
"resolved": "https://registry.npmjs.org/@react-oauth/google/-/google-0.12.2.tgz",
|
||||||
@@ -1989,9 +2094,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/parser/node_modules/brace-expansion": {
|
"node_modules/@typescript-eslint/parser/node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2255,9 +2360,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/type-utils/node_modules/brace-expansion": {
|
"node_modules/@typescript-eslint/type-utils/node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2309,6 +2414,81 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@typescript-eslint/types": {
|
||||||
|
"version": "8.26.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.26.0.tgz",
|
||||||
|
"integrity": "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@typescript-eslint/typescript-estree": {
|
||||||
|
"version": "8.26.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.0.tgz",
|
||||||
|
"integrity": "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@typescript-eslint/types": "8.26.0",
|
||||||
|
"@typescript-eslint/visitor-keys": "8.26.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"fast-glob": "^3.3.2",
|
||||||
|
"is-glob": "^4.0.3",
|
||||||
|
"minimatch": "^9.0.4",
|
||||||
|
"semver": "^7.6.0",
|
||||||
|
"ts-api-utils": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": ">=4.8.4 <5.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": {
|
||||||
|
"version": "9.0.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz",
|
||||||
|
"integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^2.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16 || 14 >=14.17"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/semver": {
|
||||||
|
"version": "7.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
||||||
|
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/utils": {
|
"node_modules/@typescript-eslint/utils": {
|
||||||
"version": "8.65.0",
|
"version": "8.65.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.65.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.65.0.tgz",
|
||||||
@@ -2404,9 +2584,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/utils/node_modules/brace-expansion": {
|
"node_modules/@typescript-eslint/utils/node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2458,6 +2638,23 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@typescript-eslint/visitor-keys": {
|
||||||
|
"version": "8.26.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.0.tgz",
|
||||||
|
"integrity": "sha512-2z8JQJWAzPdDd51dRQ/oqIJxe99/hoLIqmf8RMCAJQtYDc535W/Jt2+RTP4bP0aKeBG1F65yjIZuczOXCmbWwg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@typescript-eslint/types": "8.26.0",
|
||||||
|
"eslint-visitor-keys": "^4.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@vitejs/plugin-react": {
|
"node_modules/@vitejs/plugin-react": {
|
||||||
"version": "4.7.0",
|
"version": "4.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
|
||||||
@@ -2542,11 +2739,28 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Python-2.0"
|
"license": "Python-2.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/array-timsort": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/ast-types": {
|
||||||
|
"version": "0.16.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.16.1.tgz",
|
||||||
|
"integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
@@ -2563,9 +2777,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "1.1.18",
|
"version": "1.1.16",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.16.tgz",
|
||||||
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
"integrity": "sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2573,6 +2787,18 @@
|
|||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/braces": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fill-range": "^7.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/browserslist": {
|
"node_modules/browserslist": {
|
||||||
"version": "4.28.7",
|
"version": "4.28.7",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz",
|
||||||
@@ -2655,6 +2881,27 @@
|
|||||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/chokidar": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"readdirp": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14.16.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://paulmillr.com/funding/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/classnames": {
|
||||||
|
"version": "2.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
|
||||||
|
"integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/clsx": {
|
"node_modules/clsx": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||||
@@ -2684,6 +2931,22 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/comment-json": {
|
||||||
|
"version": "4.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.5.tgz",
|
||||||
|
"integrity": "sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"array-timsort": "^1.0.3",
|
||||||
|
"core-util-is": "^1.0.3",
|
||||||
|
"esprima": "^4.0.1",
|
||||||
|
"has-own-prop": "^2.0.0",
|
||||||
|
"repeat-string": "^1.6.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
@@ -2722,6 +2985,12 @@
|
|||||||
"url": "https://opencollective.com/core-js"
|
"url": "https://opencollective.com/core-js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/core-util-is": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
@@ -2744,11 +3013,22 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/debounce": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/debounce/-/debounce-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-Xks6RUDLZFdz8LIdR6q0MTH44k7FikOmnh5xkSjMig6ch45afc8sjTjRQf3P6ax8dMgcQrYO/AR2RGWURrruqw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
"version": "4.4.3",
|
"version": "4.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ms": "^2.1.3"
|
"ms": "^2.1.3"
|
||||||
@@ -2769,6 +3049,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/deepmerge-ts": {
|
||||||
|
"version": "7.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-7.1.4.tgz",
|
||||||
|
"integrity": "sha512-fxqo6nHGQ9zOVgI4KXqtWXJR/yCLtC7aXIVq+6jc8tHPFUxlFmuUcm2kC4vztQ+LJxQ3gER/XAWearGYQ8niGA==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/detect-libc": {
|
"node_modules/detect-libc": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||||
@@ -2969,7 +3258,6 @@
|
|||||||
"version": "4.2.1",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
|
||||||
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
|
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -2996,6 +3284,19 @@
|
|||||||
"url": "https://opencollective.com/eslint"
|
"url": "https://opencollective.com/eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/esprima": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"bin": {
|
||||||
|
"esparse": "bin/esparse.js",
|
||||||
|
"esvalidate": "bin/esvalidate.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esquery": {
|
"node_modules/esquery": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz",
|
||||||
@@ -3049,6 +3350,34 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/fast-glob": {
|
||||||
|
"version": "3.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||||
|
"integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@nodelib/fs.stat": "^2.0.2",
|
||||||
|
"@nodelib/fs.walk": "^1.2.3",
|
||||||
|
"glob-parent": "^5.1.2",
|
||||||
|
"merge2": "^1.3.0",
|
||||||
|
"micromatch": "^4.0.8"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fast-glob/node_modules/glob-parent": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"is-glob": "^4.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fast-json-stable-stringify": {
|
"node_modules/fast-json-stable-stringify": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
||||||
@@ -3063,6 +3392,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/fastq": {
|
||||||
|
"version": "1.20.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz",
|
||||||
|
"integrity": "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"reusify": "^1.0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/file-entry-cache": {
|
"node_modules/file-entry-cache": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||||
@@ -3076,6 +3414,18 @@
|
|||||||
"node": ">=16.0.0"
|
"node": ">=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fill-range": {
|
||||||
|
"version": "7.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||||
|
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"to-regex-range": "^5.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/find-up": {
|
"node_modules/find-up": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
|
||||||
@@ -3114,6 +3464,36 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/flowbite-react": {
|
||||||
|
"version": "0.11.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/flowbite-react/-/flowbite-react-0.11.9.tgz",
|
||||||
|
"integrity": "sha512-S8KwzbR2PcVv+iJDpIp62NrIjSkKIm6ZrwdssK0k4mDU8SvYSuecKstATrIxdHAIL3/FiT4VGNuCoTUSj4OcEQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@floating-ui/core": "1.6.9",
|
||||||
|
"@floating-ui/react": "0.27.3",
|
||||||
|
"@iarna/toml": "2.2.5",
|
||||||
|
"@typescript-eslint/typescript-estree": "8.26.0",
|
||||||
|
"chokidar": "4.0.3",
|
||||||
|
"classnames": "2.5.1",
|
||||||
|
"comment-json": "4.2.5",
|
||||||
|
"debounce": "2.2.0",
|
||||||
|
"deepmerge-ts": "7.1.4",
|
||||||
|
"klona": "2.0.6",
|
||||||
|
"package-manager-detector": "0.2.9",
|
||||||
|
"recast": "0.23.11",
|
||||||
|
"tailwind-merge-v2": "npm:tailwind-merge@2.6.0",
|
||||||
|
"tailwind-merge-v3": "npm:tailwind-merge@3.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"flowbite-react": "dist/cli/bin.js"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^18 || ^19",
|
||||||
|
"react-dom": "^18 || ^19",
|
||||||
|
"tailwindcss": "^3 || ^4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fsevents": {
|
"node_modules/fsevents": {
|
||||||
"version": "2.3.3",
|
"version": "2.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
|
||||||
@@ -3182,6 +3562,15 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/has-own-prop": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ignore": {
|
"node_modules/ignore": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",
|
||||||
@@ -3223,7 +3612,6 @@
|
|||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
|
||||||
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
@@ -3233,7 +3621,6 @@
|
|||||||
"version": "4.0.3",
|
"version": "4.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
|
||||||
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"is-extglob": "^2.1.1"
|
"is-extglob": "^2.1.1"
|
||||||
@@ -3242,6 +3629,15 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/is-number": {
|
||||||
|
"version": "7.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||||
|
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/isexe": {
|
"node_modules/isexe": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||||
@@ -3267,9 +3663,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.3.1",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.0.tgz",
|
||||||
"integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==",
|
"integrity": "sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -3346,6 +3742,15 @@
|
|||||||
"json-buffer": "3.0.1"
|
"json-buffer": "3.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/klona": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz",
|
||||||
|
"integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/levn": {
|
"node_modules/levn": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
||||||
@@ -3685,6 +4090,28 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/merge2": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromatch": {
|
||||||
|
"version": "4.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||||
|
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"braces": "^3.0.3",
|
||||||
|
"picomatch": "^2.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.5",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
||||||
@@ -3702,13 +4129,12 @@
|
|||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.3.18",
|
"version": "3.3.16",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz",
|
||||||
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
|
"integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -3791,6 +4217,12 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/package-manager-detector": {
|
||||||
|
"version": "0.2.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-0.2.9.tgz",
|
||||||
|
"integrity": "sha512-+vYvA/Y31l8Zk8dwxHhL3JfTuHPm6tlxM2A3GeQyl7ovYnSp1+mzAxClxaOr0qO1TtPxbQxetI7v5XqKLJZk7Q==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/parent-module": {
|
"node_modules/parent-module": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
|
||||||
@@ -3831,6 +4263,18 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/picomatch": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.23",
|
"version": "8.5.23",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.23.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.23.tgz",
|
||||||
@@ -3880,6 +4324,26 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/queue-microtask": {
|
||||||
|
"version": "1.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
||||||
|
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/react": {
|
"node_modules/react": {
|
||||||
"version": "19.2.8",
|
"version": "19.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
|
||||||
@@ -3935,9 +4399,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router": {
|
"node_modules/react-router": {
|
||||||
"version": "7.18.2",
|
"version": "7.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.1.tgz",
|
||||||
"integrity": "sha512-aUVMjFm3GAPTTZL7oYr5E7ETiqfQCHRLH+B+5afnICvf0r7kkK4eR6SMuwbSTJw/7t+12khT/Kahij49fqOCIg==",
|
"integrity": "sha512-GDLgg3i3uM0aeJO3Fm+TCS+sDQ7gu12T6x0qdTEzcwqEfleci7JwugVNIF3U//0FWKnJT7ptG+20B2jfDqnZAg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cookie": "^1.0.1",
|
"cookie": "^1.0.1",
|
||||||
@@ -3957,12 +4421,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-router-dom": {
|
"node_modules/react-router-dom": {
|
||||||
"version": "7.18.2",
|
"version": "7.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.1.tgz",
|
||||||
"integrity": "sha512-AIKJ/jgGlFb3EbfCXk5Gzshiwt+l3mqbCrNjmEWMMjqQxNJ3svBa6bgzFyCC2Sw3RA0VWF1kg3uQf2OFhxb8hw==",
|
"integrity": "sha512-KaZh+X/6UtEp28x51AUYZDMg9NGoz2ja3dNHa+ta/tk40vCzKhQ/RypCWBMLbmDr6//E24Vv5uPsrqXFozdkAg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-router": "7.18.2"
|
"react-router": "7.18.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
@@ -3972,6 +4436,44 @@
|
|||||||
"react-dom": ">=18"
|
"react-dom": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/readdirp": {
|
||||||
|
"version": "4.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
||||||
|
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14.18.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://paulmillr.com/funding/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/recast": {
|
||||||
|
"version": "0.23.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/recast/-/recast-0.23.11.tgz",
|
||||||
|
"integrity": "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ast-types": "^0.16.1",
|
||||||
|
"esprima": "~4.0.0",
|
||||||
|
"source-map": "~0.6.1",
|
||||||
|
"tiny-invariant": "^1.3.3",
|
||||||
|
"tslib": "^2.0.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/repeat-string": {
|
||||||
|
"version": "1.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
|
||||||
|
"integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/resolve-from": {
|
"node_modules/resolve-from": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||||
@@ -3982,6 +4484,16 @@
|
|||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/reusify": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"iojs": ">=1.0.0",
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "4.62.2",
|
"version": "4.62.2",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz",
|
||||||
@@ -4027,6 +4539,29 @@
|
|||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/run-parallel": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"queue-microtask": "^1.2.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/scheduler": {
|
"node_modules/scheduler": {
|
||||||
"version": "0.27.0",
|
"version": "0.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
|
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz",
|
||||||
@@ -4072,6 +4607,15 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
@@ -4108,11 +4652,38 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tabbable": {
|
||||||
|
"version": "6.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.5.0.tgz",
|
||||||
|
"integrity": "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/tailwind-merge-v2": {
|
||||||
|
"name": "tailwind-merge",
|
||||||
|
"version": "2.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-2.6.0.tgz",
|
||||||
|
"integrity": "sha512-P+Vu1qXfzediirmHOC3xKGAYeZtPcV9g76X+xg2FD4tYgR71ewMA35Y3sCz3zhiN/dwefRpJX0yBcgwi1fXNQA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/dcastil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tailwind-merge-v3": {
|
||||||
|
"name": "tailwind-merge",
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-AvzE8FmSoXC7nC+oU5GlQJbip2UO7tmOhOfQyOmPhrStOGXHU08j8mZEHZ4BmCqY5dWTCo4ClWkNyRNx1wpT0g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/dcastil"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "4.3.3",
|
"version": "4.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz",
|
||||||
"integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==",
|
"integrity": "sha512-gOhV3P7ufE62QDGg1zVaTgCR+EtPv92k2nIhVcVKcLmxT1sUBsQGhnZj175j+MqRt4zLF7ic+sCYjfhxMxj7YQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
@@ -4129,6 +4700,12 @@
|
|||||||
"url": "https://opencollective.com/webpack"
|
"url": "https://opencollective.com/webpack"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tiny-invariant": {
|
||||||
|
"version": "1.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
|
||||||
|
"integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/tinyglobby": {
|
"node_modules/tinyglobby": {
|
||||||
"version": "0.2.17",
|
"version": "0.2.17",
|
||||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
||||||
@@ -4177,11 +4754,22 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/to-regex-range": {
|
||||||
|
"version": "5.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
|
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"is-number": "^7.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ts-api-utils": {
|
"node_modules/ts-api-utils": {
|
||||||
"version": "2.5.0",
|
"version": "2.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz",
|
||||||
"integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
|
"integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.12"
|
"node": ">=18.12"
|
||||||
@@ -4194,9 +4782,7 @@
|
|||||||
"version": "2.8.1",
|
"version": "2.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||||
"dev": true,
|
"license": "0BSD"
|
||||||
"license": "0BSD",
|
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"node_modules/type-check": {
|
"node_modules/type-check": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
@@ -4215,7 +4801,6 @@
|
|||||||
"version": "5.8.3",
|
"version": "5.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
@@ -4320,9 +4905,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript-eslint/node_modules/brace-expansion": {
|
"node_modules/typescript-eslint/node_modules/brace-expansion": {
|
||||||
"version": "5.0.9",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
||||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview",
|
||||||
|
"postinstall": "flowbite-react patch"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-oauth/google": "^0.12.2",
|
"@react-oauth/google": "^0.12.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"flowbite-react": "^0.11.8",
|
||||||
"lucide-react": "^0.511.0",
|
"lucide-react": "^0.511.0",
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
|
|||||||
42
frontend/src/App.css
Normal file
42
frontend/src/App.css
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#root {
|
||||||
|
max-width: 1280px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 2rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
height: 6em;
|
||||||
|
padding: 1.5em;
|
||||||
|
will-change: filter;
|
||||||
|
transition: filter 300ms;
|
||||||
|
}
|
||||||
|
.logo:hover {
|
||||||
|
filter: drop-shadow(0 0 2em #646cffaa);
|
||||||
|
}
|
||||||
|
.logo.react:hover {
|
||||||
|
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes logo-spin {
|
||||||
|
from {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: no-preference) {
|
||||||
|
a:nth-of-type(2) .logo {
|
||||||
|
animation: logo-spin infinite 20s linear;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
padding: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.read-the-docs {
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
@@ -15,11 +15,6 @@ import EditVod from "./pages/EditVod.tsx";
|
|||||||
import Profile from "./pages/Profile.tsx";
|
import Profile from "./pages/Profile.tsx";
|
||||||
import StreamControl from "./pages/StreamControl.tsx";
|
import StreamControl from "./pages/StreamControl.tsx";
|
||||||
import { GoogleOAuthProvider } from '@react-oauth/google';
|
import { GoogleOAuthProvider } from '@react-oauth/google';
|
||||||
import {config} from "./config.ts";
|
|
||||||
import NotFound from "./pages/NotFound.tsx";
|
|
||||||
import AuthProvider from "./auth/AuthProvider.tsx";
|
|
||||||
import ThemeProvider from "./theme/ThemeProvider.tsx";
|
|
||||||
import RequireAuth from "./auth/RequireAuth.tsx";
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -28,33 +23,24 @@ function App() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GoogleOAuthProvider clientId={config.googleClientId}>
|
<GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_CLIENT_ID}>
|
||||||
<ThemeProvider>
|
<Router>
|
||||||
<AuthProvider>
|
<Routes>
|
||||||
<Router>
|
<Route element={<MainLayout />}>
|
||||||
<Routes>
|
<Route path="/" element={<Home />} />
|
||||||
<Route element={<MainLayout />}>
|
<Route path="/create" element={<ClipUpload />} />
|
||||||
<Route path="/" element={<Home />} />
|
<Route path="/create/:id" element={<ClipEdit />} />
|
||||||
<Route path="/create" element={<ClipUpload />} />
|
<Route path="/my-clips" element={<MyClips />} />
|
||||||
<Route path="/create/:id" element={<ClipEdit />} />
|
<Route path="/my-vods" element={<MyVods />} />
|
||||||
|
<Route path="/video/:id" element={<MediaPlayer noun="Clip" getMediaUrl={getClipMediaUrl} fetchDetails={getClipById} />} />
|
||||||
<Route element={<RequireAuth />}>
|
<Route path="/vod/:id" element={<MediaPlayer noun="VoD" getMediaUrl={getVodMediaUrl} fetchDetails={getVodById} />} />
|
||||||
<Route path="/my-clips" element={<MyClips />} />
|
<Route path="/clips/:id/edit" element={<EditClip />} />
|
||||||
<Route path="/my-vods" element={<MyVods />} />
|
<Route path="/vods/:id/edit" element={<EditVod />} />
|
||||||
<Route path="/video/:id" element={<MediaPlayer noun="Clip" getMediaUrl={getClipMediaUrl} fetchDetails={getClipById} />} />
|
<Route path="/profile" element={<Profile />} />
|
||||||
<Route path="/vod/:id" element={<MediaPlayer noun="VoD" getMediaUrl={getVodMediaUrl} fetchDetails={getVodById} />} />
|
<Route path="/stream" element={<StreamControl />} />
|
||||||
<Route path="/clips/:id/edit" element={<EditClip />} />
|
</Route>
|
||||||
<Route path="/vods/:id/edit" element={<EditVod />} />
|
</Routes>
|
||||||
<Route path="/profile" element={<Profile />} />
|
</Router>
|
||||||
<Route path="/stream" element={<StreamControl />} />
|
|
||||||
</Route>
|
|
||||||
|
|
||||||
<Route path="*" element={<NotFound />} />
|
|
||||||
</Route>
|
|
||||||
</Routes>
|
|
||||||
</Router>
|
|
||||||
</AuthProvider>
|
|
||||||
</ThemeProvider>
|
|
||||||
</ GoogleOAuthProvider>
|
</ GoogleOAuthProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import { createContext } from "react";
|
|
||||||
import type { User } from "../utils/types.ts";
|
|
||||||
|
|
||||||
type AuthContextValue = {
|
|
||||||
/** The currently authenticated user, or null when logged out. */
|
|
||||||
user: User | null;
|
|
||||||
/** True until the initial "who am I" request has resolved. */
|
|
||||||
loading: boolean;
|
|
||||||
/** Exchange a Google credential for a session, then load the user. */
|
|
||||||
login: (googleCredential: string) => Promise<void>;
|
|
||||||
/** End the session and clear the user. */
|
|
||||||
logout: () => Promise<void>;
|
|
||||||
/** Re-fetch the current user (e.g. after a profile change). */
|
|
||||||
refresh: () => Promise<void>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const AuthContext = createContext<AuthContextValue | null>(null);
|
|
||||||
|
|
||||||
export { AuthContext };
|
|
||||||
export type { AuthContextValue };
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
|
||||||
import type { ReactNode } from "react";
|
|
||||||
import type { User } from "../utils/types.ts";
|
|
||||||
import { login as apiLogin, logout as apiLogout, getUser } from "../utils/api/users.ts";
|
|
||||||
import { AuthContext } from "./AuthContext.ts";
|
|
||||||
import {registerUnauthorizedHandler} from "../utils/api/client.ts";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Owns the single source of truth for the authenticated user. Everything that
|
|
||||||
* needs to know who is logged in — the layout, the top bar, protected pages —
|
|
||||||
* reads it through the `useAuth` hook rather than fetching the user itself.
|
|
||||||
*/
|
|
||||||
const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
||||||
const [user, setUser] = useState<User | null>(null);
|
|
||||||
const [loading, setLoading] = useState(true);
|
|
||||||
|
|
||||||
const refresh = useCallback(async () => {
|
|
||||||
try {
|
|
||||||
setUser(await getUser());
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch user:", error);
|
|
||||||
setUser(null);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refresh().finally(() => setLoading(false));
|
|
||||||
}, [refresh]);
|
|
||||||
|
|
||||||
const login = useCallback(async (googleCredential: string) => {
|
|
||||||
await apiLogin(googleCredential);
|
|
||||||
await refresh();
|
|
||||||
}, [refresh]);
|
|
||||||
|
|
||||||
const logout = useCallback(async () => {
|
|
||||||
await apiLogout();
|
|
||||||
await refresh();
|
|
||||||
}, [refresh]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
registerUnauthorizedHandler(() => setUser(null));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<AuthContext.Provider value={{ user, loading, login, logout, refresh }}>
|
|
||||||
{children}
|
|
||||||
</AuthContext.Provider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AuthProvider;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { Navigate, Outlet, useLocation } from "react-router-dom";
|
|
||||||
import { useAuth } from "./useAuth";
|
|
||||||
|
|
||||||
const RequireAuth = () => {
|
|
||||||
const { user, loading } = useAuth();
|
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
if (loading) return null;
|
|
||||||
if (!user) return <Navigate to="/" replace state={{ from: location }} />;
|
|
||||||
|
|
||||||
return <Outlet />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default RequireAuth;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { useContext } from "react";
|
|
||||||
import { AuthContext } from "./AuthContext.ts";
|
|
||||||
import type { AuthContextValue } from "./AuthContext.ts";
|
|
||||||
|
|
||||||
/** Access the centralised auth state. Must be used within an <AuthProvider>. */
|
|
||||||
const useAuth = (): AuthContextValue => {
|
|
||||||
const context = useContext(AuthContext);
|
|
||||||
if (!context) {
|
|
||||||
throw new Error("useAuth must be used within an AuthProvider");
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { useAuth };
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -7,7 +6,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Box = ({ children, className }: Props) => (
|
const Box = ({ children, className }: Props) => (
|
||||||
<div className={clsx("bg-card border-hairline shadow-sm rounded-lg", className)}>
|
<div className={clsx("bg-white border border-gray-200 shadow-sm rounded-lg", className)}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import type { ElementType } from "react";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
icon: ElementType;
|
|
||||||
title: string;
|
|
||||||
accent?: "primary" | "accent";
|
|
||||||
};
|
|
||||||
|
|
||||||
const CardHeader = ({ icon: Icon, title, accent = "primary" }: Props) => (
|
|
||||||
<div className="flex items-center gap-2.5">
|
|
||||||
<div className={`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${accent === "primary" ? "bg-terracotta/10" : "bg-olive/10"}`}>
|
|
||||||
<Icon size={16} className={accent === "primary" ? "text-terracotta" : "text-olive"} />
|
|
||||||
</div>
|
|
||||||
<h2 className="text-xl font-heading text-text-primary">{title}</h2>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default CardHeader;
|
|
||||||
@@ -9,7 +9,7 @@ type DropdownItemProps = {
|
|||||||
|
|
||||||
const DropdownItem = ({ item, onClick, className }: DropdownItemProps) => (
|
const DropdownItem = ({ item, onClick, className }: DropdownItemProps) => (
|
||||||
<li
|
<li
|
||||||
className={clsx("cursor-pointer hover:bg-hover px-3 py-2 text-sm rounded-md", className)}
|
className={clsx("cursor-pointer hover:bg-gray-50 px-3 py-2 text-sm text-gray-700", className)}
|
||||||
onClick={() => onClick(item)}
|
onClick={() => onClick(item)}
|
||||||
>
|
>
|
||||||
{item}
|
{item}
|
||||||
@@ -40,12 +40,12 @@ const Dropdown = ({ label, children, className }: DropdownProps) => {
|
|||||||
<div className={clsx(className, "relative inline-block text-left")} ref={ref}>
|
<div className={clsx(className, "relative inline-block text-left")} ref={ref}>
|
||||||
<button
|
<button
|
||||||
onClick={() => setIsOpen(v => !v)}
|
onClick={() => setIsOpen(v => !v)}
|
||||||
className="inline-flex items-center gap-1 px-3 py-2 text-sm transition-colors duration-150"
|
className="inline-flex items-center gap-1 rounded-lg px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-100 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</button>
|
</button>
|
||||||
{isOpen && (
|
{isOpen && (
|
||||||
<ul className="absolute right-0 mt-1 w-36 origin-top-right rounded-lg bg-background border border-hairline shadow-md z-50 py-1 overflow-hidden">
|
<ul className="absolute right-0 mt-1 w-36 origin-top-right rounded-lg bg-white border border-gray-200 shadow-md z-50 py-1 overflow-hidden">
|
||||||
{children}
|
{children}
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ type Props = {
|
|||||||
|
|
||||||
const Selector = ({ children, label }: Props) => (
|
const Selector = ({ children, label }: Props) => (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<label className="w-full text-sm text-text-secondary">{label}</label>
|
<label className="w-full text-sm text-gray-600">{label}</label>
|
||||||
<div className="w-px h-5 text-text-secondary mx-2" />
|
<div className="w-px h-5 bg-gray-200 mx-2" />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,51 +1,50 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import SidebarButton from "./buttons/SidebarButton.tsx";
|
import SidebarButton from "./buttons/SidebarButton.tsx";
|
||||||
import { Plus, Film, Home, User as UserIcon, Video, Radio } from 'lucide-react';
|
import { Plus, Film, Home, User as UserIcon, Video, Radio } from 'lucide-react';
|
||||||
import { useAuth } from "../auth/useAuth.ts";
|
import type {User} from "../utils/types.ts";
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
|
user: User | null;
|
||||||
className?: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const Divider = () => <hr className="w-full my-1.5 mx-2 border-hover" />;
|
const Divider = () => <hr className="my-1.5 mx-2 border-gray-100" />;
|
||||||
|
|
||||||
const Sidebar = ({className}: props) => {
|
|
||||||
const { user } = useAuth();
|
|
||||||
|
|
||||||
|
const Sidebar = ({user, className}: props) => {
|
||||||
return (
|
return (
|
||||||
<aside className={clsx("h-screen flex flex-col bg-sidebar border-r border-hairline p-2 items-center gap-1", className)}>
|
<aside className={clsx("h-screen flex flex-col bg-white border-r border-gray-200", className)}>
|
||||||
<h2 className={"font-heading text-2xl mt-1"}>The VoD System</h2>
|
<div className="px-4 pt-5 pb-3">
|
||||||
|
<img
|
||||||
<nav className="flex flex-col flex-1 items-center w-3/4">
|
className="w-36 mx-auto"
|
||||||
<Divider />
|
src="../../public/logo.png"
|
||||||
|
alt="VoD System Logo"
|
||||||
<div className="flex flex-col gap-0.5 w-full">
|
/>
|
||||||
|
</div>
|
||||||
|
<nav className="flex flex-col flex-1 px-2 pb-4">
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
<SidebarButton url="/" logo={<Home size={18}/>} label="Home" />
|
<SidebarButton url="/" logo={<Home size={18}/>} label="Home" />
|
||||||
<SidebarButton url="/create" logo={<Plus size={18}/>} label="Create Clip" />
|
<SidebarButton url="/create" logo={<Plus size={18}/>} label="Create Clip" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
{user && (
|
{user && (
|
||||||
<div className="flex flex-col gap-0.5 w-full">
|
<>
|
||||||
<div>
|
<Divider />
|
||||||
<SidebarButton url="/stream" logo={<Radio size={18}/>} label="Stream" />
|
<div className="flex flex-col gap-0.5">
|
||||||
<SidebarButton url="/my-clips" logo={<Film size={18}/>} label="Clips" />
|
<SidebarButton url="/stream" logo={<Radio size={18}/>} label="Stream" />
|
||||||
<SidebarButton url="/my-vods" logo={<Video size={18}/>} label="VoDs" />
|
<SidebarButton url="/my-clips" logo={<Film size={18}/>} label="Clips" />
|
||||||
</div>
|
<SidebarButton url="/my-vods" logo={<Video size={18}/>} label="VoDs" />
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
|
|
||||||
<div className={"w-full"}>
|
{user && (
|
||||||
{user && (
|
<>
|
||||||
<>
|
<Divider />
|
||||||
<Divider />
|
<SidebarButton url="/profile" logo={<UserIcon size={18}/>} label="Profile" />
|
||||||
<SidebarButton url="/profile" logo={<UserIcon size={18}/>} label="Profile" />
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
import { Menu, X, Sun, Moon } from 'lucide-react';
|
import { Menu, X } from 'lucide-react';
|
||||||
|
import { login, logout } from "../utils/api/users.ts";
|
||||||
import { Dropdown, DropdownItem } from "./Dropdown.tsx";
|
import { Dropdown, DropdownItem } from "./Dropdown.tsx";
|
||||||
import { GoogleLogin } from '@react-oauth/google';
|
import { GoogleLogin } from '@react-oauth/google';
|
||||||
|
|
||||||
|
import type { User } from "../utils/types.ts";
|
||||||
import type { CredentialResponse } from '@react-oauth/google';
|
import type { CredentialResponse } from '@react-oauth/google';
|
||||||
|
|
||||||
import MenuButton from "./buttons/MenuButton.tsx";
|
import MenuButton from "./buttons/MenuButton.tsx";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import {useNavigate} from "react-router-dom";
|
import {useNavigate} from "react-router-dom";
|
||||||
import { useAuth } from "../auth/useAuth.ts";
|
|
||||||
import { useTheme } from "../theme/useTheme.ts";
|
|
||||||
|
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
sidebarToggled: boolean;
|
sidebarToggled: boolean;
|
||||||
setSidebarToggled: (toggled: boolean) => void;
|
setSidebarToggled: (toggled: boolean) => void;
|
||||||
|
user: User | null;
|
||||||
|
fetchUser: () => void;
|
||||||
isStreaming: boolean;
|
isStreaming: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
@@ -21,12 +23,12 @@ type props = {
|
|||||||
const Topbar = ({
|
const Topbar = ({
|
||||||
sidebarToggled,
|
sidebarToggled,
|
||||||
setSidebarToggled,
|
setSidebarToggled,
|
||||||
|
user,
|
||||||
|
fetchUser,
|
||||||
isStreaming,
|
isStreaming,
|
||||||
className}: props) => {
|
className}: props) => {
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { user, login, logout } = useAuth();
|
|
||||||
const { theme, toggleTheme } = useTheme();
|
|
||||||
|
|
||||||
const handleLogin = (response: CredentialResponse) => {
|
const handleLogin = (response: CredentialResponse) => {
|
||||||
if (!response.credential) {
|
if (!response.credential) {
|
||||||
@@ -35,38 +37,34 @@ const Topbar = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
login(response.credential)
|
login(response.credential)
|
||||||
|
.then(() => {
|
||||||
|
fetchUser();
|
||||||
|
navigate(0);
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Login failed:", error);
|
console.error("Login failed:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const themeLabel = theme === "dark" ? "Switch to light mode" : "Switch to dark mode";
|
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
logout()
|
logout()
|
||||||
.then(() => navigate("/"))
|
.then(() => {
|
||||||
|
fetchUser();
|
||||||
|
navigate("/");
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("Logout failed:", error);
|
console.error("Logout failed:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(className, "flex justify-between items-center px-4 py-2 bg-sidebar border-b border-hairline")}>
|
<div className={clsx(className, "flex justify-between items-center px-4 py-2 bg-white border-b border-gray-200")}>
|
||||||
<MenuButton onClick={() => setSidebarToggled(!sidebarToggled)}>
|
<MenuButton onClick={() => setSidebarToggled(!sidebarToggled)}>
|
||||||
{sidebarToggled ? <Menu size={24}/> : <X size={24}/>}
|
{sidebarToggled ? <Menu size={24}/> : <X size={24}/>}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
{ user ? (
|
||||||
<MenuButton
|
<div>
|
||||||
onClick={toggleTheme}
|
|
||||||
title={themeLabel}
|
|
||||||
aria-label={themeLabel}
|
|
||||||
>
|
|
||||||
{theme === "dark" ? <Sun size={20}/> : <Moon size={20}/>}
|
|
||||||
</MenuButton>
|
|
||||||
|
|
||||||
{ user ? (
|
|
||||||
<div className={"hover:bg-hover rounded-lg p-0.5"}>
|
|
||||||
<img
|
<img
|
||||||
className={"w-8 h-8 rounded-full inline-block"}
|
className={"w-8 h-8 rounded-full inline-block"}
|
||||||
src={user.profilePictureUrl}
|
src={user.profilePictureUrl}
|
||||||
@@ -78,8 +76,8 @@ const Topbar = ({
|
|||||||
{user.name}
|
{user.name}
|
||||||
{isStreaming && (
|
{isStreaming && (
|
||||||
<span className="relative flex h-2 w-2">
|
<span className="relative flex h-2 w-2">
|
||||||
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-live opacity-75" />
|
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-500 opacity-75" />
|
||||||
<span className="relative inline-flex rounded-full h-2 w-2 bg-live" />
|
<span className="relative inline-flex rounded-full h-2 w-2 bg-red-500" />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
@@ -88,18 +86,16 @@ const Topbar = ({
|
|||||||
onClick={() => navigate("/profile")} />
|
onClick={() => navigate("/profile")} />
|
||||||
<DropdownItem item="Logout"
|
<DropdownItem item="Logout"
|
||||||
onClick={() => handleLogout()}
|
onClick={() => handleLogout()}
|
||||||
className={"text-error font-medium"} />
|
className={"text-red-500 font-medium"} />
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
) :
|
) :
|
||||||
(
|
(
|
||||||
<GoogleLogin
|
<GoogleLogin
|
||||||
shape={"pill"}
|
shape={"pill"}
|
||||||
theme={theme === "dark" ? "filled_black" : "outline"}
|
|
||||||
useOneTap={false}
|
useOneTap={false}
|
||||||
onSuccess={(credentialResponse) => handleLogin(credentialResponse)} />
|
onSuccess={(credentialResponse) => handleLogin(credentialResponse)} />
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
14
frontend/src/components/buttons/BlueButton.tsx
Normal file
14
frontend/src/components/buttons/BlueButton.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
type Props = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
||||||
|
|
||||||
|
const BlueButton: React.FC<Props> = ({ className = "", ...props }) => {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className={`bg-primary text-white font-medium rounded-lg hover:bg-primary-pressed transition-colors duration-150 h-10 px-4 ${className}`}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BlueButton;
|
||||||
@@ -6,7 +6,7 @@ type Props = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|||||||
const MenuButton: React.FC<Props> = ({ className = "", ...props }) => {
|
const MenuButton: React.FC<Props> = ({ className = "", ...props }) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={clsx("p-2 rounded-md text-text-secondary hover:bg-hover hover:text-text-primary transition-colors duration-150", className)}
|
className={clsx("p-2 rounded-md text-gray-600 hover:bg-gray-100 hover:text-gray-900 transition-colors duration-150", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
type Props = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
||||||
|
|
||||||
const PrimaryButton: React.FC<Props> = ({ className = "", ...props }) => {
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
className={`bg-terracotta text-on-accent font-body text-sm rounded-lg hover:bg-terracotta-hover disabled:bg-terracotta-disabled transition-colors duration-150 h-10 px-4 ${className}`}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PrimaryButton;
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
import MenuButton from "./MenuButton.tsx";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -13,17 +13,11 @@ const SidebarButton = ({url, logo, label}: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Link className="w-full" to={url}>
|
<Link className="w-full" to={url}>
|
||||||
<button className={`flex items-center gap-2.5 w-full text-sm
|
<MenuButton className={`flex items-center gap-2.5 w-full px-3 py-2 text-sm font-medium rounded-md ${isActive ? "bg-gray-100 text-gray-900" : "text-gray-600"}`}>
|
||||||
font-body p-2 hover:bg-hover hover:text-text-strong
|
|
||||||
rounded-md
|
|
||||||
${isActive ?
|
|
||||||
"bg-card text-text-strong font-medium shadow-sm"
|
|
||||||
:
|
|
||||||
"text-text-primary"}`}>
|
|
||||||
{logo}{label}
|
{logo}{label}
|
||||||
</button>
|
</MenuButton>
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SidebarButton;
|
export default SidebarButton;
|
||||||
|
|||||||
@@ -1,173 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { Bookmark, Plus, X } from "lucide-react";
|
|
||||||
import clsx from "clsx";
|
|
||||||
import Box from "../Box.tsx";
|
|
||||||
import CardHeader from "../CardHeader.tsx";
|
|
||||||
import PrimaryButton from "../buttons/PrimaryButton.tsx";
|
|
||||||
import type { Marker } from "../../utils/types.ts";
|
|
||||||
import { formatLocalTime } from "../../utils/utils.ts";
|
|
||||||
|
|
||||||
const inputClass = "border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors";
|
|
||||||
|
|
||||||
type RailSegment = "none" | "plain" | "lit";
|
|
||||||
|
|
||||||
const railClass = (segment: RailSegment) => clsx(
|
|
||||||
"w-px",
|
|
||||||
segment === "lit" && "bg-terracotta",
|
|
||||||
segment === "plain" && "bg-inactive-strong/60",
|
|
||||||
segment === "none" && "bg-transparent"
|
|
||||||
);
|
|
||||||
|
|
||||||
type MarkerRowProps = {
|
|
||||||
marker: Marker;
|
|
||||||
role: "start" | "end" | "between" | null;
|
|
||||||
/** Rail segments above and below the dot — "lit" inside the chosen section. */
|
|
||||||
railAbove: RailSegment;
|
|
||||||
railBelow: RailSegment;
|
|
||||||
onSelect: () => void;
|
|
||||||
onDelete: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const MarkerRow = ({ marker, role, railAbove, railBelow, onSelect, onDelete }: MarkerRowProps) => (
|
|
||||||
<li className="group relative flex gap-3">
|
|
||||||
{/* Timeline rail: a dot per marker, with the segment between the chosen
|
|
||||||
start and end lit so the selected section reads as one run. */}
|
|
||||||
<div className="flex w-2.5 flex-col items-center flex-shrink-0">
|
|
||||||
<span className={clsx("h-3.5 flex-shrink-0", railClass(railAbove))} />
|
|
||||||
<span className={clsx(
|
|
||||||
"h-2.5 w-2.5 rounded-full border-2 flex-shrink-0 transition-colors duration-150",
|
|
||||||
role === "start" && "border-terracotta bg-terracotta",
|
|
||||||
role === "end" && "border-olive bg-olive",
|
|
||||||
role === "between" && "border-terracotta bg-card",
|
|
||||||
role === null && "border-inactive-strong bg-card"
|
|
||||||
)} />
|
|
||||||
<span className={clsx("flex-1", railClass(railBelow))} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* The rail spans the full row, so the breathing room goes on the button —
|
|
||||||
the line stays continuous while neighbouring rings no longer touch. */}
|
|
||||||
<button
|
|
||||||
onClick={onSelect}
|
|
||||||
className={clsx(
|
|
||||||
"min-w-0 flex-1 rounded-md my-0.5 py-2 pl-2.5 pr-7 text-left transition-colors duration-150",
|
|
||||||
role === "start" && "bg-selected ring-1 ring-terracotta",
|
|
||||||
role === "end" && "bg-selected ring-1 ring-olive",
|
|
||||||
(role === "between" || role === null) && "hover:bg-hover"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<p className="truncate text-sm font-medium text-text-strong">{marker.message}</p>
|
|
||||||
<p className="font-data text-[11px] text-muted tabular-nums">
|
|
||||||
{formatLocalTime(marker.timestamp)}
|
|
||||||
{role === "start" && <span className="font-medium text-terracotta"> · start</span>}
|
|
||||||
{role === "end" && <span className="font-medium text-olive"> · end</span>}
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onClick={onDelete}
|
|
||||||
title="Delete marker"
|
|
||||||
aria-label={`Delete marker ${marker.message}`}
|
|
||||||
className="absolute right-1 top-2.5 flex h-5 w-5 items-center justify-center rounded-md text-muted opacity-0 transition duration-150 hover:bg-hover hover:text-error focus-visible:opacity-100 group-hover:opacity-100"
|
|
||||||
>
|
|
||||||
<X size={12} />
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
/** Newest first — the list renders them in the order given. */
|
|
||||||
markers: Marker[];
|
|
||||||
startMarkerId: string;
|
|
||||||
endMarkerId: string;
|
|
||||||
error: string | null;
|
|
||||||
/** Resolves true once the marker exists, so the input only clears on success. */
|
|
||||||
onAdd: (message: string) => Promise<boolean>;
|
|
||||||
onSelect: (id: number) => void;
|
|
||||||
onDelete: (id: number) => void;
|
|
||||||
className?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const MarkerList = ({ markers, startMarkerId, endMarkerId, error, onAdd, onSelect, onDelete, className }: Props) => {
|
|
||||||
const [message, setMessage] = useState("");
|
|
||||||
const [busy, setBusy] = useState(false);
|
|
||||||
|
|
||||||
const handleAdd = async () => {
|
|
||||||
if (!message.trim() || busy) return;
|
|
||||||
setBusy(true);
|
|
||||||
if (await onAdd(message.trim())) setMessage("");
|
|
||||||
setBusy(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Either of the two may have been picked first, so the lit run is bounded by
|
|
||||||
// whichever indices come first/last rather than by start/end.
|
|
||||||
const startIndex = markers.findIndex((m) => String(m.id) === startMarkerId);
|
|
||||||
const endIndex = markers.findIndex((m) => String(m.id) === endMarkerId);
|
|
||||||
const hasRange = startIndex !== -1 && endIndex !== -1;
|
|
||||||
const rangeFrom = hasRange ? Math.min(startIndex, endIndex) : -1;
|
|
||||||
const rangeTo = hasRange ? Math.max(startIndex, endIndex) : -1;
|
|
||||||
// The rail segment sitting between marker `i` and the one after it.
|
|
||||||
const railSegment = (i: number): RailSegment => {
|
|
||||||
if (i < 0 || i >= markers.length - 1) return "none";
|
|
||||||
return hasRange && i >= rangeFrom && i < rangeTo ? "lit" : "plain";
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box className={clsx("p-5 flex flex-col gap-4", className)}>
|
|
||||||
<div className="flex items-center justify-between gap-3">
|
|
||||||
<CardHeader icon={Bookmark} title="Markers" accent="accent" />
|
|
||||||
{markers.length > 0 && (
|
|
||||||
<span className="font-data text-[11px] text-muted tabular-nums">{markers.length}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={message}
|
|
||||||
onChange={(e) => setMessage(e.target.value)}
|
|
||||||
onKeyDown={(e) => e.key === "Enter" && handleAdd()}
|
|
||||||
placeholder="What just happened?"
|
|
||||||
className={inputClass}
|
|
||||||
/>
|
|
||||||
<PrimaryButton
|
|
||||||
onClick={handleAdd}
|
|
||||||
disabled={busy || !message.trim()}
|
|
||||||
className="flex items-center gap-1.5 px-3 whitespace-nowrap"
|
|
||||||
>
|
|
||||||
<Plus size={15} />
|
|
||||||
Add
|
|
||||||
</PrimaryButton>
|
|
||||||
</div>
|
|
||||||
{error && <p className="text-sm text-error">{error}</p>}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{markers.length === 0 ? (
|
|
||||||
<p className="text-sm text-muted">
|
|
||||||
Nothing marked yet. Markers stack up here, newest first — pick two to save the section between them.
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
/* py-0.5 keeps the scroll container from clipping the selection
|
|
||||||
ring on the first and last rows. */
|
|
||||||
<ul className="-mr-1 flex max-h-[26rem] flex-col overflow-y-auto py-0.5 pr-1">
|
|
||||||
{markers.map((m, i) => (
|
|
||||||
<MarkerRow
|
|
||||||
key={m.id}
|
|
||||||
marker={m}
|
|
||||||
role={String(m.id) === startMarkerId ? "start"
|
|
||||||
: String(m.id) === endMarkerId ? "end"
|
|
||||||
: hasRange && i > rangeFrom && i < rangeTo ? "between"
|
|
||||||
: null}
|
|
||||||
railAbove={railSegment(i - 1)}
|
|
||||||
railBelow={railSegment(i)}
|
|
||||||
onSelect={() => onSelect(m.id)}
|
|
||||||
onDelete={() => onDelete(m.id)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MarkerList;
|
|
||||||
@@ -8,7 +8,7 @@ type Props = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const inputClass = "border border-hairline bg-card rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors";
|
const inputClass = "border border-gray-300 bg-white rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors";
|
||||||
|
|
||||||
export default function ConfigBox({ setMetadata, className }: Props) {
|
export default function ConfigBox({ setMetadata, className }: Props) {
|
||||||
const updateRes = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
const updateRes = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
||||||
@@ -26,7 +26,7 @@ export default function ConfigBox({ setMetadata, className }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx("flex flex-col gap-3 p-6", className)}>
|
<div className={clsx("flex flex-col gap-3 p-6", className)}>
|
||||||
<h2 className="text-sm text-text-primary font-semibold mb-1">Export Settings</h2>
|
<h2 className="text-sm font-semibold text-gray-800 mb-1">Export Settings</h2>
|
||||||
|
|
||||||
<Selector label="Resolution">
|
<Selector label="Resolution">
|
||||||
<select id="resolution" name="resolution" defaultValue="1280,720"
|
<select id="resolution" name="resolution" defaultValue="1280,720"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import PrimaryButton from "../buttons/PrimaryButton.tsx";
|
import BlueButton from "../buttons/BlueButton.tsx";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
@@ -24,24 +24,24 @@ const Spinner = () => (
|
|||||||
const ExportWidget = ({dataSend, handleDownload, downloadable, progress, uploading}: props) => {
|
const ExportWidget = ({dataSend, handleDownload, downloadable, progress, uploading}: props) => {
|
||||||
return (
|
return (
|
||||||
<div className={"flex flex-col gap-3"}>
|
<div className={"flex flex-col gap-3"}>
|
||||||
<PrimaryButton
|
<BlueButton
|
||||||
onClick={dataSend}
|
onClick={dataSend}
|
||||||
disabled={uploading}
|
disabled={uploading}
|
||||||
className={uploading ? "opacity-60 cursor-not-allowed flex items-center justify-center gap-2" : ""}
|
className={uploading ? "opacity-60 cursor-not-allowed flex items-center justify-center gap-2" : ""}
|
||||||
>
|
>
|
||||||
{uploading && <Spinner />}
|
{uploading && <Spinner />}
|
||||||
{uploading ? "Uploading..." : "Export"}
|
{uploading ? "Uploading..." : "Export"}
|
||||||
</PrimaryButton>
|
</BlueButton>
|
||||||
|
|
||||||
<div className="h-10 flex items-center">
|
<div className="h-10 flex items-center">
|
||||||
{ downloadable ?
|
{ downloadable ?
|
||||||
(<PrimaryButton className="w-full" onClick={handleDownload}>
|
(<BlueButton className="w-full" onClick={handleDownload}>
|
||||||
Download
|
Download
|
||||||
</PrimaryButton>)
|
</BlueButton>)
|
||||||
:(
|
:(
|
||||||
<progress
|
<progress
|
||||||
value={progress}
|
value={progress}
|
||||||
className="w-full h-1.5 rounded bg-fields">
|
className="w-full h-1.5 rounded bg-gray-200">
|
||||||
</progress>
|
</progress>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,12 @@ type Props = {
|
|||||||
|
|
||||||
const MetadataBox = ({ setMetadata, className }: Props) => (
|
const MetadataBox = ({ setMetadata, className }: Props) => (
|
||||||
<div className={clsx("flex flex-col content-between p-6 gap-2", className)}>
|
<div className={clsx("flex flex-col content-between p-6 gap-2", className)}>
|
||||||
<p className="w-full font-body text-text-strong font-bold text-sm">
|
<p className="w-full font-semibold text-gray-800 text-sm">Title</p>
|
||||||
Title <span className="text-error">*</span>
|
|
||||||
</p>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
|
||||||
placeholder="Enter title"
|
placeholder="Enter title"
|
||||||
onChange={(e) => setMetadata(prev => ({ ...prev, title: e.target.value }))}
|
onChange={(e) => setMetadata(prev => ({ ...prev, title: e.target.value }))}
|
||||||
className="border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors"
|
className="border border-gray-300 bg-white rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -62,11 +62,11 @@ export default function Playbar({ video, videoMetadata, className }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={togglePlay}
|
onClick={togglePlay}
|
||||||
className="hover:bg-hover rounded-full p-1.5 transition-colors duration-150 text-text-body"
|
className="hover:bg-gray-100 rounded-full p-1.5 transition-colors duration-150 text-gray-700"
|
||||||
>
|
>
|
||||||
{isPlaying ? <Pause size={24} /> : <Play size={24} />}
|
{isPlaying ? <Pause size={24} /> : <Play size={24} />}
|
||||||
</button>
|
</button>
|
||||||
<span className="font-data text-sm text-text-secondary tabular-nums">
|
<span>
|
||||||
{formatTime(video?.currentTime ?? 0)} / {formatTime(videoMetadata.duration ?? 0)}
|
{formatTime(video?.currentTime ?? 0)} / {formatTime(videoMetadata.duration ?? 0)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { formatTime, stringToDate, dateToTimeAgo } from "../../utils/utils.ts";
|
import { formatTime, stringToDate, dateToTimeAgo } from "../../utils/utils.ts";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import React, { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
import { isThumbnailAvailable } from "../../utils/api/client.ts";
|
||||||
import { MoreVertical, Pencil, Trash2 } from "lucide-react";
|
import { MoreVertical, Pencil, Trash2 } from "lucide-react";
|
||||||
import {config} from "../../config.ts";
|
|
||||||
|
|
||||||
type VideoCardProps = {
|
type VideoCardProps = {
|
||||||
id: number,
|
id: number,
|
||||||
@@ -18,12 +18,12 @@ type VideoCardProps = {
|
|||||||
itemLabel?: string,
|
itemLabel?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const fallbackThumbnail = "public/default_thumbnail.png";
|
const fallbackThumbnail = "../../../public/default_thumbnail.png";
|
||||||
const API_URL = config.apiUrl;
|
const API_URL = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className, mediaApiPath = '/api/v1/clips', playerPath = '/video', itemLabel = 'clip' }: VideoCardProps) => {
|
const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className, mediaApiPath = '/api/v1/clips', playerPath = '/video', itemLabel = 'clip' }: VideoCardProps) => {
|
||||||
const [timeAgo, setTimeAgo] = useState(dateToTimeAgo(stringToDate(createdAt)));
|
const [timeAgo, setTimeAgo] = useState(dateToTimeAgo(stringToDate(createdAt)));
|
||||||
const [imgFailed, setImgFailed] = useState(false);
|
const [thumbnailAvailable, setThumbnailAvailable] = useState(true);
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
const [confirmDelete, setConfirmDelete] = useState(false);
|
const [confirmDelete, setConfirmDelete] = useState(false);
|
||||||
const menuRef = useRef<HTMLDivElement>(null);
|
const menuRef = useRef<HTMLDivElement>(null);
|
||||||
@@ -36,6 +36,12 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [createdAt]);
|
}, [createdAt]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
isThumbnailAvailable(thumbnailUrl)
|
||||||
|
.then(setThumbnailAvailable)
|
||||||
|
.catch(() => setThumbnailAvailable(false));
|
||||||
|
}, [thumbnailUrl]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!menuOpen) return;
|
if (!menuOpen) return;
|
||||||
const handleClickOutside = (e: MouseEvent) => {
|
const handleClickOutside = (e: MouseEvent) => {
|
||||||
@@ -59,13 +65,12 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
<div className={clsx("flex flex-col group cursor-pointer", className)}>
|
<div className={clsx("flex flex-col group cursor-pointer", className)}>
|
||||||
<div className="relative overflow-hidden rounded-lg">
|
<div className="relative overflow-hidden rounded-lg">
|
||||||
<img
|
<img
|
||||||
src={imgFailed ? fallbackThumbnail : thumbnailUrl}
|
src={thumbnailAvailable ? thumbnailUrl : fallbackThumbnail}
|
||||||
onError={() => setImgFailed(true)}
|
|
||||||
alt="Video Thumbnail"
|
alt="Video Thumbnail"
|
||||||
className="w-full aspect-video object-cover group-hover:scale-105 transition-transform duration-200"
|
className="w-full aspect-video object-cover group-hover:scale-105 transition-transform duration-200"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span className="absolute top-1.5 left-1.5 bg-media-backdrop/75 text-on-dark px-1.5 py-0.5 rounded text-xs font-data pointer-events-none">
|
<span className="absolute top-1.5 left-1.5 bg-black/70 text-white px-1.5 py-0.5 rounded text-xs font-medium pointer-events-none">
|
||||||
{formatTime(duration)}
|
{formatTime(duration)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@@ -77,18 +82,18 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => stopAndRun(e, () => { setMenuOpen(v => !v); setConfirmDelete(false); })}
|
onClick={(e) => stopAndRun(e, () => { setMenuOpen(v => !v); setConfirmDelete(false); })}
|
||||||
className="bg-media-backdrop/75 hover:bg-media-backdrop/90 text-on-dark rounded p-0.5 transition-colors"
|
className="bg-black/70 hover:bg-black/90 text-white rounded p-0.5 transition-colors"
|
||||||
>
|
>
|
||||||
<MoreVertical size={14} />
|
<MoreVertical size={14} />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{menuOpen && (
|
{menuOpen && (
|
||||||
<div className="absolute right-0 top-7 w-32 bg-card rounded-lg border border-hairline shadow-md z-50 py-1 overflow-hidden">
|
<div className="absolute right-0 top-7 w-32 bg-white rounded-lg border border-gray-200 shadow-md z-50 py-1 overflow-hidden">
|
||||||
{!confirmDelete && (<>
|
{!confirmDelete && (<>
|
||||||
{onEdit && (
|
{onEdit && (
|
||||||
<button
|
<button
|
||||||
onClick={(e) => stopAndRun(e, onEdit)}
|
onClick={(e) => stopAndRun(e, onEdit)}
|
||||||
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-text-body hover:bg-hover"
|
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
<Pencil size={13} /> Edit
|
<Pencil size={13} /> Edit
|
||||||
</button>
|
</button>
|
||||||
@@ -96,7 +101,7 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
{onDelete && (
|
{onDelete && (
|
||||||
<button
|
<button
|
||||||
onClick={(e) => stopAndRun(e, () => setConfirmDelete(true))}
|
onClick={(e) => stopAndRun(e, () => setConfirmDelete(true))}
|
||||||
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-error hover:bg-hover"
|
className="flex items-center gap-2 w-full px-3 py-2 text-sm text-red-500 hover:bg-red-50"
|
||||||
>
|
>
|
||||||
<Trash2 size={13} /> Delete
|
<Trash2 size={13} /> Delete
|
||||||
</button>
|
</button>
|
||||||
@@ -104,17 +109,17 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
</>)}
|
</>)}
|
||||||
{confirmDelete && (
|
{confirmDelete && (
|
||||||
<div className="px-3 py-2">
|
<div className="px-3 py-2">
|
||||||
<p className="text-xs text-text-secondary mb-2">Delete this {itemLabel}?</p>
|
<p className="text-xs text-gray-600 mb-2">Delete this {itemLabel}?</p>
|
||||||
<div className="flex gap-1.5">
|
<div className="flex gap-1.5">
|
||||||
<button
|
<button
|
||||||
onClick={(e) => stopAndRun(e, onDelete!)}
|
onClick={(e) => stopAndRun(e, onDelete!)}
|
||||||
className="flex-1 text-xs bg-error text-on-accent rounded px-2 py-1 hover:bg-terracotta-hover transition-colors"
|
className="flex-1 text-xs bg-red-500 text-white rounded px-2 py-1 hover:bg-red-600 transition-colors"
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={(e) => stopAndRun(e, () => setConfirmDelete(false))}
|
onClick={(e) => stopAndRun(e, () => setConfirmDelete(false))}
|
||||||
className="flex-1 text-xs bg-fields text-text-secondary rounded px-2 py-1 hover:bg-hover transition-colors"
|
className="flex-1 text-xs bg-gray-100 text-gray-600 rounded px-2 py-1 hover:bg-gray-200 transition-colors"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
@@ -128,10 +133,10 @@ const VideoCard = ({ id, title, duration, createdAt, onEdit, onDelete, className
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col p-2">
|
<div className="flex flex-col p-2">
|
||||||
<p className="font-body text-text-strong text-sm leading-snug line-clamp-2">
|
<p className="font-medium text-gray-900 text-sm leading-snug line-clamp-2">
|
||||||
{title === "" ? "(No Title)" : title}
|
{title === "" ? "(No Title)" : title}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-muted text-xs mt-0.5">{timeAgo}</p>
|
<p className="text-gray-500 text-xs mt-0.5">{timeAgo}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
export const config = {
|
|
||||||
apiUrl: window._env_?.VITE_API_URL ?? import.meta.env.VITE_API_URL ?? '',
|
|
||||||
frontendUrl: window._env_?.VITE_FRONTEND_URL ?? import.meta.env.VITE_FRONTEND_URL ?? '',
|
|
||||||
googleClientId: window._env_?.VITE_GOOGLE_CLIENT_ID ?? import.meta.env.VITE_GOOGLE_CLIENT_ID ?? '',
|
|
||||||
};
|
|
||||||
@@ -1,159 +1,45 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
@plugin "flowbite-react/plugin/tailwindcss";
|
||||||
/* Drive the `dark:` variant off the same data-theme attribute the toggle sets,
|
@source "../.flowbite-react/class-list.json";
|
||||||
instead of Tailwind's default prefers-color-scheme. Without this a stray
|
|
||||||
`dark:` utility would disagree with an explicit light/dark choice. */
|
|
||||||
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
/* ── Fonts ───────────────────────────────────────────────────────────── */
|
--font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||||
--font-body: "IBM Plex Sans", system-ui, sans-serif;
|
|
||||||
--font-data: "IBM Plex Mono", monospace;
|
|
||||||
|
|
||||||
/* ── Surfaces ────────────────────────────────────────────────────────── */
|
/* Breakpoints */
|
||||||
--color-background: #F7F4EE;
|
--breakpoint-3xl: 1920px;
|
||||||
--color-sidebar: #F2EEE6;
|
|
||||||
--color-card: #FDFBF7;
|
|
||||||
--color-fields: #F4F0E8;
|
|
||||||
--color-dropzone: #F9F6EF;
|
|
||||||
|
|
||||||
/* Letterbox behind video. Dark in both themes — it is a cinema surface,
|
--color-primary: oklch(0.55 0.21 254);
|
||||||
not an ink colour — so `text-on-dark` always reads on top of it. */
|
--color-primary-pressed: oklch(0.45 0.21 254);
|
||||||
--color-media-backdrop: #2B2620;
|
--color-secondary: oklch(0.94 0.01 250);
|
||||||
|
--color-accent: oklch(0.68 0.20 288);
|
||||||
|
--color-text: oklch(0.17 0.01 270);
|
||||||
|
--color-background: oklch(0.97 0.005 250);
|
||||||
|
--color-surface: oklch(1 0 0);
|
||||||
|
--color-border: oklch(0.91 0.008 250);
|
||||||
|
|
||||||
/* ── Ink ─────────────────────────────────────────────────────────────── */
|
/* Easing */
|
||||||
--color-text-primary: #2B2620;
|
--ease-fluid: cubic-bezier(0.3, 0, 0, 1);
|
||||||
--color-text-strong: #35302A;
|
--ease-snappy: cubic-bezier(0.2, 0, 0, 1);
|
||||||
--color-text-body: #554D44;
|
|
||||||
--color-text-secondary: #6E6559;
|
|
||||||
--color-muted: #9A9084;
|
|
||||||
--color-faint-mono: #A79C8E;
|
|
||||||
|
|
||||||
/* ── Accents ─────────────────────────────────────────────────────────── */
|
|
||||||
--color-terracotta: #A85A38;
|
|
||||||
--color-terracotta-hover: #94492A;
|
|
||||||
--color-terracotta-light: #C87A52;
|
|
||||||
--color-terracotta-disabled: #C9AE9C;
|
|
||||||
--color-olive: #6E7A50;
|
|
||||||
|
|
||||||
/* ── Status ──────────────────────────────────────────────────────────── */
|
|
||||||
--color-live: #B5432E;
|
|
||||||
--color-error: #B5432E;
|
|
||||||
|
|
||||||
/* ── Ink on dark / accent surfaces ───────────────────────────────────── */
|
|
||||||
--color-on-dark: #FBF8F2;
|
|
||||||
--color-on-accent: #FDFBF7;
|
|
||||||
|
|
||||||
/* ── Lines, chips, placeholders ──────────────────────────────────────── */
|
|
||||||
--color-hairline: #F0EBE2;
|
|
||||||
--color-hover: #E7E0D2;
|
|
||||||
--color-selected: #F6EFE6;
|
|
||||||
--color-ring: #E2DACB;
|
|
||||||
--color-inactive: #DED7CA;
|
|
||||||
--color-inactive-strong: #C4BAA9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dark mode. Only token values change here: every component already styles
|
#range-slider .range-slider__range {
|
||||||
itself with the semantic utilities above, so the whole UI follows from this
|
background: var(--color-primary);
|
||||||
one block. `--color-on-dark` is deliberately absent — it is the ink on the
|
}
|
||||||
media backdrop, which stays dark in both themes. */
|
|
||||||
:root[data-theme="dark"] {
|
|
||||||
color-scheme: dark;
|
|
||||||
|
|
||||||
/* ── Surfaces ── near-black canvas, neutral cards lifting off it ─────── */
|
#range-slider .range-slider__thumb {
|
||||||
--color-background: #0E0E10;
|
background: var(--color-primary);
|
||||||
--color-sidebar: #09090B;
|
|
||||||
--color-card: #17171A;
|
|
||||||
--color-fields: #121215;
|
|
||||||
--color-dropzone: #141417;
|
|
||||||
|
|
||||||
--color-media-backdrop: #000000;
|
|
||||||
|
|
||||||
/* ── Ink ─────────────────────────────────────────────────────────────── */
|
|
||||||
--color-text-primary: #F4F4F5;
|
|
||||||
--color-text-strong: #E3E3E7;
|
|
||||||
--color-text-body: #BFBFC6;
|
|
||||||
--color-text-secondary: #94949D;
|
|
||||||
--color-muted: #76767F;
|
|
||||||
--color-faint-mono: #6A6A73;
|
|
||||||
|
|
||||||
/* ── Accents ── brightened to carry on a dark canvas, so hover now lifts
|
|
||||||
rather than deepens ─────────────────────────────────────────────────── */
|
|
||||||
--color-terracotta: #E07A4C;
|
|
||||||
--color-terracotta-hover: #F08F62;
|
|
||||||
--color-terracotta-light: #F0A177;
|
|
||||||
--color-terracotta-disabled: #5E463A;
|
|
||||||
--color-olive: #A3B678;
|
|
||||||
|
|
||||||
/* ── Status ──────────────────────────────────────────────────────────── */
|
|
||||||
--color-live: #F2604A;
|
|
||||||
--color-error: #F2604A;
|
|
||||||
|
|
||||||
/* ── Ink on accent surfaces ── the accents are light here, so the ink that
|
|
||||||
sits on them flips dark ─────────────────────────────────────────────── */
|
|
||||||
--color-on-accent: #17100B;
|
|
||||||
|
|
||||||
/* ── Lines, chips, placeholders ──────────────────────────────────────── */
|
|
||||||
--color-hairline: #232327;
|
|
||||||
--color-hover: #26262B;
|
|
||||||
--color-selected: #2A1F18;
|
|
||||||
--color-ring: #33333A;
|
|
||||||
--color-inactive: #2C2C32;
|
|
||||||
--color-inactive-strong: #55555E;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-synthesis: none;
|
font-synthesis: none;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
color-scheme: light;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: var(--color-background);
|
background-color: var(--color-background);
|
||||||
font-family: "IBM Plex Sans", system-ui, sans-serif;
|
|
||||||
color: var(--color-text-body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@utility font-heading {
|
|
||||||
font-family: "Newsreader", serif;
|
|
||||||
font-weight: 400;
|
|
||||||
color: var(--color-text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Google Identity Services renders its sign-in button in a cross-origin iframe
|
|
||||||
whose document is light-scheme with a transparent background. Left to inherit
|
|
||||||
our `color-scheme: dark`, Chrome cannot honour dark there and paints an opaque
|
|
||||||
white canvas behind it instead — framing the pill in a white box on every dark
|
|
||||||
page. Pinning the iframe back to light keeps it transparent; the button's own
|
|
||||||
colours come from the `theme` prop in Topbar.tsx. */
|
|
||||||
iframe[src*="accounts.google.com/gsi/"] {
|
|
||||||
color-scheme: light;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clip trim slider (react-range-slider-input). Its own stylesheet ships blue
|
|
||||||
defaults; the #id beats those class selectors regardless of import order. */
|
|
||||||
#range-slider {
|
|
||||||
height: 8px;
|
|
||||||
background: var(--color-fields);
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#range-slider .range-slider__range {
|
|
||||||
background: var(--color-terracotta-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
#range-slider .range-slider__thumb {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
background: var(--color-terracotta);
|
|
||||||
box-shadow: 0 1px 2px rgba(90, 40, 20, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#range-slider .range-slider__thumb:focus-visible {
|
|
||||||
box-shadow: 0 0 0 4px color-mix(in oklab, var(--color-terracotta) 35%, transparent);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,27 @@ import Sidebar from '../components/Sidebar'
|
|||||||
import Topbar from '../components/Topbar'
|
import Topbar from '../components/Topbar'
|
||||||
import { Outlet } from 'react-router-dom';
|
import { Outlet } from 'react-router-dom';
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import { useAuth } from "../auth/useAuth";
|
import type {User} from "../utils/types";
|
||||||
|
import { getUser } from "../utils/api/users";
|
||||||
import { getStreamStatus } from "../utils/api/stream";
|
import { getStreamStatus } from "../utils/api/stream";
|
||||||
|
|
||||||
const MainLayout = () => {
|
const MainLayout = () => {
|
||||||
const [sidebarToggled, setSidebarToggled] = useState(false);
|
const [sidebarToggled, setSidebarToggled] = useState(false);
|
||||||
|
const [user, setUser] = useState<null | User>(null);
|
||||||
const [isStreaming, setIsStreaming] = useState(false);
|
const [isStreaming, setIsStreaming] = useState(false);
|
||||||
const { user } = useAuth();
|
|
||||||
|
const fetchUser = async () => {
|
||||||
|
try {
|
||||||
|
const userData = await getUser();
|
||||||
|
setUser(userData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to fetch user:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchUser();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
@@ -20,13 +34,16 @@ const MainLayout = () => {
|
|||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`transition-all duration-300 grid h-screen ${sidebarToggled ? "grid-cols-[0px_1fr]" : "grid-cols-[252px_1fr]"} grid-rows-[auto_1fr]`}>
|
<div className={`transition-all duration-300 grid h-screen ${sidebarToggled ? "grid-cols-[0px_1fr]" : "grid-cols-[240px_1fr]"} grid-rows-[auto_1fr]`}>
|
||||||
<Sidebar
|
<Sidebar
|
||||||
|
user={user}
|
||||||
className={`row-span-2 transition-all duration-300 overflow-hidden whitespace-nowrap ${sidebarToggled ? "-translate-x-full" : "translate-x-0"}`}/>
|
className={`row-span-2 transition-all duration-300 overflow-hidden whitespace-nowrap ${sidebarToggled ? "-translate-x-full" : "translate-x-0"}`}/>
|
||||||
<Topbar
|
<Topbar
|
||||||
className={"transition-all duration-300"}
|
className={"transition-all duration-300"}
|
||||||
sidebarToggled={sidebarToggled}
|
sidebarToggled={sidebarToggled}
|
||||||
setSidebarToggled={setSidebarToggled}
|
setSidebarToggled={setSidebarToggled}
|
||||||
|
user={user}
|
||||||
|
fetchUser={fetchUser}
|
||||||
isStreaming={isStreaming}/>
|
isStreaming={isStreaming}/>
|
||||||
<div className="overflow-auto bg-background">
|
<div className="overflow-auto bg-background">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
@@ -34,4 +51,4 @@ const MainLayout = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default MainLayout;
|
export default MainLayout;
|
||||||
@@ -6,11 +6,13 @@ import ClipRangeSlider from "./../components/video/ClipRangeSlider";
|
|||||||
import ConfigBox from "../components/video/ConfigBox.tsx";
|
import ConfigBox from "../components/video/ConfigBox.tsx";
|
||||||
import ExportWidget from "../components/video/ExportWidget.tsx";
|
import ExportWidget from "../components/video/ExportWidget.tsx";
|
||||||
import { compress } from "../utils/api/media"
|
import { compress } from "../utils/api/media"
|
||||||
import { getJob, downloadJob } from "../utils/api/jobs"
|
import { getJob } from "../utils/api/jobs"
|
||||||
import type { VideoMetadata } from "../utils/types.ts";
|
import type { VideoMetadata } from "../utils/types.ts";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
import MetadataBox from "../components/video/MetadataBox.tsx";
|
import MetadataBox from "../components/video/MetadataBox.tsx";
|
||||||
|
|
||||||
|
const API_URL = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const ClipEdit = () => {
|
const ClipEdit = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const localFile: File = location.state?.file;
|
const localFile: File = location.state?.file;
|
||||||
@@ -61,18 +63,12 @@ const ClipEdit = () => {
|
|||||||
const sendData = async () => {
|
const sendData = async () => {
|
||||||
if (!localFile || uploading) return;
|
if (!localFile || uploading) return;
|
||||||
|
|
||||||
const title = outputMetadata.title.trim();
|
|
||||||
if (!title) {
|
|
||||||
setError('A title is required before exporting.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
let jobId: string;
|
let jobId: string;
|
||||||
try {
|
try {
|
||||||
jobId = await compress(localFile, { ...outputMetadata, title });
|
jobId = await compress(localFile, outputMetadata);
|
||||||
setUploadedId(jobId);
|
setUploadedId(jobId);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
setError(`Failed to start compression: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
setError(`Failed to start compression: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
||||||
@@ -83,7 +79,7 @@ const ClipEdit = () => {
|
|||||||
const interval = setInterval(async () => await pollProgress(jobId, interval), 500);
|
const interval = setInterval(async () => await pollProgress(jobId, interval), 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
const pollProgress = async (jobId: string, intervalId: ReturnType<typeof setInterval>) => {
|
const pollProgress = async (jobId: string, intervalId: number) => {
|
||||||
getJob(jobId)
|
getJob(jobId)
|
||||||
.then((job) => {
|
.then((job) => {
|
||||||
setProgress(job.progress);
|
setProgress(job.progress);
|
||||||
@@ -108,14 +104,14 @@ const ClipEdit = () => {
|
|||||||
const handleDownload = async () => {
|
const handleDownload = async () => {
|
||||||
if (!uploadedId) return;
|
if (!uploadedId) return;
|
||||||
|
|
||||||
let blob: Blob;
|
const response = await fetch(API_URL + `/api/v1/jobs/${uploadedId}/download`, { credentials: 'include' });
|
||||||
try {
|
|
||||||
blob = await downloadJob(uploadedId);
|
if (!response.ok) {
|
||||||
} catch (err) {
|
console.error('Download failed');
|
||||||
console.error('Download failed', err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const blob = await response.blob();
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
|
|
||||||
@@ -132,7 +128,7 @@ const ClipEdit = () => {
|
|||||||
<video
|
<video
|
||||||
ref={videoRef}
|
ref={videoRef}
|
||||||
src={videoUrl}
|
src={videoUrl}
|
||||||
className={"w-full rounded-lg shadow-sm bg-media-backdrop"}
|
className={"w-full rounded-lg shadow-sm bg-black"}
|
||||||
onLoadedMetadata={handleVideoMetadataLoaded}
|
onLoadedMetadata={handleVideoMetadataLoaded}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -146,7 +142,7 @@ const ClipEdit = () => {
|
|||||||
<Playbar
|
<Playbar
|
||||||
video={videoRef.current}
|
video={videoRef.current}
|
||||||
videoMetadata={metadata}
|
videoMetadata={metadata}
|
||||||
className={"w-full accent-terracotta"}
|
className={"w-full accent-primary"}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PlaybackSlider
|
<PlaybackSlider
|
||||||
@@ -154,7 +150,7 @@ const ClipEdit = () => {
|
|||||||
videoMetadata={metadata}
|
videoMetadata={metadata}
|
||||||
sliderValue={playbackValue}
|
sliderValue={playbackValue}
|
||||||
setSliderValue={setPlaybackValue}
|
setSliderValue={setPlaybackValue}
|
||||||
className={"w-full accent-terracotta"}
|
className={"w-full accent-primary"}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ClipRangeSlider
|
<ClipRangeSlider
|
||||||
@@ -162,11 +158,11 @@ const ClipEdit = () => {
|
|||||||
videoMetadata={metadata}
|
videoMetadata={metadata}
|
||||||
setSliderValue={setPlaybackValue}
|
setSliderValue={setPlaybackValue}
|
||||||
setMetadata={setOutputMetadata}
|
setMetadata={setOutputMetadata}
|
||||||
className={"w-full mt-2"}
|
className={"w-full mt-2 bg-primary"}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<div className={"text-error text-center mt-2"}>
|
<div className={"text-red-600 text-center mt-2"}>
|
||||||
{error}
|
{error}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import {useState} from "react";
|
import {useState} from "react";
|
||||||
import {useNavigate} from "react-router-dom";
|
import {useNavigate} from "react-router-dom";
|
||||||
|
import BlueButton from "../components/buttons/BlueButton.tsx";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
|
|
||||||
const ClipUpload = () => {
|
const ClipUpload = () => {
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [error, setError] = useState<null | string>(null);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const [error, setError] = useState<null | string>(null);
|
||||||
|
|
||||||
const press = () => {
|
const press = () => {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -16,40 +17,23 @@ const ClipUpload = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center p-8">
|
<div className="flex items-start justify-center p-8 min-h-full">
|
||||||
<Box className="flex flex-col gap-4 p-6 w-full max-w-md">
|
<Box className="flex flex-col gap-4 p-6 w-full max-w-md">
|
||||||
<div
|
<h1 className="text-lg font-semibold text-gray-900">Upload Clip</h1>
|
||||||
className="cursor-pointer rounded-lg border-2
|
|
||||||
border-dashed border-hairline bg-dropzone
|
|
||||||
text-center text-sm text-text-secondary
|
|
||||||
hover:bg-hover transition-colors duration-150
|
|
||||||
min-h-50 flex flex-col items-center justify-center gap-2"
|
|
||||||
>
|
|
||||||
<label className="cursor-pointer flex flex-col items-center justify-center gap-2 w-full h-full">
|
|
||||||
Choose file
|
|
||||||
<input
|
|
||||||
type="file"
|
|
||||||
onChange={(e) => {
|
|
||||||
const selected = e.target.files?.[0] ?? null;
|
|
||||||
setFile(selected);
|
|
||||||
setError(null);
|
|
||||||
}}
|
|
||||||
className="hidden"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
{file && (
|
|
||||||
<p className="mt-2 text-xs text-text-secondary">{file.name}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<input
|
||||||
onClick={press}
|
type="file"
|
||||||
className={"hover:bg-hover p-1 rounded-md"}
|
onChange={(e) => {
|
||||||
>
|
const selected = e.target.files?.[0] ?? null;
|
||||||
Upload
|
setFile(selected);
|
||||||
</button>
|
setError(null);
|
||||||
|
}}
|
||||||
|
className="h-36 cursor-pointer rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 p-4 text-center text-sm text-gray-500 hover:bg-gray-100 hover:border-primary transition-colors duration-150"
|
||||||
|
/>
|
||||||
|
|
||||||
{error && <p className="text-sm font-body text-center">{error}</p>}
|
<BlueButton onClick={press}>Upload</BlueButton>
|
||||||
|
|
||||||
|
{error && <p className="text-sm text-red-500 text-center">{error}</p>}
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { useNavigate, useParams } from "react-router-dom";
|
|||||||
import { ArrowLeft, Check } from "lucide-react";
|
import { ArrowLeft, Check } from "lucide-react";
|
||||||
import { getClipById, patchClip } from "../utils/api/clips.ts";
|
import { getClipById, patchClip } from "../utils/api/clips.ts";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
import PrimaryButton from "../components/buttons/PrimaryButton.tsx";
|
import BlueButton from "../components/buttons/BlueButton.tsx";
|
||||||
|
|
||||||
const inputClass = "border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors";
|
const inputClass = "border border-gray-300 bg-white rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors";
|
||||||
|
|
||||||
const EditClip = () => {
|
const EditClip = () => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -50,20 +50,20 @@ const EditClip = () => {
|
|||||||
<div className="px-8 py-10 max-w-2xl mx-auto">
|
<div className="px-8 py-10 max-w-2xl mx-auto">
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary mb-6 transition-colors duration-150"
|
className="flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 mb-6 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
<ArrowLeft size={16} />
|
<ArrowLeft size={16} />
|
||||||
Back
|
Back
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<h1 className="text-4xl font-heading text-text-primary mb-6">Edit Clip</h1>
|
<h1 className="text-2xl font-semibold text-gray-900 mb-6">Edit Clip</h1>
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="text-muted text-sm">Loading...</div>
|
<div className="text-gray-400 text-sm">Loading...</div>
|
||||||
) : (
|
) : (
|
||||||
<Box className="p-6 flex flex-col gap-4">
|
<Box className="p-6 flex flex-col gap-4">
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
<label className="text-sm font-medium text-text-secondary">Title</label>
|
<label className="text-sm font-medium text-gray-700">Title</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={title}
|
value={title}
|
||||||
@@ -74,7 +74,7 @@ const EditClip = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
<label className="text-sm font-medium text-text-secondary">Description</label>
|
<label className="text-sm font-medium text-gray-700">Description</label>
|
||||||
<textarea
|
<textarea
|
||||||
value={description}
|
value={description}
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
@@ -84,17 +84,17 @@ const EditClip = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <p className="text-sm text-error">{error}</p>}
|
{error && <p className="text-sm text-red-500">{error}</p>}
|
||||||
|
|
||||||
<div className="flex items-center gap-3 pt-1">
|
<div className="flex items-center gap-3 pt-1">
|
||||||
<PrimaryButton onClick={handleSave} disabled={saving} className="w-28">
|
<BlueButton onClick={handleSave} disabled={saving} className="w-28">
|
||||||
{saving ? "Saving…" : saved
|
{saving ? "Saving…" : saved
|
||||||
? <span className="flex items-center gap-1.5 justify-center"><Check size={14} />Saved</span>
|
? <span className="flex items-center gap-1.5 justify-center"><Check size={14} />Saved</span>
|
||||||
: "Save"}
|
: "Save"}
|
||||||
</PrimaryButton>
|
</BlueButton>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="text-sm text-text-secondary hover:text-text-primary transition-colors duration-150"
|
className="text-sm text-gray-500 hover:text-gray-900 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { useNavigate, useParams } from "react-router-dom";
|
|||||||
import { ArrowLeft, Check } from "lucide-react";
|
import { ArrowLeft, Check } from "lucide-react";
|
||||||
import { getVodById, patchVod } from "../utils/api/vods.ts";
|
import { getVodById, patchVod } from "../utils/api/vods.ts";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
import PrimaryButton from "../components/buttons/PrimaryButton.tsx";
|
import BlueButton from "../components/buttons/BlueButton.tsx";
|
||||||
|
|
||||||
const inputClass = "border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors";
|
const inputClass = "border border-gray-300 bg-white rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors";
|
||||||
|
|
||||||
const EditVod = () => {
|
const EditVod = () => {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
@@ -50,20 +50,20 @@ const EditVod = () => {
|
|||||||
<div className="px-8 py-10 max-w-2xl mx-auto">
|
<div className="px-8 py-10 max-w-2xl mx-auto">
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary mb-6 transition-colors duration-150"
|
className="flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 mb-6 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
<ArrowLeft size={16} />
|
<ArrowLeft size={16} />
|
||||||
Back
|
Back
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<h1 className="text-4xl font-heading text-text-primary mb-6">Edit VoD</h1>
|
<h1 className="text-2xl font-semibold text-gray-900 mb-6">Edit VoD</h1>
|
||||||
|
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="text-muted text-sm">Loading...</div>
|
<div className="text-gray-400 text-sm">Loading...</div>
|
||||||
) : (
|
) : (
|
||||||
<Box className="p-6 flex flex-col gap-4">
|
<Box className="p-6 flex flex-col gap-4">
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
<label className="text-sm font-medium text-text-secondary">Title</label>
|
<label className="text-sm font-medium text-gray-700">Title</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={title}
|
value={title}
|
||||||
@@ -74,7 +74,7 @@ const EditVod = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
<label className="text-sm font-medium text-text-secondary">Description</label>
|
<label className="text-sm font-medium text-gray-700">Description</label>
|
||||||
<textarea
|
<textarea
|
||||||
value={description}
|
value={description}
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
@@ -84,17 +84,17 @@ const EditVod = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <p className="text-sm text-error">{error}</p>}
|
{error && <p className="text-sm text-red-500">{error}</p>}
|
||||||
|
|
||||||
<div className="flex items-center gap-3 pt-1">
|
<div className="flex items-center gap-3 pt-1">
|
||||||
<PrimaryButton onClick={handleSave} disabled={saving} className="w-28">
|
<BlueButton onClick={handleSave} disabled={saving} className="w-28">
|
||||||
{saving ? "Saving…" : saved
|
{saving ? "Saving…" : saved
|
||||||
? <span className="flex items-center gap-1.5 justify-center"><Check size={14} />Saved</span>
|
? <span className="flex items-center gap-1.5 justify-center"><Check size={14} />Saved</span>
|
||||||
: "Save"}
|
: "Save"}
|
||||||
</PrimaryButton>
|
</BlueButton>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="text-sm text-text-secondary hover:text-text-primary transition-colors duration-150"
|
className="text-sm text-gray-500 hover:text-gray-900 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ const Home = () => {
|
|||||||
alt="VoD System Logo"
|
alt="VoD System Logo"
|
||||||
className="h-24 mb-6 object-contain"
|
className="h-24 mb-6 object-contain"
|
||||||
/>
|
/>
|
||||||
<h1 className="text-4xl font-heading text-text-primary">
|
<h1 className="text-4xl font-semibold text-gray-900 mb-3 leading-tight">
|
||||||
A home for your clips.
|
A home for your clips.
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-text-secondary">
|
<p className="text-base text-gray-500 leading-relaxed">
|
||||||
Upload, trim, and export video clips. Stream live if you need to.
|
Upload, trim, and export video clips. Stream live if you need to.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,21 +56,21 @@ const Home = () => {
|
|||||||
{features.map(({ icon: Icon, title, description }) => (
|
{features.map(({ icon: Icon, title, description }) => (
|
||||||
<div
|
<div
|
||||||
key={title}
|
key={title}
|
||||||
className="bg-card border border-hairline rounded-xl p-5 flex flex-col gap-3 shadow-sm"
|
className="bg-white border border-gray-200 rounded-xl p-5 flex flex-col gap-3 shadow-sm"
|
||||||
>
|
>
|
||||||
<div className="w-9 h-9 rounded-lg flex items-center justify-center shrink-0">
|
<div className="w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0">
|
||||||
<Icon size={18} className="text-terracotta" />
|
<Icon size={18} className="text-primary" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="font-body text-text-strong font-bold text-sm mb-1">{title}</p>
|
<p className="font-semibold text-gray-900 text-sm mb-1">{title}</p>
|
||||||
<p className="text-sm text-text-secondary leading-relaxed">{description}</p>
|
<p className="text-sm text-gray-500 leading-relaxed">{description}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Format note */}
|
{/* Format note */}
|
||||||
<p className="text-xs text-muted">
|
<p className="text-xs text-gray-400">
|
||||||
Supports MP4, MOV, WebM, and OGG.
|
Supports MP4, MOV, WebM, and OGG.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -202,16 +202,16 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
if (notAuthenticated) {
|
if (notAuthenticated) {
|
||||||
return (
|
return (
|
||||||
<div className="h-full flex flex-col items-center justify-center gap-4 text-center p-8">
|
<div className="h-full flex flex-col items-center justify-center gap-4 text-center p-8">
|
||||||
<div className="w-14 h-14 rounded-full bg-fields flex items-center justify-center">
|
<div className="w-14 h-14 rounded-full bg-gray-100 flex items-center justify-center">
|
||||||
<Lock size={24} className="text-muted" />
|
<Lock size={24} className="text-gray-400" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-heading text-text-primary">Not authenticated</p>
|
<p className="text-lg font-semibold text-gray-900">Not authenticated</p>
|
||||||
<p className="text-sm text-text-secondary mt-1">You don't have access to this {noun.toLowerCase()}.</p>
|
<p className="text-sm text-gray-500 mt-1">You don't have access to this {noun.toLowerCase()}.</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary transition-colors duration-150"
|
className="flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
<ArrowLeft size={16} />
|
<ArrowLeft size={16} />
|
||||||
Go back
|
Go back
|
||||||
@@ -224,7 +224,7 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
<div className="h-full flex flex-col p-4 gap-3">
|
<div className="h-full flex flex-col p-4 gap-3">
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => navigate(-1)}
|
||||||
className="flex items-center gap-1.5 text-sm text-text-secondary hover:text-text-primary flex-shrink-0 transition-colors duration-150"
|
className="flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 flex-shrink-0 transition-colors duration-150"
|
||||||
>
|
>
|
||||||
<ArrowLeft size={16} />
|
<ArrowLeft size={16} />
|
||||||
Back
|
Back
|
||||||
@@ -233,7 +233,7 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
{/* Player */}
|
{/* Player */}
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
className="relative bg-media-backdrop rounded-xl overflow-hidden flex-1 min-h-0 select-none"
|
className="relative bg-black rounded-xl overflow-hidden flex-1 min-h-0 select-none"
|
||||||
onMouseMove={showControls}
|
onMouseMove={showControls}
|
||||||
onMouseLeave={() => isPlaying && setControlsVisible(false)}
|
onMouseLeave={() => isPlaying && setControlsVisible(false)}
|
||||||
onClick={togglePlay}
|
onClick={togglePlay}
|
||||||
@@ -265,7 +265,7 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
{/* Buffering spinner */}
|
{/* Buffering spinner */}
|
||||||
{isWaiting && mediaUrl && (
|
{isWaiting && mediaUrl && (
|
||||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
<div className="absolute inset-0 flex items-center justify-center pointer-events-none">
|
||||||
<div className="w-11 h-11 rounded-full border-[3px] border-on-dark/20 border-t-on-dark animate-spin" />
|
<div className="w-11 h-11 rounded-full border-[3px] border-white/20 border-t-white animate-spin" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -282,20 +282,20 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
{/* Scrub bar */}
|
{/* Scrub bar */}
|
||||||
<div
|
<div
|
||||||
ref={progressRef}
|
ref={progressRef}
|
||||||
className="relative h-1 rounded-full bg-on-dark/25 cursor-pointer mb-3 group/prog hover:h-1.5 transition-[height] duration-150"
|
className="relative h-1 rounded-full bg-white/25 cursor-pointer mb-3 group/prog hover:h-1.5 transition-[height] duration-150"
|
||||||
onMouseDown={(e) => { setIsDragging(true); seekTo(e.clientX); }}
|
onMouseDown={(e) => { setIsDragging(true); seekTo(e.clientX); }}
|
||||||
>
|
>
|
||||||
<div className="absolute inset-y-0 left-0 bg-on-dark/35 rounded-full" style={{ width: `${bufferedPct}%` }} />
|
<div className="absolute inset-y-0 left-0 bg-white/35 rounded-full" style={{ width: `${bufferedPct}%` }} />
|
||||||
<div className="absolute inset-y-0 left-0 bg-terracotta-light rounded-full" style={{ width: `${progressPct}%` }} />
|
<div className="absolute inset-y-0 left-0 bg-primary rounded-full" style={{ width: `${progressPct}%` }} />
|
||||||
<div
|
<div
|
||||||
className="absolute top-1/2 -translate-y-1/2 w-3 h-3 bg-on-dark rounded-full shadow opacity-0 group-hover/prog:opacity-100 transition-opacity"
|
className="absolute top-1/2 -translate-y-1/2 w-3 h-3 bg-white rounded-full shadow opacity-0 group-hover/prog:opacity-100 transition-opacity"
|
||||||
style={{ left: `calc(${progressPct}% - 6px)` }}
|
style={{ left: `calc(${progressPct}% - 6px)` }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Buttons row */}
|
{/* Buttons row */}
|
||||||
<div className="flex items-center gap-3 text-on-dark">
|
<div className="flex items-center gap-3 text-white">
|
||||||
<button onClick={togglePlay} className="hover:text-on-dark/70 transition-colors">
|
<button onClick={togglePlay} className="hover:text-white/70 transition-colors">
|
||||||
{isPlaying
|
{isPlaying
|
||||||
? <Pause size={20} fill="currentColor" />
|
? <Pause size={20} fill="currentColor" />
|
||||||
: <Play size={20} fill="currentColor" />}
|
: <Play size={20} fill="currentColor" />}
|
||||||
@@ -303,7 +303,7 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
|
|
||||||
{/* Volume — slider expands on hover */}
|
{/* Volume — slider expands on hover */}
|
||||||
<div className="flex items-center gap-1.5 group/vol">
|
<div className="flex items-center gap-1.5 group/vol">
|
||||||
<button onClick={toggleMute} className="hover:text-on-dark/70 transition-colors">
|
<button onClick={toggleMute} className="hover:text-white/70 transition-colors">
|
||||||
<VolumeIcon size={18} />
|
<VolumeIcon size={18} />
|
||||||
</button>
|
</button>
|
||||||
<div className="overflow-hidden w-0 group-hover/vol:w-16 transition-[width] duration-200">
|
<div className="overflow-hidden w-0 group-hover/vol:w-16 transition-[width] duration-200">
|
||||||
@@ -312,18 +312,18 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
min={0} max={1} step={0.02}
|
min={0} max={1} step={0.02}
|
||||||
value={effectiveVolume}
|
value={effectiveVolume}
|
||||||
onChange={handleVolumeChange}
|
onChange={handleVolumeChange}
|
||||||
className="w-16 accent-on-dark cursor-pointer"
|
className="w-16 accent-white cursor-pointer"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span className="text-xs font-data tabular-nums text-on-dark/80">
|
<span className="text-xs font-mono tabular-nums text-white/80">
|
||||||
{formatTime(currentTime)} / {formatTime(duration)}
|
{formatTime(currentTime)} / {formatTime(duration)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
|
|
||||||
<button onClick={toggleFullscreen} className="hover:text-on-dark/70 transition-colors">
|
<button onClick={toggleFullscreen} className="hover:text-white/70 transition-colors">
|
||||||
{isFullscreen ? <Minimize size={18} /> : <Maximize size={18} />}
|
{isFullscreen ? <Minimize size={18} /> : <Maximize size={18} />}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -331,17 +331,17 @@ const MediaPlayer = ({ noun, getMediaUrl, fetchDetails }: MediaPlayerProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="text-error text-sm mt-3">{error}</div>}
|
{error && <div className="text-red-500 text-sm mt-3">{error}</div>}
|
||||||
{!mediaLoaded && !error && (
|
{!mediaLoaded && !error && (
|
||||||
<div className="text-muted text-sm mt-3 flex items-center gap-2">
|
<div className="text-gray-400 text-sm mt-3 flex items-center gap-2">
|
||||||
<div className="w-3 h-3 rounded-full border-2 border-inactive border-t-muted animate-spin" />
|
<div className="w-3 h-3 rounded-full border-2 border-gray-300 border-t-gray-500 animate-spin" />
|
||||||
Loading video...
|
Loading video...
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Box className="p-4 flex-shrink-0">
|
<Box className="p-4 flex-shrink-0">
|
||||||
<p className="text-2xl font-heading text-text-primary">{item?.title || "(No Title)"}</p>
|
<p className="text-xl font-semibold text-gray-900">{item?.title || "(No Title)"}</p>
|
||||||
<p className="text-sm text-text-secondary mt-1">{timeAgo}</p>
|
<p className="text-sm text-gray-500 mt-1">{timeAgo}</p>
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const MyClips = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<h1 className="text-4xl font-heading text-text-primary mb-6">My Clips</h1>
|
<h1 className="text-2xl font-semibold text-gray-900 mb-6">My Clips</h1>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
|
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
|
||||||
{clips.map((clip) => (
|
{clips.map((clip) => (
|
||||||
@@ -43,13 +43,13 @@ const MyClips = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{clips.length === 0 && !error && (
|
{clips.length === 0 && !error && (
|
||||||
<div className="flex flex-col items-center justify-center py-16 text-muted">
|
<div className="flex flex-col items-center justify-center py-16 text-gray-400">
|
||||||
<p className="text-base">No clips yet.</p>
|
<p className="text-base">No clips yet.</p>
|
||||||
<p className="text-sm mt-1">Upload your first clip to get started.</p>
|
<p className="text-sm mt-1">Upload your first clip to get started.</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && <p className="text-sm text-error mt-4">{error.toString()}</p>}
|
{error && <p className="text-sm text-red-500 mt-4">{error.toString()}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const MyVods = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<h1 className="text-4xl font-heading text-text-primary mb-6">My VoDs</h1>
|
<h1 className="text-2xl font-semibold text-gray-900 mb-6">My VoDs</h1>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
|
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
|
||||||
{vods.map((vod) => (
|
{vods.map((vod) => (
|
||||||
@@ -46,13 +46,13 @@ const MyVods = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{vods.length === 0 && !error && (
|
{vods.length === 0 && !error && (
|
||||||
<div className="flex flex-col items-center justify-center py-16 text-muted">
|
<div className="flex flex-col items-center justify-center py-16 text-gray-400">
|
||||||
<p className="text-base">No VoDs yet.</p>
|
<p className="text-base">No VoDs yet.</p>
|
||||||
<p className="text-sm mt-1">Your stream recordings will appear here.</p>
|
<p className="text-sm mt-1">Your stream recordings will appear here.</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && <p className="text-sm text-error mt-4">{error}</p>}
|
{error && <p className="text-sm text-red-500 mt-4">{error}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { Lock } from 'lucide-react';
|
|
||||||
import {useNavigate} from "react-router-dom";
|
|
||||||
|
|
||||||
const NotFound = () => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const goHomePage = () => {
|
|
||||||
navigate("/")
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full min-h-screen flex flex-col items-center justify-center gap-3 text-center px-6">
|
|
||||||
<Lock className="w-8 h-8 text-faint-mono/60 mb-1" strokeWidth={1.5} />
|
|
||||||
<h2 className="font-heading text-2xl md:text-3xl text-faint-mono">
|
|
||||||
This page does not exist.
|
|
||||||
</h2>
|
|
||||||
<p className="text-sm text-faint-mono/70 max-w-xs">
|
|
||||||
<a onClick={goHomePage} className={"font-bold cursor-pointer"}>Click here</a> to get back to the home page.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NotFound;
|
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Eye, EyeOff, Copy, Check } from "lucide-react";
|
import { Eye, EyeOff, Copy, Check } from "lucide-react";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
import { useAuth } from "../auth/useAuth.ts";
|
import { getUser } from "../utils/api/users.ts";
|
||||||
|
import type { User } from "../utils/types.ts";
|
||||||
import { formatLocalDate } from "../utils/utils.ts";
|
import { formatLocalDate } from "../utils/utils.ts";
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
const { user } = useAuth();
|
const [user, setUser] = useState<User | null>(null);
|
||||||
const [keyVisible, setKeyVisible] = useState(false);
|
const [keyVisible, setKeyVisible] = useState(false);
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getUser().then(setUser).catch(console.error);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleCopy = () => {
|
const handleCopy = () => {
|
||||||
if (!user?.streamKey) return;
|
if (!user?.streamKey) return;
|
||||||
navigator.clipboard.writeText(user.streamKey);
|
navigator.clipboard.writeText(user.streamKey);
|
||||||
@@ -18,7 +23,7 @@ const Profile = () => {
|
|||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center h-full text-muted text-base">
|
<div className="flex justify-center items-center h-full text-gray-400 text-base">
|
||||||
Please log in to view your profile.
|
Please log in to view your profile.
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -26,7 +31,7 @@ const Profile = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-8 py-10 max-w-2xl mx-auto">
|
<div className="px-8 py-10 max-w-2xl mx-auto">
|
||||||
<h1 className="text-4xl font-heading text-text-primary mb-6">Profile</h1>
|
<h1 className="text-2xl font-semibold text-gray-900 mb-6">Profile</h1>
|
||||||
|
|
||||||
<Box className="p-6 mb-4 flex items-center gap-5">
|
<Box className="p-6 mb-4 flex items-center gap-5">
|
||||||
<img
|
<img
|
||||||
@@ -36,31 +41,31 @@ const Profile = () => {
|
|||||||
className="w-20 h-20 rounded-full shadow-sm"
|
className="w-20 h-20 rounded-full shadow-sm"
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-heading text-text-primary">{user.name}</p>
|
<p className="text-lg font-semibold text-gray-900">{user.name}</p>
|
||||||
<p className="text-sm text-text-secondary">@{user.username}</p>
|
<p className="text-sm text-gray-500">@{user.username}</p>
|
||||||
<p className="text-sm text-text-secondary">{user.email}</p>
|
<p className="text-sm text-gray-500">{user.email}</p>
|
||||||
<p className="text-xs text-muted mt-1">
|
<p className="text-xs text-gray-400 mt-1">
|
||||||
Member since {formatLocalDate(user.createdAt)}
|
Member since {formatLocalDate(user.createdAt)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box className="p-6">
|
<Box className="p-6">
|
||||||
<h2 className="text-xl font-heading text-text-primary mb-1">Stream Key</h2>
|
<h2 className="text-sm font-semibold text-gray-800 mb-1">Stream Key</h2>
|
||||||
<p className="text-sm text-text-secondary mb-4">
|
<p className="text-sm text-gray-500 mb-4">
|
||||||
Use this key in OBS or any RTMP-compatible software to start streaming.
|
Use this key in OBS or any RTMP-compatible software to start streaming.
|
||||||
Keep it private — anyone with this key can stream to your account.
|
Keep it private — anyone with this key can stream to your account.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<div className="flex-1 bg-fields border border-hairline rounded-md px-4 py-2 font-data text-sm text-text-strong overflow-hidden">
|
<div className="flex-1 bg-gray-50 border border-gray-200 rounded-md px-4 py-2 font-mono text-sm text-gray-700 overflow-hidden">
|
||||||
{keyVisible ? user.streamKey : "•".repeat(user.streamKey.length)}
|
{keyVisible ? user.streamKey : "•".repeat(user.streamKey.length)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setKeyVisible(v => !v)}
|
onClick={() => setKeyVisible(v => !v)}
|
||||||
title={keyVisible ? "Hide key" : "Show key"}
|
title={keyVisible ? "Hide key" : "Show key"}
|
||||||
className="p-2 rounded-md bg-fields hover:bg-hover transition-colors duration-150 text-text-secondary"
|
className="p-2 rounded-md bg-gray-100 hover:bg-gray-200 transition-colors duration-150 text-gray-600"
|
||||||
>
|
>
|
||||||
{keyVisible ? <EyeOff size={16} /> : <Eye size={16} />}
|
{keyVisible ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||||
</button>
|
</button>
|
||||||
@@ -68,9 +73,9 @@ const Profile = () => {
|
|||||||
<button
|
<button
|
||||||
onClick={handleCopy}
|
onClick={handleCopy}
|
||||||
title="Copy key"
|
title="Copy key"
|
||||||
className="p-2 rounded-md bg-fields hover:bg-hover transition-colors duration-150 text-text-secondary"
|
className="p-2 rounded-md bg-gray-100 hover:bg-gray-200 transition-colors duration-150 text-gray-600"
|
||||||
>
|
>
|
||||||
{copied ? <Check size={16} className="text-olive" /> : <Copy size={16} />}
|
{copied ? <Check size={16} className="text-green-600" /> : <Copy size={16} />}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Radio, Check, Scissors, Film, Activity, Loader2, X } from "lucide-react";
|
import { Radio, Check, Bookmark, Scissors, Film, Activity, Loader2, X } from "lucide-react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import Box from "../components/Box.tsx";
|
import Box from "../components/Box.tsx";
|
||||||
import CardHeader from "../components/CardHeader.tsx";
|
import BlueButton from "../components/buttons/BlueButton.tsx";
|
||||||
import MarkerList from "../components/stream/MarkerList.tsx";
|
import { getUser } from "../utils/api/users.ts";
|
||||||
import PrimaryButton from "../components/buttons/PrimaryButton.tsx";
|
|
||||||
import { useAuth } from "../auth/useAuth.ts";
|
|
||||||
import { getCurrentStream, getStreamHistory } from "../utils/api/stream.ts";
|
import { getCurrentStream, getStreamHistory } from "../utils/api/stream.ts";
|
||||||
import { getMarkers, createMarker, deleteMarker } from "../utils/api/markers.ts";
|
import { getMarkers, createMarker, deleteMarker } from "../utils/api/markers.ts";
|
||||||
import { saveSectionByMarkers, clipSection } from "../utils/api/media.ts";
|
import { saveSectionByMarkers, clipSection } from "../utils/api/media.ts";
|
||||||
import { getJob } from "../utils/api/jobs.ts";
|
import { getJob } from "../utils/api/jobs.ts";
|
||||||
import type { StreamStatus, StreamHistoryItem, Marker, JobResponse } from "../utils/types.ts";
|
import type { User, StreamStatus, StreamHistoryItem, Marker, JobResponse } from "../utils/types.ts";
|
||||||
import { formatLocalDate, stringToDate } from "../utils/utils.ts";
|
import { formatTime, formatLocalDate, stringToDate } from "../utils/utils.ts";
|
||||||
|
|
||||||
const inputClass = "border border-hairline bg-fields rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-muted transition-colors";
|
const inputClass = "border border-gray-300 bg-white rounded-md w-full p-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary transition-colors";
|
||||||
const labelClass = "font-data text-[11px] text-muted uppercase tracking-[0.12em]";
|
const labelClass = "text-xs font-medium text-gray-500 uppercase tracking-wide";
|
||||||
|
|
||||||
type TrackedJob = {
|
type TrackedJob = {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
@@ -24,40 +22,52 @@ type TrackedJob = {
|
|||||||
errorOutput: string | null;
|
errorOutput: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CardHeader = ({ icon: Icon, title, accent = "primary" }: { icon: React.ElementType; title: string; accent?: "primary" | "accent" }) => (
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<div className={clsx("w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0", accent === "primary" ? "bg-primary/10" : "bg-accent/10")}>
|
||||||
|
<Icon size={16} className={accent === "primary" ? "text-primary" : "text-accent"} />
|
||||||
|
</div>
|
||||||
|
<h2 className="text-sm font-semibold text-gray-800">{title}</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
const JobStatus = ({ job }: { job: TrackedJob }) => {
|
const JobStatus = ({ job }: { job: TrackedJob }) => {
|
||||||
if (job.state === 'FAILED') {
|
if (job.state === 'FAILED') {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-start gap-2 text-sm">
|
<div className="flex items-start gap-2 text-sm">
|
||||||
<X size={15} className="text-error mt-0.5 flex-shrink-0" />
|
<X size={15} className="text-red-500 mt-0.5 flex-shrink-0" />
|
||||||
<p className="text-error">{job.label} failed: {job.errorOutput ?? "Unknown error"}</p>
|
<p className="text-red-500">{job.label} failed: {job.errorOutput ?? "Unknown error"}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (job.state === 'SUCCEEDED') {
|
if (job.state === 'SUCCEEDED') {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2 text-sm">
|
<div className="flex items-center gap-2 text-sm">
|
||||||
<Check size={15} className="text-olive flex-shrink-0" />
|
<Check size={15} className="text-green-600 flex-shrink-0" />
|
||||||
<p className="text-text-body">{job.label} saved</p>
|
<p className="text-gray-700">{job.label} saved</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Loader2 size={15} className="text-terracotta animate-spin flex-shrink-0" />
|
<Loader2 size={15} className="text-primary animate-spin flex-shrink-0" />
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<p className="text-sm text-text-secondary mb-1">{job.label}…</p>
|
<p className="text-sm text-gray-600 mb-1">{job.label}…</p>
|
||||||
<progress value={job.progress} className="w-full h-1.5 rounded bg-fields" />
|
<progress value={job.progress} className="w-full h-1.5 rounded bg-gray-200" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const StreamControl = () => {
|
const StreamControl = () => {
|
||||||
const { user } = useAuth();
|
const [user, setUser] = useState<User | null>(null);
|
||||||
const [streamStatus, setStreamStatus] = useState<StreamStatus | null>(null);
|
const [streamStatus, setStreamStatus] = useState<StreamStatus | null>(null);
|
||||||
const [streamDetails, setStreamDetails] = useState<StreamHistoryItem | null>(null);
|
const [streamDetails, setStreamDetails] = useState<StreamHistoryItem | null>(null);
|
||||||
|
const [now, setNow] = useState(Date.now());
|
||||||
|
|
||||||
const [markers, setMarkers] = useState<Marker[]>([]);
|
const [markers, setMarkers] = useState<Marker[]>([]);
|
||||||
|
const [markerMessage, setMarkerMessage] = useState("");
|
||||||
|
const [markerBusy, setMarkerBusy] = useState(false);
|
||||||
const [markerError, setMarkerError] = useState<string | null>(null);
|
const [markerError, setMarkerError] = useState<string | null>(null);
|
||||||
|
|
||||||
const [clipDuration, setClipDuration] = useState(30);
|
const [clipDuration, setClipDuration] = useState(30);
|
||||||
@@ -75,6 +85,10 @@ const StreamControl = () => {
|
|||||||
|
|
||||||
const isStreaming = streamStatus?.isStreaming ?? false;
|
const isStreaming = streamStatus?.isStreaming ?? false;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getUser().then(setUser).catch(() => setUser(null));
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
const poll = () => getCurrentStream().then(setStreamStatus).catch(() => {});
|
const poll = () => getCurrentStream().then(setStreamStatus).catch(() => {});
|
||||||
@@ -93,10 +107,16 @@ const StreamControl = () => {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}, [user, streamStatus?.id]);
|
}, [user, streamStatus?.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!streamDetails?.startDate) return;
|
||||||
|
const interval = setInterval(() => setNow(Date.now()), 1000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [streamDetails?.startDate]);
|
||||||
|
|
||||||
const refreshMarkers = () => {
|
const refreshMarkers = () => {
|
||||||
getMarkers()
|
getMarkers()
|
||||||
.then((data) => setMarkers(data
|
.then((data) => setMarkers(data
|
||||||
.sort((a, b) => stringToDate(b.timestamp).getTime() - stringToDate(a.timestamp).getTime())))
|
.sort((a, b) => stringToDate(a.timestamp).getTime() - stringToDate(b.timestamp).getTime())))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -133,15 +153,18 @@ const StreamControl = () => {
|
|||||||
setJobs((prev) => [{ uuid, label, progress: 0, state: 'READY', errorOutput: null }, ...prev]);
|
setJobs((prev) => [{ uuid, label, progress: 0, state: 'READY', errorOutput: null }, ...prev]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddMarker = async (message: string) => {
|
const handleAddMarker = async () => {
|
||||||
|
if (!markerMessage.trim() || markerBusy) return;
|
||||||
|
setMarkerBusy(true);
|
||||||
setMarkerError(null);
|
setMarkerError(null);
|
||||||
try {
|
try {
|
||||||
await createMarker(message);
|
await createMarker(markerMessage.trim());
|
||||||
|
setMarkerMessage("");
|
||||||
refreshMarkers();
|
refreshMarkers();
|
||||||
return true;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setMarkerError(err instanceof Error ? err.message : "Failed to add marker");
|
setMarkerError(err instanceof Error ? err.message : "Failed to add marker");
|
||||||
return false;
|
} finally {
|
||||||
|
setMarkerBusy(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,7 +183,7 @@ const StreamControl = () => {
|
|||||||
const handleSaveByMarkers = async () => {
|
const handleSaveByMarkers = async () => {
|
||||||
setMarkerSaveError(null);
|
setMarkerSaveError(null);
|
||||||
if (!startMarkerId || !endMarkerId) {
|
if (!startMarkerId || !endMarkerId) {
|
||||||
setMarkerSaveError("Pick a start and an end marker from the timeline");
|
setMarkerSaveError("Tap two markers above to pick a start and end");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -191,7 +214,7 @@ const StreamControl = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectMarker = (id: number) => {
|
const handleChipClick = (id: number) => {
|
||||||
const idStr = String(id);
|
const idStr = String(id);
|
||||||
setMarkerSaveError(null);
|
setMarkerSaveError(null);
|
||||||
if (startMarkerId === idStr) { setStartMarkerId(""); return; }
|
if (startMarkerId === idStr) { setStartMarkerId(""); return; }
|
||||||
@@ -203,88 +226,112 @@ const StreamControl = () => {
|
|||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center items-center h-full text-muted text-base">
|
<div className="flex justify-center items-center h-full text-gray-400 text-base">
|
||||||
Please log in to control your stream.
|
Please log in to control your stream.
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const elapsed = streamDetails?.startDate
|
||||||
|
? formatTime((now - stringToDate(streamDetails.startDate).getTime()) / 1000)
|
||||||
|
: null;
|
||||||
|
|
||||||
const startMarker = markers.find((m) => String(m.id) === startMarkerId);
|
const startMarker = markers.find((m) => String(m.id) === startMarkerId);
|
||||||
const endMarker = markers.find((m) => String(m.id) === endMarkerId);
|
const endMarker = markers.find((m) => String(m.id) === endMarkerId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-8 py-10 max-w-5xl mx-auto flex flex-col gap-5">
|
<div className="px-8 py-10 max-w-5xl mx-auto flex flex-col gap-5">
|
||||||
<h1 className="text-4xl font-heading text-text-primary">Stream Control</h1>
|
<h1 className="text-2xl font-semibold text-gray-900">Stream Control</h1>
|
||||||
|
|
||||||
{/* Hero status bar */}
|
{/* Hero status bar */}
|
||||||
<Box className={clsx(
|
<Box className={clsx(
|
||||||
"p-6 flex items-center justify-between gap-6 border-l-4",
|
"p-6 flex items-center justify-between gap-6 border-l-4",
|
||||||
isStreaming ? "border-l-live" : "border-l-hairline"
|
isStreaming ? "border-l-red-500" : "border-l-gray-200"
|
||||||
)}>
|
)}>
|
||||||
<div className="flex items-center gap-3.5">
|
<div className="flex items-center gap-3.5">
|
||||||
<span className="relative flex h-3.5 w-3.5">
|
<span className="relative flex h-3.5 w-3.5">
|
||||||
{isStreaming && <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-live opacity-75" />}
|
{isStreaming && <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-500 opacity-75" />}
|
||||||
<span className={clsx("relative inline-flex rounded-full h-3.5 w-3.5", isStreaming ? "bg-live" : "bg-inactive-strong")} />
|
<span className={clsx("relative inline-flex rounded-full h-3.5 w-3.5", isStreaming ? "bg-red-500" : "bg-gray-300")} />
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-2xl font-heading text-text-primary leading-tight">{isStreaming ? "Live" : "Offline"}</p>
|
<p className="font-semibold text-gray-900 text-lg leading-tight">{isStreaming ? "Live" : "Offline"}</p>
|
||||||
{isStreaming && streamDetails?.startDate ? (
|
{isStreaming && streamDetails?.startDate ? (
|
||||||
<p className="text-sm text-text-secondary">Started {formatLocalDate(streamDetails.startDate)}</p>
|
<p className="text-sm text-gray-500">Started {formatLocalDate(streamDetails.startDate)}</p>
|
||||||
) : !isStreaming ? (
|
) : !isStreaming ? (
|
||||||
<p className="text-sm text-text-secondary">Point OBS at your stream key (see Profile) to go live.</p>
|
<p className="text-sm text-gray-500">Point OBS at your stream key (see Profile) to go live.</p>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Radio size={28} className={isStreaming ? "text-live" : "text-inactive"} />
|
{isStreaming && elapsed ? (
|
||||||
|
<div className="text-right">
|
||||||
|
<p className="text-2xl font-mono font-semibold text-gray-900 tabular-nums">{elapsed}</p>
|
||||||
|
<p className="text-xs text-gray-400 uppercase tracking-wide">elapsed</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<Radio size={28} className="text-gray-200" />
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{isStreaming && (
|
{isStreaming && (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_20rem] gap-5 items-start">
|
<>
|
||||||
{/* Marker timeline. First on narrow screens, where marking
|
{/* Quick mark toolbar */}
|
||||||
something as it happens beats the action forms for urgency. */}
|
<Box className="p-4 flex flex-col gap-3">
|
||||||
<MarkerList
|
<div className="flex items-center gap-3">
|
||||||
className="lg:order-last lg:sticky lg:top-6"
|
<Bookmark size={18} className="text-accent flex-shrink-0" />
|
||||||
markers={markers}
|
<input
|
||||||
startMarkerId={startMarkerId}
|
type="text"
|
||||||
endMarkerId={endMarkerId}
|
value={markerMessage}
|
||||||
error={markerError}
|
onChange={(e) => setMarkerMessage(e.target.value)}
|
||||||
onAdd={handleAddMarker}
|
onKeyDown={(e) => e.key === "Enter" && handleAddMarker()}
|
||||||
onSelect={handleSelectMarker}
|
placeholder="What just happened?"
|
||||||
onDelete={handleDeleteMarker}
|
className={inputClass}
|
||||||
/>
|
/>
|
||||||
|
<BlueButton onClick={handleAddMarker} disabled={markerBusy || !markerMessage.trim()} className="whitespace-nowrap">
|
||||||
|
Add Marker
|
||||||
|
</BlueButton>
|
||||||
|
</div>
|
||||||
|
{markerError && <p className="text-sm text-red-500">{markerError}</p>}
|
||||||
|
|
||||||
|
{markers.length > 0 && (
|
||||||
|
<div className="flex gap-2 overflow-x-auto pb-0.5 -mx-1 px-1 pt-1.5">
|
||||||
|
{markers.map((m) => {
|
||||||
|
const isStart = startMarkerId === String(m.id);
|
||||||
|
const isEnd = endMarkerId === String(m.id);
|
||||||
|
return (
|
||||||
|
<div key={m.id} className="group relative flex-shrink-0">
|
||||||
|
<button
|
||||||
|
onClick={() => handleChipClick(m.id)}
|
||||||
|
className={clsx(
|
||||||
|
"flex flex-col items-start gap-0.5 rounded-lg border px-3 py-1.5 text-left transition-colors duration-150",
|
||||||
|
isStart && "border-primary bg-primary/5 ring-1 ring-primary",
|
||||||
|
isEnd && "border-accent bg-accent/5 ring-1 ring-accent",
|
||||||
|
!isStart && !isEnd && "border-gray-200 hover:border-gray-300 hover:bg-gray-50"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="text-xs font-medium text-gray-800 max-w-40 truncate">{m.message}</span>
|
||||||
|
<span className="text-[11px] text-gray-400">
|
||||||
|
{formatLocalDate(m.timestamp, { hour: "2-digit", minute: "2-digit", second: "2-digit" })}
|
||||||
|
{isStart && <span className="text-primary font-medium"> · start</span>}
|
||||||
|
{isEnd && <span className="text-accent font-medium"> · end</span>}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={(e) => { e.stopPropagation(); handleDeleteMarker(m.id); }}
|
||||||
|
title="Delete marker"
|
||||||
|
className="hidden group-hover:flex items-center justify-center absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-gray-400 hover:bg-red-500 text-white transition-colors duration-150"
|
||||||
|
>
|
||||||
|
<X size={10} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
|
||||||
{/* Forefront actions */}
|
{/* Forefront actions */}
|
||||||
<div className="flex flex-col gap-5">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-5 items-stretch">
|
||||||
<Box className="p-6 flex flex-col gap-3">
|
|
||||||
<CardHeader icon={Film} title="Save between two markers" accent="accent" />
|
|
||||||
{markers.length < 2 ? (
|
|
||||||
<p className="text-sm text-muted">Add at least two markers to save a section between them.</p>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
|
||||||
<span className={clsx(
|
|
||||||
"text-xs font-medium px-2.5 py-1 rounded-full border",
|
|
||||||
startMarker ? "border-terracotta text-terracotta bg-selected" : "border-dashed border-inactive text-muted"
|
|
||||||
)}>
|
|
||||||
{startMarker ? startMarker.message : "Tap a marker to set start"}
|
|
||||||
</span>
|
|
||||||
<span className="text-inactive-strong">→</span>
|
|
||||||
<span className={clsx(
|
|
||||||
"text-xs font-medium px-2.5 py-1 rounded-full border",
|
|
||||||
endMarker ? "border-olive text-olive bg-selected" : "border-dashed border-inactive text-muted"
|
|
||||||
)}>
|
|
||||||
{endMarker ? endMarker.message : "Tap a marker to set end"}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<input type="text" placeholder="Title" value={markerSaveTitle} onChange={(e) => setMarkerSaveTitle(e.target.value)} className={inputClass} />
|
|
||||||
<textarea placeholder="Description" value={markerSaveDescription} onChange={(e) => setMarkerSaveDescription(e.target.value)} rows={2} className={inputClass + " resize-none"} />
|
|
||||||
{markerSaveError && <p className="text-sm text-error">{markerSaveError}</p>}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<PrimaryButton onClick={handleSaveByMarkers} disabled={markers.length < 2} className="self-start mt-auto">Save</PrimaryButton>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box className="p-6 flex flex-col gap-3">
|
<Box className="p-6 flex flex-col gap-3">
|
||||||
<CardHeader icon={Scissors} title="Clip the last few seconds" />
|
<CardHeader icon={Scissors} title="Clip the last few seconds" />
|
||||||
<div className="flex flex-col gap-1.5">
|
<div className="flex flex-col gap-1.5">
|
||||||
@@ -299,22 +346,51 @@ const StreamControl = () => {
|
|||||||
</div>
|
</div>
|
||||||
<input type="text" placeholder="Title" value={clipTitle} onChange={(e) => setClipTitle(e.target.value)} className={inputClass} />
|
<input type="text" placeholder="Title" value={clipTitle} onChange={(e) => setClipTitle(e.target.value)} className={inputClass} />
|
||||||
<textarea placeholder="Description" value={clipDescription} onChange={(e) => setClipDescription(e.target.value)} rows={2} className={inputClass + " resize-none"} />
|
<textarea placeholder="Description" value={clipDescription} onChange={(e) => setClipDescription(e.target.value)} rows={2} className={inputClass + " resize-none"} />
|
||||||
{clipError && <p className="text-sm text-error">{clipError}</p>}
|
{clipError && <p className="text-sm text-red-500">{clipError}</p>}
|
||||||
<PrimaryButton onClick={handleClip} className="self-start mt-auto">Clip</PrimaryButton>
|
<BlueButton onClick={handleClip} className="self-start mt-auto">Clip</BlueButton>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box className="p-5 flex flex-col gap-3">
|
<Box className="p-6 flex flex-col gap-3">
|
||||||
<CardHeader icon={Activity} title="Recent actions" />
|
<CardHeader icon={Film} title="Save between two markers" accent="accent" />
|
||||||
{jobs.length === 0 ? (
|
{markers.length < 2 ? (
|
||||||
<p className="text-sm text-muted">Clip and save actions will show up here.</p>
|
<p className="text-sm text-gray-400">Add at least two markers above to save a section between them.</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-3">
|
<>
|
||||||
{jobs.map((job) => <JobStatus key={job.uuid} job={job} />)}
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
</div>
|
<span className={clsx(
|
||||||
|
"text-xs font-medium px-2.5 py-1 rounded-full border",
|
||||||
|
startMarker ? "border-primary text-primary bg-primary/5" : "border-dashed border-gray-300 text-gray-400"
|
||||||
|
)}>
|
||||||
|
{startMarker ? startMarker.message : "Tap a marker to set start"}
|
||||||
|
</span>
|
||||||
|
<span className="text-gray-300">→</span>
|
||||||
|
<span className={clsx(
|
||||||
|
"text-xs font-medium px-2.5 py-1 rounded-full border",
|
||||||
|
endMarker ? "border-accent text-accent bg-accent/5" : "border-dashed border-gray-300 text-gray-400"
|
||||||
|
)}>
|
||||||
|
{endMarker ? endMarker.message : "Tap a marker to set end"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<input type="text" placeholder="Title" value={markerSaveTitle} onChange={(e) => setMarkerSaveTitle(e.target.value)} className={inputClass} />
|
||||||
|
<textarea placeholder="Description" value={markerSaveDescription} onChange={(e) => setMarkerSaveDescription(e.target.value)} rows={2} className={inputClass + " resize-none"} />
|
||||||
|
{markerSaveError && <p className="text-sm text-red-500">{markerSaveError}</p>}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
<BlueButton onClick={handleSaveByMarkers} disabled={markers.length < 2} className="self-start mt-auto">Save</BlueButton>
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<Box className="p-5 flex flex-col gap-3">
|
||||||
|
<CardHeader icon={Activity} title="Recent actions" />
|
||||||
|
{jobs.length === 0 ? (
|
||||||
|
<p className="text-sm text-gray-400">Clip and save actions will show up here.</p>
|
||||||
|
) : (
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
{jobs.map((job) => <JobStatus key={job.uuid} job={job} />)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import { createContext } from "react";
|
|
||||||
|
|
||||||
/** What the user chose. "system" defers to the OS setting. */
|
|
||||||
type ThemePreference = "light" | "dark" | "system";
|
|
||||||
|
|
||||||
/** The theme actually on screen, once "system" has been resolved. */
|
|
||||||
type ResolvedTheme = "light" | "dark";
|
|
||||||
|
|
||||||
type ThemeContextValue = {
|
|
||||||
/** The stored choice, which may be "system". */
|
|
||||||
preference: ThemePreference;
|
|
||||||
/** The theme currently applied to the document. */
|
|
||||||
theme: ResolvedTheme;
|
|
||||||
/** Store a new preference and apply it immediately. */
|
|
||||||
setPreference: (preference: ThemePreference) => void;
|
|
||||||
/** Flip between light and dark, pinning the result as an explicit choice. */
|
|
||||||
toggleTheme: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
|
||||||
|
|
||||||
export { ThemeContext };
|
|
||||||
export type { ThemeContextValue, ThemePreference, ResolvedTheme };
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
|
||||||
import type { ReactNode } from "react";
|
|
||||||
import { ThemeContext } from "./ThemeContext.ts";
|
|
||||||
import type { ResolvedTheme, ThemePreference } from "./ThemeContext.ts";
|
|
||||||
|
|
||||||
/** Shared with the pre-paint script in index.html — keep the two in step. */
|
|
||||||
const STORAGE_KEY = "theme";
|
|
||||||
const DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
||||||
|
|
||||||
const readPreference = (): ThemePreference => {
|
|
||||||
try {
|
|
||||||
const stored = localStorage.getItem(STORAGE_KEY);
|
|
||||||
if (stored === "light" || stored === "dark" || stored === "system") {
|
|
||||||
return stored;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Storage blocked (private browsing, cookies disabled) — follow the OS.
|
|
||||||
}
|
|
||||||
return "system";
|
|
||||||
};
|
|
||||||
|
|
||||||
const readSystemTheme = (): ResolvedTheme =>
|
|
||||||
window.matchMedia(DARK_QUERY).matches ? "dark" : "light";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Owns the single source of truth for the active theme. Nothing reads colours
|
|
||||||
* from here: the palette lives in index.css and switches on the `data-theme`
|
|
||||||
* attribute this provider writes, so components keep using the semantic
|
|
||||||
* utilities (`bg-card`, `text-text-primary`) and follow along for free.
|
|
||||||
*/
|
|
||||||
const ThemeProvider = ({ children }: { children: ReactNode }) => {
|
|
||||||
const [preference, setPreferenceState] = useState<ThemePreference>(readPreference);
|
|
||||||
const [systemTheme, setSystemTheme] = useState<ResolvedTheme>(readSystemTheme);
|
|
||||||
|
|
||||||
// Keep following the OS while the preference is "system".
|
|
||||||
useEffect(() => {
|
|
||||||
const query = window.matchMedia(DARK_QUERY);
|
|
||||||
const onChange = (event: MediaQueryListEvent) =>
|
|
||||||
setSystemTheme(event.matches ? "dark" : "light");
|
|
||||||
|
|
||||||
query.addEventListener("change", onChange);
|
|
||||||
return () => query.removeEventListener("change", onChange);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const theme: ResolvedTheme = preference === "system" ? systemTheme : preference;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
document.documentElement.dataset.theme = theme;
|
|
||||||
}, [theme]);
|
|
||||||
|
|
||||||
const setPreference = useCallback((next: ThemePreference) => {
|
|
||||||
setPreferenceState(next);
|
|
||||||
try {
|
|
||||||
localStorage.setItem(STORAGE_KEY, next);
|
|
||||||
} catch {
|
|
||||||
// Storage blocked — the choice still applies for this session.
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const toggleTheme = useCallback(() => {
|
|
||||||
setPreference(theme === "dark" ? "light" : "dark");
|
|
||||||
}, [theme, setPreference]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ThemeContext.Provider value={{ preference, theme, setPreference, toggleTheme }}>
|
|
||||||
{children}
|
|
||||||
</ThemeContext.Provider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ThemeProvider;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import { useContext } from "react";
|
|
||||||
import { ThemeContext } from "./ThemeContext.ts";
|
|
||||||
import type { ThemeContextValue } from "./ThemeContext.ts";
|
|
||||||
|
|
||||||
/** Access the centralised theme state. Must be used within a <ThemeProvider>. */
|
|
||||||
const useTheme = (): ThemeContextValue => {
|
|
||||||
const context = useContext(ThemeContext);
|
|
||||||
if (!context) {
|
|
||||||
throw new Error("useTheme must be used within a ThemeProvider");
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { useTheme };
|
|
||||||
@@ -1,48 +1,12 @@
|
|||||||
import {config} from "../../config.ts";
|
const API_URL = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const API_URL = config.apiUrl;
|
|
||||||
|
|
||||||
class AuthError extends Error {
|
class AuthError extends Error {
|
||||||
constructor() { super("Not authenticated"); this.name = "AuthError"; }
|
constructor() { super("Not authenticated"); this.name = "AuthError"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
let onUnauthorized: (() => void) | null = null;
|
const isThumbnailAvailable = async (thumbnailUrl: string): Promise<boolean> => {
|
||||||
|
const response = await fetch(thumbnailUrl, { credentials: 'include' });
|
||||||
|
return response.ok;
|
||||||
|
};
|
||||||
|
|
||||||
export function registerUnauthorizedHandler(handler: () => void) {
|
export { API_URL, AuthError, isThumbnailAvailable };
|
||||||
onUnauthorized = handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Performs a request against the API, sending session cookies and funnelling
|
|
||||||
* expired/missing sessions through the registered unauthorized handler so the
|
|
||||||
* UI can drop back to a logged out state. Returns the raw response so callers
|
|
||||||
* that need something other than JSON (blobs, streams) can read it themselves.
|
|
||||||
*/
|
|
||||||
async function apiFetchRaw(url: string, options: RequestInit = {}): Promise<Response> {
|
|
||||||
const response = await fetch(url, {
|
|
||||||
...options,
|
|
||||||
credentials: 'include'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status == 401 || response.status == 403) {
|
|
||||||
onUnauthorized?.();
|
|
||||||
throw new AuthError();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const text = await response.text();
|
|
||||||
let message = text;
|
|
||||||
try { message = JSON.parse(text).message ?? text; } catch { /* not JSON, use raw text */ }
|
|
||||||
throw new Error(message || `Request failed: ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function apiFetch<T>(url: string, options: RequestInit = {}): Promise<T> {
|
|
||||||
const response = await apiFetchRaw(url, options);
|
|
||||||
const text = await response.text();
|
|
||||||
return text ? JSON.parse(text) : (undefined as T);
|
|
||||||
}
|
|
||||||
|
|
||||||
export { API_URL, AuthError, apiFetch, apiFetchRaw };
|
|
||||||
|
|||||||
@@ -1,17 +1,27 @@
|
|||||||
import type { APIResponse, Clip } from "../types.ts";
|
import type { APIResponse, Clip } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL, AuthError } from "./client.ts";
|
||||||
|
|
||||||
const getClips = async (): Promise<Clip[]> => {
|
const getClips = async (): Promise<Clip[]> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/clips');
|
const response = await fetch(API_URL + '/api/v1/clips', { credentials: 'include' });
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch clips: ${result.message}`);
|
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorResult: APIResponse = await response.json();
|
||||||
|
throw new Error(`Failed to fetch clips: ${errorResult.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getClipById = async (id: string): Promise<Clip | null> => {
|
const getClipById = async (id: string): Promise<Clip | null> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/clips/${id}`);
|
const response = await fetch(API_URL + `/api/v1/clips/${id}`, { credentials: 'include' });
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch clip: ${result.message}`);
|
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 401 || response.status === 403) throw new AuthError();
|
||||||
|
throw new Error(`Failed to fetch clip: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,20 +31,31 @@ const getClipById = async (id: string): Promise<Clip | null> => {
|
|||||||
const getClipMediaUrl = (id: string): string => API_URL + `/api/v1/clips/${id}/media`;
|
const getClipMediaUrl = (id: string): string => API_URL + `/api/v1/clips/${id}/media`;
|
||||||
|
|
||||||
const patchClip = async (id: number, data: { title?: string; description?: string }): Promise<Clip> => {
|
const patchClip = async (id: number, data: { title?: string; description?: string }): Promise<Clip> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/clips/${id}`, {
|
const response = await fetch(API_URL + `/api/v1/clips/${id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to update clip: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to update clip: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to update clip: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteClip = async (id: number): Promise<void> => {
|
const deleteClip = async (id: number): Promise<void> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/clips/${id}`, { method: 'DELETE' });
|
const response = await fetch(API_URL + `/api/v1/clips/${id}`, {
|
||||||
if (result?.status === 'error') throw new Error(`Failed to delete clip: ${result.message}`);
|
method: 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to delete clip: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
|
if (result.status === 'error') throw new Error(`Failed to delete clip: ${result.message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getClips, getClipById, getClipMediaUrl, patchClip, deleteClip };
|
export { getClips, getClipById, getClipMediaUrl, patchClip, deleteClip };
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
import type { APIResponse, JobResponse } from "../types.ts";
|
import type { APIResponse, JobResponse } from "../types.ts";
|
||||||
import { API_URL, apiFetch, apiFetchRaw } from "./client.ts";
|
import { API_URL } from "./client.ts";
|
||||||
|
|
||||||
const getJob = async (uuid: string): Promise<JobResponse> => {
|
const getJob = async (uuid: string): Promise<JobResponse> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/jobs/${uuid}`);
|
const response = await fetch(API_URL + `/api/v1/jobs/${uuid}`, { credentials: 'include' });
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to fetch job: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch job: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to fetch job: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadJob = async (uuid: string): Promise<Blob> => {
|
export { getJob };
|
||||||
const response = await apiFetchRaw(API_URL + `/api/v1/jobs/${uuid}/download`);
|
|
||||||
return response.blob();
|
|
||||||
};
|
|
||||||
|
|
||||||
export { getJob, downloadJob };
|
|
||||||
|
|||||||
@@ -1,28 +1,40 @@
|
|||||||
import type { APIResponse, Marker } from "../types.ts";
|
import type { APIResponse, Marker } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL } from "./client.ts";
|
||||||
|
|
||||||
const getMarkers = async (): Promise<Marker[]> => {
|
const getMarkers = async (): Promise<Marker[]> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/markers');
|
const response = await fetch(API_URL + '/api/v1/markers', { credentials: 'include' });
|
||||||
|
if (!response.ok) throw new Error(`Failed to fetch markers: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch markers: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to fetch markers: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createMarker = async (message: string): Promise<Marker> => {
|
const createMarker = async (message: string): Promise<Marker> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/markers', {
|
const response = await fetch(API_URL + '/api/v1/markers', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify({ message }),
|
body: JSON.stringify({ message }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.status === 'error') throw new Error(`Failed to add marker: ${result.message}`);
|
const result: APIResponse = await response.json();
|
||||||
|
if (!response.ok || result.status === 'error') throw new Error(`Failed to add marker: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMarker = async (id: number): Promise<void> => {
|
const deleteMarker = async (id: number): Promise<void> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/markers/${id}`, { method: 'DELETE' });
|
const response = await fetch(API_URL + `/api/v1/markers/${id}`, {
|
||||||
if (result?.status === 'error') throw new Error(`Failed to delete marker: ${result.message}`);
|
method: 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to delete marker: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
|
if (result.status === 'error') throw new Error(`Failed to delete marker: ${result.message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getMarkers, createMarker, deleteMarker };
|
export { getMarkers, createMarker, deleteMarker };
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { APIResponse, VideoMetadata } from "../types.ts";
|
import type { APIResponse, VideoMetadata } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL } from "./client.ts";
|
||||||
|
|
||||||
const compress = async (file: File, options: VideoMetadata): Promise<string> => {
|
const compress = async (file: File, options: VideoMetadata): Promise<string> => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
@@ -13,48 +13,58 @@ const compress = async (file: File, options: VideoMetadata): Promise<string> =>
|
|||||||
if (options.height) formData.append('height', options.height.toString());
|
if (options.height) formData.append('height', options.height.toString());
|
||||||
if (options.fileSize) formData.append('fileSize', options.fileSize.toString());
|
if (options.fileSize) formData.append('fileSize', options.fileSize.toString());
|
||||||
|
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/media/compress', {
|
const response = await fetch(API_URL + '/api/v1/media/compress', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Compression failed: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Compression failed: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Compression failed: ${result.message}`);
|
||||||
|
|
||||||
return result.data.uuid;
|
return result.data.uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveSection = async (startTime: string, endTime: string, title?: string, description?: string): Promise<string> => {
|
const saveSection = async (startTime: string, endTime: string, title?: string, description?: string): Promise<string> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/media/save', {
|
const response = await fetch(API_URL + '/api/v1/media/save', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify({ startTime, endTime, title, description }),
|
body: JSON.stringify({ startTime, endTime, title, description }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.status === 'error') throw new Error(`Failed to save section: ${result.message}`);
|
const result: APIResponse = await response.json();
|
||||||
|
if (!response.ok || result.status === 'error') throw new Error(`Failed to save section: ${result.message}`);
|
||||||
|
|
||||||
return result.data.uuid;
|
return result.data.uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveSectionByMarkers = async (startMarkerId: number, endMarkerId: number, title?: string, description?: string): Promise<string> => {
|
const saveSectionByMarkers = async (startMarkerId: number, endMarkerId: number, title?: string, description?: string): Promise<string> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/media/save/markers', {
|
const response = await fetch(API_URL + '/api/v1/media/save/markers', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify({ startMarkerId, endMarkerId, title, description }),
|
body: JSON.stringify({ startMarkerId, endMarkerId, title, description }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.status === 'error') throw new Error(`Failed to save section: ${result.message}`);
|
const result: APIResponse = await response.json();
|
||||||
|
if (!response.ok || result.status === 'error') throw new Error(`Failed to save section: ${result.message}`);
|
||||||
|
|
||||||
return result.data.uuid;
|
return result.data.uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clipSection = async (duration: number, title?: string, description?: string): Promise<string> => {
|
const clipSection = async (duration: number, title?: string, description?: string): Promise<string> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/media/clip', {
|
const response = await fetch(API_URL + '/api/v1/media/clip', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify({ duration, title, description }),
|
body: JSON.stringify({ duration, title, description }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.status === 'error') throw new Error(`Failed to clip section: ${result.message}`);
|
const result: APIResponse = await response.json();
|
||||||
|
if (!response.ok || result.status === 'error') throw new Error(`Failed to clip section: ${result.message}`);
|
||||||
|
|
||||||
return result.data.uuid;
|
return result.data.uuid;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
import type { APIResponse, StreamHistoryItem, StreamStatus } from "../types.ts";
|
import type { APIResponse, StreamHistoryItem, StreamStatus } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL } from "./client.ts";
|
||||||
|
|
||||||
const getStreamStatus = async (): Promise<boolean> => {
|
const getStreamStatus = async (): Promise<boolean> => {
|
||||||
try {
|
const response = await fetch(API_URL + '/api/v1/stream/current', { credentials: 'include' });
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/stream/current');
|
if (!response.ok) return false;
|
||||||
return result.status === 'success' && result.data?.isStreaming === true;
|
const result: APIResponse = await response.json();
|
||||||
} catch {
|
return result.status === 'success' && result.data?.isStreaming === true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCurrentStream = async (): Promise<StreamStatus> => {
|
const getCurrentStream = async (): Promise<StreamStatus> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/stream/current');
|
const response = await fetch(API_URL + '/api/v1/stream/current', { credentials: 'include' });
|
||||||
|
if (!response.ok) throw new Error(`Failed to fetch stream status: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch stream status: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to fetch stream status: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStreamHistory = async (userId: number): Promise<StreamHistoryItem[]> => {
|
const getStreamHistory = async (userId: number): Promise<StreamHistoryItem[]> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/stream/history/${userId}`);
|
const response = await fetch(API_URL + `/api/v1/stream/history/${userId}`, { credentials: 'include' });
|
||||||
|
if (!response.ok) throw new Error(`Failed to fetch stream history: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch stream history: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to fetch stream history: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import type { APIResponse, User } from "../types.ts";
|
import type { APIResponse, User } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL } from "./client.ts";
|
||||||
|
|
||||||
// login and getUser deliberately use fetch directly: they run when there may be
|
|
||||||
// no session at all, and getUser is what the unauthorized handler calls to
|
|
||||||
// refresh — routing them through apiFetch would loop on a 401.
|
|
||||||
const login = async (googleToken: string): Promise<string> => {
|
const login = async (googleToken: string): Promise<string> => {
|
||||||
const response = await fetch(API_URL + '/api/v1/users/login', {
|
const response = await fetch(API_URL + '/api/v1/users/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -21,8 +18,15 @@ const login = async (googleToken: string): Promise<string> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const logout = async (): Promise<void> => {
|
const logout = async (): Promise<void> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/users/logout', { method: 'POST' });
|
const response = await fetch(API_URL + '/api/v1/users/logout', {
|
||||||
if (result?.status === 'error') throw new Error(`Logout failed: ${result.message}`);
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Logout failed: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
|
if (result.status === 'error') throw new Error(`Logout failed: ${result.message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUser = async (): Promise<User | null> => {
|
const getUser = async (): Promise<User | null> => {
|
||||||
|
|||||||
@@ -1,17 +1,27 @@
|
|||||||
import type { APIResponse, Vod } from "../types.ts";
|
import type { APIResponse, Vod } from "../types.ts";
|
||||||
import { API_URL, apiFetch } from "./client.ts";
|
import { API_URL, AuthError } from "./client.ts";
|
||||||
|
|
||||||
const getVods = async (): Promise<Vod[]> => {
|
const getVods = async (): Promise<Vod[]> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + '/api/v1/vods');
|
const response = await fetch(API_URL + '/api/v1/vods', { credentials: 'include' });
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch vods: ${result.message}`);
|
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorResult: APIResponse = await response.json();
|
||||||
|
throw new Error(`Failed to fetch vods: ${errorResult.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getVodById = async (id: string): Promise<Vod | null> => {
|
const getVodById = async (id: string): Promise<Vod | null> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/vods/${id}`);
|
const response = await fetch(API_URL + `/api/v1/vods/${id}`, { credentials: 'include' });
|
||||||
if (result.status === 'error') throw new Error(`Failed to fetch vod: ${result.message}`);
|
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 401 || response.status === 403) throw new AuthError();
|
||||||
|
throw new Error(`Failed to fetch vod: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,20 +31,31 @@ const getVodById = async (id: string): Promise<Vod | null> => {
|
|||||||
const getVodMediaUrl = (id: string): string => API_URL + `/api/v1/vods/${id}/media`;
|
const getVodMediaUrl = (id: string): string => API_URL + `/api/v1/vods/${id}/media`;
|
||||||
|
|
||||||
const patchVod = async (id: number, data: { title?: string; description?: string }): Promise<Vod> => {
|
const patchVod = async (id: number, data: { title?: string; description?: string }): Promise<Vod> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/vods/${id}`, {
|
const response = await fetch(API_URL + `/api/v1/vods/${id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to update vod: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
if (result.status === 'error') throw new Error(`Failed to update vod: ${result.message}`);
|
if (result.status === 'error') throw new Error(`Failed to update vod: ${result.message}`);
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteVod = async (id: number): Promise<void> => {
|
const deleteVod = async (id: number): Promise<void> => {
|
||||||
const result = await apiFetch<APIResponse>(API_URL + `/api/v1/vods/${id}`, { method: 'DELETE' });
|
const response = await fetch(API_URL + `/api/v1/vods/${id}`, {
|
||||||
if (result?.status === 'error') throw new Error(`Failed to delete vod: ${result.message}`);
|
method: 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) throw new Error(`Failed to delete vod: ${response.status}`);
|
||||||
|
|
||||||
|
const result: APIResponse = await response.json();
|
||||||
|
if (result.status === 'error') throw new Error(`Failed to delete vod: ${result.message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { getVods, getVodById, getVodMediaUrl, patchVod, deleteVod };
|
export { getVods, getVodById, getVodMediaUrl, patchVod, deleteVod };
|
||||||
|
|||||||
@@ -21,12 +21,6 @@ function formatLocalDate(dateString: string, options?: Intl.DateTimeFormatOption
|
|||||||
return stringToDate(dateString).toLocaleDateString(undefined, options ?? { year: "numeric", month: "long", day: "numeric" });
|
return stringToDate(dateString).toLocaleDateString(undefined, options ?? { year: "numeric", month: "long", day: "numeric" });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clock time only, no date — markers within a stream are all from the same day,
|
|
||||||
// so the date would just be noise beside them.
|
|
||||||
function formatLocalTime(dateString: string): string {
|
|
||||||
return stringToDate(dateString).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
|
||||||
}
|
|
||||||
|
|
||||||
function dateToTimeAgo(date: Date): string {
|
function dateToTimeAgo(date: Date): string {
|
||||||
const secondsAgo = Math.floor((Date.now() - date.getTime()) / 1000);
|
const secondsAgo = Math.floor((Date.now() - date.getTime()) / 1000);
|
||||||
const units: [number, string][] = [
|
const units: [number, string][] = [
|
||||||
@@ -46,4 +40,4 @@ function dateToTimeAgo(date: Date): string {
|
|||||||
return `${s} second${s !== 1 ? 's' : ''} ago`;
|
return `${s} second${s !== 1 ? 's' : ''} ago`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { formatTime, stringToDate, dateToTimeAgo, formatLocalDate, formatLocalTime };
|
export { formatTime, stringToDate, dateToTimeAgo, formatLocalDate };
|
||||||
|
|||||||
9
frontend/src/vite-env.d.ts
vendored
9
frontend/src/vite-env.d.ts
vendored
@@ -1,9 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
|
|
||||||
interface Window {
|
|
||||||
_env_?: {
|
|
||||||
VITE_API_URL?: string;
|
|
||||||
VITE_FRONTEND_URL?: string;
|
|
||||||
VITE_GOOGLE_CLIENT_ID?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import { defineConfig, loadEnv } from 'vite'
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
import flowbiteReact from "flowbite-react/plugin/vite";
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => { // change to function form
|
export default defineConfig(({ mode }) => { // change to function form
|
||||||
const env = loadEnv(mode, process.cwd(), '') // load all env vars
|
const env = loadEnv(mode, process.cwd(), '') // load all env vars
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss(), flowbiteReact()],
|
||||||
preview: {
|
preview: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
FROM tiangolo/nginx-rtmp:latest-2026-09-07
|
FROM tiangolo/nginx-rtmp
|
||||||
|
|
||||||
RUN apt-get update -o Acquire::Check-Valid-Until=false && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends gettext-base && \
|
apt-get install -y --no-install-recommends gettext-base && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class VodSystemApplication {
|
public class VodSystemApplication {
|
||||||
|
|
||||||
/**
|
|
||||||
* Application entry point; boots the Spring context.
|
|
||||||
*
|
|
||||||
* @param args command-line arguments passed to Spring Boot
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(VodSystemApplication.class, args);
|
SpringApplication.run(VodSystemApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ import java.util.concurrent.Executor;
|
|||||||
public class AsyncConfig implements AsyncConfigurer {
|
public class AsyncConfig implements AsyncConfigurer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AsyncConfig.class);
|
private static final Logger logger = LoggerFactory.getLogger(AsyncConfig.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides the bounded thread pool that runs ffmpeg-backed {@code @Async} media tasks.
|
|
||||||
*
|
|
||||||
* @return the configured {@link Executor} registered as {@code ffmpegTaskExecutor}
|
|
||||||
*/
|
|
||||||
@Bean(name = "ffmpegTaskExecutor")
|
@Bean(name = "ffmpegTaskExecutor")
|
||||||
public Executor taskExecutor() {
|
public Executor taskExecutor() {
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
@@ -30,11 +25,6 @@ public class AsyncConfig implements AsyncConfigurer {
|
|||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Supplies the handler that logs uncaught exceptions from void-returning {@code @Async} methods.
|
|
||||||
*
|
|
||||||
* @return the async uncaught-exception handler
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
|
||||||
return (ex, method, params) ->
|
return (ex, method, params) ->
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ public class CorsConfig {
|
|||||||
@Value("${frontend.url}")
|
@Value("${frontend.url}")
|
||||||
private String frontendUrl;
|
private String frontendUrl;
|
||||||
|
|
||||||
/**
|
|
||||||
* Configures CORS for the API, allowing credentialed requests from the configured frontend origin.
|
|
||||||
*
|
|
||||||
* @return a {@link WebMvcConfigurer} that registers the CORS mappings for {@code /api/v1/**}
|
|
||||||
*/
|
|
||||||
@Bean
|
@Bean
|
||||||
public WebMvcConfigurer corsConfigurer() {
|
public WebMvcConfigurer corsConfigurer() {
|
||||||
return new WebMvcConfigurer() {
|
return new WebMvcConfigurer() {
|
||||||
|
|||||||
@@ -22,14 +22,6 @@ public class SecurityConfig {
|
|||||||
this.jwtFilter = jwtFilter;
|
this.jwtFilter = jwtFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the security filter chain: stateless sessions, CSRF disabled, the {@link JwtFilter}
|
|
||||||
* installed, and per-endpoint authorization rules.
|
|
||||||
*
|
|
||||||
* @param http the HTTP security builder to configure
|
|
||||||
* @return the built {@link SecurityFilterChain}
|
|
||||||
* @throws Exception if the security configuration cannot be built
|
|
||||||
*/
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
@@ -38,9 +30,8 @@ public class SecurityConfig {
|
|||||||
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
|
.addFilterBefore(jwtFilter, UsernamePasswordAuthenticationFilter.class)
|
||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers(HttpMethod.OPTIONS, "/api/v1/**").permitAll()
|
.requestMatchers(HttpMethod.OPTIONS, "/api/v1/**").permitAll()
|
||||||
.requestMatchers("/api/v1/media/compress").permitAll() // compression available without authenticated
|
|
||||||
.requestMatchers("/api/v1/jobs/**").permitAll() // same with jobs
|
|
||||||
.requestMatchers("/api/v1/media/**").authenticated()
|
.requestMatchers("/api/v1/media/**").authenticated()
|
||||||
|
.requestMatchers("/api/v1/jobs/**").authenticated()
|
||||||
.requestMatchers("/api/v1/users/me", "/api/v1/users/logout").authenticated()
|
.requestMatchers("/api/v1/users/me", "/api/v1/users/logout").authenticated()
|
||||||
.requestMatchers("/api/v1/users/login").permitAll()
|
.requestMatchers("/api/v1/users/login").permitAll()
|
||||||
.requestMatchers("/api/v1/stream/start", "/api/v1/stream/stop", "/api/v1/stream/heartbeat").permitAll()
|
.requestMatchers("/api/v1/stream/start", "/api/v1/stream/stop", "/api/v1/stream/heartbeat").permitAll()
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import com.ddf.vodsystem.controllers.dto.ClipUpdateRequest;
|
|||||||
import com.ddf.vodsystem.entities.Clip;
|
import com.ddf.vodsystem.entities.Clip;
|
||||||
import com.ddf.vodsystem.services.ClipService;
|
import com.ddf.vodsystem.services.ClipService;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.MediaTypeFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/clips")
|
@RequestMapping("/api/v1/clips")
|
||||||
@@ -24,11 +26,6 @@ public class ClipController {
|
|||||||
this.clipService = clipService;
|
this.clipService = clipService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all clips belonging to the authenticated user.
|
|
||||||
*
|
|
||||||
* @return {@code 200 OK} wrapping the user's clips as {@link ClipResponse} DTOs
|
|
||||||
*/
|
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public ResponseEntity<APIResponse<List<ClipResponse>>> getClips() {
|
public ResponseEntity<APIResponse<List<ClipResponse>>> getClips() {
|
||||||
List<Clip> clips = clipService.getClipsByUser();
|
List<Clip> clips = clipService.getClipsByUser();
|
||||||
@@ -44,12 +41,6 @@ public class ClipController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a single clip owned by the authenticated user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the clip to retrieve
|
|
||||||
* @return {@code 200 OK} wrapping the clip as a {@link ClipResponse} DTO
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<ClipResponse>> getClipById(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<ClipResponse>> getClipById(@PathVariable Long id) {
|
||||||
Clip clip = clipService.getClipById(id);
|
Clip clip = clipService.getClipById(id);
|
||||||
@@ -63,13 +54,6 @@ public class ClipController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a partial update to a clip's metadata; null fields are left unchanged.
|
|
||||||
*
|
|
||||||
* @param id the ID of the clip to update
|
|
||||||
* @param updateFields the title and/or description to overwrite
|
|
||||||
* @return {@code 200 OK} wrapping the updated clip as a {@link ClipResponse} DTO
|
|
||||||
*/
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<ClipResponse>> updateClip(@PathVariable Long id,
|
public ResponseEntity<APIResponse<ClipResponse>> updateClip(@PathVariable Long id,
|
||||||
@RequestBody ClipUpdateRequest updateFields) {
|
@RequestBody ClipUpdateRequest updateFields) {
|
||||||
@@ -81,12 +65,6 @@ public class ClipController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a clip and its associated files.
|
|
||||||
*
|
|
||||||
* @param id the ID of the clip to delete
|
|
||||||
* @return {@code 200 OK} with a confirmation message
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<String>> deleteClip(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<String>> deleteClip(@PathVariable Long id) {
|
||||||
clipService.deleteClip(id);
|
clipService.deleteClip(id);
|
||||||
@@ -100,13 +78,6 @@ public class ClipController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Streams the clip's video file inline, supporting HTTP range requests.
|
|
||||||
*
|
|
||||||
* @param id the ID of the clip to download
|
|
||||||
* @return {@code 200 OK} with the video resource, or {@code 404 Not Found} if the file is missing
|
|
||||||
* @throws IOException if the resource's content length cannot be read
|
|
||||||
*/
|
|
||||||
@GetMapping(value = "/{id}/media", produces = MediaType.ALL_VALUE)
|
@GetMapping(value = "/{id}/media", produces = MediaType.ALL_VALUE)
|
||||||
public ResponseEntity<Resource> downloadClip(@PathVariable Long id) throws IOException {
|
public ResponseEntity<Resource> downloadClip(@PathVariable Long id) throws IOException {
|
||||||
Resource resource = clipService.downloadClip(id);
|
Resource resource = clipService.downloadClip(id);
|
||||||
@@ -124,15 +95,8 @@ public class ClipController {
|
|||||||
.body(resource);
|
.body(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Streams the clip's thumbnail image with a public cache policy.
|
|
||||||
*
|
|
||||||
* @param id the ID of the clip whose thumbnail to download
|
|
||||||
* @return {@code 200 OK} with the thumbnail resource, or {@code 404 Not Found} if the file is missing
|
|
||||||
* @throws IOException if the resource's last-modified time cannot be read
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}/thumbnail")
|
@GetMapping("/{id}/thumbnail")
|
||||||
public ResponseEntity<Resource> downloadThumbnail(@PathVariable Long id) throws IOException {
|
public ResponseEntity<Resource> downloadThumbnail(@PathVariable Long id) {
|
||||||
Resource resource = clipService.downloadThumbnail(id);
|
Resource resource = clipService.downloadThumbnail(id);
|
||||||
|
|
||||||
if (resource == null || !resource.exists()) {
|
if (resource == null || !resource.exists()) {
|
||||||
@@ -140,8 +104,6 @@ public class ClipController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.cacheControl(CacheControl.maxAge(2, TimeUnit.DAYS).cachePublic())
|
|
||||||
.lastModified(resource.lastModified())
|
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION, String.format(FILENAME_HEADER, resource.getFilename()))
|
.header(HttpHeaders.CONTENT_DISPOSITION, String.format(FILENAME_HEADER, resource.getFilename()))
|
||||||
.contentType(MediaTypeFactory.getMediaType(resource).orElse(MediaType.APPLICATION_OCTET_STREAM))
|
.contentType(MediaTypeFactory.getMediaType(resource).orElse(MediaType.APPLICATION_OCTET_STREAM))
|
||||||
.body(resource);
|
.body(resource);
|
||||||
|
|||||||
@@ -18,12 +18,6 @@ public class GlobalExceptionHandler {
|
|||||||
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||||
private static final String ERROR = "error";
|
private static final String ERROR = "error";
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles malformed multipart requests, returning {@code 400 Bad Request}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler({ MultipartException.class })
|
@ExceptionHandler({ MultipartException.class })
|
||||||
public ResponseEntity<APIResponse<Void>> handleMultipartException(MultipartException ex) {
|
public ResponseEntity<APIResponse<Void>> handleMultipartException(MultipartException ex) {
|
||||||
logger.error("MultipartException: {}", ex.getMessage());
|
logger.error("MultipartException: {}", ex.getMessage());
|
||||||
@@ -31,12 +25,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles requests missing a required file part, returning {@code 400 Bad Request}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler({ MissingServletRequestPartException.class })
|
@ExceptionHandler({ MissingServletRequestPartException.class })
|
||||||
public ResponseEntity<APIResponse<Void>> handleMissingPart(MissingServletRequestPartException ex) {
|
public ResponseEntity<APIResponse<Void>> handleMissingPart(MissingServletRequestPartException ex) {
|
||||||
logger.error("MissingServletRequestPartException: {}", ex.getMessage());
|
logger.error("MissingServletRequestPartException: {}", ex.getMessage());
|
||||||
@@ -44,12 +32,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles unsupported request content types, returning {@code 415 Unsupported Media Type}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler({ HttpMediaTypeNotSupportedException.class })
|
@ExceptionHandler({ HttpMediaTypeNotSupportedException.class })
|
||||||
public ResponseEntity<APIResponse<Void>> handleUnsupportedMediaType(HttpMediaTypeNotSupportedException ex) {
|
public ResponseEntity<APIResponse<Void>> handleUnsupportedMediaType(HttpMediaTypeNotSupportedException ex) {
|
||||||
logger.error("HttpMediaTypeNotSupportedException: {}", ex.getMessage());
|
logger.error("HttpMediaTypeNotSupportedException: {}", ex.getMessage());
|
||||||
@@ -57,12 +39,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(response);
|
return ResponseEntity.status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles invalid arguments, returning {@code 400 Bad Request} with the exception message.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(IllegalArgumentException.class)
|
@ExceptionHandler(IllegalArgumentException.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleIllegalArgument(IllegalArgumentException ex) {
|
public ResponseEntity<APIResponse<Void>> handleIllegalArgument(IllegalArgumentException ex) {
|
||||||
logger.error("IllegalArgumentException: {}", ex.getMessage());
|
logger.error("IllegalArgumentException: {}", ex.getMessage());
|
||||||
@@ -70,12 +46,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles lookups for a non-existent job, returning {@code 404 Not Found}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(JobNotFound.class)
|
@ExceptionHandler(JobNotFound.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleFileNotFound(JobNotFound ex) {
|
public ResponseEntity<APIResponse<Void>> handleFileNotFound(JobNotFound ex) {
|
||||||
logger.error("JobNotFound: {}", ex.getMessage());
|
logger.error("JobNotFound: {}", ex.getMessage());
|
||||||
@@ -83,12 +53,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles requests for a job that is still running, returning {@code 202 Accepted}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(JobNotFinished.class)
|
@ExceptionHandler(JobNotFinished.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleJobNotFinished(JobNotFinished ex) {
|
public ResponseEntity<APIResponse<Void>> handleJobNotFinished(JobNotFinished ex) {
|
||||||
logger.error("JobNotFinished: {}", ex.getMessage());
|
logger.error("JobNotFinished: {}", ex.getMessage());
|
||||||
@@ -96,12 +60,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.ACCEPTED).body(response);
|
return ResponseEntity.status(HttpStatus.ACCEPTED).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles ffmpeg processing failures, returning {@code 500 Internal Server Error}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(FFMPEGException.class)
|
@ExceptionHandler(FFMPEGException.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleFFMPEGException(FFMPEGException ex) {
|
public ResponseEntity<APIResponse<Void>> handleFFMPEGException(FFMPEGException ex) {
|
||||||
logger.error("FFMPEGException: {}", ex.getMessage());
|
logger.error("FFMPEGException: {}", ex.getMessage());
|
||||||
@@ -109,12 +67,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles unauthenticated or unauthorized access, returning {@code 401 Unauthorized}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(NotAuthenticated.class)
|
@ExceptionHandler(NotAuthenticated.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleNotAuthenticated(NotAuthenticated ex) {
|
public ResponseEntity<APIResponse<Void>> handleNotAuthenticated(NotAuthenticated ex) {
|
||||||
logger.error("NotAuthenticated: {}", ex.getMessage());
|
logger.error("NotAuthenticated: {}", ex.getMessage());
|
||||||
@@ -122,12 +74,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response);
|
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles an unrecognised stream key, returning {@code 404 Not Found}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(KeyNotFound.class)
|
@ExceptionHandler(KeyNotFound.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleKeyNotFound(KeyNotFound ex) {
|
public ResponseEntity<APIResponse<Void>> handleKeyNotFound(KeyNotFound ex) {
|
||||||
logger.error("KeyNotFound: {}", ex.getMessage());
|
logger.error("KeyNotFound: {}", ex.getMessage());
|
||||||
@@ -135,12 +81,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles an attempt to start a stream while one is already active, returning {@code 409 Conflict}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(AlreadyStreaming.class)
|
@ExceptionHandler(AlreadyStreaming.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleAlreadyStreaming(AlreadyStreaming ex) {
|
public ResponseEntity<APIResponse<Void>> handleAlreadyStreaming(AlreadyStreaming ex) {
|
||||||
logger.error("AlreadyStreaming: {}", ex.getMessage());
|
logger.error("AlreadyStreaming: {}", ex.getMessage());
|
||||||
@@ -148,12 +88,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(response);
|
return ResponseEntity.status(HttpStatus.CONFLICT).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles file storage failures, returning {@code 500 Internal Server Error}.
|
|
||||||
*
|
|
||||||
* @param e the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(StorageException.class)
|
@ExceptionHandler(StorageException.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleStorage(StorageException e) {
|
public ResponseEntity<APIResponse<Void>> handleStorage(StorageException e) {
|
||||||
logger.error("Storage operation failed", e);
|
logger.error("Storage operation failed", e);
|
||||||
@@ -161,12 +95,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles lookups for a non-existent clip, returning {@code 404 Not Found}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(ClipNotFound.class)
|
@ExceptionHandler(ClipNotFound.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleClipNotFound(ClipNotFound ex) {
|
public ResponseEntity<APIResponse<Void>> handleClipNotFound(ClipNotFound ex) {
|
||||||
logger.error("ClipNotFound: {}", ex.getMessage());
|
logger.error("ClipNotFound: {}", ex.getMessage());
|
||||||
@@ -174,12 +102,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles a clip whose media file exists but is not readable, returning {@code 503 Service Unavailable}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(ClipMediaUnavailable.class)
|
@ExceptionHandler(ClipMediaUnavailable.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleClipMediaUnavailable(ClipMediaUnavailable ex) {
|
public ResponseEntity<APIResponse<Void>> handleClipMediaUnavailable(ClipMediaUnavailable ex) {
|
||||||
logger.error("ClipMediaUnavailable (clip {}): {}", ex.getClipId(), ex.getMessage());
|
logger.error("ClipMediaUnavailable (clip {}): {}", ex.getClipId(), ex.getMessage());
|
||||||
@@ -187,12 +109,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
|
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles lookups for a non-existent VoD, returning {@code 404 Not Found}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(VodNotFound.class)
|
@ExceptionHandler(VodNotFound.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleVodNotFound(VodNotFound ex) {
|
public ResponseEntity<APIResponse<Void>> handleVodNotFound(VodNotFound ex) {
|
||||||
logger.error("VodNotFound: {}", ex.getMessage());
|
logger.error("VodNotFound: {}", ex.getMessage());
|
||||||
@@ -200,12 +116,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles a VoD whose media file exists but is not readable, returning {@code 503 Service Unavailable}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(VodMediaUnavailable.class)
|
@ExceptionHandler(VodMediaUnavailable.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleVodMediaUnavailable(VodMediaUnavailable ex) {
|
public ResponseEntity<APIResponse<Void>> handleVodMediaUnavailable(VodMediaUnavailable ex) {
|
||||||
logger.error("VodMediaUnavailable (vod {}): {}", ex.getVodId(), ex.getMessage());
|
logger.error("VodMediaUnavailable (vod {}): {}", ex.getVodId(), ex.getMessage());
|
||||||
@@ -213,12 +123,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
|
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles actions that require an active stream when none exists, returning {@code 409 Conflict}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(NotStreaming.class)
|
@ExceptionHandler(NotStreaming.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleNotStreaming(NotStreaming ex) {
|
public ResponseEntity<APIResponse<Void>> handleNotStreaming(NotStreaming ex) {
|
||||||
logger.error("NotStreaming: {}", ex.getMessage());
|
logger.error("NotStreaming: {}", ex.getMessage());
|
||||||
@@ -226,12 +130,6 @@ public class GlobalExceptionHandler {
|
|||||||
return ResponseEntity.status(HttpStatus.CONFLICT).body(response);
|
return ResponseEntity.status(HttpStatus.CONFLICT).body(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles lookups for a non-existent marker, returning {@code 404 Not Found}.
|
|
||||||
*
|
|
||||||
* @param ex the thrown exception
|
|
||||||
* @return an error {@link APIResponse}
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(MarkerNotFound.class)
|
@ExceptionHandler(MarkerNotFound.class)
|
||||||
public ResponseEntity<APIResponse<Void>> handleMarkerNotFound(MarkerNotFound ex) {
|
public ResponseEntity<APIResponse<Void>> handleMarkerNotFound(MarkerNotFound ex) {
|
||||||
logger.error("MarkerNotFound: {}", ex.getMessage());
|
logger.error("MarkerNotFound: {}", ex.getMessage());
|
||||||
|
|||||||
@@ -28,13 +28,6 @@ public class JobController {
|
|||||||
this.jobRegistryService = jobRegistryService;
|
this.jobRegistryService = jobRegistryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the status and progress of an asynchronous job.
|
|
||||||
*
|
|
||||||
* @param uuid the UUID of the job to look up
|
|
||||||
* @return {@code 200 OK} wrapping the job's state as a {@link JobResponse} DTO
|
|
||||||
* @throws com.ddf.vodsystem.exceptions.JobNotFound if no job with {@code uuid} exists
|
|
||||||
*/
|
|
||||||
@GetMapping("/{uuid}")
|
@GetMapping("/{uuid}")
|
||||||
public ResponseEntity<APIResponse<JobResponse>> getJob(@PathVariable String uuid) {
|
public ResponseEntity<APIResponse<JobResponse>> getJob(@PathVariable String uuid) {
|
||||||
Job job = jobRegistryService.getJob(uuid);
|
Job job = jobRegistryService.getJob(uuid);
|
||||||
@@ -54,15 +47,6 @@ public class JobController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Downloads the output file produced by a completed job.
|
|
||||||
*
|
|
||||||
* @param uuid the UUID of the job whose output to download
|
|
||||||
* @return {@code 200 OK} with the output file as a downloadable resource
|
|
||||||
* @throws com.ddf.vodsystem.exceptions.JobNotFound if no job with {@code uuid} exists
|
|
||||||
* @throws NotReadyException if the job has not yet produced a downloadable file
|
|
||||||
* @throws ClipNotFound if the job's output file no longer exists on disk
|
|
||||||
*/
|
|
||||||
@GetMapping("/{uuid}/download")
|
@GetMapping("/{uuid}/download")
|
||||||
public ResponseEntity<Resource> downloadJobFile(@PathVariable String uuid) {
|
public ResponseEntity<Resource> downloadJobFile(@PathVariable String uuid) {
|
||||||
Job job = jobRegistryService.getJob(uuid);
|
Job job = jobRegistryService.getJob(uuid);
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ public class MarkerController {
|
|||||||
this.markerService = markerService;
|
this.markerService = markerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all markers belonging to the authenticated user.
|
|
||||||
*
|
|
||||||
* @return {@code 200 OK} wrapping the user's markers as {@link MarkerResponse} DTOs
|
|
||||||
*/
|
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public ResponseEntity<APIResponse<List<MarkerResponse>>> getMarkers() {
|
public ResponseEntity<APIResponse<List<MarkerResponse>>> getMarkers() {
|
||||||
List<MarkerResponse> markers = markerService.getUserMarkers().stream()
|
List<MarkerResponse> markers = markerService.getUserMarkers().stream()
|
||||||
@@ -38,12 +33,6 @@ public class MarkerController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a single marker owned by the authenticated user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the marker to retrieve
|
|
||||||
* @return {@code 200 OK} wrapping the marker as a {@link MarkerResponse} DTO
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<MarkerResponse>> getMarkerById(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<MarkerResponse>> getMarkerById(@PathVariable Long id) {
|
||||||
Marker marker = markerService.getMarkerById(id);
|
Marker marker = markerService.getMarkerById(id);
|
||||||
@@ -53,12 +42,6 @@ public class MarkerController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a marker at the current moment on the user's active stream.
|
|
||||||
*
|
|
||||||
* @param request the marker payload carrying the marker message
|
|
||||||
* @return {@code 200 OK} wrapping the created marker as a {@link MarkerResponse} DTO
|
|
||||||
*/
|
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public ResponseEntity<APIResponse<MarkerResponse>> createMarker(@Valid @RequestBody MarkerCreateRequest request) {
|
public ResponseEntity<APIResponse<MarkerResponse>> createMarker(@Valid @RequestBody MarkerCreateRequest request) {
|
||||||
Marker marker = markerService.create(request.message());
|
Marker marker = markerService.create(request.message());
|
||||||
@@ -68,12 +51,6 @@ public class MarkerController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a marker owned by the authenticated user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the marker to delete
|
|
||||||
* @return {@code 200 OK} with a confirmation message
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<String>> deleteMarker(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<String>> deleteMarker(@PathVariable Long id) {
|
||||||
markerService.deleteMarker(id);
|
markerService.deleteMarker(id);
|
||||||
|
|||||||
@@ -26,14 +26,6 @@ public class MediaController {
|
|||||||
this.mediaService = mediaService;
|
this.mediaService = mediaService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an asynchronous job to compress an uploaded video file.
|
|
||||||
*
|
|
||||||
* @param file the uploaded video to compress
|
|
||||||
* @param options trim window, resolution, fps, and target size for the output
|
|
||||||
* @return {@code 200 OK} wrapping the new job's UUID for polling
|
|
||||||
* @throws IOException if saving the upload to temporary storage fails
|
|
||||||
*/
|
|
||||||
@PostMapping(value = "/compress", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/compress", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public ResponseEntity<APIResponse<UUIDResponse>> compress(
|
public ResponseEntity<APIResponse<UUIDResponse>> compress(
|
||||||
@RequestParam("file")MultipartFile file,
|
@RequestParam("file")MultipartFile file,
|
||||||
@@ -48,13 +40,6 @@ public class MediaController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an asynchronous job to save a section of the user's stream between two timestamps as a VoD.
|
|
||||||
*
|
|
||||||
* @param saveSectionRequest the start/end timestamps and optional title/description
|
|
||||||
* @return {@code 200 OK} wrapping the new job's UUID for polling
|
|
||||||
* @throws IOException if reading the stream segments fails
|
|
||||||
*/
|
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public ResponseEntity<APIResponse<UUIDResponse>> save(
|
public ResponseEntity<APIResponse<UUIDResponse>> save(
|
||||||
@RequestBody SaveSectionRequest saveSectionRequest) throws IOException {
|
@RequestBody SaveSectionRequest saveSectionRequest) throws IOException {
|
||||||
@@ -70,13 +55,6 @@ public class MediaController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an asynchronous job to save the section of the user's stream between two markers as a VoD.
|
|
||||||
*
|
|
||||||
* @param saveSectionByMarkerRequest the start/end marker IDs and optional title/description
|
|
||||||
* @return {@code 200 OK} wrapping the new job's UUID for polling
|
|
||||||
* @throws IOException if reading the stream segments fails
|
|
||||||
*/
|
|
||||||
@PostMapping("/save/markers")
|
@PostMapping("/save/markers")
|
||||||
public ResponseEntity<APIResponse<UUIDResponse>> saveByMarkers(
|
public ResponseEntity<APIResponse<UUIDResponse>> saveByMarkers(
|
||||||
@Valid @RequestBody SaveSectionByMarkerRequest saveSectionByMarkerRequest) throws IOException {
|
@Valid @RequestBody SaveSectionByMarkerRequest saveSectionByMarkerRequest) throws IOException {
|
||||||
@@ -92,13 +70,6 @@ public class MediaController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts an asynchronous job to save the last few seconds of the user's stream as a clip.
|
|
||||||
*
|
|
||||||
* @param clipSectionRequest the clip duration in seconds and optional title/description
|
|
||||||
* @return {@code 200 OK} wrapping the new job's UUID for polling
|
|
||||||
* @throws IOException if reading the stream segments fails
|
|
||||||
*/
|
|
||||||
@PostMapping("/clip")
|
@PostMapping("/clip")
|
||||||
public ResponseEntity<APIResponse<UUIDResponse>> clip(
|
public ResponseEntity<APIResponse<UUIDResponse>> clip(
|
||||||
@RequestBody ClipSectionRequest clipSectionRequest) throws IOException {
|
@RequestBody ClipSectionRequest clipSectionRequest) throws IOException {
|
||||||
|
|||||||
@@ -24,14 +24,6 @@ public class StreamController {
|
|||||||
this.streamService = streamService;
|
this.streamService = streamService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a new stream for the user owning the given stream key.
|
|
||||||
* <p>
|
|
||||||
* Called by nginx via its {@code on_publish} RTMP callback when a broadcast begins.
|
|
||||||
*
|
|
||||||
* @param streamKey the RTMP stream key identifying the broadcasting user
|
|
||||||
* @return {@code 200 OK} wrapping the newly started {@link Stream}
|
|
||||||
*/
|
|
||||||
// Called by nginx on_publish
|
// Called by nginx on_publish
|
||||||
@PostMapping("/start")
|
@PostMapping("/start")
|
||||||
public ResponseEntity<APIResponse<Stream>> startStream(@RequestParam("name") String streamKey) {
|
public ResponseEntity<APIResponse<Stream>> startStream(@RequestParam("name") String streamKey) {
|
||||||
@@ -40,14 +32,6 @@ public class StreamController {
|
|||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream started", stream));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream started", stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ends the active stream for the user owning the given stream key.
|
|
||||||
* <p>
|
|
||||||
* Called by nginx via its {@code on_publish_done} RTMP callback when a broadcast stops.
|
|
||||||
*
|
|
||||||
* @param streamKey the RTMP stream key identifying the broadcasting user
|
|
||||||
* @return {@code 200 OK} confirming the stream was ended
|
|
||||||
*/
|
|
||||||
// Called by nginx on_publish_done
|
// Called by nginx on_publish_done
|
||||||
@PostMapping("/stop")
|
@PostMapping("/stop")
|
||||||
public ResponseEntity<APIResponse<Void>> stopStream(@RequestParam("name") String streamKey) {
|
public ResponseEntity<APIResponse<Void>> stopStream(@RequestParam("name") String streamKey) {
|
||||||
@@ -56,14 +40,6 @@ public class StreamController {
|
|||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream ended", null));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream ended", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Records a liveness heartbeat for the active stream, keeping it from being reaped as stale.
|
|
||||||
* <p>
|
|
||||||
* Called periodically by nginx via its {@code on_update} RTMP callback.
|
|
||||||
*
|
|
||||||
* @param streamKey the RTMP stream key identifying the broadcasting user
|
|
||||||
* @return {@code 200 OK} confirming the heartbeat was recorded
|
|
||||||
*/
|
|
||||||
// Called by nginx on_update
|
// Called by nginx on_update
|
||||||
@PostMapping("/heartbeat")
|
@PostMapping("/heartbeat")
|
||||||
public ResponseEntity<APIResponse<Void>> heartbeat(@RequestParam("name") String streamKey) {
|
public ResponseEntity<APIResponse<Void>> heartbeat(@RequestParam("name") String streamKey) {
|
||||||
@@ -71,24 +47,12 @@ public class StreamController {
|
|||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Heartbeat recorded", null));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Heartbeat recorded", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the stream history for the given user.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user whose stream history to retrieve; must be the authenticated user
|
|
||||||
* @return {@code 200 OK} wrapping the user's past and current {@link Stream}s
|
|
||||||
*/
|
|
||||||
@GetMapping("/history/{userId}")
|
@GetMapping("/history/{userId}")
|
||||||
public ResponseEntity<APIResponse<List<Stream>>> getStreamHistory(@PathVariable Long userId) {
|
public ResponseEntity<APIResponse<List<Stream>>> getStreamHistory(@PathVariable Long userId) {
|
||||||
List<Stream> history = streamService.getStreamHistory(userId);
|
List<Stream> history = streamService.getStreamHistory(userId);
|
||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream history retrieved", history));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Stream history retrieved", history));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reports whether the authenticated user is currently streaming.
|
|
||||||
*
|
|
||||||
* @return {@code 200 OK} wrapping a {@link StreamResponse} indicating the live status and, if live,
|
|
||||||
* the active stream's ID
|
|
||||||
*/
|
|
||||||
@GetMapping("/current")
|
@GetMapping("/current")
|
||||||
public ResponseEntity<APIResponse<StreamResponse>> getCurrentStream() {
|
public ResponseEntity<APIResponse<StreamResponse>> getCurrentStream() {
|
||||||
Optional<Stream> stream = streamService.getActiveStream();
|
Optional<Stream> stream = streamService.getActiveStream();
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.ddf.vodsystem.controllers;
|
package com.ddf.vodsystem.controllers;
|
||||||
|
|
||||||
import com.ddf.vodsystem.controllers.dto.StreamKey;
|
|
||||||
import com.ddf.vodsystem.dto.APIResponse;
|
import com.ddf.vodsystem.dto.APIResponse;
|
||||||
import com.ddf.vodsystem.controllers.dto.Token;
|
import com.ddf.vodsystem.controllers.dto.Token;
|
||||||
import com.ddf.vodsystem.entities.Stream;
|
|
||||||
import com.ddf.vodsystem.entities.User;
|
import com.ddf.vodsystem.entities.User;
|
||||||
import com.ddf.vodsystem.exceptions.NotAuthenticated;
|
import com.ddf.vodsystem.exceptions.NotAuthenticated;
|
||||||
import com.ddf.vodsystem.services.UserService;
|
import com.ddf.vodsystem.services.UserService;
|
||||||
@@ -29,12 +27,6 @@ public class UserController {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the currently authenticated user's profile.
|
|
||||||
*
|
|
||||||
* @return {@code 200 OK} wrapping the authenticated {@link User}
|
|
||||||
* @throws NotAuthenticated if no valid session is present
|
|
||||||
*/
|
|
||||||
@GetMapping("/me")
|
@GetMapping("/me")
|
||||||
public ResponseEntity<APIResponse<User>> user() {
|
public ResponseEntity<APIResponse<User>> user() {
|
||||||
Optional<User> user = userService.getLoggedInUser();
|
Optional<User> user = userService.getLoggedInUser();
|
||||||
@@ -48,17 +40,6 @@ public class UserController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Authenticates a user from a Google ID token and issues a session JWT.
|
|
||||||
* <p>
|
|
||||||
* The JWT is set as an HttpOnly {@code token} cookie (scoped by request security) and also
|
|
||||||
* returned in the response body.
|
|
||||||
*
|
|
||||||
* @param token the payload carrying the Google ID token to verify
|
|
||||||
* @param request the incoming request, used to decide cookie {@code Secure}/{@code SameSite} flags
|
|
||||||
* @param response the response the session cookie is written to
|
|
||||||
* @return {@code 200 OK} wrapping the issued JWT as a {@link Token}
|
|
||||||
*/
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public ResponseEntity<APIResponse<Token>> login(@RequestBody Token token,
|
public ResponseEntity<APIResponse<Token>> login(@RequestBody Token token,
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@@ -80,13 +61,6 @@ public class UserController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the user out by clearing the session cookie.
|
|
||||||
*
|
|
||||||
* @param response the response the expired cookie is written to
|
|
||||||
* @param request the incoming request, used to match the original cookie's {@code Secure}/{@code SameSite} flags
|
|
||||||
* @return {@code 200 OK} confirming logout
|
|
||||||
*/
|
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public ResponseEntity<APIResponse<Void>> logout(HttpServletResponse response,
|
public ResponseEntity<APIResponse<Void>> logout(HttpServletResponse response,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
@@ -104,12 +78,4 @@ public class UserController {
|
|||||||
new APIResponse<>(SUCCESS, "Logged out successfully", null)
|
new APIResponse<>(SUCCESS, "Logged out successfully", null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/me/stream-key")
|
|
||||||
public ResponseEntity<APIResponse<StreamKey>> regenerateStreamKey() {
|
|
||||||
String streamKey = userService.regenerateStreamKey();
|
|
||||||
return ResponseEntity.ok(
|
|
||||||
new APIResponse<>(SUCCESS, "Stream key successfully", new StreamKey(streamKey))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import com.ddf.vodsystem.dto.APIResponse;
|
|||||||
import com.ddf.vodsystem.entities.Vod;
|
import com.ddf.vodsystem.entities.Vod;
|
||||||
import com.ddf.vodsystem.services.VodService;
|
import com.ddf.vodsystem.services.VodService;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.MediaTypeFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v1/vods")
|
@RequestMapping("/api/v1/vods")
|
||||||
@@ -24,11 +26,6 @@ public class VodController {
|
|||||||
this.vodService = vodService;
|
this.vodService = vodService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all VoDs belonging to the authenticated user.
|
|
||||||
*
|
|
||||||
* @return {@code 200 OK} wrapping the user's VoDs as {@link VodResponse} DTOs
|
|
||||||
*/
|
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public ResponseEntity<APIResponse<List<VodResponse>>> getVods() {
|
public ResponseEntity<APIResponse<List<VodResponse>>> getVods() {
|
||||||
List<VodResponse> vods = vodService.getUserVods().stream()
|
List<VodResponse> vods = vodService.getUserVods().stream()
|
||||||
@@ -38,25 +35,12 @@ public class VodController {
|
|||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vods retrieved successfully", vods));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vods retrieved successfully", vods));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a single VoD owned by the authenticated user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the VoD to retrieve
|
|
||||||
* @return {@code 200 OK} wrapping the VoD as a {@link VodResponse} DTO
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<VodResponse>> getVodById(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<VodResponse>> getVodById(@PathVariable Long id) {
|
||||||
VodResponse vod = convertToDTO(vodService.getVodById(id));
|
VodResponse vod = convertToDTO(vodService.getVodById(id));
|
||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vod retrieved successfully", vod));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vod retrieved successfully", vod));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a partial update to a VoD's metadata; null fields are left unchanged.
|
|
||||||
*
|
|
||||||
* @param id the ID of the VoD to update
|
|
||||||
* @param updateFields the title and/or description to overwrite
|
|
||||||
* @return {@code 200 OK} wrapping the updated VoD as a {@link VodResponse} DTO
|
|
||||||
*/
|
|
||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<VodResponse>> updateVod(@PathVariable Long id,
|
public ResponseEntity<APIResponse<VodResponse>> updateVod(@PathVariable Long id,
|
||||||
@RequestBody VodUpdateRequest updateFields) {
|
@RequestBody VodUpdateRequest updateFields) {
|
||||||
@@ -64,12 +48,6 @@ public class VodController {
|
|||||||
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vod updated successfully", vod));
|
return ResponseEntity.ok(new APIResponse<>(SUCCESS, "Vod updated successfully", vod));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a VoD and its associated files.
|
|
||||||
*
|
|
||||||
* @param id the ID of the VoD to delete
|
|
||||||
* @return {@code 200 OK} with a confirmation message
|
|
||||||
*/
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public ResponseEntity<APIResponse<String>> deleteVod(@PathVariable Long id) {
|
public ResponseEntity<APIResponse<String>> deleteVod(@PathVariable Long id) {
|
||||||
vodService.deleteVod(id);
|
vodService.deleteVod(id);
|
||||||
@@ -77,13 +55,6 @@ public class VodController {
|
|||||||
"Vod with ID " + id + " has been deleted"));
|
"Vod with ID " + id + " has been deleted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Streams the VoD's video file inline, supporting HTTP range requests.
|
|
||||||
*
|
|
||||||
* @param id the ID of the VoD to download
|
|
||||||
* @return {@code 200 OK} with the video resource, or {@code 404 Not Found} if the file is missing
|
|
||||||
* @throws IOException if the resource's content length cannot be read
|
|
||||||
*/
|
|
||||||
@GetMapping(value = "/{id}/media", produces = MediaType.ALL_VALUE)
|
@GetMapping(value = "/{id}/media", produces = MediaType.ALL_VALUE)
|
||||||
public ResponseEntity<Resource> downloadVod(@PathVariable Long id) throws IOException {
|
public ResponseEntity<Resource> downloadVod(@PathVariable Long id) throws IOException {
|
||||||
Resource resource = vodService.downloadVod(id);
|
Resource resource = vodService.downloadVod(id);
|
||||||
@@ -101,15 +72,8 @@ public class VodController {
|
|||||||
.body(resource);
|
.body(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Streams the VoD's thumbnail image with a public cache policy.
|
|
||||||
*
|
|
||||||
* @param id the ID of the VoD whose thumbnail to download
|
|
||||||
* @return {@code 200 OK} with the thumbnail resource, or {@code 404 Not Found} if the file is missing
|
|
||||||
* @throws IOException if the resource's last-modified time cannot be read
|
|
||||||
*/
|
|
||||||
@GetMapping("/{id}/thumbnail")
|
@GetMapping("/{id}/thumbnail")
|
||||||
public ResponseEntity<Resource> downloadThumbnail(@PathVariable Long id) throws IOException {
|
public ResponseEntity<Resource> downloadThumbnail(@PathVariable Long id) {
|
||||||
Resource resource = vodService.downloadThumbnail(id);
|
Resource resource = vodService.downloadThumbnail(id);
|
||||||
|
|
||||||
if (resource == null || !resource.exists()) {
|
if (resource == null || !resource.exists()) {
|
||||||
@@ -117,8 +81,6 @@ public class VodController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.cacheControl(CacheControl.maxAge(2, TimeUnit.DAYS).cachePublic())
|
|
||||||
.lastModified(resource.lastModified())
|
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION, String.format(FILENAME_HEADER, resource.getFilename()))
|
.header(HttpHeaders.CONTENT_DISPOSITION, String.format(FILENAME_HEADER, resource.getFilename()))
|
||||||
.contentType(MediaTypeFactory.getMediaType(resource).orElse(MediaType.APPLICATION_OCTET_STREAM))
|
.contentType(MediaTypeFactory.getMediaType(resource).orElse(MediaType.APPLICATION_OCTET_STREAM))
|
||||||
.body(resource);
|
.body(resource);
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
package com.ddf.vodsystem.controllers.dto;
|
|
||||||
|
|
||||||
public record StreamKey (String streamKey) {
|
|
||||||
}
|
|
||||||
@@ -10,11 +10,6 @@ public class CommandOutput {
|
|||||||
private List<String> output = new ArrayList<>();
|
private List<String> output = new ArrayList<>();
|
||||||
private int exitCode;
|
private int exitCode;
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a line to the captured command output.
|
|
||||||
*
|
|
||||||
* @param line the output line to append
|
|
||||||
*/
|
|
||||||
public void addLine(String line) {
|
public void addLine(String line) {
|
||||||
output.add(line);
|
output.add(line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,30 +4,14 @@ public class ProgressTracker {
|
|||||||
private float progress = 0.0f;
|
private float progress = 0.0f;
|
||||||
private boolean isComplete = false;
|
private boolean isComplete = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current progress.
|
|
||||||
*
|
|
||||||
* @return the progress as a fraction in {@code [0, 1]}
|
|
||||||
*/
|
|
||||||
public synchronized float getProgress() {
|
public synchronized float getProgress() {
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the tracked task has been marked complete.
|
|
||||||
*
|
|
||||||
* @return {@code true} if complete
|
|
||||||
*/
|
|
||||||
public synchronized boolean isComplete() {
|
public synchronized boolean isComplete() {
|
||||||
return isComplete;
|
return isComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the current progress.
|
|
||||||
*
|
|
||||||
* @param newProgress the progress as a fraction in {@code [0, 1]}
|
|
||||||
* @throws IllegalArgumentException if {@code newProgress} is outside {@code [0, 1]}
|
|
||||||
*/
|
|
||||||
public synchronized void setProgress(float newProgress) {
|
public synchronized void setProgress(float newProgress) {
|
||||||
if (newProgress < 0 || newProgress > 1) {
|
if (newProgress < 0 || newProgress > 1) {
|
||||||
throw new IllegalArgumentException("Progress must be between 0 and 1");
|
throw new IllegalArgumentException("Progress must be between 0 and 1");
|
||||||
@@ -35,16 +19,10 @@ public class ProgressTracker {
|
|||||||
this.progress = newProgress;
|
this.progress = newProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks the tracked task as complete.
|
|
||||||
*/
|
|
||||||
public synchronized void markComplete() {
|
public synchronized void markComplete() {
|
||||||
this.isComplete = true;
|
this.isComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets progress to zero and clears the complete flag.
|
|
||||||
*/
|
|
||||||
public synchronized void reset() {
|
public synchronized void reset() {
|
||||||
this.progress = 0.0f;
|
this.progress = 0.0f;
|
||||||
this.isComplete = false;
|
this.isComplete = false;
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ public class ClipMediaUnavailable extends RuntimeException {
|
|||||||
this.clipId = clipId;
|
this.clipId = clipId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the ID of the clip whose media was unavailable.
|
|
||||||
*
|
|
||||||
* @return the affected clip's ID
|
|
||||||
*/
|
|
||||||
public Long getClipId() {
|
public Long getClipId() {
|
||||||
return clipId;
|
return clipId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ public class VodMediaUnavailable extends RuntimeException {
|
|||||||
this.vodId = vodId;
|
this.vodId = vodId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the ID of the VoD whose media was unavailable.
|
|
||||||
*
|
|
||||||
* @return the affected VoD's ID
|
|
||||||
*/
|
|
||||||
public Long getVodId() {
|
public Long getVodId() {
|
||||||
return vodId;
|
return vodId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ import java.util.List;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ClipRepository extends JpaRepository<Clip, Long> {
|
public interface ClipRepository extends JpaRepository<Clip, Long> {
|
||||||
/**
|
|
||||||
* Finds all clips owned by the given user.
|
|
||||||
*
|
|
||||||
* @param user the owning user
|
|
||||||
* @return the user's clips
|
|
||||||
*/
|
|
||||||
@Query("SELECT c FROM Clip c WHERE c.user = ?1")
|
@Query("SELECT c FROM Clip c WHERE c.user = ?1")
|
||||||
List<Clip> findByUser(User user);
|
List<Clip> findByUser(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,21 +11,9 @@ import java.util.List;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface MarkerRepository extends JpaRepository<Marker, Long> {
|
public interface MarkerRepository extends JpaRepository<Marker, Long> {
|
||||||
/**
|
|
||||||
* Finds all markers owned by the given user.
|
|
||||||
*
|
|
||||||
* @param user the owning user
|
|
||||||
* @return the user's markers
|
|
||||||
*/
|
|
||||||
@Query("SELECT m FROM Marker m WHERE m.user = ?1")
|
@Query("SELECT m FROM Marker m WHERE m.user = ?1")
|
||||||
List<Marker> findByUser(User user);
|
List<Marker> findByUser(User user);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all markers timestamped at or before the given instant.
|
|
||||||
*
|
|
||||||
* @param time the cutoff instant (inclusive)
|
|
||||||
* @return markers at or before {@code time}
|
|
||||||
*/
|
|
||||||
@Query("SELECT m FROM Marker m WHERE m.timestamp <= ?1")
|
@Query("SELECT m FROM Marker m WHERE m.timestamp <= ?1")
|
||||||
List<Marker> findAllBefore(Instant time);
|
List<Marker> findAllBefore(Instant time);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,27 +11,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface StreamRepository extends JpaRepository<Stream, Long> {
|
public interface StreamRepository extends JpaRepository<Stream, Long> {
|
||||||
/**
|
|
||||||
* Finds the user's active (not-yet-ended) stream, if any.
|
|
||||||
*
|
|
||||||
* @param user the owning user
|
|
||||||
* @return the active stream, or empty if none
|
|
||||||
*/
|
|
||||||
Optional<Stream> findByUserAndEndDateIsNull(User user);
|
Optional<Stream> findByUserAndEndDateIsNull(User user);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all streams belonging to the given user.
|
|
||||||
*
|
|
||||||
* @param user the owning user
|
|
||||||
* @return the user's streams
|
|
||||||
*/
|
|
||||||
List<Stream> findByUser(User user);
|
List<Stream> findByUser(User user);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds active streams whose last heartbeat predates the given cutoff, i.e. stale streams.
|
|
||||||
*
|
|
||||||
* @param cutoff the last-seen cutoff; streams last seen before this are returned
|
|
||||||
* @return the stale active streams
|
|
||||||
*/
|
|
||||||
List<Stream> findByEndDateIsNullAndLastSeenBefore(Instant cutoff);
|
List<Stream> findByEndDateIsNullAndLastSeenBefore(Instant cutoff);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
/**
|
|
||||||
* Finds a user by their Google account ID.
|
|
||||||
*
|
|
||||||
* @param googleId the Google subject identifier
|
|
||||||
* @return the matching user, or empty if none
|
|
||||||
*/
|
|
||||||
@Query("SELECT u FROM User u WHERE u.googleId = ?1")
|
@Query("SELECT u FROM User u WHERE u.googleId = ?1")
|
||||||
Optional<User> findByGoogleId(String googleId);
|
Optional<User> findByGoogleId(String googleId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a user by their stream key.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key to match
|
|
||||||
* @return the matching user, or empty if none
|
|
||||||
*/
|
|
||||||
@Query("SELECT u FROM User u WHERE u.streamKey = ?1")
|
@Query("SELECT u FROM User u WHERE u.streamKey = ?1")
|
||||||
Optional<User> findByStreamKey(String streamKey);
|
Optional<User> findByStreamKey(String streamKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,6 @@ import java.util.List;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface VodRepository extends JpaRepository<Vod, Long>
|
public interface VodRepository extends JpaRepository<Vod, Long>
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Finds all VoDs owned by the given user.
|
|
||||||
*
|
|
||||||
* @param user the owning user
|
|
||||||
* @return the user's VoDs
|
|
||||||
*/
|
|
||||||
@Query("SELECT v FROM Vod v WHERE v.user = ?1")
|
@Query("SELECT v FROM Vod v WHERE v.user = ?1")
|
||||||
List<Vod> findByUser(User user);
|
List<Vod> findByUser(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,6 @@ public class JwtService {
|
|||||||
this.algorithm = Algorithm.HMAC256(jwtSecretKey);
|
this.algorithm = Algorithm.HMAC256(jwtSecretKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a signed JWT carrying the given user ID, valid for the configured expiry.
|
|
||||||
*
|
|
||||||
* @param userId the user ID to embed as a claim
|
|
||||||
* @return the signed JWT string
|
|
||||||
*/
|
|
||||||
public String generateToken(Long userId) {
|
public String generateToken(Long userId) {
|
||||||
return JWT.create()
|
return JWT.create()
|
||||||
.withClaim(USER_ID_CLAIM, userId)
|
.withClaim(USER_ID_CLAIM, userId)
|
||||||
@@ -40,12 +34,6 @@ public class JwtService {
|
|||||||
.sign(algorithm);
|
.sign(algorithm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies a JWT's signature, issuer, and expiry, returning the embedded user ID.
|
|
||||||
*
|
|
||||||
* @param token the JWT to validate
|
|
||||||
* @return the user ID claim if the token is valid and unexpired, otherwise {@code null}
|
|
||||||
*/
|
|
||||||
public Long validateTokenAndGetUserId(String token) {
|
public Long validateTokenAndGetUserId(String token) {
|
||||||
try {
|
try {
|
||||||
JWTVerifier verifier = JWT.require(algorithm)
|
JWTVerifier verifier = JWT.require(algorithm)
|
||||||
|
|||||||
@@ -40,132 +40,61 @@ public class DirectoryService {
|
|||||||
private static final String CLIPS_DIR_NAME = "clips";
|
private static final String CLIPS_DIR_NAME = "clips";
|
||||||
private static final String THUMBNAIL_DIR_NAME = "thumbnails";
|
private static final String THUMBNAIL_DIR_NAME = "thumbnails";
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the directory for temporary upload inputs.
|
|
||||||
*
|
|
||||||
* @return the configured temporary input directory path
|
|
||||||
*/
|
|
||||||
public Path getTempInputDir() {
|
public Path getTempInputDir() {
|
||||||
return Path.of(tempInputsDir);
|
return Path.of(tempInputsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the directory for temporary processing outputs.
|
|
||||||
*
|
|
||||||
* @return the configured temporary output directory path
|
|
||||||
*/
|
|
||||||
public Path getTempOutputDir() {
|
public Path getTempOutputDir() {
|
||||||
return Path.of(tempOutputsDir);
|
return Path.of(tempOutputsDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the given user's root media directory, creating it if necessary.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user
|
|
||||||
* @return the user's media directory path
|
|
||||||
* @throws IOException if the directory cannot be created
|
|
||||||
*/
|
|
||||||
public Path getUserDir(Long userId) throws IOException {
|
public Path getUserDir(Long userId) throws IOException {
|
||||||
Path userDir = Path.of(usersDir + File.separator + userId);
|
Path userDir = Path.of(usersDir + File.separator + userId);
|
||||||
Files.createDirectories(userDir);
|
Files.createDirectories(userDir);
|
||||||
return userDir;
|
return userDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the given user's VoDs directory, creating it if necessary.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user
|
|
||||||
* @return the user's VoDs directory path
|
|
||||||
* @throws IOException if the directory cannot be created
|
|
||||||
*/
|
|
||||||
public Path getVodsDir(Long userId) throws IOException {
|
public Path getVodsDir(Long userId) throws IOException {
|
||||||
Path vodDir = getUserDir(userId).resolve(VODS_DIR_NAME);
|
Path vodDir = getUserDir(userId).resolve(VODS_DIR_NAME);
|
||||||
Files.createDirectories(vodDir);
|
Files.createDirectories(vodDir);
|
||||||
return vodDir;
|
return vodDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the given user's clips directory, creating it if necessary.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user
|
|
||||||
* @return the user's clips directory path
|
|
||||||
* @throws IOException if the directory cannot be created
|
|
||||||
*/
|
|
||||||
public Path getClipsDir(Long userId) throws IOException {
|
public Path getClipsDir(Long userId) throws IOException {
|
||||||
Path clipsDir = getUserDir(userId).resolve(CLIPS_DIR_NAME);
|
Path clipsDir = getUserDir(userId).resolve(CLIPS_DIR_NAME);
|
||||||
Files.createDirectories(clipsDir);
|
Files.createDirectories(clipsDir);
|
||||||
return clipsDir;
|
return clipsDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the given user's thumbnails directory, creating it if necessary.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user
|
|
||||||
* @return the user's thumbnails directory path
|
|
||||||
* @throws IOException if the directory cannot be created
|
|
||||||
*/
|
|
||||||
public Path getThumbnailsDir(Long userId) throws IOException {
|
public Path getThumbnailsDir(Long userId) throws IOException {
|
||||||
Path thumbnailsDir = getUserDir(userId).resolve(THUMBNAIL_DIR_NAME);
|
Path thumbnailsDir = getUserDir(userId).resolve(THUMBNAIL_DIR_NAME);
|
||||||
Files.createDirectories(thumbnailsDir);
|
Files.createDirectories(thumbnailsDir);
|
||||||
return thumbnailsDir;
|
return thumbnailsDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the directory holding a stream's recorded HLS segments, creating it if necessary.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key naming the segment directory
|
|
||||||
* @return the stream's segment directory path
|
|
||||||
* @throws IOException if the directory cannot be created
|
|
||||||
*/
|
|
||||||
public Path getStreamDir(String streamKey) throws IOException {
|
public Path getStreamDir(String streamKey) throws IOException {
|
||||||
Path streamFolder = Path.of(streamsDir, streamKey);
|
Path streamFolder = Path.of(streamsDir, streamKey);
|
||||||
Files.createDirectories(streamFolder);
|
Files.createDirectories(streamFolder);
|
||||||
return streamFolder;
|
return streamFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an absolute path into one relative to the users media root, for storage in the database.
|
|
||||||
*
|
|
||||||
* @param path the absolute path to relativise
|
|
||||||
* @return the path relative to the users media directory
|
|
||||||
*/
|
|
||||||
public Path relativisePath(Path path) {
|
public Path relativisePath(Path path) {
|
||||||
Path media = Path.of(usersDir).toAbsolutePath();
|
Path media = Path.of(usersDir).toAbsolutePath();
|
||||||
Path newPath = path.toAbsolutePath();
|
Path newPath = path.toAbsolutePath();
|
||||||
return media.relativize(newPath);
|
return media.relativize(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a stored relative path back into an absolute path under the users media root.
|
|
||||||
*
|
|
||||||
* @param path the relative path, as stored in the database
|
|
||||||
* @return the absolute path on disk
|
|
||||||
*/
|
|
||||||
public Path resolvePath(String path) {
|
public Path resolvePath(String path) {
|
||||||
Path media = Path.of(usersDir).toAbsolutePath();
|
Path media = Path.of(usersDir).toAbsolutePath();
|
||||||
Path newPath = Path.of(path);
|
Path newPath = Path.of(path);
|
||||||
return media.resolve(newPath);
|
return media.resolve(newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes an uploaded file to the given path, creating parent directories and overwriting any existing file.
|
|
||||||
*
|
|
||||||
* @param path the destination path
|
|
||||||
* @param multipartFile the uploaded file to save
|
|
||||||
* @throws IOException if writing the file fails
|
|
||||||
*/
|
|
||||||
public void saveMultipartFile(Path path, MultipartFile multipartFile) throws IOException {
|
public void saveMultipartFile(Path path, MultipartFile multipartFile) throws IOException {
|
||||||
Files.createDirectories(path.getParent());
|
Files.createDirectories(path.getParent());
|
||||||
Files.copy(multipartFile.getInputStream(), path, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(multipartFile.getInputStream(), path, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies a file, creating parent directories and overwriting any existing target.
|
|
||||||
*
|
|
||||||
* @param source the file to copy from
|
|
||||||
* @param target the destination path
|
|
||||||
* @throws IOException if the copy fails
|
|
||||||
*/
|
|
||||||
public void copyFile(Path source, Path target) throws IOException {
|
public void copyFile(Path source, Path target) throws IOException {
|
||||||
Files.createDirectories(target.getParent());
|
Files.createDirectories(target.getParent());
|
||||||
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
|
||||||
@@ -217,12 +146,6 @@ public class DirectoryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the temporary and users media directories on startup and verifies they are usable.
|
|
||||||
*
|
|
||||||
* @throws IOException if a directory cannot be created
|
|
||||||
* @throws IllegalStateException if any required directory is not a readable, writable directory
|
|
||||||
*/
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void createDirectoriesIfNotExist() throws IOException {
|
public void createDirectoriesIfNotExist() throws IOException {
|
||||||
Files.createDirectories(Path.of(tempInputsDir));
|
Files.createDirectories(Path.of(tempInputsDir));
|
||||||
@@ -232,13 +155,6 @@ public class DirectoryService {
|
|||||||
checkDirPermissions();
|
checkDirPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scheduled cleanup that deletes stale files from the temporary input and output directories.
|
|
||||||
* <p>
|
|
||||||
* Runs every 30 minutes; files older than 3 hours are removed.
|
|
||||||
*
|
|
||||||
* @throws IOException if listing a temporary directory fails
|
|
||||||
*/
|
|
||||||
@Scheduled(fixedRate = TEMP_DIR_CLEANUP_RATE)
|
@Scheduled(fixedRate = TEMP_DIR_CLEANUP_RATE)
|
||||||
public void cleanTempDirectories() throws IOException {
|
public void cleanTempDirectories() throws IOException {
|
||||||
cleanUpDirectory(tempInputsDir);
|
cleanUpDirectory(tempInputsDir);
|
||||||
|
|||||||
@@ -32,14 +32,6 @@ public class MarkerService {
|
|||||||
this.markerRepository = markerRepository;
|
this.markerRepository = markerRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the marker with the given ID, verifying ownership by the current user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the marker to retrieve
|
|
||||||
* @return the matching {@link Marker}
|
|
||||||
* @throws MarkerNotFound if no marker with {@code id} exists
|
|
||||||
* @throws NotAuthenticated if the current user does not own the marker
|
|
||||||
*/
|
|
||||||
public Marker getMarkerById(Long id) {
|
public Marker getMarkerById(Long id) {
|
||||||
Optional<Marker> marker = markerRepository.findById(id);
|
Optional<Marker> marker = markerRepository.findById(id);
|
||||||
|
|
||||||
@@ -55,12 +47,6 @@ public class MarkerService {
|
|||||||
return marker.get();
|
return marker.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all markers belonging to the currently authenticated user.
|
|
||||||
*
|
|
||||||
* @return list of the current user's markers
|
|
||||||
* @throws NotAuthenticated if no user session is present
|
|
||||||
*/
|
|
||||||
public List<Marker> getUserMarkers() {
|
public List<Marker> getUserMarkers() {
|
||||||
Optional<User> user = userService.getLoggedInUser();
|
Optional<User> user = userService.getLoggedInUser();
|
||||||
|
|
||||||
@@ -71,15 +57,8 @@ public class MarkerService {
|
|||||||
return markerRepository.findByUser(user.get());
|
return markerRepository.findByUser(user.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Marker create(String message) {
|
||||||
* Creates a marker timestamped now on the current user's active stream.
|
Optional<Stream> stream = streamService.getActiveStream();
|
||||||
*
|
|
||||||
* @param message the marker's descriptive message
|
|
||||||
* @return the persisted {@link Marker}
|
|
||||||
* @throws NotStreaming if the user has no active stream to mark
|
|
||||||
*/
|
|
||||||
public Marker create(User user, String message) {
|
|
||||||
Optional<Stream> stream = streamService.getActiveStream(user);
|
|
||||||
|
|
||||||
if (stream.isEmpty()) {
|
if (stream.isEmpty()) {
|
||||||
throw new NotStreaming("User must be streaming to mark");
|
throw new NotStreaming("User must be streaming to mark");
|
||||||
@@ -93,23 +72,11 @@ public class MarkerService {
|
|||||||
return markerRepository.saveAndFlush(marker);
|
return markerRepository.saveAndFlush(marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a marker owned by the current user.
|
|
||||||
*
|
|
||||||
* @param id the ID of the marker to delete
|
|
||||||
* @throws MarkerNotFound if no marker with {@code id} exists
|
|
||||||
* @throws NotAuthenticated if the current user does not own the marker
|
|
||||||
*/
|
|
||||||
public void deleteMarker(Long id) {
|
public void deleteMarker(Long id) {
|
||||||
Marker marker = getMarkerById(id);
|
Marker marker = getMarkerById(id);
|
||||||
markerRepository.delete(marker);
|
markerRepository.delete(marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scheduled cleanup that deletes markers older than the configured maximum stream length.
|
|
||||||
* <p>
|
|
||||||
* Runs periodically (every 6 minutes) to purge markers left behind by streams that have ended.
|
|
||||||
*/
|
|
||||||
@Scheduled(fixedDelay = 360_000)
|
@Scheduled(fixedDelay = 360_000)
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteOldMarkers() {
|
public void deleteOldMarkers() {
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class MediaService {
|
|||||||
onSuccess.run();
|
onSuccess.run();
|
||||||
}).exceptionally(ex -> {
|
}).exceptionally(ex -> {
|
||||||
job.setState(JobState.FAILED);
|
job.setState(JobState.FAILED);
|
||||||
job.setErrorOutput("FFMPEG failed to save stream segments");
|
job.setErrorOutput(ex.getMessage());
|
||||||
logger.error("Stream save job {} failed: {}", job.getUuid(), ex.getMessage());
|
logger.error("Stream save job {} failed: {}", job.getUuid(), ex.getMessage());
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,14 +30,6 @@ public class StreamService {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a new stream for the user identified by the given stream key.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key resolving to the broadcasting user
|
|
||||||
* @return the newly persisted {@link Stream}
|
|
||||||
* @throws KeyNotFound if no user owns {@code streamKey}
|
|
||||||
* @throws AlreadyStreaming if the user already has an active stream
|
|
||||||
*/
|
|
||||||
public Stream startStream(String streamKey) {
|
public Stream startStream(String streamKey) {
|
||||||
User user = resolveUser(streamKey);
|
User user = resolveUser(streamKey);
|
||||||
|
|
||||||
@@ -53,13 +45,6 @@ public class StreamService {
|
|||||||
return streamRepository.saveAndFlush(stream);
|
return streamRepository.saveAndFlush(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ends the active stream for the user identified by the given stream key.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key resolving to the broadcasting user
|
|
||||||
* @throws KeyNotFound if no user owns {@code streamKey}
|
|
||||||
* @throws IllegalStateException if the user has no active stream
|
|
||||||
*/
|
|
||||||
public void endStream(String streamKey) {
|
public void endStream(String streamKey) {
|
||||||
User user = resolveUser(streamKey);
|
User user = resolveUser(streamKey);
|
||||||
|
|
||||||
@@ -71,13 +56,6 @@ public class StreamService {
|
|||||||
streamRepository.saveAndFlush(stream);
|
streamRepository.saveAndFlush(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Records a liveness heartbeat on the active stream, refreshing its last-seen time.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key resolving to the broadcasting user
|
|
||||||
* @throws KeyNotFound if no user owns {@code streamKey}
|
|
||||||
* @throws IllegalStateException if the user has no active stream
|
|
||||||
*/
|
|
||||||
public void heartbeatStream(String streamKey) {
|
public void heartbeatStream(String streamKey) {
|
||||||
User user = resolveUser(streamKey);
|
User user = resolveUser(streamKey);
|
||||||
|
|
||||||
@@ -89,25 +67,16 @@ public class StreamService {
|
|||||||
streamRepository.saveAndFlush(stream);
|
streamRepository.saveAndFlush(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Optional<Stream> getActiveStream() {
|
||||||
* Returns the user's active (not-yet-ended) stream, if any.
|
Optional<User> user = userService.getLoggedInUser();
|
||||||
*
|
|
||||||
* @param user the User object
|
if (user.isEmpty()) {
|
||||||
* @return the active {@link Stream}, or empty if the user is not currently streaming
|
throw new NotAuthenticated("Log in to see user streams");
|
||||||
* @throws NotAuthenticated if no user session is present
|
}
|
||||||
*/
|
|
||||||
public Optional<Stream> getActiveStream(User user) {
|
return streamRepository.findByUserAndEndDateIsNull(user.get());
|
||||||
return streamRepository.findByUserAndEndDateIsNull(user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full stream history for the given user.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user whose history to retrieve
|
|
||||||
* @return the user's streams, past and present
|
|
||||||
* @throws IllegalArgumentException if no user with {@code userId} exists
|
|
||||||
* @throws NotAuthenticated if no user is authenticated, or the caller is not that user
|
|
||||||
*/
|
|
||||||
public List<Stream> getStreamHistory(Long userId) {
|
public List<Stream> getStreamHistory(Long userId) {
|
||||||
User streamUser = userService.getUserById(userId)
|
User streamUser = userService.getUserById(userId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("User not found: " + userId));
|
.orElseThrow(() -> new IllegalArgumentException("User not found: " + userId));
|
||||||
@@ -125,12 +94,6 @@ public class StreamService {
|
|||||||
return streamRepository.findByUser(streamUser);
|
return streamRepository.findByUser(streamUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Scheduled sweep that ends streams which have missed heartbeats past the timeout.
|
|
||||||
* <p>
|
|
||||||
* Runs every 30 seconds; any active stream whose last heartbeat is older than
|
|
||||||
* {@value #HEARTBEAT_TIMEOUT_SECONDS} seconds is marked ended.
|
|
||||||
*/
|
|
||||||
@Scheduled(fixedDelay = 30_000)
|
@Scheduled(fixedDelay = 30_000)
|
||||||
@Transactional
|
@Transactional
|
||||||
public void endStaleStreams() {
|
public void endStaleStreams() {
|
||||||
|
|||||||
@@ -44,21 +44,10 @@ public class UserService {
|
|||||||
this.jwtService = jwtService;
|
this.jwtService = jwtService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Looks up a user by their database ID.
|
|
||||||
*
|
|
||||||
* @param userId the ID of the user to find
|
|
||||||
* @return the matching {@link User}, or empty if none exists
|
|
||||||
*/
|
|
||||||
public Optional<User> getUserById(Long userId) {
|
public Optional<User> getUserById(Long userId) {
|
||||||
return userRepository.findById(userId);
|
return userRepository.findById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the user backing the current Spring Security authentication, if authenticated.
|
|
||||||
*
|
|
||||||
* @return the authenticated {@link User}, or empty if no user is authenticated
|
|
||||||
*/
|
|
||||||
public Optional<User> getLoggedInUser() {
|
public Optional<User> getLoggedInUser() {
|
||||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof User user) {
|
if (auth != null && auth.isAuthenticated() && auth.getPrincipal() instanceof User user) {
|
||||||
@@ -67,13 +56,6 @@ public class UserService {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies a Google ID token, creating or updating the corresponding user, and issues a session JWT.
|
|
||||||
*
|
|
||||||
* @param idToken the Google ID token to verify
|
|
||||||
* @return a signed JWT for the authenticated user
|
|
||||||
* @throws NotAuthenticated if the token is invalid or its subject is missing
|
|
||||||
*/
|
|
||||||
public String login(String idToken) {
|
public String login(String idToken) {
|
||||||
GoogleIdToken googleIdToken = getGoogleIdToken(idToken);
|
GoogleIdToken googleIdToken = getGoogleIdToken(idToken);
|
||||||
String googleId = googleIdToken.getPayload().getSubject();
|
String googleId = googleIdToken.getPayload().getSubject();
|
||||||
@@ -88,22 +70,10 @@ public class UserService {
|
|||||||
return jwtService.generateToken(user.getId());
|
return jwtService.generateToken(user.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Looks up a user by their stream key.
|
|
||||||
*
|
|
||||||
* @param streamKey the stream key to match
|
|
||||||
* @return the matching {@link User}, or empty if none exists
|
|
||||||
*/
|
|
||||||
public Optional<User> getUserByStreamKey(String streamKey) {
|
public Optional<User> getUserByStreamKey(String streamKey) {
|
||||||
return userRepository.findByStreamKey(streamKey);
|
return userRepository.findByStreamKey(streamKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String regenerateStreamKey(User user) {
|
|
||||||
user.setStreamKey(generateStreamKey());
|
|
||||||
userRepository.saveAndFlush(user);
|
|
||||||
return user.getStreamKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
private User createOrUpdateUser(User user) {
|
private User createOrUpdateUser(User user) {
|
||||||
Optional<User> existingUser = userRepository.findByGoogleId(user.getGoogleId());
|
Optional<User> existingUser = userRepository.findByGoogleId(user.getGoogleId());
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,6 @@ import java.util.regex.Pattern;
|
|||||||
public class CommandRunner {
|
public class CommandRunner {
|
||||||
private static final Pattern timePattern = Pattern.compile("out_time_ms=(\\d+)");
|
private static final Pattern timePattern = Pattern.compile("out_time_ms=(\\d+)");
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs an external command, capturing its merged stdout/stderr and streaming each line to a callback.
|
|
||||||
*
|
|
||||||
* @param command the command and its arguments
|
|
||||||
* @param onOutput invoked for each output line as it is read, or {@code null} to skip streaming
|
|
||||||
* @return the captured output and exit code
|
|
||||||
* @throws IOException if the process fails to start or exits with a non-zero code
|
|
||||||
* @throws InterruptedException if the current thread is interrupted while awaiting the process
|
|
||||||
*/
|
|
||||||
public CommandOutput run(List<String> command, Consumer<String> onOutput) throws IOException, InterruptedException {
|
public CommandOutput run(List<String> command, Consumer<String> onOutput) throws IOException, InterruptedException {
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
ProcessBuilder processBuilder = new ProcessBuilder(command);
|
||||||
processBuilder.redirectErrorStream(true);
|
processBuilder.redirectErrorStream(true);
|
||||||
@@ -52,33 +43,15 @@ public class CommandRunner {
|
|||||||
return commandOutput;
|
return commandOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs an external command, capturing its output without streaming.
|
|
||||||
*
|
|
||||||
* @param command the command and its arguments
|
|
||||||
* @return the captured output and exit code
|
|
||||||
* @throws IOException if the process fails to start or exits with a non-zero code
|
|
||||||
* @throws InterruptedException if the current thread is interrupted while awaiting the process
|
|
||||||
*/
|
|
||||||
public CommandOutput run(List<String> command) throws IOException, InterruptedException {
|
public CommandOutput run(List<String> command) throws IOException, InterruptedException {
|
||||||
return run(command, null);
|
return run(command, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses an ffmpeg progress line and updates the tracker with the fraction completed.
|
|
||||||
* <p>
|
|
||||||
* Lines without an {@code out_time_ms} field are ignored.
|
|
||||||
*
|
|
||||||
* @param line a single line of ffmpeg {@code -progress} output
|
|
||||||
* @param progress the tracker to update
|
|
||||||
* @param length the total media length in seconds, used as the progress denominator
|
|
||||||
*/
|
|
||||||
public void setProgress(String line, ProgressTracker progress, float length) {
|
public void setProgress(String line, ProgressTracker progress, float length) {
|
||||||
Matcher matcher = timePattern.matcher(line);
|
Matcher matcher = timePattern.matcher(line);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
float timeInSeconds = Float.parseFloat(matcher.group(1)) / 1_000_000f;
|
float timeInMs = Float.parseFloat(matcher.group(1)) / 1000000f;
|
||||||
float fraction = Math.clamp(timeInSeconds / length, 0f, 1f);
|
progress.setProgress(timeInMs / length);
|
||||||
progress.setProgress(fraction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,17 +27,6 @@ public class CompressionService {
|
|||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Compresses (and optionally trims/rescales) a video with ffmpeg on a background executor.
|
|
||||||
* <p>
|
|
||||||
* Runs asynchronously; failures complete the returned future exceptionally rather than throwing.
|
|
||||||
*
|
|
||||||
* @param inputFile the source video file
|
|
||||||
* @param outputFile the destination for the compressed output
|
|
||||||
* @param clipOptions the trim window, target resolution/fps, and size driving the ffmpeg command
|
|
||||||
* @param progress the tracker updated as encoding progresses
|
|
||||||
* @return a future completing with the ffmpeg output, or exceptionally on failure
|
|
||||||
*/
|
|
||||||
@Async("ffmpegTaskExecutor")
|
@Async("ffmpegTaskExecutor")
|
||||||
public CompletableFuture<CommandOutput> compress(Path inputFile,
|
public CompletableFuture<CommandOutput> compress(Path inputFile,
|
||||||
Path outputFile,
|
Path outputFile,
|
||||||
|
|||||||
@@ -26,14 +26,6 @@ public class MetadataService {
|
|||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Probes a video file with ffprobe and returns its metadata (duration, dimensions, fps, size).
|
|
||||||
* <p>
|
|
||||||
* Runs asynchronously; failures complete the returned future exceptionally rather than throwing.
|
|
||||||
*
|
|
||||||
* @param file the video file to probe
|
|
||||||
* @return a future completing with the parsed {@link ClipOptions}, or exceptionally on failure
|
|
||||||
*/
|
|
||||||
@Async("ffmpegTaskExecutor")
|
@Async("ffmpegTaskExecutor")
|
||||||
public CompletableFuture<ClipOptions> getVideoMetadata(Path file) {
|
public CompletableFuture<ClipOptions> getVideoMetadata(Path file) {
|
||||||
logger.info("Getting metadata for file {}", file);
|
logger.info("Getting metadata for file {}", file);
|
||||||
|
|||||||
@@ -21,17 +21,6 @@ public class RemuxService {
|
|||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Re-encodes a video to H.264/AAC in an MP4 container with ffmpeg on a background executor.
|
|
||||||
* <p>
|
|
||||||
* Runs asynchronously; failures complete the returned future exceptionally rather than throwing.
|
|
||||||
*
|
|
||||||
* @param inputFile the source video file
|
|
||||||
* @param outputFile the destination for the remuxed MP4
|
|
||||||
* @param remuxProgress the tracker updated as encoding progresses
|
|
||||||
* @param length the media length in seconds, used to compute progress
|
|
||||||
* @return a future completing with the ffmpeg output, or exceptionally on failure
|
|
||||||
*/
|
|
||||||
@Async("ffmpegTaskExecutor")
|
@Async("ffmpegTaskExecutor")
|
||||||
public CompletableFuture<CommandOutput> remux(File inputFile,
|
public CompletableFuture<CommandOutput> remux(File inputFile,
|
||||||
File outputFile,
|
File outputFile,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,14 +42,13 @@ public class StreamActionsService {
|
|||||||
* A resolved section of a stream, ready to be muxed by {@link #saveSection}.
|
* A resolved section of a stream, ready to be muxed by {@link #saveSection}.
|
||||||
*
|
*
|
||||||
* @param segments the segments to concatenate, in playback order; never empty
|
* @param segments the segments to concatenate, in playback order; never empty
|
||||||
* @param trimOffset seconds between the start of {@code segments.getFirst()} and
|
* @param trimOffset seconds to trim from the start of {@code segments.getFirst()}
|
||||||
* the requested start, or {@code 0} when the first segment
|
* so playback begins at the requested moment, or {@code 0}
|
||||||
* already starts there. Segments are copied whole, so this is
|
* when the first segment already starts there
|
||||||
* lead-in the section carries before the requested moment, not
|
* @param duration seconds of footage to keep, measured from the trim point.
|
||||||
* footage that gets trimmed away
|
* When the requested start fell in a recording gap and the
|
||||||
* @param duration seconds of footage to keep, measured from the start of
|
* leading segment was dropped, this is measured from the
|
||||||
* {@code segments.getFirst()} so the section ends at the
|
* later real start so the section still ends where requested
|
||||||
* requested end time with the lead-in included
|
|
||||||
*/
|
*/
|
||||||
public record SegmentSelection(List<Path> segments, float trimOffset, float duration) {}
|
public record SegmentSelection(List<Path> segments, float trimOffset, float duration) {}
|
||||||
|
|
||||||
@@ -80,6 +78,8 @@ public class StreamActionsService {
|
|||||||
long firstMs = parseTimestampMs(segments.getFirst());
|
long firstMs = parseTimestampMs(segments.getFirst());
|
||||||
float trimOffset = Math.max(0f, (startTime.toEpochMilli() - firstMs) / 1000f);
|
float trimOffset = Math.max(0f, (startTime.toEpochMilli() - firstMs) / 1000f);
|
||||||
|
|
||||||
|
// A first segment shorter than the trim offset means the requested start
|
||||||
|
// lands in a gap after it; drop it and begin at the next recorded footage.
|
||||||
if (trimOffset > 0 && probeDurationSeconds(segments.getFirst()) < trimOffset) {
|
if (trimOffset > 0 && probeDurationSeconds(segments.getFirst()) < trimOffset) {
|
||||||
segments.removeFirst();
|
segments.removeFirst();
|
||||||
if (segments.isEmpty()) {
|
if (segments.isEmpty()) {
|
||||||
@@ -89,19 +89,18 @@ public class StreamActionsService {
|
|||||||
trimOffset = 0f;
|
trimOffset = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Measure duration from where playback actually begins so a dropped
|
||||||
|
// leading segment shortens the section rather than overrunning endTime.
|
||||||
|
long effectiveStartMs = firstMs + (long) (trimOffset * 1000);
|
||||||
|
float duration = (endTime.toEpochMilli() - effectiveStartMs) / 1000f;
|
||||||
|
|
||||||
float duration = (endTime.toEpochMilli() - firstMs) / 1000f;
|
|
||||||
return new SegmentSelection(segments, trimOffset, duration);
|
return new SegmentSelection(segments, trimOffset, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Muxes a {@link SegmentSelection} to {@code outputFile}, keeping
|
* Muxes a {@link SegmentSelection} to {@code outputFile}, trimming the leading
|
||||||
* {@code selection.duration()} seconds of footage.
|
* segment to {@code selection.trimOffset()} and keeping {@code selection.duration()}
|
||||||
* <p>
|
* seconds of footage.
|
||||||
* Segments are concatenated byte-wise through ffmpeg's {@code concat:} protocol,
|
|
||||||
* which preserves the continuous timestamps nginx writes across fragments. The
|
|
||||||
* leading segment is copied whole rather than trimmed, so playback begins up to
|
|
||||||
* {@code selection.trimOffset()} seconds before the requested moment.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Runs asynchronously; failures (process-launch errors, ffmpeg failures,
|
* Runs asynchronously; failures (process-launch errors, ffmpeg failures,
|
||||||
* interruption) complete the returned future exceptionally rather than being
|
* interruption) complete the returned future exceptionally rather than being
|
||||||
@@ -132,19 +131,37 @@ public class StreamActionsService {
|
|||||||
"trimOffset must be >= 0 and duration must be > 0 (got " + trimOffset + ", " + duration + ")"));
|
"trimOffset must be >= 0 and duration must be > 0 (got " + trimOffset + ", " + duration + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path headFragment = null;
|
||||||
|
Path concatList = null;
|
||||||
try {
|
try {
|
||||||
String concatInput = "concat:" + segments.stream()
|
// Only the first segment is trimmed, so re-encode just that fragment and
|
||||||
.map(p -> p.toAbsolutePath().toString())
|
// stream-copy the rest. A zero offset means the first segment already
|
||||||
.collect(Collectors.joining("|"));
|
// starts at the requested point, so re-encoding it would be wasted work.
|
||||||
|
List<Path> fragments;
|
||||||
|
if (trimOffset > 0) {
|
||||||
|
headFragment = Files.createTempFile("reencode-section-", ".ts");
|
||||||
|
encodeHead(segments.getFirst(), trimOffset, headFragment);
|
||||||
|
|
||||||
|
fragments = new ArrayList<>();
|
||||||
|
fragments.add(headFragment);
|
||||||
|
fragments.addAll(segments.subList(1, segments.size()));
|
||||||
|
} else {
|
||||||
|
fragments = segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The concat demuxer (unlike the concat: byte protocol) rebases each
|
||||||
|
// fragment's timestamps to run continuously across the joins, absorbing
|
||||||
|
// the discontinuity between the PTS-0 head and the copied fragments.
|
||||||
|
concatList = writeConcatList(fragments);
|
||||||
|
|
||||||
List<String> command = List.of(
|
List<String> command = List.of(
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
"-y",
|
"-y",
|
||||||
"-progress", "pipe:1",
|
"-f", "concat",
|
||||||
"-i", concatInput,
|
"-safe", "0",
|
||||||
|
"-i", concatList.toAbsolutePath().toString(),
|
||||||
"-t", String.valueOf(duration),
|
"-t", String.valueOf(duration),
|
||||||
"-c", "copy",
|
"-c", "copy",
|
||||||
"-avoid_negative_ts", "make_zero",
|
|
||||||
outputFile.toAbsolutePath().toString()
|
outputFile.toAbsolutePath().toString()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -163,6 +180,9 @@ public class StreamActionsService {
|
|||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
logger.error("Failed to save section to '{}': {}", outputFile, e.toString());
|
logger.error("Failed to save section to '{}': {}", outputFile, e.toString());
|
||||||
return CompletableFuture.failedFuture(e);
|
return CompletableFuture.failedFuture(e);
|
||||||
|
} finally {
|
||||||
|
deleteTempQuietly(headFragment);
|
||||||
|
deleteTempQuietly(concatList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,4 +257,52 @@ public class StreamActionsService {
|
|||||||
throw new IOException("Failed to probe segment duration: " + segment, e);
|
throw new IOException("Failed to probe segment duration: " + segment, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void encodeHead(Path firstSegment, float trimOffset, Path head)
|
||||||
|
throws IOException, InterruptedException {
|
||||||
|
|
||||||
|
List<String> command = List.of(
|
||||||
|
"ffmpeg",
|
||||||
|
"-y",
|
||||||
|
"-i", firstSegment.toAbsolutePath().toString(),
|
||||||
|
"-ss", String.valueOf(trimOffset),
|
||||||
|
"-c:v", "libx264",
|
||||||
|
"-preset", "veryfast",
|
||||||
|
"-crf", "20",
|
||||||
|
"-pix_fmt", "yuv420p",
|
||||||
|
"-c:a", "aac",
|
||||||
|
"-b:a", "160k",
|
||||||
|
"-muxdelay", "0",
|
||||||
|
"-muxpreload", "0",
|
||||||
|
"-f", "mpegts",
|
||||||
|
head.toAbsolutePath().toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
logger.debug("Re-encoding head fragment '{}' from {}s", firstSegment, trimOffset);
|
||||||
|
commandRunner.run(command, line -> { /* head pass is short; no progress reporting */ });
|
||||||
|
|
||||||
|
if (!Files.exists(head) || Files.size(head) == 0) {
|
||||||
|
throw new IOException("Head re-encode produced no output — trimOffset " + trimOffset
|
||||||
|
+ "s may exceed the duration of " + firstSegment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path writeConcatList(List<Path> fragments) throws IOException {
|
||||||
|
Path listFile = Files.createTempFile("concat-list-", ".txt");
|
||||||
|
List<String> lines = fragments.stream()
|
||||||
|
.map(p -> "file '" + p.toAbsolutePath().toString().replace("'", "'\\''") + "'")
|
||||||
|
.toList();
|
||||||
|
Files.write(listFile, lines);
|
||||||
|
return listFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTempQuietly(Path tempFile) {
|
||||||
|
if (tempFile != null) {
|
||||||
|
try {
|
||||||
|
Files.deleteIfExists(tempFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warn("Failed to delete temp file '{}': {}", tempFile, e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,6 @@ public class ThumbnailService {
|
|||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts a single frame from a video as a thumbnail image with ffmpeg on a background executor.
|
|
||||||
* <p>
|
|
||||||
* Runs asynchronously; failures complete the returned future exceptionally rather than throwing.
|
|
||||||
*
|
|
||||||
* @param inputFile the source video file
|
|
||||||
* @param outputFile the destination for the thumbnail image
|
|
||||||
* @param timeInVideo the timestamp in seconds at which to capture the frame
|
|
||||||
* @return a future completing with the ffmpeg output, or exceptionally on failure
|
|
||||||
*/
|
|
||||||
@Async("ffmpegTaskExecutor")
|
@Async("ffmpegTaskExecutor")
|
||||||
public CompletableFuture<CommandOutput> createThumbnail(Path inputFile, Path outputFile, Float timeInVideo) {
|
public CompletableFuture<CommandOutput> createThumbnail(Path inputFile, Path outputFile, Float timeInVideo) {
|
||||||
logger.info("Creating thumbnail at {} seconds", timeInVideo);
|
logger.info("Creating thumbnail at {} seconds", timeInVideo);
|
||||||
|
|||||||
@@ -3,6 +3,4 @@ spring.docker.compose.file=docker-compose.dev.yml
|
|||||||
media.temp.inputs=./videos/inputs
|
media.temp.inputs=./videos/inputs
|
||||||
media.temp.outputs=./videos/outputs
|
media.temp.outputs=./videos/outputs
|
||||||
media.users=${MEDIA_DATA}
|
media.users=${MEDIA_DATA}
|
||||||
media.streams=${STREAM_DATA}
|
media.streams=${STREAM_DATA}
|
||||||
|
|
||||||
logging.level.com.ddf.vodsystem=DEBUG
|
|
||||||
@@ -57,6 +57,23 @@ class StreamActionsServiceTest {
|
|||||||
when(metadataService.getVideoMetadata(any())).thenReturn(CompletableFuture.completedFuture(meta));
|
when(metadataService.getVideoMetadata(any())).thenReturn(CompletableFuture.completedFuture(meta));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stubs the two-arg {@link CommandRunner#run} so the head re-encode pass
|
||||||
|
* actually writes a non-empty file at its output path — {@code encodeHead}
|
||||||
|
* verifies its output exists and is non-empty before continuing. The concat
|
||||||
|
* pass (no {@code mpegts} muxer) is left untouched. Returns {@code output}
|
||||||
|
* for both invocations.
|
||||||
|
*/
|
||||||
|
private void stubRunnerProducingHead(CommandOutput output) throws IOException, InterruptedException {
|
||||||
|
when(commandRunner.run(anyList(), any())).thenAnswer(inv -> {
|
||||||
|
List<String> cmd = inv.getArgument(0);
|
||||||
|
if (cmd.contains("mpegts")) {
|
||||||
|
Files.writeString(Path.of(cmd.getLast()), "x");
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// selectSegments: missing / invalid directories
|
// selectSegments: missing / invalid directories
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
@@ -230,10 +247,8 @@ class StreamActionsServiceTest {
|
|||||||
assertThat(selection.segments()).extracting(p -> p.getFileName().toString())
|
assertThat(selection.segments()).extracting(p -> p.getFileName().toString())
|
||||||
.containsExactly("30.ts", "33.ts");
|
.containsExactly("30.ts", "33.ts");
|
||||||
assertThat(selection.trimOffset()).isEqualTo(1.5f);
|
assertThat(selection.trimOffset()).isEqualTo(1.5f);
|
||||||
// 30.ts is copied whole, so the section starts at 30s rather than the
|
// effective start equals the requested 31.5s, so duration runs to endTime: 40 - 31.5
|
||||||
// requested 31.5s; duration runs from there to endTime: 40 - 30. The
|
assertThat(selection.duration()).isEqualTo(8.5f);
|
||||||
// 1.5s trimOffset is carried as lead-in, not cut away.
|
|
||||||
assertThat(selection.duration()).isEqualTo(10f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -340,7 +355,7 @@ class StreamActionsServiceTest {
|
|||||||
ProgressTracker progress = new ProgressTracker();
|
ProgressTracker progress = new ProgressTracker();
|
||||||
CommandOutput commandOutput = new CommandOutput();
|
CommandOutput commandOutput = new CommandOutput();
|
||||||
|
|
||||||
when(commandRunner.run(anyList(), any())).thenReturn(commandOutput);
|
stubRunnerProducingHead(commandOutput);
|
||||||
|
|
||||||
var future = service.saveSection(
|
var future = service.saveSection(
|
||||||
new StreamActionsService.SegmentSelection(List.of(segmentA, segmentB), 5.0f, 12.0f), output, progress);
|
new StreamActionsService.SegmentSelection(List.of(segmentA, segmentB), 5.0f, 12.0f), output, progress);
|
||||||
@@ -348,29 +363,24 @@ class StreamActionsServiceTest {
|
|||||||
assertThat(future.get()).isSameAs(commandOutput);
|
assertThat(future.get()).isSameAs(commandOutput);
|
||||||
assertThat(progress.isComplete()).isTrue();
|
assertThat(progress.isComplete()).isTrue();
|
||||||
|
|
||||||
// The section is one stream-copy pass over the byte-concatenated segments:
|
// With a non-zero trim offset saveSection issues two ffmpeg passes: the
|
||||||
// the concat: protocol joins them without rebasing the timestamps nginx
|
// head re-encode (trims the first segment via -ss) followed by the
|
||||||
// wrote across fragments, which is what keeps the joins seamless.
|
// concat-demuxer stream copy (-f concat / -t / -c copy).
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ArgumentCaptor<List<String>> captor = ArgumentCaptor.forClass(List.class);
|
ArgumentCaptor<List<String>> captor = ArgumentCaptor.forClass(List.class);
|
||||||
Mockito.verify(commandRunner, Mockito.times(1)).run(captor.capture(), any());
|
Mockito.verify(commandRunner, Mockito.times(2)).run(captor.capture(), any());
|
||||||
List<String> command = captor.getValue();
|
List<String> headCommand = captor.getAllValues().get(0);
|
||||||
|
List<String> concatCommand = captor.getAllValues().get(1);
|
||||||
|
|
||||||
assertThat(command).containsSequence(
|
assertThat(headCommand).containsSequence("-ss", "5.0");
|
||||||
"-i", "concat:" + segmentA.toAbsolutePath() + "|" + segmentB.toAbsolutePath());
|
assertThat(concatCommand).containsSequence("-f", "concat");
|
||||||
assertThat(command).containsSequence("-t", "12.0");
|
assertThat(concatCommand).containsSequence("-t", "12.0");
|
||||||
assertThat(command).containsSequence("-c", "copy");
|
assertThat(concatCommand).containsSequence("-c", "copy");
|
||||||
assertThat(command).containsSequence("-avoid_negative_ts", "make_zero");
|
assertThat(concatCommand).endsWith(output.toAbsolutePath().toString());
|
||||||
assertThat(command).endsWith(output.toAbsolutePath().toString());
|
|
||||||
|
|
||||||
// The leading segment is copied whole, so nothing seeks and the concat
|
|
||||||
// demuxer (-f concat) is deliberately not used.
|
|
||||||
assertThat(command).doesNotContain("-ss");
|
|
||||||
assertThat(command).doesNotContainSequence("-f", "concat");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void saveSection_zeroTrimOffset_buildsTheSameSingleCopyPass() throws Exception {
|
void saveSection_zeroTrimOffset_skipsHeadReencodeAndRunsSingleConcatPass() throws Exception {
|
||||||
Path output = Path.of("/tmp/out/clip.mp4");
|
Path output = Path.of("/tmp/out/clip.mp4");
|
||||||
ProgressTracker progress = new ProgressTracker();
|
ProgressTracker progress = new ProgressTracker();
|
||||||
CommandOutput commandOutput = new CommandOutput();
|
CommandOutput commandOutput = new CommandOutput();
|
||||||
@@ -384,14 +394,14 @@ class StreamActionsServiceTest {
|
|||||||
assertThat(future.get()).isSameAs(commandOutput);
|
assertThat(future.get()).isSameAs(commandOutput);
|
||||||
assertThat(progress.isComplete()).isTrue();
|
assertThat(progress.isComplete()).isTrue();
|
||||||
|
|
||||||
// trimOffset no longer changes the command shape: with or without lead-in
|
// trimOffset 0 means the first segment already starts at the requested point:
|
||||||
// the section is the same single copy pass over the joined segments.
|
// no head re-encode pass, just a single concat-demuxer copy (no -ss).
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ArgumentCaptor<List<String>> captor = ArgumentCaptor.forClass(List.class);
|
ArgumentCaptor<List<String>> captor = ArgumentCaptor.forClass(List.class);
|
||||||
Mockito.verify(commandRunner, Mockito.times(1)).run(captor.capture(), any());
|
Mockito.verify(commandRunner, Mockito.times(1)).run(captor.capture(), any());
|
||||||
List<String> command = captor.getValue();
|
List<String> command = captor.getValue();
|
||||||
|
|
||||||
assertThat(command).containsSequence("-i", "concat:/tmp/a.ts|/tmp/b.ts");
|
assertThat(command).containsSequence("-f", "concat");
|
||||||
assertThat(command).containsSequence("-t", "10.0");
|
assertThat(command).containsSequence("-t", "10.0");
|
||||||
assertThat(command).doesNotContain("-ss");
|
assertThat(command).doesNotContain("-ss");
|
||||||
}
|
}
|
||||||
@@ -401,7 +411,8 @@ class StreamActionsServiceTest {
|
|||||||
Path output = Path.of("/tmp/out/clip.mp4");
|
Path output = Path.of("/tmp/out/clip.mp4");
|
||||||
ProgressTracker progress = new ProgressTracker();
|
ProgressTracker progress = new ProgressTracker();
|
||||||
|
|
||||||
// The copy pass is the only ffmpeg invocation, so its failure must surface.
|
// With a non-zero trim offset the head re-encode is the first ffmpeg pass;
|
||||||
|
// its failure must surface.
|
||||||
when(commandRunner.run(anyList(), any())).thenThrow(new IOException("ffmpeg boom"));
|
when(commandRunner.run(anyList(), any())).thenThrow(new IOException("ffmpeg boom"));
|
||||||
|
|
||||||
var future = service.saveSection(
|
var future = service.saveSection(
|
||||||
@@ -431,8 +442,8 @@ class StreamActionsServiceTest {
|
|||||||
void saveSection_nullOutputFile_completesExceptionally() {
|
void saveSection_nullOutputFile_completesExceptionally() {
|
||||||
ProgressTracker progress = new ProgressTracker();
|
ProgressTracker progress = new ProgressTracker();
|
||||||
|
|
||||||
// Building the command dereferences the null output path, so no ffmpeg
|
// trimOffset 0 skips the head pass; building the concat command dereferences
|
||||||
// pass ever runs.
|
// the null output path, so no ffmpeg pass ever runs.
|
||||||
var future = service.saveSection(
|
var future = service.saveSection(
|
||||||
new StreamActionsService.SegmentSelection(List.of(Path.of("/tmp/a.ts")), 0f, 10f), null, progress);
|
new StreamActionsService.SegmentSelection(List.of(Path.of("/tmp/a.ts")), 0f, 10f), null, progress);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user