diff --git a/.env b/.env index 961218c0..c8fb832e 100644 --- a/.env +++ b/.env @@ -1,12 +1,16 @@ -### Config ### -ENVIRONMENT_STAGE=Development +### CONFIG ### -### Ports and hosts ### +# The environment stage set for individual services +ENVIRONMENT_STAGE=development +# The tag used for pulling the docker images +DOCKER_COMPOSE_IMAGES_TAG=latest + +### HOSTS & PORTS ### # Frontend FRONTEND_HOST=frontend FRONTEND_PORT=80 # Backend -BACKEND_HOST=api-gateway -BACKEND_PORT=8081 \ No newline at end of file +VITE_BACKEND_HOST=localhost +VITE_BACKEND_PORT=8081 \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..04dc09fd --- /dev/null +++ b/.env.production @@ -0,0 +1,16 @@ +### CONFIG ### + +# The environment stage set for individual services +ENVIRONMENT_STAGE=production +# The tag used for pulling the docker images +DOCKER_COMPOSE_IMAGES_TAG=production + +### HOSTS & PORTS ### + +# Frontend +FRONTEND_HOST=frontend +FRONTEND_PORT=80 + +# Backend +VITE_BACKEND_HOST=prod.amos.b-ci.de +VITE_BACKEND_PORT=8081 \ No newline at end of file diff --git a/.env.test b/.env.test new file mode 100644 index 00000000..3d73593a --- /dev/null +++ b/.env.test @@ -0,0 +1,16 @@ +### CONFIG ### + +# The environment stage set for individual services +ENVIRONMENT_STAGE=test +# The tag used for pulling the docker images +DOCKER_COMPOSE_IMAGES_TAG=test + +### HOSTS & PORTS ### + +# Frontend +FRONTEND_HOST=frontend +FRONTEND_PORT=80 + +# Backend +VITE_BACKEND_HOST=test.amos.b-ci.de +VITE_BACKEND_PORT=8081 \ No newline at end of file diff --git a/.github/workflows/deploy_production.yml b/.github/workflows/deploy_production.yml index e16450c1..4c97728d 100644 --- a/.github/workflows/deploy_production.yml +++ b/.github/workflows/deploy_production.yml @@ -8,6 +8,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer + STAGE: production jobs: build-and-publish-frontend: @@ -18,14 +19,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -35,7 +36,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -43,8 +46,10 @@ jobs: context: ./frontend file: ./frontend/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-api-gateway: name: Build and publish - API Gateway @@ -54,14 +59,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -71,7 +76,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -79,8 +86,10 @@ jobs: context: ./backend/src/BIE.Core file: ./backend/src/BIE.Core/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-datapipeline: name: Build and publish - Data Pipeline @@ -90,14 +99,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -107,7 +116,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -115,8 +126,10 @@ jobs: context: ./backend/src/BIE.DataPipeline file: ./backend/src/BIE.DataPipeline/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-sql-database: name: Build and publish - SQL Database @@ -126,14 +139,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -143,7 +156,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -151,8 +166,10 @@ jobs: context: ./backend/database file: ./backend/database/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} deploy-prod-env: needs: @@ -162,7 +179,7 @@ jobs: build-and-publish-backend-datapipeline, build-and-publish-backend-sql-database, ] - name: Deploy Image in the Production Environment + name: Deploy Docker Images in the Production Environment runs-on: ubuntu-latest steps: @@ -178,7 +195,7 @@ jobs: - name: Copy necessary files run: | scp ./docker-compose.yml ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie - scp ./.env ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie + scp ./.env.production ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie/.env - name: Connect and Pull run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit" - name: Cleanup diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index 359ec036..915c8f8d 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -8,6 +8,7 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer + STAGE: test jobs: build-and-publish-frontend: @@ -18,14 +19,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -35,7 +36,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -43,8 +46,10 @@ jobs: context: ./frontend file: ./frontend/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-api-gateway: name: Build and publish - API Gateway @@ -54,14 +59,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -71,7 +76,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -79,8 +86,10 @@ jobs: context: ./backend/src/BIE.Core file: ./backend/src/BIE.Core/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-datapipeline: name: Build and publish - Data Pipeline @@ -90,14 +99,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -107,7 +116,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -115,8 +126,10 @@ jobs: context: ./backend/src/BIE.DataPipeline file: ./backend/src/BIE.DataPipeline/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} build-and-publish-backend-sql-database: name: Build and publish - SQL Database @@ -126,14 +139,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Log in to the container registry uses: docker/login-action@v3 with: - registry: ${{env.REGISTRY}} - username: ${{github.actor}} - password: ${{secrets.GITHUB_TOKEN}} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta @@ -143,7 +156,9 @@ jobs: tags: | type=ref,event=tag type=sha - latest + type=raw,value=${{ env.STAGE }} + labels: | + stage=${{ env.STAGE }} - name: Build and Publish Docker Images uses: docker/build-push-action@v5 @@ -151,8 +166,10 @@ jobs: context: ./backend/database file: ./backend/database/Dockerfile push: true - tags: ${{steps.meta.outputs.tags}} - labels: ${{steps.meta.outputs.labels}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + STAGE: ${{ env.STAGE }} deploy-test-env: needs: @@ -169,17 +186,17 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{github.ref_name}} + ref: ${{ github.ref_name }} - name: Install SSH key run: | install -m 600 -D /dev/null ~/.ssh/id_rsa - echo "${{secrets.TEST_ENV_SSH_PRIVATE_KEY}}" > ~/.ssh/id_rsa - ssh-keyscan -H ${{secrets.TEST_ENV_SSH_HOST}} > ~/.ssh/known_hosts + echo "${{ secrets.TEST_ENV_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.TEST_ENV_SSH_HOST }} > ~/.ssh/known_hosts - name: Copy necessary files run: | - scp ./docker-compose.yml ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}}:/var/lib/bie - scp ./.env ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}}:/var/lib/bie + scp ./docker-compose.yml ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }}:/var/lib/bie + scp ./.env.test ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }}:/var/lib/bie/.env - name: Connect and Pull - run: ssh ${{secrets.TEST_ENV_SSH_USER}}@${{secrets.TEST_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit" + run: ssh ${{ secrets.TEST_ENV_SSH_USER }}@${{ secrets.TEST_ENV_SSH_HOST }} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit" - name: Cleanup run: rm -rf ~/.ssh diff --git a/Deliverables/sprint-04/feature-board.jpg b/Deliverables/sprint-04/feature-board.jpg new file mode 100644 index 00000000..26830fc8 Binary files /dev/null and b/Deliverables/sprint-04/feature-board.jpg differ diff --git a/Deliverables/sprint-04/feature-board.tsv b/Deliverables/sprint-04/feature-board.tsv new file mode 100644 index 00000000..53f15626 --- /dev/null +++ b/Deliverables/sprint-04/feature-board.tsv @@ -0,0 +1,101 @@ +Title URL Assignees Priority Estimate Size Labels Milestone Actual Size +Upload imp-squared board sprint 1 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/4 Battlemech P0 organizational +Design Team Logo https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/7 Superschnizel P0 organizational +Watch getting started with amos Videos https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/6 dancingsushii, op-hub P1 organizational +Ask Chris to provide prioritised list of sources and papers https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/41 dancingsushii P0 feature +Set up Team Contract https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/13 dancingsushii, op-hub P0 organizational +Define division and team distribution https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/11 dancingsushii, op-hub P0 organizational +Upload planning document Sprint 2 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/64 dancingsushii P0 organizational +Upload Imp-Squared board Sprint 2 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/65 Battlemech P0 organizational +Upload Snapshot Feature Board Sprint 2 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/63 dancingsushii P0 organizational +Upload Snapshot feature board sprint 1 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/2 dancingsushii, op-hub P0 organizational +Upload Planning document pdf sprint 1 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/3 dancingsushii, op-hub P0 organizational +Research on how should data pipeline work https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/40 Ahsankkhan, nicolasbandel, Superschnizel P0 1 backend, feature +Team Logo and Tshirt https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/5 Superschnizel P1 organizational +Add support for satellite image in map https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/119 P1 feature, frontend Building time machine +Research Additional datasets and ingest them (starting with bavaria) https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/122 P0 backend, feature Automated energy assessment +Adopt sustainability data for user view https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/102 P0 backend, feature, frontend Automated energy assessment +Solar potential assessment tool https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/104 P0 backend, feature, frontend +Automated district energy assessment tool https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/103 P1 backend, feature, frontend +Implement basic BE CI https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/52 P2 backend, devops, feature +Improve searching by adding suggestions https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/115 P2 backend, feature, frontend +Additional map controls https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/116 P2 backend, feature, frontend +Ingest Hausumringe bayern https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/145 P0 Epic +Create geoJson parser https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/146 backend, feature +Display Hausumringe in FE https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/147 feature, frontend +Discussion about Data storage https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/149 P0 backend, feature +Extend API Endpoints for Hausumringe https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/151 backend, feature, frontend +Ingest ALKIS-Parzellarkarte https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/155 Epic Substainability certification +Ingest ALKIS-Tatsächliche Nutzung https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/156 P0 Epic +Create GeoPackage parser https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/157 backend, feature +Display Tatsächliche Nutzung (acutal use) in FE https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/158 feature, frontend +Extend API Endpoints for Tatsächliche Nutzung (acutal use) https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/159 backend, feature, frontend +Create CityGML parser https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/161 backend, feature +Display LoD2 data in FE https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/162 feature, frontend +Extend API Endpoints for LoD2 data https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/163 backend, feature, frontend +Ingest LoD2 data bavaria https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/160 P0 0 Epic Solar potential +Team Dicussion on serveral topics https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/123 P0 organizational +Automate workflow with GitHub Actions https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/28 Corgam P0 3 devops, feature 3 +Create video recording and documentation about build process https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/81 Corgam P0 2 devops, organizational 1 +Research Github Actions constraints https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/29 Corgam P0 2 devops, feature 2 +Simplify .env file https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/69 Corgam P1 1 devops, feature 0 +Tag sprint candidate https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/68 Corgam P0 2 devops, feature 2 +Setup deployment pipeline/branches https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/30 Corgam P0 3 devops, feature 2 +Create basic layout for main UI interface https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/73 Corgam P0 2 feature, frontend 1 +Create multimap view component https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/60 Corgam P0 3 feature, frontend 3 +Technology Research (Map APIs) https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/15 CelineMP P0 3 feature, frontend 1 +Create basic data view component https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/61 CelineMP P0 3 feature, frontend 3 +Compose the FE - Composition and Style https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/137 feature, frontend +Documentation - BE technology https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/22 Ahsankkhan, nicolasbandel, Superschnizel P1 1 backend, feature +Crash on special character https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/124 nicolasbandel 1 backend, bug +Discuss Labels and Milestones https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/19 dancingsushii, op-hub P1 organizational +Row mapping/filtering https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/74 nicolasbandel P0 3 backend, feature +Allow building of Backend Projects with command line https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/128 Superschnizel backend, devops, feature +Create endpoint to request datapoints for an area https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/131 Superschnizel backend, feature +Compose the FE - Context and states https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/138 Corgam feature, frontend +Integrate dockerfiles in docker compose https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/132 Ahsankkhan devops, feature +Implement search by coordinate https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/101 CelineMP P0 backend, feature, frontend +FE filtering changes data entries https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/117 CelineMP P2 1 bug, frontend +Create architecture / system design for fe components https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/135 Lucas-Nan feature, frontend +Fix pinning of the tabs going crazy after deleting some tabs https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/112 Corgam P0 1 bug, frontend +Develop YAML Parser https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/56 Superschnizel P0 5 backend, feature 2 +Develop CSV parser https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/57 nicolasbandel P0 5 backend, feature 5 +Dockefile for data pipeline https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/71 Ahsankkhan P0 3 backend, feature 3 +Configure database connection https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/58 Ahsankkhan P0 3 backend, feature 3 +Dockerfile for database https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/70 Ahsankkhan P2 3 backend, feature 5 +Compose and finish the UI of the FE https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/113 CelineMP, Corgam, Lucas-Nan P0 3 feature, frontend +Decide on API endpoints - to have one hour meeting https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/17 Corgam, dancingsushii, Lucas-Nan, op-hub P2 5 backend, feature, frontend +Create 3d view component https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/78 CelineMP P0 5 feature, frontend +Clarify preferred storage for meeting notes with Prof. Riehle https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/59 op-hub P2 1 organizational +Upload deliverables Sprint 3 https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/75 op-hub P0 organizational +Create map component from OSM https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/77 Lucas-Nan P0 3 feature, frontend 3 +Create pop-up with favourites https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/80 Lucas-Nan P0 2 feature, frontend 2 +Create generic pop-up container https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/79 Lucas-Nan P0 1 feature, frontend 1 +Trigger Data view only on button press https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/66 Lucas-Nan P0 1 feature, frontend +Search bar: Cache and bookmarking https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/62 P1 feature, frontend +Watch a video provided by AMOS team about well-run team meeting https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/83 dancingsushii, op-hub P2 1 organizational +Agree on product vision and mission https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/88 dancingsushii, op-hub P0 organizational +Allow Default Values in Datadescription Yaml https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/129 Superschnizel backend, feature +Add discard_if_empty attribute to yaml. https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/130 nicolasbandel backend +Update the CI-CD for the new BE https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/139 devops, feature +Agree on project-specific definition of done for feature, sprint, and project release https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/89 dancingsushii, op-hub P0 organizational +Update GitHub README.md https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/85 P0 organizational +Create build process video and upload to Deliverables folder https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/84 P0 devops, organizational +Create mid-project release plan https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/90 P0 devops, organizational +Clarify open source scope of the project with Prof. Riele https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/31 dancingsushii P1 organizational +Transfer all meeting notes and other relevant documentation to GitHub https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/25 dancingsushii P0 2 organizational +Review notes from IP meeting and develop PO's concept https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/82 dancingsushii P0 2 organizational +Documentation - FE technology https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/21 Lucas-Nan P0 1 feature, frontend 1 +Research on FE RestAPI requirements https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/16 Lucas-Nan P1 3 feature, frontend 2 +Setup basic React + NodeJS frontend https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/14 CelineMP P0 2 feature, frontend 1 +Create FE Concept https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/18 CelineMP, dancingsushii, Lucas-Nan, op-hub P0 3 feature, frontend 5 +Create boilerplate API project https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/38 Ahsankkhan P0 5 backend, feature 3 +Ingest Data [2] https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/35 Ahsankkhan, Superschnizel P0 3 backend, feature 3 +Request Deutsche Bahn dataset https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/37 Superschnizel P0 1 backend, bug, feature 1 +API project docker file https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/54 Ahsankkhan P0 3 backend, devops, feature 3 +Ingest data [3] https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/36 nicolasbandel P0 3 backend, feature 3 +Ingest Data [1] https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/34 Superschnizel P0 3 backend, feature 2 +Get Backend container running https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/27 Corgam P0 2 backend, devops, feature 2 +Documentation - CI/CD technology https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/23 Corgam P1 1 devops, feature 1 +Get FE container running https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/26 Corgam P0 2 devops, feature, frontend 2 +Initialize Github Wiki https://github.com/amosproj/amos2024ss04-building-information-enhancer/issues/20 Corgam P0 1 feature 1 \ No newline at end of file diff --git a/Deliverables/sprint-04/imp-squared-backlog.png b/Deliverables/sprint-04/imp-squared-backlog.png new file mode 100644 index 00000000..bc41bd00 Binary files /dev/null and b/Deliverables/sprint-04/imp-squared-backlog.png differ diff --git a/Deliverables/sprint-04/imp-squared-backlog.tsv b/Deliverables/sprint-04/imp-squared-backlog.tsv new file mode 100644 index 00000000..b59b1481 --- /dev/null +++ b/Deliverables/sprint-04/imp-squared-backlog.tsv @@ -0,0 +1,11 @@ +Title Assignees Status Priority Estimate Size Iteration +Stay on topic in Meetings Done +Documentation mainly on GitHub Wiki Done +Read user story and acceptance during sprint review Done +Smaller, atomic issues Done +Frontend/Backend team communication Done +Avoid pushing decsions to extra meetings Done +Small follow-up summary messages after meetings In Progress +Using our new milestones - epics - tickets structure In Progress +Plan mid-term release In Progress +Earlier feature preparation for sprint In Progress \ No newline at end of file diff --git a/Deliverables/sprint-04/planning-documents.pdf b/Deliverables/sprint-04/planning-documents.pdf new file mode 100644 index 00000000..de991f6e Binary files /dev/null and b/Deliverables/sprint-04/planning-documents.pdf differ diff --git a/README.md b/README.md index 3a1f005f..e0a0e9ff 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@
-
- Code.ing Group Logo -
-
-

