diff --git a/README.md b/README.md index 6658e918d3151f3b96a72dd249bbf308890871fa..d2b24166df0e79b63c3427a5d40c8f93afe8492c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,13 @@ VN---N ## En cas d'erreur + +### Problèmes sur l'interface web + +Nous avons remarqué qu'il y a des problèmes avec Firefox, il faut utiliser un navigateur Chromium + +### Docker Neo4j + `neo4j | Folder /data is not accessible for user: 7474 or group 7474 or groups 7474, this is commonly a file permissions issue on the mounted folder.` Solution: diff --git a/docker-compose.yml b/docker-compose.yml index 43d0a2b14c4884a5bc5ce99baf9ec2c5429a402f..212118e141fde47c7806196928bb9bf927b5d067 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3.9' services: database: @@ -9,16 +9,15 @@ services: - "7474:7474" - "7687:7687" volumes: - - ./neo4j/import:/var/lib/neo4j/import - - ./neo4j/data:/var/lib/neo4j/data + - neo4j-import:/var/lib/neo4j/import + - neo4j-data:/var/lib/neo4j/data container_name: neo4j redis: - image: "redis:alpine" + image: "redis:7-alpine" ports: - "6379:6379" sg-backend: build: ./sg-backend - command: sh -c "/wait && uvicorn main:app --reload --host 0.0.0.0" environment: - FRONTEND_URL="http://localhost" - NEO4J_URI=neo4j://database:7687 @@ -26,8 +25,9 @@ services: - NEO4J_PASSWORD=test - WAIT_HOSTS=database:7474 - WAIT_HOSTS_TIMEOUT=300 - - WAIT_SLEEP_INTERVAL=5 + - WAIT_SLEEP_INTERVAL=3 - WAIT_HOST_CONNECT_TIMEOUT=30 + - REDIS_URL=redis://redis:6379 volumes: - ./sg-backend:/code depends_on: @@ -47,4 +47,6 @@ services: depends_on: - sg-backend volumes: + neo4j-import: + neo4j-data: node_modules: \ No newline at end of file diff --git a/neo4j/Dockerfile b/neo4j/Dockerfile index 25461cecfceb763ab4c6954bd1c32b44eb08fcff..c36362cf5603d81eeeea7997e43c2ed345f868a5 100755 --- a/neo4j/Dockerfile +++ b/neo4j/Dockerfile @@ -1,5 +1,6 @@ -FROM neo4j:4.4.0 +FROM neo4j:4.4 -USER neo4j +COPY ./import /var/lib/neo4j/import +COPY ./data /var/lib/neo4j/data EXPOSE 7474 7473 7687 \ No newline at end of file diff --git a/neo4j/data/dbms/auth.ini b/neo4j/data/dbms/auth.ini old mode 100644 new mode 100755 diff --git a/neo4j/import/data_cypher.cypher b/neo4j/import/data_cypher.cypher old mode 100644 new mode 100755 diff --git a/neo4j/import/index.cypher b/neo4j/import/index.cypher old mode 100644 new mode 100755 diff --git a/neo4j/import/insert.cypher b/neo4j/import/insert.cypher old mode 100644 new mode 100755 diff --git a/neo4j/import/reset.cypher b/neo4j/import/reset.cypher old mode 100644 new mode 100755 diff --git a/sg-backend/.gitignore b/sg-backend/.gitignore index c8cf1b4303136ebcf07ce04dda4b39280b4c26fe..f3f68148a373bb9a124891259050d5bd8ce63b82 100644 --- a/sg-backend/.gitignore +++ b/sg-backend/.gitignore @@ -1,2 +1,2 @@ -__pycache +__pycache__ .idea/ \ No newline at end of file diff --git a/sg-backend/Dockerfile b/sg-backend/Dockerfile index c8b1dafc6c90847a115101449a1785f1e0e2ff97..d6aa430b5fd33f1ec9a6d989c32cf7de417c3f8d 100644 --- a/sg-backend/Dockerfile +++ b/sg-backend/Dockerfile @@ -1,6 +1,9 @@ FROM python:3.10-slim + +ENV POETRY_VERSION=1.2 +ENV WAIT_VERSION 2.7.2 + WORKDIR /code -ENV POETRY_VERSION=1.2.2 RUN pip install "poetry==$POETRY_VERSION" @@ -9,8 +12,10 @@ COPY poetry.lock pyproject.toml /code/ RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi COPY . /code -EXPOSE 8000 -ENV WAIT_VERSION 2.7.2 ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait -RUN chmod +x /wait \ No newline at end of file +RUN chmod +x /wait + +EXPOSE 8000 + +CMD /wait && uvicorn main:app --reload --host 0.0.0.0 --port 8000 diff --git a/sg-backend/cache.py b/sg-backend/cache.py index 95a0cf009771b2c0a7dd532dbf422c944e428688..233e2542cc2aeb916abc31c41cdaef5ec3c81bed 100644 --- a/sg-backend/cache.py +++ b/sg-backend/cache.py @@ -1,15 +1,16 @@ +import os + from fastapi_cache import FastAPICache from fastapi_cache.backends.redis import RedisBackend - from redis import asyncio as aioredis class RedisCache: def __init__(self): - redis = aioredis.from_url("redis://redis", encoding="utf8", decode_responses=True) + redis = aioredis.from_url(os.getenv("REDIS_URL"), encoding="utf8", decode_responses=True) FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache") @staticmethod async def clear_softwares_cache(): await FastAPICache.clear(key="software") - await FastAPICache.clear(key="software-graph") \ No newline at end of file + await FastAPICache.clear(key="software-graph") diff --git a/sg-frontend/Dockerfile b/sg-frontend/Dockerfile index fa344f1e343f0cdcfce694601a25c57f643c8e89..eddab06afe4204e747bf3b7c5e8301b4dee49352 100644 --- a/sg-frontend/Dockerfile +++ b/sg-frontend/Dockerfile @@ -2,11 +2,11 @@ FROM node:18-slim COPY package.json /app/ WORKDIR /app -#RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm +RUN npm install -g npm@9 RUN npm install +COPY . /app -ENV VITE_BACKEND_URL=http://sg-backend:8000 EXPOSE 5173 -CMD ["npm","run", "dev", "--","--host", "0.0.0.0", "--port", "5173"] \ No newline at end of file +CMD npm run dev -- --host 0.0.0.0 --port 5173 \ No newline at end of file diff --git a/sg-frontend/build.Dockerfile b/sg-frontend/build.Dockerfile index 18ffdede8dde4c9be06b0d4173f940bf2c073b6f..957f336a23c9bde5b85be71676c2245fcaf5cf15 100644 --- a/sg-frontend/build.Dockerfile +++ b/sg-frontend/build.Dockerfile @@ -2,11 +2,10 @@ FROM node:18-slim WORKDIR /app COPY . /app -#RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm RUN npm install RUN npm run build -ENV VITE_BACKEND_URL=http://sg-backend:8000 + EXPOSE 4173 -CMD ["npm","run", "preview", "--","--host", "0.0.0.0", "--port", "4173"] \ No newline at end of file +CMD npm run preview --host 0.0.0.0 --port 4173 \ No newline at end of file diff --git a/sg-frontend/package-lock.json b/sg-frontend/package-lock.json index 54ca3c28a85d4ab28b9f400fe296ef26373e2905..1a0ccc8fed85ad76bcde0b720ef0650de442a5e3 100644 --- a/sg-frontend/package-lock.json +++ b/sg-frontend/package-lock.json @@ -387,38 +387,6 @@ "node": ">=12" } }, - "node_modules/esbuild-darwin-64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.14.tgz", - "integrity": "sha512-ToNuf1uifu8hhwWvoZJGCdLIX/1zpo8cOGnT0XAhDQXiKOKYaotVNx7pOVB1f+wHoWwTLInrOmh3EmA7Fd+8Vg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/esbuild-darwin-arm64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.14.tgz", - "integrity": "sha512-KgGP+y77GszfYJgceO0Wi/PiRtYo5y2Xo9rhBUpxTPaBgWDJ14gqYN0+NMbu+qC2fykxXaipHxN4Scaj9tUS1A==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/esbuild-freebsd-64": { "version": "0.15.14", "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.14.tgz", @@ -1832,8 +1800,6 @@ "@esbuild/linux-loong64": "0.15.14", "esbuild-android-64": "0.15.14", "esbuild-android-arm64": "0.15.14", - "esbuild-darwin-64": "0.15.14", - "esbuild-darwin-arm64": "0.15.14", "esbuild-freebsd-64": "0.15.14", "esbuild-freebsd-arm64": "0.15.14", "esbuild-linux-32": "0.15.14", @@ -1866,20 +1832,6 @@ "dev": true, "optional": true }, - "esbuild-darwin-64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.14.tgz", - "integrity": "sha512-ToNuf1uifu8hhwWvoZJGCdLIX/1zpo8cOGnT0XAhDQXiKOKYaotVNx7pOVB1f+wHoWwTLInrOmh3EmA7Fd+8Vg==", - "dev": true, - "optional": true - }, - "esbuild-darwin-arm64": { - "version": "0.15.14", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.14.tgz", - "integrity": "sha512-KgGP+y77GszfYJgceO0Wi/PiRtYo5y2Xo9rhBUpxTPaBgWDJ14gqYN0+NMbu+qC2fykxXaipHxN4Scaj9tUS1A==", - "dev": true, - "optional": true - }, "esbuild-freebsd-64": { "version": "0.15.14", "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.14.tgz", diff --git a/sg-frontend/src/components/SoftwareInsert.svelte b/sg-frontend/src/components/SoftwareInsert.svelte index ef898086198cc74f05ae7c1edde47a82c8dffded..abb98b83aaf0cf8aa71916c34e6dac413f69e84d 100644 --- a/sg-frontend/src/components/SoftwareInsert.svelte +++ b/sg-frontend/src/components/SoftwareInsert.svelte @@ -1,50 +1,34 @@ <script> - import {onMount} from "svelte"; const BACKEND_URL = import.meta.env.VITE_BACKEND_URL; + let newNodeName = ""; - let softwares = [], - result, - node; - - - onMount(async () => { - const softwareName = document.getElementById("softwareName"); - const newNodeButton = document.getElementById("newNodeButton"); - - newNodeButton.addEventListener("click", (e) => { - postSoftwareInsert(); - e.preventDefault(); - window.location.reload(); - }); - - async function postSoftwareInsert() { - const res = await fetch(BACKEND_URL + "/software-insert", { + function postSoftwareInsert() { + if (newNodeName) { + fetch(BACKEND_URL + "/software-insert", { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify({"newNodeName": softwareName.value}), - }); + body: JSON.stringify({"newNodeName": newNodeName}), + }).then(() => window.location.reload()); } - - }); + } </script> -<form class="form-inline"> - <label for="softwareName">Software Name :</label> - <input type="text" id="softwareName" placeholder="" name="softwareName"> - <button id="newNodeButton">Submit</button> -</form> +<div class="form-inline"> + <label>Software Name :</label> + <input type="text" bind:value={newNodeName} placeholder=""> + <button on:click={postSoftwareInsert}>Submit</button> +</div> <style> /* Style the form - display items horizontally */ .form-inline { display: flex; - flex-flow: row wrap; align-items: center; } @@ -74,7 +58,7 @@ } } - form { + .form-inline { max-width: 400px; background: #f4f4f4; padding: 20px;