Compare commits

..

65 Commits
v1.1.1 ... main

Author SHA1 Message Date
bizcochito e697660a48 Merge pull request 'chore(deps): update https://github.com/renovatebot/github-action action to v41.0.13' (#64) from renovate/https-github.com-renovatebot-github-action-41.x into main
renovate / renovate (push) Successful in 1m18s Details
Reviewed-on: #64
2025-02-22 19:19:55 +00:00
Renovate Bot 694bb8ca19 chore(deps): update https://github.com/renovatebot/github-action action to v41.0.13 2025-02-22 19:15:01 +00:00
bizcochito 2c922fc0eb Merge pull request 'chore(deps): pin dependencies' (#63) from renovate/pin-dependencies into main
renovate / renovate (push) Successful in 57s Details
Reviewed-on: #63
2025-02-22 19:14:07 +00:00
Alie 740104df26 add renovate yaml
renovate / renovate (push) Successful in 1m55s Details
2025-02-22 20:12:25 +01:00
Renovate Bot 8f9bfd071a chore(deps): pin dependencies 2025-02-22 19:10:43 +00:00
bizcochito 5fc66917c5 Merge pull request 'chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.1.0' (#62) from renovate/ghcr.io-siesta-cat-2chi-api-1.x into main
Reviewed-on: #62
2025-02-22 13:12:39 +00:00
Renovate Bot 089fcef4ca chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.1.0 2025-02-22 13:01:12 +00:00
bizcochito a46c288744 Merge pull request 'chore(deps): update docker/setup-buildx-action digest to f7ce87c' (#61) from renovate/docker-setup-buildx-action-digest into main
Reviewed-on: #61
2025-02-21 19:03:56 +00:00
bizcochito bd71cbbd0c Merge pull request 'chore(deps): update docker/build-push-action digest to 0adf995' (#60) from renovate/docker-build-push-action-digest into main
Reviewed-on: #60
2025-02-21 17:38:26 +00:00
Renovate Bot 61b1b20e9a chore(deps): update docker/setup-buildx-action digest to f7ce87c
Build image / build (pull_request) Successful in 18m1s Details
2025-02-21 17:01:28 +00:00
Renovate Bot 7af2e396a9 chore(deps): update docker/build-push-action digest to 0adf995
Build image / build (pull_request) Successful in 27m44s Details
2025-02-21 17:01:25 +00:00
bizcochito 0a22fab875 Merge pull request 'chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.5' (#59) from renovate/ghcr.io-siesta-cat-2chi-api-1.x into main
Build image / build (push) Successful in 1m53s Details
Reviewed-on: #59
2025-02-21 16:31:31 +00:00
bizcochito e5833f1f9c Merge pull request 'chore(deps): update ghcr.io/siesta-cat/2chi-verifier-be docker tag to v2.1.3' (#58) from renovate/ghcr.io-siesta-cat-2chi-verifier-be-2.x into main
Reviewed-on: #58
2025-02-21 16:31:24 +00:00
Alie c19cd3a889 chore: fix build pipeline 2025-02-21 17:34:26 +01:00
Renovate Bot 2e98137088 chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.5 2025-02-21 16:01:32 +00:00
Renovate Bot c96da4e30f chore(deps): update ghcr.io/siesta-cat/2chi-verifier-be docker tag to v2.1.3 2025-02-21 15:02:16 +00:00
bizcochito 4c47a71b84 Merge pull request 'chore(deps): update docker/build-push-action digest to 0adf995' (#57) from renovate/docker-build-push-action-digest into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#57
2025-02-20 15:13:01 +00:00
bizcochito ebcf811bc7 Merge pull request 'fix(deps): update dependency vite to v6.1.1' (#56) from renovate/vite-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#56
2025-02-20 10:51:42 +00:00
Renovate Bot 8e631e5da5 chore(deps): update docker/build-push-action digest to 0adf995
Build image / build (pull_request) Successful in 52s Details
2025-02-19 16:01:06 +00:00
Renovate Bot 11fca38500 fix(deps): update dependency vite to v6.1.1 2025-02-19 10:01:35 +00:00
bizcochito c3385ea7b8 Merge pull request 'chore(deps): update dependency @types/react-dom to v19.0.4' (#55) from renovate/react-monorepo into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#55
2025-02-17 10:52:33 +00:00
bizcochito ac3dfd95a6 Merge pull request 'chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.4' (#54) from renovate/ghcr.io-siesta-cat-2chi-api-1.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#54
2025-02-17 10:52:27 +00:00
Renovate Bot baa78d8933 chore(deps): update dependency @types/react-dom to v19.0.4 2025-02-17 10:01:40 +00:00
Renovate Bot 11baf70a48 chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.4 2025-02-15 14:01:00 +00:00
bizcochito 38fc85e6df Merge pull request 'chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.3' (#53) from renovate/ghcr.io-siesta-cat-2chi-api-1.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#53
2025-02-15 13:17:47 +00:00
Renovate Bot f856f89a81 chore(deps): update ghcr.io/siesta-cat/2chi-api docker tag to v1.0.3 2025-02-15 12:01:05 +00:00
bizcochito 5f22ef3e27 Merge pull request 'chore(deps): update node.js to v23.8.0' (#52) from renovate/node-23.x into main
Build image / build (push) Successful in 1m2s Details
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#52
2025-02-14 21:21:23 +00:00
Renovate Bot a316f5a3fa chore(deps): update node.js to v23.8.0 2025-02-14 11:00:57 +00:00
Alie 40c51ce4c7 fix: issue with getbackendurl cache 2025-02-12 13:13:37 +01:00
Alie 339cab776a feat: consolidate alt text in same useState 2025-02-12 13:13:18 +01:00
Alie 00991ad93c BREAKING CHANGE: deprecated use of auth and bot api to only use 2chi verifier be 2025-02-12 13:01:37 +01:00
bizcochito e04dbdce01 Merge pull request 'chore(deps): update dependency @vitejs/plugin-react-swc to v3.8.0' (#51) from renovate/vitejs-plugin-react-swc-3.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#51
2025-02-12 09:42:23 +00:00
bizcochito 7c8b5fff1b Merge pull request 'fix(deps): update dependency vite to v6.1.0' (#49) from renovate/vite-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#49
2025-02-12 09:41:41 +00:00
Renovate Bot 1f4d6e66e2 chore(deps): update dependency @vitejs/plugin-react-swc to v3.8.0 2025-02-09 00:02:41 +00:00
bizcochito 2239fbf169 Merge pull request 'chore(deps): update docker/setup-buildx-action digest to f7ce87c' (#50) from renovate/docker-setup-buildx-action-digest into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#50
2025-02-07 11:04:44 +00:00
Renovate Bot 251f363bc5 chore(deps): update docker/setup-buildx-action digest to f7ce87c
Build image / build (pull_request) Successful in 1m57s Details
2025-02-06 14:00:51 +00:00
Renovate Bot 3ca6108431 fix(deps): update dependency vite to v6.1.0 2025-02-05 14:01:11 +00:00
bizcochito 0ef4cb8e5b Merge pull request 'chore(deps): update node.js to v23.7.0' (#48) from renovate/node-23.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#48
2025-02-02 21:08:56 +00:00
Renovate Bot d77949f0dd chore(deps): update node.js to v23.7.0 2025-01-31 20:00:50 +00:00
bizcochito 520d6bee7c Merge pull request 'chore(deps): update docker/build-push-action digest to ca877d9' (#47) from renovate/docker-build-push-action-digest into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#47
2025-01-24 14:27:38 +00:00
bizcochito c038eacce4 Merge pull request 'chore(deps): update node.js to v23.6.1' (#46) from renovate/node-23.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#46
2025-01-24 14:27:11 +00:00
Renovate Bot 2de0b52143 chore(deps): update docker/build-push-action digest to ca877d9
Build image / build (pull_request) Successful in 1m44s Details
2025-01-24 10:00:45 +00:00
Renovate Bot 0a98f6fd35 chore(deps): update node.js to v23.6.1 2025-01-22 17:00:59 +00:00
bizcochito f3683624e3 Merge pull request 'fix(deps): update dependency vite to v6.0.11' (#45) from renovate/vite-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#45
2025-01-21 11:11:28 +00:00
Renovate Bot 8633524a94 fix(deps): update dependency vite to v6.0.11 2025-01-21 11:01:38 +00:00
bizcochito 9ab44b4b43 Merge pull request 'fix(deps): update dependency vite to v6.0.10' (#44) from renovate/vite-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#44
2025-01-21 10:22:40 +00:00
Renovate Bot aa5d2673c6 fix(deps): update dependency vite to v6.0.10 2025-01-20 20:01:54 +00:00
bizcochito c32f809e56 Merge pull request 'fix(deps): update dependency vite to v6.0.9' (#43) from renovate/vite-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#43
2025-01-20 11:54:30 +00:00
Renovate Bot d42cd02105 fix(deps): update dependency vite to v6.0.9 2025-01-20 10:03:07 +00:00
bizcochito b27228890e Merge pull request 'chore(deps): update docker/build-push-action digest to 67a2d40' (#42) from renovate/docker-build-push-action-digest into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#42
2025-01-15 18:43:57 +00:00
Renovate Bot 15ec8f5dbe chore(deps): update docker/build-push-action digest to 67a2d40
Build image / build (pull_request) Successful in 1m30s Details
2025-01-15 13:00:48 +00:00
bizcochito 088c88997f Merge pull request 'chore(deps): update dependency @types/react-dom to v19.0.3' (#41) from renovate/react-monorepo into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#41
2025-01-12 11:46:20 +00:00
Renovate Bot bd266eb973 chore(deps): update dependency @types/react-dom to v19.0.3 2025-01-12 11:01:48 +00:00
bizcochito ed49a7f23a Merge pull request 'fix(deps): update dependency typescript to v5.7.3' (#40) from renovate/typescript-5.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#40
2025-01-10 13:23:19 +00:00
bizcochito 9064d51ba1 Merge pull request 'chore(deps): update node.js to v23.6.0' (#38) from renovate/node-23.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#38
2025-01-10 13:23:08 +00:00
bizcochito fec13f71fa Merge pull request 'chore(deps): update docker/build-push-action digest to b32b51a' (#39) from renovate/docker-build-push-action-digest into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#39
2025-01-09 17:58:01 +00:00
Renovate Bot 63e3efac7d fix(deps): update dependency typescript to v5.7.3 2025-01-08 20:03:28 +00:00
Renovate Bot 51c92081c4 chore(deps): update docker/build-push-action digest to b32b51a
Build image / build (pull_request) Successful in 1m26s Details
2025-01-08 10:01:03 +00:00
Renovate Bot abe31e46bd chore(deps): update node.js to v23.6.0 2025-01-08 02:00:47 +00:00
bizcochito d18ccefa26 fix: pin docker compose images 2025-01-07 10:14:33 +00:00
bizcochito 633a8e6192 Merge pull request 'chore(deps): update docker/setup-buildx-action action to v3' (#37) from renovate/docker-setup-buildx-action-3.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#37
2025-01-03 11:46:32 +00:00
bizcochito c8b5baf66b Merge pull request 'chore(deps): update docker/build-push-action action to v6' (#36) from renovate/docker-build-push-action-6.x into main
Reviewed-on: fedi-image-bot/bot-image-moderation-fe#36
2025-01-03 11:46:08 +00:00
Renovate Bot 9f338ddac7 chore(deps): update docker/setup-buildx-action action to v3
Build image / build (pull_request) Successful in 1m45s Details
2025-01-03 11:43:03 +00:00
Renovate Bot 82d00ffa41 chore(deps): update docker/build-push-action action to v6
Build image / build (pull_request) Successful in 1m34s Details
2025-01-03 11:42:57 +00:00
Alie ff9744d46a add tool versions 2025-01-03 10:22:58 +01:00
11 changed files with 570 additions and 240 deletions

View File

@ -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: .

26
.github/workflows/renovate.yaml vendored Normal file
View File

@ -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 }}

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
nodejs 23.8.0

View File

@ -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

View File

@ -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:

482
package-lock.json generated
View File

@ -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"

View File

@ -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"
}
}

View File

@ -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} />;
}
}

View File

@ -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>
);
}

View File

@ -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%",

View File

@ -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>
);
}