Building Information Enhancer (AMOS SS 2024)

+  
+    Code.ing Group Logo +    
+  
+  

Building Information Enhancer (AMOS SS 2024)

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) @@ -21,22 +21,29 @@ This project is integrated with a full CI/CD pipeline, thus deployed automatical ## 📦 Deployment using Docker -To deploy the project on your local machine using Docker Engine, follow the instructions below: +To deploy the latest release of the project on your local machine using Docker Engine, follow the instructions below: 1. Clone this repository (https://github.com/amosproj/amos2024ss04-building-information-enhancer). 2. Before deploying the project be sure you have installed the [Node.js](https://nodejs.org/en) ( >= 20.12.2) and a running [Docker Engine](https://docs.docker.com/engine/install/). -3. Run the `npm run deploy` command in the root folder of the repository. +3. Run the `npm run deploy` command in the root folder of the repository. \* 4. Connect to the frontend at port 80 (`localhost:80`). +\* This command pulls the newest release of the images, if you want to build your local files, use `npm run deploy:build` instead. + ## 💻 Developement Deployment -In order to deploy and/or develop one or more services without Docker, follow the instructions below: +In order to deploy and/or develop one or more services, follow the instructions below: + +### Setup 1. Clone this repository (https://github.com/amosproj/amos2024ss04-building-information-enhancer). 2. Before deploying the project make sure you have installed the [Node.js](https://nodejs.org/en) ( >= 20.12.2) and [Dotnet SDK](https://dotnet.microsoft.com/en-us/download) ( >= 8.0.3). 3. Run the `npm run setup:` command to download all necessary packages and build the services, replacing `` with `windows`, `linux` or `macos` based on your operating system. -4. If you want to develop the frontend service, run the `npm run deploy:backend:api` to deploy the backend and in a new terminal run the `npm run deploy:frontend:dev` command to deploy the frontend developement server. -5. To develop one of the backend services using Visual Studio IDE (for other IDEs, search online), go to the service's subfolder in the `backend` folder and open the corresponding `.sln` file. + +### Developement + +1. If you want to develop the frontend service, run the `npm run deploy:backend:api` to deploy the backend, and in a new terminal run the `npm run deploy:frontend:dev` command to deploy the frontend development server. +2. If you want to develop one of the backend services, instead you need to make the changes and re-build the backend executables afterward. To do so, go to the `backend` folder and open the corresponding `.sln` file. To build all services type, go back to the root folder and type `npm run deploy:backend:api`. ## 👥 The Team diff --git a/docker-compose.yml b/docker-compose.yml index 4eb70c8c..2dc0cf24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,12 +5,9 @@ services: context: ./frontend dockerfile: Dockerfile container_name: frontend - image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-frontend + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-frontend:${DOCKER_COMPOSE_IMAGES_TAG} environment: - - HOST=${FRONTEND_HOST} - - PORT=${FRONTEND_PORT} - - BACKEND_HOST=${BACKEND_HOST} - - BACKEND_PORT=${BACKEND_PORT} + - NODE_ENV=${ENVIRONMENT_STAGE} networks: - bie-network ports: @@ -22,9 +19,9 @@ services: context: ./backend/src/BIE.Core dockerfile: Dockerfile container_name: api-gateway - image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-api-gateway + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-api-gateway:${DOCKER_COMPOSE_IMAGES_TAG} environment: - - ASPNETCORE_ENVIRONMENT=${ENVIRONMENT_STAGE} # Needs to be changed to `Production` for production env. + - ASPNETCORE_ENVIRONMENT=${ENVIRONMENT_STAGE} - DB_NAME=BIEDB - DB_PASSWORD=MyPass@1234 - DB_SERVER=sql-db @@ -32,7 +29,7 @@ services: - DB_TYPE=SQL - TRUSTED=False ports: - - ${BACKEND_PORT}:80 + - ${VITE_BACKEND_PORT}:80 networks: - bie-network depends_on: @@ -43,7 +40,7 @@ services: build: context: ./backend/src/BIE.DataPipeline dockerfile: Dockerfile - image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-datapipeline + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-datapipeline:${DOCKER_COMPOSE_IMAGES_TAG} environment: - DB_NAME=BIEDB - DB_PASSWORD=MyPass@1234 @@ -63,7 +60,7 @@ services: context: ./backend/database dockerfile: Dockerfile container_name: sql-db - image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-sql-database + image: ghcr.io/amosproj/amos2024ss04-building-information-enhancer-sql-database:${DOCKER_COMPOSE_IMAGES_TAG} networks: - bie-network volumes: diff --git a/frontend/.env b/frontend/.env new file mode 100644 index 00000000..21e205b7 --- /dev/null +++ b/frontend/.env @@ -0,0 +1,11 @@ +# Parameters for local deployment +VITE_API_HOST_DEV = "localhost" +VITE_API_PORT_DEV = 8081 + +# Parameters for test environment deployment +VITE_API_HOST_TEST = "test.amos.b-ci.de" +VITE_API_PORT_TEST = 8081 + +# Parameters for production environment deployment +VITE_API_HOST_PRODUCTION = "prod.amos.b-ci.de" +VITE_API_PORT_PRODUCTION = 8081 \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 621958fb..f75ad4d4 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,6 +4,10 @@ FROM node:20-slim as builder # Create app work directory WORKDIR /usr/src/app +# Set environment variables +ARG STAGE +ENV VITE_STAGE=${STAGE} + ### Install dependencies ### # Copy package.json and package-lock.json to the working directory @@ -18,17 +22,13 @@ ADD . . RUN npm run build -### Deploy the server ### +### Deploy the server ### # Use Apache HTTP server FROM httpd:2.4 COPY --from=builder /usr/src/app/dist /usr/local/apache2/htdocs/ -## Environment variables -ENV NODE_ENV=production -ENV PORT=80 - # Expose the port EXPOSE "${PORT}" diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 8d3a382d..96bf57a1 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -17,6 +17,7 @@ "@mui/x-data-grid": "^7.4.0", "@phosphor-icons/react": "^2.1.5", "@types/geojson": "^7946.0.14", + "axios": "^1.7.2", "geojson": "^0.5.0", "leaflet": "^1.9.4", "leaflet-geosearch": "^4.0.0", @@ -26,6 +27,7 @@ }, "devDependencies": { "@types/leaflet": "^1.9.12", + "@types/node": "^20.12.12", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", "@typescript-eslint/eslint-plugin": "^7.2.0", @@ -1798,6 +1800,15 @@ "@types/geojson": "*" } }, + "node_modules/@types/node": { + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/parse-json": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", @@ -2116,6 +2127,21 @@ "node": ">=8" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-plugin-macros": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz", @@ -2259,6 +2285,17 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2327,6 +2364,14 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -2822,6 +2867,38 @@ "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3266,6 +3343,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "9.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", @@ -3518,6 +3614,11 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -3922,6 +4023,12 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", diff --git a/frontend/package.json b/frontend/package.json index d4563922..26cb0424 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,6 +19,7 @@ "@mui/x-data-grid": "^7.4.0", "@phosphor-icons/react": "^2.1.5", "@types/geojson": "^7946.0.14", + "axios": "^1.7.2", "geojson": "^0.5.0", "leaflet": "^1.9.4", "leaflet-geosearch": "^4.0.0", @@ -28,6 +29,7 @@ }, "devDependencies": { "@types/leaflet": "^1.9.12", + "@types/node": "^20.12.12", "@types/react": "^18.2.66", "@types/react-dom": "^18.2.22", "@typescript-eslint/eslint-plugin": "^7.2.0", diff --git a/frontend/src/components/Alerts/ErrorAlert.tsx b/frontend/src/components/Alerts/ErrorAlert.tsx index 992957fc..f3bcf77c 100644 --- a/frontend/src/components/Alerts/ErrorAlert.tsx +++ b/frontend/src/components/Alerts/ErrorAlert.tsx @@ -19,7 +19,7 @@ const ErrorAlert: React.FC = () => { ...currentAlertCache, isAlertOpened: false, }); - }, 3000); + }, 4000); return () => { clearTimeout(timeId); diff --git a/frontend/src/components/MapView/DataFetch.tsx b/frontend/src/components/MapView/DataFetch.tsx index 4cba50cf..69960534 100644 --- a/frontend/src/components/MapView/DataFetch.tsx +++ b/frontend/src/components/MapView/DataFetch.tsx @@ -2,12 +2,33 @@ import { FeatureCollection, Geometry } from "geojson"; import defaultCityLocationData from "./FeatureCollection.json"; import defaultPolygonData from "./gemeinden_simplify20.json"; import { LatLngBounds } from "leaflet"; -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; +import axios from "axios"; +import { AlertContext } from "../../contexts/AlertContext"; const geojsonCities: FeatureCollection = defaultCityLocationData as FeatureCollection; const geojsonGemeindenPolygons: FeatureCollection = defaultPolygonData as FeatureCollection; +// Define the base of the API URL +const getBaseApiUrl = () => { + console.log("Checking base url: " + import.meta.env.VITE_STAGE); + switch (import.meta.env.VITE_STAGE) { + case "production": + return `http://${import.meta.env.VITE_API_HOST_PRODUCTION}:${ + import.meta.env.VITE_API_PORT_PRODUCTION + }`; + case "test": + return `http://${import.meta.env.VITE_API_HOST_TEST}:${ + import.meta.env.VITE_API_PORT_TEST + }`; + default: + return `http://${import.meta.env.VITE_API_HOST_DEV}:${ + import.meta.env.VITE_API_PORT_DEV + }`; + } +}; + const useGeoData = ( id: string, bounds: LatLngBounds, @@ -15,40 +36,84 @@ const useGeoData = ( onUpdate: (data: FeatureCollection) => void ): FeatureCollection | undefined => { const [data, setData] = useState>(); + const { currentAlertCache, setCurrentAlertCache } = useContext(AlertContext); - useEffect(() => { - /* eslint-disable */ - const fetchData = async (_bounds: LatLngBounds) => { - /* eslint-enable */ - if (id === "house_footprints") { - setData(geojsonGemeindenPolygons as FeatureCollection); - onUpdate(geojsonGemeindenPolygons); - return; - } + // Returns the API URL of the endpoint for a specific dataset + const getApiUrlForDataset = (): string => { + switch (id) { + case "charging_stations": + return getBaseApiUrl() + "/api/v1.0/Dataset/1/data"; + case "house_footprints": + return getBaseApiUrl() + ""; + default: + // Display alert + setCurrentAlertCache({ + ...currentAlertCache, + isAlertOpened: true, + text: "Dataset with provided ID does not exist.", + }); + return ""; + } + }; + useEffect(() => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const fetchData = async (_bounds: LatLngBounds): Promise => { try { // const bottomLat = bounds.getSouth(); // const bottomLong = bounds.getWest(); // const topLat = bounds.getNorth(); // const topLong = bounds.getEast(); - // TO-DO: Fix so it is not hardcoded - const url = `http://localhost:8081/api/v1.0/Dataset/1/data?BottomLat=9&BottomLong=10&TopLat=48&TopLong=49`; - const response = await fetch(url); - if (!response.ok) { - throw new Error("Network response was not ok"); - } - const result = await response.json(); - setData(result as FeatureCollection); - onUpdate(result); + console.log(getBaseApiUrl()); + // Define the query parameters + const params = { + BottomLat: 9, // bottomLat, + BottomLong: 10, //bottomLong, + TopLat: 48, //topLat, + TopLong: 49, //topLong, + ZoomLevel: zoom, + }; + const response = await axios.get>( + getApiUrlForDataset(), + { + params, + } + ); + setData(response.data); + onUpdate(response.data); } catch (error) { - console.error("Fetching data failed, using local GeoJSON data:", error); - setData(geojsonCities as FeatureCollection); - onUpdate(geojsonCities); + // Display alert + setCurrentAlertCache({ + ...currentAlertCache, + isAlertOpened: true, + text: "Fetching data failed, using local GeoJSON data.", + }); + console.error("Fetching data failed, using local GeoJSON data.", error); + // Console log the error + if (axios.isAxiosError(error)) { + console.error("Axios error fetching data:", error.message); + } else { + console.error("Unknown error fetching data:", error); + } + // Load the static data + switch (id) { + case "charging_stations": + setData(geojsonCities as FeatureCollection); + onUpdate(geojsonCities); + return; + case "house_footprints": + setData(geojsonGemeindenPolygons as FeatureCollection); + onUpdate(geojsonGemeindenPolygons); + return; + default: + return; + } } }; fetchData(bounds); - }, [bounds, zoom, id, onUpdate]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [bounds, zoom, id]); return data; }; diff --git a/package.json b/package.json index a0c51a2a..6a91d349 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "setup:backend:windows": "backend_build.bat", "setup:backend:linux": "./backend_build.sh linux-x64", "setup:backend:macos": "./backend_build.sh osx-x64", - "deploy": "docker compose up --build -d", + "deploy": "docker compose pull && docker compose up -d", + "deploy:build": "docker compose up --build -d", "deploy:frontend:dev": "cd frontend/ && npm run dev", "deploy:backend:api": "cd backend/src/BIE.Core/BIE.Core.API/bin/build && BIE.Core.API" }