mirror of
https://github.com/kerberos-io/agent.git
synced 2026-11-21 22:50:39 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
485ec02c55 | ||
|
|
00398a4dd7 | ||
|
|
7e8431c11c | ||
|
|
6cd077daa3 | ||
|
|
6c49611211 |
@@ -1,5 +1,9 @@
|
||||
FROM mcr.microsoft.com/devcontainers/go:1.26-trixie
|
||||
|
||||
# Same pin as the main Dockerfile: Go 1.26.11 rejects moq-go-ffi v0.3.x's
|
||||
# archives (LLVM bitcode), which breaks `go build -tags moq`.
|
||||
ENV GOTOOLCHAIN=go1.26.10
|
||||
|
||||
# Install node environment
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
|
||||
ARG GO_IMAGE=golang:1.26-trixie
|
||||
# Pinned to 1.26.10: Go 1.26.11 rejects C archives containing LLVM bitcode
|
||||
# ("disallowed LTO section .llvmbc"), and moq-go-ffi v0.3.x ships such archives.
|
||||
# Unpin once the MoQ code moves to moq.dev/moq (moq-ffi v0.4.27+ is clean).
|
||||
ARG GO_IMAGE=golang:1.26.10-trixie
|
||||
ARG RUNTIME_IMAGE=debian:trixie-slim
|
||||
ARG VERSION=0.0.0
|
||||
FROM ${GO_IMAGE} AS build-machinery
|
||||
|
||||
@@ -662,7 +662,9 @@ The Kerberos Agent is divided in two parts: a `machinery` and `web` part. Both p
|
||||
|
||||
### UI
|
||||
|
||||
The `web` is a **React** project which is the main entry point for an end user to view recordings, a livestream, and modify the configuration of the `machinery`.
|
||||
The `web` is a **React** project, built with [Vite](https://vite.dev), which is
|
||||
the main entry point for an end user to view recordings, a livestream, and
|
||||
modify the configuration of the `machinery`.
|
||||
|
||||
git clone https://github.com/kerberos-io/agent
|
||||
cd ui
|
||||
@@ -671,7 +673,7 @@ The `web` is a **React** project which is the main entry point for an end user t
|
||||
This starts the web app on port `3000`. In development, the UI connects to the
|
||||
Agent API on port `8082`. Override that port when needed:
|
||||
|
||||
REACT_APP_AGENT_API_PORT=9090 yarn start
|
||||
VITE_AGENT_API_PORT=9090 yarn start
|
||||
|
||||

|
||||
|
||||
@@ -691,7 +693,7 @@ You can simply run the `machinery` using following commands.
|
||||
|
||||
This will launch the Kerberos Agent and run a webserver on port `8082`, matching
|
||||
the UI development default. You can change the port together with
|
||||
`REACT_APP_AGENT_API_PORT`. We strongly support the usage of
|
||||
`VITE_AGENT_API_PORT`. We strongly support the usage of
|
||||
[Goland](https://www.jetbrains.com/go/) or
|
||||
[Visual Studio Code](https://code.visualstudio.com/), as it comes with all the
|
||||
debugging and linting features built in.
|
||||
|
||||
+2
-2
@@ -27,6 +27,7 @@ require (
|
||||
github.com/kerberos-io/joy4 v1.0.64
|
||||
github.com/kerberos-io/onvif v1.2.3
|
||||
github.com/minio/minio-go/v6 v6.0.57
|
||||
github.com/moq-dev/moq-go v0.5.7
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/pion/interceptor v0.1.47
|
||||
github.com/pion/rtcp v1.2.17
|
||||
@@ -46,7 +47,6 @@ require (
|
||||
go.opentelemetry.io/otel/sdk v1.47.0
|
||||
go.opentelemetry.io/otel/trace v1.47.0
|
||||
golang.org/x/net v0.62.0
|
||||
moq.dev/moq v0.7.27
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -99,6 +99,7 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/moq-dev/moq-go-ffi v0.3.7 // indirect
|
||||
github.com/nxadm/tail v1.4.11 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pion/datachannel v1.6.2 // indirect
|
||||
@@ -142,5 +143,4 @@ require (
|
||||
gopkg.in/ini.v1 v1.42.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
|
||||
moq.dev/moq-ffi v0.4.27 // indirect
|
||||
)
|
||||
|
||||
+4
-4
@@ -857,6 +857,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
|
||||
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/moq-dev/moq-go v0.5.7 h1:LfFpgAU8FRMcnU85L5Lb03HzxhYbQ2+BhT/pJQdjy5U=
|
||||
github.com/moq-dev/moq-go v0.5.7/go.mod h1:5K8zjKKjWe5lzfCtlfxoAfdCr3KX6EBuTOZsz0WBnzw=
|
||||
github.com/moq-dev/moq-go-ffi v0.3.7 h1:+xwPOzTJHvB0tuTnW6znbvvOgT4yLnN7sMqXXZYh02M=
|
||||
github.com/moq-dev/moq-go-ffi v0.3.7/go.mod h1:zxpOlUetvaoxWBnbXTdILtLLUytaoVuLvO36lftwWO0=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
|
||||
@@ -2170,10 +2174,6 @@ modernc.org/tcl v1.15.1/go.mod h1:aEjeGJX2gz1oWKOLDVZ2tnEWLUrIn8H+GFu+akoDhqs=
|
||||
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
|
||||
moq.dev/moq v0.7.27 h1:MICXMveLyoFBPj6Tu10oLH8NMhkYaDOa7oe6ay0RQ/c=
|
||||
moq.dev/moq v0.7.27/go.mod h1:zdCa+pXvmwXg+qTXgVJzO9jX7GbI7R/AFGwWOx1BKg0=
|
||||
moq.dev/moq-ffi v0.4.27 h1:PCXoyW1QTUN2XnM4pkAIBGpOAFjhm1OmCyPfPHszKPc=
|
||||
moq.dev/moq-ffi v0.4.27/go.mod h1:a+uEvcnNtY3e9T4/3UqjHBnyYHNLY8rZp+/m7tmL5n8=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/kerberos-io/agent/machinery/src/cloud/livemoq"
|
||||
"github.com/kerberos-io/agent/machinery/src/models"
|
||||
"github.com/kerberos-io/agent/machinery/src/packets"
|
||||
"moq.dev/moq"
|
||||
"github.com/moq-dev/moq-go/moq"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -292,7 +292,7 @@ func publishLiveStreamMoQ(ctx context.Context, config liveMoQConfig) error {
|
||||
}
|
||||
defer finishBroadcast()
|
||||
|
||||
stream, err := broadcast.PublishVideo(moq.VideoFormatAvc3, nil)
|
||||
stream, err := broadcast.PublishMedia("avc3", nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create H.264 media stream: %w", err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/kerberos-io/agent/machinery/src/cloud/livemoq"
|
||||
"github.com/kerberos-io/agent/machinery/src/models"
|
||||
"moq.dev/moq"
|
||||
"github.com/moq-dev/moq-go/moq"
|
||||
)
|
||||
|
||||
func TestCloseLiveMoQPublisherFinishesBeforeClosingClient(t *testing.T) {
|
||||
@@ -155,7 +155,7 @@ func TestNativeMoQClientCloseStopsActiveWriter(t *testing.T) {
|
||||
server.Close()
|
||||
t.Fatal(err)
|
||||
}
|
||||
stream, err := broadcast.PublishVideo(moq.VideoFormatAvc3, nil)
|
||||
stream, err := broadcast.PublishMedia("avc3", nil)
|
||||
if err != nil {
|
||||
client.Close()
|
||||
server.Close()
|
||||
|
||||
+27
-60
@@ -1,70 +1,37 @@
|
||||
# Getting Started with Create React App
|
||||
# Kerberos Agent UI
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
The web interface of the Kerberos Agent: a React app built with
|
||||
[Vite](https://vite.dev) and tested with [Vitest](https://vitest.dev).
|
||||
Requires Node.js 20.19 or newer.
|
||||
|
||||
## Available Scripts
|
||||
## Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
- `yarn start`: starts the dev server on
|
||||
[http://localhost:3000](http://localhost:3000) with hot reload.
|
||||
- `yarn build`: builds for production and moves the output to
|
||||
`../machinery/www`, where the Agent serves it.
|
||||
- `yarn preview`: serves the production build from `../machinery/www` on
|
||||
port 3000. Run `yarn build` first.
|
||||
- `yarn test`: runs the test suite once. `yarn test:watch` keeps it running.
|
||||
- `yarn lint`: lints `src/` with ESLint.
|
||||
- `yarn format`: formats the code with Prettier.
|
||||
|
||||
### `yarn start`
|
||||
## Configuration
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
In development the UI talks to the Agent API on port `8082` of the same host.
|
||||
Override it with `VITE_AGENT_API_PORT`:
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
VITE_AGENT_API_PORT=9090 yarn start
|
||||
|
||||
### `yarn test`
|
||||
In production builds the UI uses the host and port it was served from.
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
Runtime settings that differ per deployment (such as demo mode) live in
|
||||
`public/env.js`, which the Agent can replace without rebuilding the UI.
|
||||
|
||||
### `yarn build`
|
||||
## Layout
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `yarn eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
|
||||
### Code Splitting
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
|
||||
### Making a Progressive Web App
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
|
||||
### Deployment
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
|
||||
### `yarn build` fails to minify
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
||||
- `index.html`: the HTML entry point; Vite injects the bundle here.
|
||||
- `src/`: application code. `src/index.jsx` is the entry module.
|
||||
- `public/`: copied unchanged to the build root (favicons, fonts, locales, `env.js`).
|
||||
- Bundled JS, CSS and assets go to `static/` in the build, so they don't mix
|
||||
with the `assets/` folder from `public/`.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png?v=1">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png?v=1">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png?v=1">
|
||||
<link rel="manifest" href="/favicons/site.webmanifest?v=1">
|
||||
<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg?v=1" color="#b4524e">
|
||||
<link rel="shortcut icon" href="/favicons/favicon.ico?v=1">
|
||||
<meta name="msapplication-TileColor" content="#b4524e">
|
||||
<meta name="msapplication-config" content="/favicons/browserconfig.xml?v=1">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<script src="/env.js"></script>
|
||||
<title>Kerberos Agent | Video surveillance for everyone </title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/index.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
+14
-22
@@ -1,9 +1,12 @@
|
||||
{
|
||||
"name": "agent-ui",
|
||||
"version": "0.1.0",
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@giantmachines/redux-websocket": "^1.5.1",
|
||||
"@kerberos-io/ui": "^1.76.0",
|
||||
"@kerberos-io/ui": "https://github.com/kerberos-io/ui/releases/download/v1.77.1/kerberos-io-ui-1.77.1.tgz",
|
||||
"@material-ui/core": "^4.12.4",
|
||||
"@material-ui/icons": "^4.11.3",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
@@ -29,7 +32,6 @@
|
||||
"react-router": "^5.2.0",
|
||||
"react-router-dom": "^5.3.3",
|
||||
"react-router-redux": "^4.0.8",
|
||||
"react-scripts": "5.*",
|
||||
"react-tooltip": "^4.2.21",
|
||||
"redux": "^4.2.0",
|
||||
"redux-devtools-extension": "^2.13.9",
|
||||
@@ -44,38 +46,28 @@
|
||||
"crypto": false
|
||||
},
|
||||
"scripts": {
|
||||
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
|
||||
"build": "DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=false REACT_APP_ENVIRONMENT=production react-scripts build && rm -rf ../machinery/www && mv build ../machinery/www",
|
||||
"test": "DISABLE_ESLINT_PLUGIN=true react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"start": "vite",
|
||||
"build": "vite build && rm -rf ../machinery/www && mv build ../machinery/www",
|
||||
"preview": "vite preview --outDir ../machinery/www",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"lint": "eslint --debug 'src/**/*.{js,jsx,ts,tsx}'",
|
||||
"format": "prettier --write \"**/*.{js,jsx,json,md}\""
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^6.3.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-airbnb": "^18.2.1",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||
"eslint-plugin-react": "^7.30.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"sass": "^1.54.4",
|
||||
"sass-loader": "^10.3.1"
|
||||
"jsdom": "^29.1.1",
|
||||
"sass": "^1.108.2",
|
||||
"vite": "^8.3.8",
|
||||
"vitest": "^4.1.12"
|
||||
},
|
||||
"resolutions": {
|
||||
"@tootallnate/once": "^2.0.1",
|
||||
"serialize-javascript": "^7.1.3",
|
||||
"uuid": "^11.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/favicons/apple-touch-icon.png?v=1">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/favicons/favicon-32x32.png?v=1">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/favicons/favicon-16x16.png?v=1">
|
||||
<link rel="manifest" href="%PUBLIC_URL%/favicons/site.webmanifest?v=1">
|
||||
<link rel="mask-icon" href="%PUBLIC_URL%/favicons/safari-pinned-tab.svg?v=1" color="#b4524e">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicons/favicon.ico?v=1">
|
||||
<meta name="msapplication-TileColor" content="#b4524e">
|
||||
<meta name="msapplication-config" content="%PUBLIC_URL%/favicons/browserconfig.xml?v=1">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<script src="%PUBLIC_URL%/env.js"></script>
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>Kerberos Agent | Video surveillance for everyone </title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
+33
-28
@@ -1,4 +1,5 @@
|
||||
/* eslint-env jest */
|
||||
import { vi } from 'vitest';
|
||||
/* eslint-disable react/prop-types */
|
||||
import React from 'react';
|
||||
import { interval } from 'rxjs';
|
||||
@@ -6,11 +7,11 @@ import { App } from './App';
|
||||
|
||||
const subscriptions = [];
|
||||
|
||||
jest.mock('rxjs', () => ({
|
||||
interval: jest.fn(),
|
||||
vi.mock('rxjs', () => ({
|
||||
interval: vi.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('@kerberos-io/ui', () => {
|
||||
vi.mock('@kerberos-io/ui', () => {
|
||||
const Mock = ({ children }) => <div>{children}</div>;
|
||||
return {
|
||||
Badge: Mock,
|
||||
@@ -27,42 +28,46 @@ jest.mock('@kerberos-io/ui', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('./components/LanguageSelect/LanguageSelect', () => () => null);
|
||||
jest.mock('./actions', () => ({ logout: jest.fn() }));
|
||||
jest.mock('./actions/agent', () => ({
|
||||
getDashboardInformation: jest.fn(),
|
||||
vi.mock('./components/LanguageSelect/LanguageSelect', () => ({
|
||||
default: () => null,
|
||||
}));
|
||||
jest.mock('./config', () => ({
|
||||
MODE: 'release',
|
||||
URL: 'http://localhost',
|
||||
WS_URL: 'ws://localhost/ws',
|
||||
vi.mock('./actions', () => ({ logout: vi.fn() }));
|
||||
vi.mock('./actions/agent', () => ({
|
||||
getDashboardInformation: vi.fn(),
|
||||
}));
|
||||
jest.mock('react-redux', () => ({
|
||||
vi.mock('./config', () => ({
|
||||
default: {
|
||||
MODE: 'release',
|
||||
URL: 'http://localhost',
|
||||
WS_URL: 'ws://localhost/ws',
|
||||
},
|
||||
}));
|
||||
vi.mock('react-redux', () => ({
|
||||
connect: () => (Component) => Component,
|
||||
}));
|
||||
jest.mock('react-i18next', () => ({
|
||||
vi.mock('react-i18next', () => ({
|
||||
withTranslation: () => (Component) => Component,
|
||||
}));
|
||||
jest.mock('react-router-dom', () => ({
|
||||
vi.mock('react-router-dom', () => ({
|
||||
Link: ({ children }) => <>{children}</>,
|
||||
}));
|
||||
jest.mock('@giantmachines/redux-websocket', () => ({
|
||||
connect: jest.fn(),
|
||||
disconnect: jest.fn(),
|
||||
send: jest.fn(),
|
||||
vi.mock('@giantmachines/redux-websocket', () => ({
|
||||
connect: vi.fn(),
|
||||
disconnect: vi.fn(),
|
||||
send: vi.fn(),
|
||||
}));
|
||||
jest.mock('uuid', () => ({
|
||||
v4: jest.fn(() => 'uuid-1'),
|
||||
vi.mock('uuid', () => ({
|
||||
v4: vi.fn(() => 'uuid-1'),
|
||||
}));
|
||||
|
||||
describe('App lifecycle refresh behaviour', () => {
|
||||
const baseProps = () => ({
|
||||
t: (value) => value,
|
||||
dispatchLogout: jest.fn(),
|
||||
dispatchConnect: jest.fn(),
|
||||
dispatchDisconnect: jest.fn(),
|
||||
dispatchSend: jest.fn(),
|
||||
dispatchGetDashboardInformation: jest.fn((onSuccess) => {
|
||||
dispatchLogout: vi.fn(),
|
||||
dispatchConnect: vi.fn(),
|
||||
dispatchDisconnect: vi.fn(),
|
||||
dispatchSend: vi.fn(),
|
||||
dispatchGetDashboardInformation: vi.fn((onSuccess) => {
|
||||
if (onSuccess) {
|
||||
onSuccess();
|
||||
}
|
||||
@@ -78,12 +83,12 @@ describe('App lifecycle refresh behaviour', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
subscriptions.length = 0;
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
interval.mockImplementation(() => ({
|
||||
subscribe: jest.fn((callback) => {
|
||||
subscribe: vi.fn((callback) => {
|
||||
const subscription = {
|
||||
callback,
|
||||
unsubscribe: jest.fn(),
|
||||
unsubscribe: vi.fn(),
|
||||
};
|
||||
subscriptions.push(subscription);
|
||||
return subscription;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/* eslint-env jest */
|
||||
import { vi } from 'vitest';
|
||||
import API from './api';
|
||||
import { doGetDashboardInformation } from './agent';
|
||||
|
||||
jest.mock('./api', () => ({
|
||||
get: jest.fn(),
|
||||
vi.mock('./api', () => ({
|
||||
default: {
|
||||
get: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('dashboard API', () => {
|
||||
it('bounds dashboard requests so polling can recover', async () => {
|
||||
const onSuccess = jest.fn();
|
||||
const onError = jest.fn();
|
||||
const onSuccess = vi.fn();
|
||||
const onError = vi.fn();
|
||||
API.get.mockResolvedValue({
|
||||
status: 200,
|
||||
data: { uptime: '1 minute' },
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
/* eslint-env jest */
|
||||
import { vi } from 'vitest';
|
||||
import { ImageCanvas } from './ImageCanvas';
|
||||
|
||||
jest.mock('vott-ct', () => ({
|
||||
vi.mock('vott-ct', () => ({
|
||||
CanvasTools: {
|
||||
Editor: jest.fn(),
|
||||
Editor: vi.fn(),
|
||||
Core: {
|
||||
RegionData: jest.fn(),
|
||||
Point2D: jest.fn(),
|
||||
Tag: jest.fn(),
|
||||
TagsDescriptor: jest.fn(),
|
||||
RegionData: vi.fn(),
|
||||
Point2D: vi.fn(),
|
||||
Tag: vi.fn(),
|
||||
TagsDescriptor: vi.fn(),
|
||||
Colors: {
|
||||
Color: jest.fn(),
|
||||
Color: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
|
||||
vi.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
|
||||
SelectionMode: {
|
||||
NONE: 'none',
|
||||
RECT: 'rect',
|
||||
@@ -24,7 +25,7 @@ jest.mock('vott-ct/lib/js/CanvasTools/Interface/ISelectorSettings', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
|
||||
vi.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
|
||||
RegionDataType: {
|
||||
Polygon: 'polygon',
|
||||
},
|
||||
@@ -32,9 +33,9 @@ jest.mock('vott-ct/lib/js/CanvasTools/Core/RegionData', () => ({
|
||||
|
||||
describe('ImageCanvas update guards', () => {
|
||||
const callbacks = {
|
||||
onAddRegion: jest.fn(),
|
||||
onUpdateRegion: jest.fn(),
|
||||
onDeleteRegion: jest.fn(),
|
||||
onAddRegion: vi.fn(),
|
||||
onUpdateRegion: vi.fn(),
|
||||
onDeleteRegion: vi.fn(),
|
||||
};
|
||||
|
||||
const baseProps = () => ({
|
||||
@@ -45,7 +46,7 @@ describe('ImageCanvas update guards', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('ignores unrelated parent updates', () => {
|
||||
@@ -55,8 +56,8 @@ describe('ImageCanvas update guards', () => {
|
||||
};
|
||||
const canvas = new ImageCanvas(props);
|
||||
canvas.props = props;
|
||||
canvas.loadImage = jest.fn();
|
||||
canvas.loadData = jest.fn();
|
||||
canvas.loadImage = vi.fn();
|
||||
canvas.loadData = vi.fn();
|
||||
|
||||
canvas.componentDidUpdate({
|
||||
...props,
|
||||
@@ -71,8 +72,8 @@ describe('ImageCanvas update guards', () => {
|
||||
const props = baseProps();
|
||||
const canvas = new ImageCanvas(props);
|
||||
canvas.props = props;
|
||||
canvas.loadImage = jest.fn();
|
||||
canvas.loadData = jest.fn();
|
||||
canvas.loadImage = vi.fn();
|
||||
canvas.loadData = vi.fn();
|
||||
|
||||
canvas.componentDidUpdate({
|
||||
...props,
|
||||
@@ -97,8 +98,8 @@ describe('ImageCanvas update guards', () => {
|
||||
width: 100,
|
||||
height: 100,
|
||||
};
|
||||
canvas.loadImage = jest.fn();
|
||||
canvas.loadData = jest.fn();
|
||||
canvas.loadImage = vi.fn();
|
||||
canvas.loadData = vi.fn();
|
||||
|
||||
canvas.componentDidUpdate({
|
||||
...props,
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
const { hostname, host, protocol } = window.location;
|
||||
const websocketprotocol = protocol === 'http:' ? 'ws:' : 'wss:';
|
||||
const devAgentPort = process.env.REACT_APP_AGENT_API_PORT || '8082';
|
||||
const devAgentPort = import.meta.env.VITE_AGENT_API_PORT || '8082';
|
||||
|
||||
// Uncomment this when using codespaces or other special DNS names (which you can't control)
|
||||
// replace this with the DNS name of the kerberos agent server (the codespace url)
|
||||
@@ -22,7 +22,7 @@ const dev = {
|
||||
};
|
||||
|
||||
const prod = {
|
||||
ENV: process.env.REACT_APP_ENVIRONMENT,
|
||||
ENV: import.meta.env.MODE,
|
||||
HOSTNAME: hostname,
|
||||
API_URL: `${protocol}//${host}/api`,
|
||||
URL: `${protocol}//${host}`,
|
||||
@@ -30,7 +30,7 @@ const prod = {
|
||||
MODE: window['env']['mode'],
|
||||
};
|
||||
|
||||
const config = process.env.REACT_APP_ENVIRONMENT === 'production' ? prod : dev;
|
||||
const config = import.meta.env.PROD ? prod : dev;
|
||||
|
||||
export default {
|
||||
// Add common config values here
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/* eslint-env jest */
|
||||
import { vi } from 'vitest';
|
||||
/* eslint-disable react/prop-types */
|
||||
import React from 'react';
|
||||
import { Settings } from './Settings';
|
||||
|
||||
jest.mock('rxjs', () => ({
|
||||
interval: jest.fn(() => ({
|
||||
subscribe: jest.fn(() => ({
|
||||
unsubscribe: jest.fn(),
|
||||
vi.mock('rxjs', () => ({
|
||||
interval: vi.fn(() => ({
|
||||
subscribe: vi.fn(() => ({
|
||||
unsubscribe: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock('@kerberos-io/ui', () => {
|
||||
vi.mock('@kerberos-io/ui', () => {
|
||||
const Mock = ({ children }) => <div>{children}</div>;
|
||||
return {
|
||||
Breadcrumb: Mock,
|
||||
@@ -31,36 +32,37 @@ jest.mock('@kerberos-io/ui', () => {
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('react-redux', () => ({
|
||||
vi.mock('react-redux', () => ({
|
||||
connect: () => (Component) => Component,
|
||||
}));
|
||||
jest.mock('react-i18next', () => ({
|
||||
vi.mock('react-i18next', () => ({
|
||||
withTranslation: () => (Component) => Component,
|
||||
}));
|
||||
jest.mock('react-router-dom', () => ({
|
||||
vi.mock('react-router-dom', () => ({
|
||||
Link: ({ children }) => <>{children}</>,
|
||||
withRouter: (Component) => Component,
|
||||
}));
|
||||
jest.mock('@giantmachines/redux-websocket', () => ({
|
||||
send: jest.fn(),
|
||||
vi.mock('@giantmachines/redux-websocket', () => ({
|
||||
send: vi.fn(),
|
||||
}));
|
||||
jest.mock('../../components/ImageCanvas/ImageCanvas', () => () => null);
|
||||
jest.mock('../../websocket', () => ({
|
||||
__esModule: true,
|
||||
vi.mock('../../components/ImageCanvas/ImageCanvas', () => ({
|
||||
default: () => null,
|
||||
}));
|
||||
vi.mock('../../websocket', () => ({
|
||||
default: 'uuid-1',
|
||||
}));
|
||||
jest.mock('../../actions/agent', () => ({
|
||||
addRegion: jest.fn(),
|
||||
updateRegion: jest.fn(),
|
||||
removeRegion: jest.fn(),
|
||||
saveConfig: jest.fn(),
|
||||
verifyOnvif: jest.fn(),
|
||||
verifyCamera: jest.fn(),
|
||||
verifyHub: jest.fn(),
|
||||
verifyPersistence: jest.fn(),
|
||||
verifySecondaryPersistence: jest.fn(),
|
||||
getConfig: jest.fn(),
|
||||
updateConfig: jest.fn(),
|
||||
vi.mock('../../actions/agent', () => ({
|
||||
addRegion: vi.fn(),
|
||||
updateRegion: vi.fn(),
|
||||
removeRegion: vi.fn(),
|
||||
saveConfig: vi.fn(),
|
||||
verifyOnvif: vi.fn(),
|
||||
verifyCamera: vi.fn(),
|
||||
verifyHub: vi.fn(),
|
||||
verifyPersistence: vi.fn(),
|
||||
verifySecondaryPersistence: vi.fn(),
|
||||
getConfig: vi.fn(),
|
||||
updateConfig: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('Settings liveview lifecycle', () => {
|
||||
@@ -78,22 +80,22 @@ describe('Settings liveview lifecycle', () => {
|
||||
connected: true,
|
||||
config,
|
||||
images: [],
|
||||
dispatchVerifyHub: jest.fn(),
|
||||
dispatchVerifyPersistence: jest.fn(),
|
||||
dispatchVerifySecondaryPersistence: jest.fn(),
|
||||
dispatchGetConfig: jest.fn(),
|
||||
dispatchUpdateConfig: jest.fn(),
|
||||
dispatchSaveConfig: jest.fn(),
|
||||
dispatchAddRegion: jest.fn(),
|
||||
dispatchUpdateRegion: jest.fn(),
|
||||
dispatchRemoveRegion: jest.fn(),
|
||||
dispatchVerifyCamera: jest.fn(),
|
||||
dispatchVerifyOnvif: jest.fn(),
|
||||
dispatchSend: jest.fn(),
|
||||
dispatchVerifyHub: vi.fn(),
|
||||
dispatchVerifyPersistence: vi.fn(),
|
||||
dispatchVerifySecondaryPersistence: vi.fn(),
|
||||
dispatchGetConfig: vi.fn(),
|
||||
dispatchUpdateConfig: vi.fn(),
|
||||
dispatchSaveConfig: vi.fn(),
|
||||
dispatchAddRegion: vi.fn(),
|
||||
dispatchUpdateRegion: vi.fn(),
|
||||
dispatchRemoveRegion: vi.fn(),
|
||||
dispatchVerifyCamera: vi.fn(),
|
||||
dispatchVerifyOnvif: vi.fn(),
|
||||
dispatchSend: vi.fn(),
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('starts and stops SD imagery with the conditions editor visibility', () => {
|
||||
@@ -105,8 +107,8 @@ describe('Settings liveview lifecycle', () => {
|
||||
selectedTab: 'conditions',
|
||||
search: '',
|
||||
};
|
||||
settings.initialiseLiveview = jest.fn();
|
||||
settings.stopLiveview = jest.fn();
|
||||
settings.initialiseLiveview = vi.fn();
|
||||
settings.stopLiveview = vi.fn();
|
||||
|
||||
settings.componentDidUpdate(props, {
|
||||
...settings.state,
|
||||
@@ -138,7 +140,7 @@ describe('Settings liveview lifecycle', () => {
|
||||
search: '',
|
||||
};
|
||||
settings.sdLiveviewActive = true;
|
||||
settings.requestSDLiveviewFrame = jest.fn();
|
||||
settings.requestSDLiveviewFrame = vi.fn();
|
||||
|
||||
settings.componentDidUpdate(
|
||||
{
|
||||
@@ -157,7 +159,7 @@ describe('Settings liveview lifecycle', () => {
|
||||
settings.props = props;
|
||||
settings.sdLiveviewActive = true;
|
||||
settings.requestStreamSubscription = {
|
||||
unsubscribe: jest.fn(),
|
||||
unsubscribe: vi.fn(),
|
||||
};
|
||||
|
||||
settings.componentWillUnmount();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// eslint-plugin-import 2.x cannot resolve packages that only define "exports".
|
||||
/* eslint-disable import/no-unresolved */
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: '/',
|
||||
server: {
|
||||
port: 3000,
|
||||
host: true,
|
||||
},
|
||||
preview: {
|
||||
port: 3000,
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
// public/assets already holds static files; keep bundled output separate.
|
||||
assetsDir: 'static',
|
||||
sourcemap: false,
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'jsdom',
|
||||
setupFiles: './src/setupTests.js',
|
||||
css: false,
|
||||
},
|
||||
});
|
||||
+800
-7365
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user