Compare commits
65 Commits
Author | SHA1 | Date |
---|---|---|
|
e697660a48 | |
|
694bb8ca19 | |
|
2c922fc0eb | |
|
740104df26 | |
|
8f9bfd071a | |
|
5fc66917c5 | |
|
089fcef4ca | |
|
a46c288744 | |
|
bd71cbbd0c | |
|
61b1b20e9a | |
|
7af2e396a9 | |
|
0a22fab875 | |
|
e5833f1f9c | |
|
c19cd3a889 | |
|
2e98137088 | |
|
c96da4e30f | |
|
4c47a71b84 | |
|
ebcf811bc7 | |
|
8e631e5da5 | |
|
11fca38500 | |
|
c3385ea7b8 | |
|
ac3dfd95a6 | |
|
baa78d8933 | |
|
11baf70a48 | |
|
38fc85e6df | |
|
f856f89a81 | |
|
5f22ef3e27 | |
|
a316f5a3fa | |
|
40c51ce4c7 | |
|
339cab776a | |
|
00991ad93c | |
|
e04dbdce01 | |
|
7c8b5fff1b | |
|
1f4d6e66e2 | |
|
2239fbf169 | |
|
251f363bc5 | |
|
3ca6108431 | |
|
0ef4cb8e5b | |
|
d77949f0dd | |
|
520d6bee7c | |
|
c038eacce4 | |
|
2de0b52143 | |
|
0a98f6fd35 | |
|
f3683624e3 | |
|
8633524a94 | |
|
9ab44b4b43 | |
|
aa5d2673c6 | |
|
c32f809e56 | |
|
d42cd02105 | |
|
b27228890e | |
|
15ec8f5dbe | |
|
088c88997f | |
|
bd266eb973 | |
|
ed49a7f23a | |
|
9064d51ba1 | |
|
fec13f71fa | |
|
63e3efac7d | |
|
51c92081c4 | |
|
abe31e46bd | |
|
d18ccefa26 | |
|
633a8e6192 | |
|
c8b5baf66b | |
|
9f338ddac7 | |
|
82d00ffa41 | |
|
ff9744d46a |
|
@ -1,4 +1,8 @@
|
|||
name: Build image
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
|
@ -9,33 +13,24 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
container:
|
||||
image: docker:dind
|
||||
volumes:
|
||||
- /data/.cache/act:/data/.cache/act
|
||||
- /var/lib/docker/image:/var/lib/docker/image
|
||||
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Starting docker daemon
|
||||
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
|
||||
- name: Installing necessary packages
|
||||
run: apk add nodejs git curl bash
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: https://github.com/docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
|
||||
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
|
||||
with:
|
||||
# list of Docker images to use as base name for tags
|
||||
images: |
|
||||
git.fai.st/fedi-image-bot/moderation-fe
|
||||
git.fai.st/${{ github.repository }}
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{raw}}
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2
|
||||
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
|
||||
- name: Login to fai.st docker registry
|
||||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
|
||||
with:
|
||||
|
@ -43,7 +38,7 @@ jobs:
|
|||
username: ${{ secrets.DOCKER_USER }}
|
||||
password: ${{ secrets.DOCKER_PASS }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # v4
|
||||
uses: docker/build-push-action@0adf9959216b96bec444f325f1e493d4aa344497 # v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
context: .
|
|
@ -0,0 +1,26 @@
|
|||
name: renovate
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
schedule:
|
||||
- cron: "@daily"
|
||||
|
||||
jobs:
|
||||
renovate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Self-hosted Renovate
|
||||
uses: https://github.com/renovatebot/github-action@e084b5ac6fd201023db6dd7743aec023babb02c8 # v41.0.13
|
||||
with:
|
||||
token: ${{ secrets.RENOVATE_TOKEN }}
|
||||
env-regex: "^(?:RENOVATE_\\w+|GITHUB_COM_TOKEN)$"
|
||||
env:
|
||||
RENOVATE_ENDPOINT: ${{ github.server_url }}
|
||||
RENOVATE_PLATFORM: "gitea"
|
||||
RENOVATE_GIT_AUTHOR: "Renovate Bot <contact@siesta.cat>"
|
||||
RENOVATE_REPOSITORIES: ${{ github.repository }}
|
||||
GITHUB_COM_TOKEN: ${{ secrets.RENOVATE_GHPAT }}
|
|
@ -0,0 +1 @@
|
|||
nodejs 23.8.0
|
|
@ -1,4 +1,4 @@
|
|||
FROM --platform=$BUILDPLATFORM node:23.5.0-alpine AS install
|
||||
FROM --platform=$BUILDPLATFORM node:23.8.0-alpine AS install
|
||||
RUN mkdir -p /temp/prod
|
||||
COPY package*.json /temp/prod/
|
||||
RUN cd /temp/prod && npm install --frozen-lockfile
|
||||
|
|
29
compose.yaml
29
compose.yaml
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
mongodb:
|
||||
image: mongo:bionic
|
||||
container_name: mongodb-fe
|
||||
container_name: fe-mongodb
|
||||
ports:
|
||||
- "27017:27017"
|
||||
environment:
|
||||
|
@ -10,32 +10,34 @@ services:
|
|||
MONGO_INITDB_DATABASE: bot
|
||||
volumes:
|
||||
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
|
||||
- mongodb_data:/data/db
|
||||
|
||||
bot-api:
|
||||
image: git.fai.st/fedi-image-bot/bot-api:latest
|
||||
container_name: bot-api-fe
|
||||
image: ghcr.io/siesta-cat/2chi-api:v1.1.0
|
||||
container_name: fe-2chi-api
|
||||
restart: on-failure
|
||||
ports:
|
||||
- 8080:8080
|
||||
depends_on:
|
||||
- mongodb
|
||||
environment:
|
||||
PORT: 8080
|
||||
MONGODB_URI: "mongodb://mongodb:27017/bot"
|
||||
MONGODB_USER: "root"
|
||||
MONGODB_PASS: "password"
|
||||
JWTSECRET: "cooljwtsecret"
|
||||
DB_HOST: "mongodb"
|
||||
DB_NAME: "bot"
|
||||
DB_USER: "root"
|
||||
DB_PASS: "password"
|
||||
|
||||
fe-middleware:
|
||||
image: git.fai.st/fedi-image-bot/fe-middleware:latest
|
||||
container_name: fe-middleware-fe
|
||||
image: ghcr.io/siesta-cat/2chi-verifier-be:v2.1.3
|
||||
container_name: fe-2chi-verifier-be
|
||||
stop_signal: sigkill
|
||||
ports:
|
||||
- 8081:8081
|
||||
depends_on:
|
||||
- bot-api
|
||||
environment:
|
||||
PORT: 8081
|
||||
BOT_API_URI: "http://bot-api:8080"
|
||||
BOT_API_BASE_URL: "http://bot-api:8080"
|
||||
TOKEN_SECRET: Y2hpY2FzZWNyZXQK
|
||||
GELBOORU_IMAGES_PER_REQUEST: 100 # Number of images per request, maximum 100
|
||||
GELBOORU_TAGS: "2girls sleeping" # Tags of the images. The images will have all of these tags
|
||||
|
||||
|
@ -44,12 +46,11 @@ services:
|
|||
container_name: bot-image-moderation-fe
|
||||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
VITE_BACKEND_URL: "http://localhost:8081"
|
||||
develop:
|
||||
watch:
|
||||
- action: rebuild
|
||||
path: .
|
||||
ignore:
|
||||
- node_modules/
|
||||
|
||||
volumes:
|
||||
mongodb_data:
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"react-dom": "19.0.0",
|
||||
"typescript": "5.7.2",
|
||||
"vite": "6.0.7"
|
||||
"typescript": "5.7.3",
|
||||
"vite": "6.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-dom": "19.0.2",
|
||||
"@vitejs/plugin-react-swc": "3.7.2"
|
||||
"@types/react-dom": "19.0.4",
|
||||
"@vitejs/plugin-react-swc": "3.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
|
@ -417,8 +417,192 @@
|
|||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.3.tgz",
|
||||
"integrity": "sha512-8kq/NjMKkMTGKMPldWihncOl62kgnLYk7cW+/4NCUWfS70/wz4+gQ7rMxMMpZ3dIOP/xw7wKNzIuUnN/H2GfUg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm64": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.3.tgz",
|
||||
"integrity": "sha512-1PqMHiuRochQ6++SDI7SaRDWJKr/NgAlezBi5nOne6Da6IWJo3hK0TdECBDwd92IUDPG4j/bZmWuwOnomNT8wA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.3.tgz",
|
||||
"integrity": "sha512-fqbrykX4mGV3DlCDXhF4OaMGcchd2tmLYxVt3On5oOZWVDFfdEoYAV2alzNChl8OzNaeMAGqm1f7gk7eIw/uDg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-darwin-x64": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.3.tgz",
|
||||
"integrity": "sha512-8Wxrx/KRvMsTyLTbdrMXcVKfpW51cCNW8x7iQD72xSEbjvhCY3b+w83Bea3nQfysTMR7K28esc+ZFITThXm+1w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-arm64": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.3.tgz",
|
||||
"integrity": "sha512-lpBmV2qSiELh+ATQPTjQczt5hvbTLsE0c43Rx4bGxN2VpnAZWy77we7OO62LyOSZNY7CzjMoceRPc+Lt4e9J6A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-freebsd-x64": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.3.tgz",
|
||||
"integrity": "sha512-sNPvBIXpgaYcI6mAeH13GZMXFrrw5mdZVI1M9YQPRG2LpjwL8DSxSIflZoh/B5NEuOi53kxsR/S2GKozK1vDXA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.3.tgz",
|
||||
"integrity": "sha512-MW6N3AoC61OfE1VgnN5O1OW0gt8VTbhx9s/ZEPLBM11wEdHjeilPzOxVmmsrx5YmejpGPvez8QwGGvMU+pGxpw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm-musleabihf": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.3.tgz",
|
||||
"integrity": "sha512-2SQkhr5xvatYq0/+H6qyW0zvrQz9LM4lxGkpWURLoQX5+yP8MsERh4uWmxFohOvwCP6l/+wgiHZ1qVwLDc7Qmw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-R3JLYt8YoRwKI5shJsovLpcR6pwIMui/MGG/MmxZ1DYI3iRSKI4qcYrvYgDf4Ss2oCR3RL3F3dYK7uAGQgMIuQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.3.tgz",
|
||||
"integrity": "sha512-4XQhG8v/t3S7Rxs7rmFUuM6j09hVrTArzONS3fUZ6oBRSN/ps9IPQjVhp62P0W3KhqJdQADo/MRlYRMdgxr/3w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-loongarch64-gnu": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-QlW1jCUZ1LHUIYCAK2FciVw1ptHsxzApYVi05q7bz2A8oNE8QxQ85NhM4arLxkAlcnS42t4avJbSfzSQwbIaKg==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-kMbLToizVeCcN69+nnm20Dh0hrRIAjgaaL+Wh0gWZcNt8e542d2FUGtsyuNsHVNNF3gqTJrpzUGIdwMGLEUM7g==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-YgD0DnZ3CHtvXRH8rzjVSxwI0kMTr0RQt3o1N92RwxGdx7YejzbBO0ELlSU48DP96u1gYYVWfUhDRyaGNqJqJg==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-dIOoOz8altjp6UjAi3U9EW99s8nta4gzi52FeI45GlPyrUH4QixUoBMH9VsVjt+9A2RiZBWyjYNHlJ/HmJOBCQ==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||
"version": "4.28.0",
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.3.tgz",
|
||||
"integrity": "sha512-lOyG3aF4FTKrhpzXfMmBXgeKUUXdAWmP2zSNf8HTAXPqZay6QYT26l64hVizBjq+hJx3pl0DTEyvPi9sTA6VGA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
@ -429,7 +613,9 @@
|
|||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||
"version": "4.28.0",
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.3.tgz",
|
||||
"integrity": "sha512-usztyYLu2i+mYzzOjqHZTaRXbUOqw3P6laNUh1zcqxbPH1P2Tz/QdJJCQSnGxCtsRQeuU2bCyraGMtMumC46rw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
@ -439,8 +625,49 @@
|
|||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.3.tgz",
|
||||
"integrity": "sha512-ojFOKaz/ZyalIrizdBq2vyc2f0kFbJahEznfZlxdB6pF9Do6++i1zS5Gy6QLf8D7/S57MHrmBLur6AeRYeQXSA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.3.tgz",
|
||||
"integrity": "sha512-K/V97GMbNa+Da9mGcZqmSl+DlJmWfHXTuI9V8oB2evGsQUtszCl67+OxWjBKpeOnYwox9Jpmt/J6VhpeRCYqow==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.3.tgz",
|
||||
"integrity": "sha512-CUypcYP31Q8O04myV6NKGzk9GVXslO5EJNfmARNSzLF2A+5rmZUlDJ4et6eoJaZgBT9wrC2p4JZH04Vkic8HdQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@swc/core": {
|
||||
"version": "1.9.3",
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.10.15.tgz",
|
||||
"integrity": "sha512-/iFeQuNaGdK7mfJbQcObhAhsMqLT7qgMYl7jX2GEIO+VDTejESpzAyKwaMeYXExN8D6e5BRHBCe7M5YlsuzjDA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
|
@ -456,16 +683,16 @@
|
|||
"url": "https://opencollective.com/swc"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@swc/core-darwin-arm64": "1.9.3",
|
||||
"@swc/core-darwin-x64": "1.9.3",
|
||||
"@swc/core-linux-arm-gnueabihf": "1.9.3",
|
||||
"@swc/core-linux-arm64-gnu": "1.9.3",
|
||||
"@swc/core-linux-arm64-musl": "1.9.3",
|
||||
"@swc/core-linux-x64-gnu": "1.9.3",
|
||||
"@swc/core-linux-x64-musl": "1.9.3",
|
||||
"@swc/core-win32-arm64-msvc": "1.9.3",
|
||||
"@swc/core-win32-ia32-msvc": "1.9.3",
|
||||
"@swc/core-win32-x64-msvc": "1.9.3"
|
||||
"@swc/core-darwin-arm64": "1.10.15",
|
||||
"@swc/core-darwin-x64": "1.10.15",
|
||||
"@swc/core-linux-arm-gnueabihf": "1.10.15",
|
||||
"@swc/core-linux-arm64-gnu": "1.10.15",
|
||||
"@swc/core-linux-arm64-musl": "1.10.15",
|
||||
"@swc/core-linux-x64-gnu": "1.10.15",
|
||||
"@swc/core-linux-x64-musl": "1.10.15",
|
||||
"@swc/core-win32-arm64-msvc": "1.10.15",
|
||||
"@swc/core-win32-ia32-msvc": "1.10.15",
|
||||
"@swc/core-win32-x64-msvc": "1.10.15"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@swc/helpers": "*"
|
||||
|
@ -476,8 +703,95 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-darwin-arm64": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.10.15.tgz",
|
||||
"integrity": "sha512-zFdZ6/yHqMCPk7OhLFqHy/MQ1EqJhcZMpNHd1gXYT7VRU3FaqvvKETrUlG3VYl65McPC7AhMRfXPyJ0JO/jARQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-darwin-x64": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.10.15.tgz",
|
||||
"integrity": "sha512-8g4yiQwbr8fxOOjKXdot0dEkE5zgE8uNZudLy/ZyAhiwiZ8pbJ8/wVrDOu6dqbX7FBXAoDnvZ7fwN1jk4C8jdA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-linux-arm-gnueabihf": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.10.15.tgz",
|
||||
"integrity": "sha512-rl+eVOltl2+7WXOnvmWBpMgh6aO13G5x0U0g8hjwlmD6ku3Y9iRcThpOhm7IytMEarUp5pQxItNoPq+VUGjVHg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-linux-arm64-gnu": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.10.15.tgz",
|
||||
"integrity": "sha512-qxWEQeyAJMWJqjaN4hi58WMpPdt3Tn0biSK9CYRegQtvZWCbewr6v2agtSu5AZ2rudeH6OfCWAMDQQeSgn6PJQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-linux-arm64-musl": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.10.15.tgz",
|
||||
"integrity": "sha512-QcELd9/+HjZx0WCxRrKcyKGWTiQ0485kFb5w8waxcSNd0d9Lgk4EFfWWVyvIb5gIHpDQmhrgzI/yRaWQX4YSZQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-linux-x64-gnu": {
|
||||
"version": "1.9.3",
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.10.15.tgz",
|
||||
"integrity": "sha512-S1+ZEEn3+a/MiMeQqQypbwTGoBG8/sPoCvpNbk+uValyygT+jSn3U0xVr45FbukpmMB+NhBMqfedMLqKA0QnJA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
@ -492,7 +806,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@swc/core-linux-x64-musl": {
|
||||
"version": "1.9.3",
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.10.15.tgz",
|
||||
"integrity": "sha512-qW+H9g/2zTJ4jP7NDw4VAALY0ZlNEKzYsEoSj/HKi7k3tYEHjMzsxjfsY9I8WZCft23bBdV3RTCPoxCshaj1CQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
|
@ -506,6 +822,57 @@
|
|||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-win32-arm64-msvc": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.10.15.tgz",
|
||||
"integrity": "sha512-AhRB11aA6LxjIqut+mg7qsu/7soQDmbK6MKR9nP3hgBszpqtXbRba58lr24xIbBCMr+dpo6kgEapWt+t5Po6Zg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-win32-ia32-msvc": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.10.15.tgz",
|
||||
"integrity": "sha512-UGdh430TQwbDn6KjgvRTg1fO022sbQ4yCCHUev0+5B8uoBwi9a89qAz3emy2m56C8TXxUoihW9Y9OMfaRwPXUw==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/core-win32-x64-msvc": {
|
||||
"version": "1.10.15",
|
||||
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.10.15.tgz",
|
||||
"integrity": "sha512-XJzBCqO1m929qbJsOG7FZXQWX26TnEoMctS3QjuCoyBmkHxxQmZsy78KjMes1aomTcKHCyFYgrRGWgVmk7tT4Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "Apache-2.0 AND MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@swc/counter": {
|
||||
"version": "0.1.3",
|
||||
"dev": true,
|
||||
|
@ -544,9 +911,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/react-dom": {
|
||||
"version": "19.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.2.tgz",
|
||||
"integrity": "sha512-c1s+7TKFaDRRxr1TxccIX2u7sfCnc3RxkVyBIUA2lCpyqCF+QoAwQ/CBg7bsMdVwP120HEH143VQezKtef5nCg==",
|
||||
"version": "19.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.0.4.tgz",
|
||||
"integrity": "sha512-4fSQ8vWFkg+TGhePfUzVmat3eC14TXYSsiiDSLI0dVLsrm9gZFABjPy/Qu6TKgl1tq1Bu1yDsuQgY3A3DOjCcg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
|
@ -554,13 +921,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@vitejs/plugin-react-swc": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.7.2.tgz",
|
||||
"integrity": "sha512-y0byko2b2tSVVf5Gpng1eEhX1OvPC7x8yns1Fx8jDzlJp4LS6CMkCPfLw47cjyoMrshQDoQw4qcgjsU9VvlCew==",
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.8.0.tgz",
|
||||
"integrity": "sha512-T4sHPvS+DIqDP51ifPqa9XIRAz/kIvIi8oXcnOZZgHmMotgmmdxe/DD5tMFlt5nuIRzT0/QuiwmKlH0503Aapw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@swc/core": "^1.7.26"
|
||||
"@swc/core": "^1.10.15"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4 || ^5 || ^6"
|
||||
|
@ -647,7 +1014,9 @@
|
|||
"license": "ISC"
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.4.49",
|
||||
"version": "8.5.2",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.2.tgz",
|
||||
"integrity": "sha512-MjOadfU3Ys9KYoX0AdkBlFEF1Vx37uCCeN4ZHnmwm9FfpbsGWMZeBLMmmpY+6Ocqod7mkdZ0DT31OlbsFrLlkA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
|
@ -664,7 +1033,7 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.7",
|
||||
"nanoid": "^3.3.8",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
},
|
||||
|
@ -695,7 +1064,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "4.28.0",
|
||||
"version": "4.34.3",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.3.tgz",
|
||||
"integrity": "sha512-ORCtU0UBJyiAIn9m0llUXJXAswG/68pZptCrqxHG7//Z2DDzAUeyyY5hqf4XrsGlUxscMr9GkQ2QI7KTLqeyPw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "1.0.6"
|
||||
|
@ -708,24 +1079,25 @@
|
|||
"npm": ">=8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rollup/rollup-android-arm-eabi": "4.28.0",
|
||||
"@rollup/rollup-android-arm64": "4.28.0",
|
||||
"@rollup/rollup-darwin-arm64": "4.28.0",
|
||||
"@rollup/rollup-darwin-x64": "4.28.0",
|
||||
"@rollup/rollup-freebsd-arm64": "4.28.0",
|
||||
"@rollup/rollup-freebsd-x64": "4.28.0",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.28.0",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.28.0",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.28.0",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.28.0",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.28.0",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.28.0",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.28.0",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.28.0",
|
||||
"@rollup/rollup-linux-x64-musl": "4.28.0",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.28.0",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.28.0",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.28.0",
|
||||
"@rollup/rollup-android-arm-eabi": "4.34.3",
|
||||
"@rollup/rollup-android-arm64": "4.34.3",
|
||||
"@rollup/rollup-darwin-arm64": "4.34.3",
|
||||
"@rollup/rollup-darwin-x64": "4.34.3",
|
||||
"@rollup/rollup-freebsd-arm64": "4.34.3",
|
||||
"@rollup/rollup-freebsd-x64": "4.34.3",
|
||||
"@rollup/rollup-linux-arm-gnueabihf": "4.34.3",
|
||||
"@rollup/rollup-linux-arm-musleabihf": "4.34.3",
|
||||
"@rollup/rollup-linux-arm64-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-arm64-musl": "4.34.3",
|
||||
"@rollup/rollup-linux-loongarch64-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-powerpc64le-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-riscv64-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-s390x-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-x64-gnu": "4.34.3",
|
||||
"@rollup/rollup-linux-x64-musl": "4.34.3",
|
||||
"@rollup/rollup-win32-arm64-msvc": "4.34.3",
|
||||
"@rollup/rollup-win32-ia32-msvc": "4.34.3",
|
||||
"@rollup/rollup-win32-x64-msvc": "4.34.3",
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
|
@ -743,9 +1115,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.7.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||
"version": "5.7.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
|
||||
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
|
@ -762,14 +1134,14 @@
|
|||
"peer": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "6.0.7",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.0.7.tgz",
|
||||
"integrity": "sha512-RDt8r/7qx9940f8FcOIAH9PTViRrghKaK2K1jY3RaAURrEUbm9Du1mJ72G+jlhtG3WwodnfzY8ORQZbBavZEAQ==",
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-6.1.1.tgz",
|
||||
"integrity": "sha512-4GgM54XrwRfrOp297aIYspIti66k56v16ZnqHvrIM7mG+HjDlAwS7p+Srr7J6fGvEdOJ5JcQ/D9T7HhtdXDTzA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.24.2",
|
||||
"postcss": "^8.4.49",
|
||||
"rollup": "^4.23.0"
|
||||
"postcss": "^8.5.2",
|
||||
"rollup": "^4.30.1"
|
||||
},
|
||||
"bin": {
|
||||
"vite": "bin/vite.js"
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"react-dom": "19.0.0",
|
||||
"typescript": "5.7.2",
|
||||
"vite": "6.0.7"
|
||||
"typescript": "5.7.3",
|
||||
"vite": "6.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-dom": "19.0.2",
|
||||
"@vitejs/plugin-react-swc": "3.7.2"
|
||||
"@types/react-dom": "19.0.4",
|
||||
"@vitejs/plugin-react-swc": "3.8.0"
|
||||
}
|
||||
}
|
||||
|
|
20
src/App.tsx
20
src/App.tsx
|
@ -1,24 +1,14 @@
|
|||
import { useState } from "react";
|
||||
import GetBackendUrl from "./components/ImageModerator/GetBackendUrl";
|
||||
import ImageModerator from "./components/ImageModerator/ImageModerator";
|
||||
import Login from "./components/Login/Login";
|
||||
|
||||
function App() {
|
||||
const [{ apiUrl, middlewareUrl, token }, setRemote] = useState({
|
||||
apiUrl: "",
|
||||
middlewareUrl: "",
|
||||
token: "",
|
||||
});
|
||||
const [backendUrl, setBackendUrl] = useState("");
|
||||
|
||||
if (token) {
|
||||
return (
|
||||
<ImageModerator
|
||||
token={token}
|
||||
apiUrl={apiUrl}
|
||||
middlewareUrl={middlewareUrl}
|
||||
/>
|
||||
);
|
||||
if (backendUrl) {
|
||||
return <ImageModerator backendUrl={backendUrl} />;
|
||||
} else {
|
||||
return <Login setRemote={setRemote} />;
|
||||
return <GetBackendUrl setRemote={setBackendUrl} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function GetBackendUrl({ setRemote }: { setRemote: Function }) {
|
||||
const sendLabel = "Input Backend URL";
|
||||
const [backendUrl, setBackendUrl] = useState("");
|
||||
|
||||
function sendAction() {
|
||||
event?.preventDefault();
|
||||
try {
|
||||
if (backendUrl) {
|
||||
localStorage.setItem("backendUrl", backendUrl);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
setRemote(backendUrl);
|
||||
}
|
||||
|
||||
function handleChange(
|
||||
e: {
|
||||
target: { value: React.SetStateAction<string> };
|
||||
},
|
||||
setter: React.Dispatch<React.SetStateAction<string>>
|
||||
): void {
|
||||
setter(e.target.value);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const savedRemote = localStorage.getItem("backendUrl");
|
||||
|
||||
if (savedRemote) {
|
||||
setRemote(savedRemote);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
}}>
|
||||
<form
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
onSubmit={sendAction}>
|
||||
<label>Backend URL: </label>
|
||||
<input
|
||||
type="url"
|
||||
id="backend"
|
||||
name="backend"
|
||||
value={backendUrl}
|
||||
onChange={(e) => handleChange(e, setBackendUrl)}
|
||||
/>
|
||||
<button type="submit">{sendLabel}</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -2,50 +2,45 @@ import { useEffect, useState } from "react";
|
|||
import Button from "../Button/Button";
|
||||
|
||||
interface ImageModeratorProps {
|
||||
token: string;
|
||||
apiUrl: string;
|
||||
middlewareUrl: string;
|
||||
backendUrl: string;
|
||||
}
|
||||
|
||||
export default function ImageModerator({
|
||||
token,
|
||||
apiUrl,
|
||||
middlewareUrl,
|
||||
}: ImageModeratorProps) {
|
||||
export default function ImageModerator({ backendUrl }: ImageModeratorProps) {
|
||||
const acceptLabel = "Accept";
|
||||
const discardLabel = "Discard";
|
||||
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [imageData, setImageData] = useState({ url: "", tags: [] });
|
||||
const [imageAlt, setImageAlt] = useState("No image");
|
||||
const [imageData, setImageData] = useState({
|
||||
url: "",
|
||||
token: "",
|
||||
alt: "No image",
|
||||
});
|
||||
|
||||
function acceptAction() {
|
||||
fetch(`${apiUrl}/images`, {
|
||||
fetch(`${backendUrl}/image/review`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
url: imageData.url,
|
||||
status: "available",
|
||||
tags: imageData.tags,
|
||||
token: imageData.token,
|
||||
is_accepted: true,
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
setIsLoading(true);
|
||||
}
|
||||
|
||||
function discardAction() {
|
||||
fetch(`${apiUrl}/images`, {
|
||||
fetch(`${backendUrl}/image/review`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
url: imageData.url,
|
||||
status: "unavailable",
|
||||
tags: imageData.tags,
|
||||
token: imageData.token,
|
||||
is_accepted: false,
|
||||
}),
|
||||
headers: {
|
||||
"Content-type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
setIsLoading(true);
|
||||
|
@ -53,8 +48,8 @@ export default function ImageModerator({
|
|||
|
||||
const getNewImage = () => {
|
||||
if (isLoading) {
|
||||
setImageData({ url: "", tags: [] });
|
||||
fetch(`${middlewareUrl}/image`, {
|
||||
setImageData({ url: "", token: "", alt: "Loading..." });
|
||||
fetch(`${backendUrl}/image`, {
|
||||
method: "GET",
|
||||
})
|
||||
.then((response) => {
|
||||
|
@ -62,13 +57,10 @@ export default function ImageModerator({
|
|||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
const url = data.url;
|
||||
const tags = data.tags;
|
||||
setImageData({ url, tags });
|
||||
setImageAlt(url);
|
||||
setImageData({ url: data.url, token: data.token, alt: data.url });
|
||||
})
|
||||
.catch((error) => {
|
||||
setImageAlt("Error");
|
||||
setImageData({ url: "", token: "", alt: "Error" });
|
||||
console.error(error);
|
||||
})
|
||||
.finally(() => {
|
||||
|
@ -94,7 +86,7 @@ export default function ImageModerator({
|
|||
) : (
|
||||
<img
|
||||
src={imageData.url}
|
||||
alt={imageAlt}
|
||||
alt={imageData.alt}
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function Login({ setRemote }: { setRemote: Function }) {
|
||||
const sendLabel = "Login";
|
||||
const [middlewareUrl, setMiddlewareUrl] = useState("");
|
||||
const [apiUrl, setApiUrl] = useState("");
|
||||
const [app, setApp] = useState("");
|
||||
const [secret, setSecret] = useState("");
|
||||
|
||||
function sendAction() {
|
||||
event?.preventDefault();
|
||||
try {
|
||||
if (apiUrl && middlewareUrl && app && secret) {
|
||||
localStorage.setItem(
|
||||
"credentials",
|
||||
JSON.stringify({ apiUrl, middlewareUrl, app, secret })
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
fetch(`${apiUrl}/login`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ app, secret }),
|
||||
headers: { "Content-type": "application/json" },
|
||||
})
|
||||
.then((response) => {
|
||||
return response.json();
|
||||
})
|
||||
.then((body) => {
|
||||
setRemote({ apiUrl, middlewareUrl, token: body.token });
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(
|
||||
e: {
|
||||
target: { value: React.SetStateAction<string> };
|
||||
},
|
||||
setter: React.Dispatch<React.SetStateAction<string>>
|
||||
): void {
|
||||
setter(e.target.value);
|
||||
}
|
||||
useEffect(() => {
|
||||
const savedRemote = localStorage.getItem("credentials");
|
||||
|
||||
if (savedRemote) {
|
||||
const savedData = JSON.parse(savedRemote);
|
||||
setApiUrl(savedData.apiUrl);
|
||||
setMiddlewareUrl(savedData.middlewareUrl);
|
||||
setApp(savedData.app);
|
||||
setSecret(savedData.secret);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (secret) {
|
||||
sendAction();
|
||||
}
|
||||
}, [secret]);
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
}}>
|
||||
<form
|
||||
style={{
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
onSubmit={sendAction}>
|
||||
<label>API URL: </label>
|
||||
<input
|
||||
type="url"
|
||||
id="api"
|
||||
name="api"
|
||||
value={apiUrl}
|
||||
onChange={(e) => handleChange(e, setApiUrl)}
|
||||
/>
|
||||
<label>Source URL: </label>
|
||||
<input
|
||||
type="url"
|
||||
id="middleware"
|
||||
name="middleware"
|
||||
value={middlewareUrl}
|
||||
onChange={(e) => handleChange(e, setMiddlewareUrl)}
|
||||
/>
|
||||
<label>App name: </label>
|
||||
<input
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
value={app}
|
||||
onChange={(e) => handleChange(e, setApp)}
|
||||
/>
|
||||
<label>Secret: </label>
|
||||
<input
|
||||
type="password"
|
||||
value={secret}
|
||||
onChange={(e) => handleChange(e, setSecret)}
|
||||
/>
|
||||
<button type="submit">{sendLabel}</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue