From 2ebecf090cfe650c9838188a0bbf1096252c8d5f Mon Sep 17 00:00:00 2001 From: David Mendy Date: Sun, 23 Jun 2024 21:44:49 +0200 Subject: [PATCH 01/23] Refactor expertise form --- frontend/src/api/api-client.ts | 44 ++ frontend/src/api/api-routes.ts | 5 + frontend/src/components/AskingExpert.vue | 117 ++-- .../GuideAskingExpertise/ExpertiseForm.vue | 609 ++++++++++++++++++ 4 files changed, 713 insertions(+), 62 deletions(-) create mode 100644 frontend/src/api/api-client.ts create mode 100644 frontend/src/api/api-routes.ts create mode 100644 frontend/src/views/GuideAskingExpertise/ExpertiseForm.vue diff --git a/frontend/src/api/api-client.ts b/frontend/src/api/api-client.ts new file mode 100644 index 00000000..ec61f1a8 --- /dev/null +++ b/frontend/src/api/api-client.ts @@ -0,0 +1,44 @@ +import axios from "axios"; +import { + ASK_FOR_OPINION_ROUTE, + IDENTIFICATION_DUMMY_ROUTE, + IDENTIFICATION_FEEDBACK_ROUTE, + TUTORIAL_FEEDBACK_ROUTE, + UPLOAD_PHOTO_FOR_DETECTION_ROUTE, +} from "./api-routes"; + +export const uploadPhotoForDetection = async (file: File) => { + const fd = new FormData(); + fd.append("image", file, file.name); + fd.append("date", "" + Date.now() / 1000); // date.now gives in milliseconds, convert to seconds + + const { data } = await axios.post(UPLOAD_PHOTO_FOR_DETECTION_ROUTE, fd); + return data; +}; + +export const sendTutorialFeedback = async (feedback: any) => { + const { data } = await axios.post(TUTORIAL_FEEDBACK_ROUTE, feedback); + return data; +}; + +export const sendIdentificationFeedback = async (feedbackData: any) => { + const { data } = await axios.post( + IDENTIFICATION_FEEDBACK_ROUTE, + feedbackData, + ); + return data; +}; + +export const sendIdentificationDummyFeedback = async (feedbackDummy: any) => { + const { data } = await axios.post(IDENTIFICATION_DUMMY_ROUTE, feedbackDummy); + return data; +}; + +export const sendExpertiseForm = async (feedbackExpert: any) => { + const { data } = await axios.post(ASK_FOR_OPINION_ROUTE, feedbackExpert, { + headers: { + "Content-Type": "application/json", + }, + }); + return data; +}; diff --git a/frontend/src/api/api-routes.ts b/frontend/src/api/api-routes.ts new file mode 100644 index 00000000..e796e7cd --- /dev/null +++ b/frontend/src/api/api-routes.ts @@ -0,0 +1,5 @@ +export const UPLOAD_PHOTO_FOR_DETECTION_ROUTE = "/upload"; +export const TUTORIAL_FEEDBACK_ROUTE = "/tutorial-feedback"; +export const IDENTIFICATION_FEEDBACK_ROUTE = "/identification-feedback"; +export const IDENTIFICATION_DUMMY_ROUTE = "/identification-dummy"; +export const ASK_FOR_OPINION_ROUTE = "http://localhost:8000/api/requests/"; diff --git a/frontend/src/components/AskingExpert.vue b/frontend/src/components/AskingExpert.vue index 81afbae8..0ea5613b 100644 --- a/frontend/src/components/AskingExpert.vue +++ b/frontend/src/components/AskingExpert.vue @@ -1,92 +1,86 @@ - From 366e132646c838390a5654786ce88b0f143d5308 Mon Sep 17 00:00:00 2001 From: David Mendy Date: Mon, 15 Jul 2024 11:26:21 +0200 Subject: [PATCH 02/23] fix: :bug: fix popup uzi video --- .../src/utils/firearms-utils/semi-auto-style-militaire-autre.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/utils/firearms-utils/semi-auto-style-militaire-autre.ts b/frontend/src/utils/firearms-utils/semi-auto-style-militaire-autre.ts index 87878d72..842cbee4 100644 --- a/frontend/src/utils/firearms-utils/semi-auto-style-militaire-autre.ts +++ b/frontend/src/utils/firearms-utils/semi-auto-style-militaire-autre.ts @@ -10,6 +10,7 @@ import semiAutoMilitairePistoletMitralleurImg from "@/assets/guide-mise-en-secur import semiAutoMilitairePistoletMitralleurVideo from "@/assets/guide-mise-en-securite/videos/semi_auto_militaire_autre/semi_auto_mil_uzi.mp4"; import semiAutoMilitaireCartridges from "@/assets/guide-identification/photos/semi_auto_militaire_autre/semi_automatique_militaire_autre_chargeur_cartouche.jpg"; import semiAutoMilitaireBalls from "@/assets/guide-identification/photos/semi_auto_militaire_autre/semi_automatique_militaire_autre_chargeur_billes.jpg"; +import PopupVideo from "@/components/PopupVideo.vue"; /* Armes d’épaule semi-automatiques ou automatiques type militaire moderne AR15 @@ -93,6 +94,7 @@ export const semi_auto_style_militaire_autre = { 'Appuyer sur le bouton de verrouillage du chargeur en bas de la poignée', "Retirer le chargeur", 'Tirer le levier d’armement situé sur le dessus de l’arme vers l’arrière et retirer la munition éventuelle de la chambre', + PopupVideo, ], timeVideo: "35 sec", img: semiAutoMilitairePistoletMitralleurImg, From 9af6aa91798f5d5405319ad950feadb97b1dbf9d Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Fri, 12 Jul 2024 20:51:27 +0200 Subject: [PATCH 03/23] ci: :green_heart: fix ci build by removing references to deleted files --- .gitlab-ci-dso.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci-dso.yml b/.gitlab-ci-dso.yml index 61b8f422..bea57bb5 100644 --- a/.gitlab-ci-dso.yml +++ b/.gitlab-ci-dso.yml @@ -3,7 +3,7 @@ include: file: vault-ci.yml ref: main - project: $CATALOG_PATH - file: kaniko-ci-mirror.yml + file: kaniko-ci.yml ref: main default: @@ -30,7 +30,7 @@ docker-build-frontend: BUILD_ARGS: --build-arg=VERSION=1.1.1 stage: docker-build extends: - - .kaniko-mirror:build-push + - .kaniko:build-push docker-build-backend: variables: @@ -40,4 +40,4 @@ docker-build-backend: BUILD_ARGS: --build-arg=VERSION=1.1.1 stage: docker-build extends: - - .kaniko-mirror:build-push + - .kaniko:build-push From fdfd4460cd242b3a3642046348fd7608e77d5358 Mon Sep 17 00:00:00 2001 From: David Mendy Date: Tue, 16 Jul 2024 13:00:27 +0200 Subject: [PATCH 04/23] fix: :bug: fix disclaimer display on dummy weapons --- frontend/src/components.d.ts | 4 ++++ frontend/src/components/ResultPage.vue | 1 + 2 files changed, 5 insertions(+) diff --git a/frontend/src/components.d.ts b/frontend/src/components.d.ts index 4ed047d3..dbbe9e11 100644 --- a/frontend/src/components.d.ts +++ b/frontend/src/components.d.ts @@ -14,11 +14,15 @@ declare module "vue" { copy: (typeof import("./components/authentification/AuthRedirect copy.vue"))["default"]; DsfrAlert: (typeof import("@gouvminint/vue-dsfr"))["DsfrAlert"]; DsfrButton: (typeof import("@gouvminint/vue-dsfr"))["DsfrButton"]; + DsfrCheckbox: (typeof import("@gouvminint/vue-dsfr"))["DsfrCheckbox"]; + DsfrFileUpload: (typeof import("@gouvminint/vue-dsfr"))["DsfrFileUpload"]; DsfrHeader: (typeof import("@gouvminint/vue-dsfr"))["DsfrHeader"]; DsfrInput: (typeof import("@gouvminint/vue-dsfr"))["DsfrInput"]; DsfrModal: (typeof import("@gouvminint/vue-dsfr"))["DsfrModal"]; DsfrPicture: (typeof import("@gouvminint/vue-dsfr"))["DsfrPicture"]; DsfrRadioButton: (typeof import("@gouvminint/vue-dsfr"))["DsfrRadioButton"]; + DsfrSelect: (typeof import("@gouvminint/vue-dsfr"))["DsfrSelect"]; + DsfrTag: (typeof import("@gouvminint/vue-dsfr"))["DsfrTag"]; HeaderMain: (typeof import("./components/HeaderMain.vue"))["default"]; MissingCardAlert: (typeof import("./components/MissingCardAlert.vue"))["default"]; OnboardingSwiper: (typeof import("./components/OnboardingSwiper.vue"))["default"]; diff --git a/frontend/src/components/ResultPage.vue b/frontend/src/components/ResultPage.vue index 76ccbb77..c71ff603 100644 --- a/frontend/src/components/ResultPage.vue +++ b/frontend/src/components/ResultPage.vue @@ -155,6 +155,7 @@ function sendFeedback(isCorrect: boolean) { v-if=" disclaimer && confidenceLevel !== 'low' && + isDummy == false && ($route.name !== 'IdentificationTypologyResult' || !hasDummyOptions) " From d246280f91229df92e32d52161b7d1b1536e1bb9 Mon Sep 17 00:00:00 2001 From: David Mendy Date: Wed, 17 Jul 2024 10:07:53 +0200 Subject: [PATCH 05/23] style: :speech_balloon: update text for sending email to ircgn --- frontend/src/views/GuideContactExpert/ExpertSituation.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/GuideContactExpert/ExpertSituation.vue b/frontend/src/views/GuideContactExpert/ExpertSituation.vue index f608aca2..761c8a12 100644 --- a/frontend/src/views/GuideContactExpert/ExpertSituation.vue +++ b/frontend/src/views/GuideContactExpert/ExpertSituation.vue @@ -268,8 +268,8 @@ const currentPhone = computed(() => { {{ currentPhone }}

- Vous trouverez ci-dessous l'adresse mail de la permanence de - l'IRCGN.

+ Veuilez cliquer sur l'adresse mail ci-dessous pour envoyer un + mail pré-rempli à l'IRCGN :

{{ IRCGN.email From 7d76bb54de5939995c0bfa1e63ee495772cca159 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 17 Jul 2024 10:27:27 +0200 Subject: [PATCH 06/23] fix: :bug: fix tutorial log when user is not able to perform a step --- backend/src/router.py | 4 +- frontend/src/components/AskingExpert.vue | 51 ++++++------------------ frontend/src/stores/result.ts | 3 -- 3 files changed, 14 insertions(+), 44 deletions(-) diff --git a/backend/src/router.py b/backend/src/router.py index ac6c00bc..e87eb7d6 100644 --- a/backend/src/router.py +++ b/backend/src/router.py @@ -134,7 +134,7 @@ async def log_tutorial_feedback( "confidence", "confidence_level", "tutorial_feedback", - "tutorial_option", + "selected_options", "route_name", ]: extras_logging["bg_" + key] = res[key] @@ -158,7 +158,7 @@ async def log_identification_dummy( "label", "confidence", "confidence_level", - "tutorial_option", + "selected_options", ]: extras_logging["bg_" + key] = res[key] diff --git a/frontend/src/components/AskingExpert.vue b/frontend/src/components/AskingExpert.vue index 0ea5613b..3b6a2c04 100644 --- a/frontend/src/components/AskingExpert.vue +++ b/frontend/src/components/AskingExpert.vue @@ -20,31 +20,32 @@ const imgUrl = computed(() => store.imgUrl); const showModal = ref(false); function onClose() { - store.tutorialFeedback = ""; + tutorialFeedback.value = ""; showModal.value = false; } -async function submitTutorialFeedback() { +const tutorialFeedback = ref(""); + +async function sendTutorialFeedback() { const feedback = { image_url: imgUrl.value, - tutorial_feedback: store.tutorialFeedback, + tutorial_feedback: tutorialFeedback.value, label: typology.value, - tutorial_option: store.currentOptionStep[store.currentStep] || null, + selected_options: store.selectedOptions, route_name: route.name, confidence: confidence.value, confidence_level: confidenceLevel.value, }; await axios .post("/tutorial-feedback", feedback) - .then(async () => { - store.tutorialFeedback = feedback.tutorial_feedback; + .then(() => { setMessage({ type: "success", message: "Votre message a été pris en compte", }); }) - .catch(async (err) => { - import.meta.env.DEV && console.log(err); + .catch((error) => { + console.log(error); setMessage({ type: "error", message: "Une erreur a eu lieu en enregistrant de votre message.", @@ -52,7 +53,6 @@ async function submitTutorialFeedback() { }) .finally(() => setTimeout(() => { - store.tutorialFeedback = ""; router.push({ name: "ResultPage" }); }, 3000), ); @@ -80,20 +80,16 @@ async function submitTutorialFeedback() { contenu de ce tutoriel en nous décrivant votre problème ci-dessous.

- -
-
-
- @@ -105,27 +101,4 @@ async function submitTutorialFeedback() { :deep(.fr-btn) span { margin: auto !important; } - -.modal { - display: flex; - flex-direction: column; -} - -.modal-content { - flex: 1; - overflow-y: auto; -} - -.modal-footer { - position: sticky; - bottom: 0; - text-align: center; - background-color: #f5f5fe; - box-shadow: 0 -4px 16px rgb(0 0 0 / 25%); - padding: 1rem !important; - width: 100%; -} -.modal-footer button { - width: 100%; -} diff --git a/frontend/src/stores/result.ts b/frontend/src/stores/result.ts index c9932313..d0b794ed 100644 --- a/frontend/src/stores/result.ts +++ b/frontend/src/stores/result.ts @@ -15,7 +15,6 @@ export const useStore = defineStore("result", { const selectedOptions = ref([]); const selectedAmmo = ref(undefined); const selectedAlarmGun = ref(undefined); - const tutorialFeedback = ref(""); const isDummy = computed(() => !!(selectedAmmo.value === "billes")); const isModalTransparentAmmoOpened = ref(null); @@ -32,7 +31,6 @@ export const useStore = defineStore("result", { selectedOptions.value = []; selectedAmmo.value = undefined; selectedAlarmGun.value = undefined; - tutorialFeedback.value = ""; isModalTransparentAmmoOpened.value = null; } @@ -48,7 +46,6 @@ export const useStore = defineStore("result", { selectedOptions, selectedAmmo, selectedAlarmGun, - tutorialFeedback, isDummy, isModalTransparentAmmoOpened, $reset, From b358002af1cc1515dd094cb12b761c1bde703b5e Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 17 Jul 2024 11:21:57 +0200 Subject: [PATCH 07/23] fix: :bug: feedback not working on resultpage --- frontend/src/components/ResultPage.vue | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/ResultPage.vue b/frontend/src/components/ResultPage.vue index c71ff603..7e29ef30 100644 --- a/frontend/src/components/ResultPage.vue +++ b/frontend/src/components/ResultPage.vue @@ -45,29 +45,28 @@ const disclaimer = computed(() => ); function sendFeedback(isCorrect: boolean) { - const json = { - image_url: store.imgUrl, - feedback: isCorrect, - confidence: confidence.value, - label: typology.value, - confidence_level: confidenceLevel.value, - }; if (isCorrect) { isUp.value = true; } else { isDown.value = true; } axios - .post("/identification-feedback", json) - .then(async (res) => { - console.log(res); + .post("/identification-feedback", { + image_url: store.imgUrl, + feedback: isCorrect, + confidence: confidence.value, + label: label.value, + confidence_level: confidenceLevel.value, + }) + .then((data) => { + console.log(data); setMessage({ type: "success", message: "Votre vote a été pris en compte", }); }) - .catch(async (err) => { - console.log(err); + .catch((error) => { + console.log(error); setMessage({ type: "error", message: "Une erreur a eu lieu en enregistrant votre vote.", From da762b31bbfaae41c26c8fec672cf8f1225af080 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 17 Jul 2024 14:20:53 +0200 Subject: [PATCH 08/23] ci: :fire: remove ci related to new tag which is not used anymore --- .github/workflows/prod.yml | 124 ++++++++++++++++++------------------- Makefile | 2 +- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index a3c2b22b..186cdca2 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -20,67 +20,67 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-push: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build the Docker image - run: make build-prod - - name: Test running the docker containers - run: | - make up-prod - ./infra/scripts/test-alive.sh localhost - make down-prod - - name: Login to GHCR - if: success() - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Push on GHCR - if: success() - run: | - make push - make push-latest - - name: Delete untagged images - uses: vlaurin/action-ghcr-prune@main - with: - token: ${{ secrets.PERSO_ACCESS_TOKEN }} - organization: dnum-mi - container: basegun/basegun-backend - dry-run: false - untagged: true - - name: Delete untagged images - uses: vlaurin/action-ghcr-prune@main - with: - token: ${{ secrets.PERSO_ACCESS_TOKEN }} - organization: dnum-mi - container: basegun/basegun-frontend - dry-run: false - untagged: true + # build-push: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - name: Build the Docker image + # run: make build-prod + # - name: Test running the docker containers + # run: | + # make up-prod + # ./infra/scripts/test-alive.sh localhost + # make down-prod + # - name: Login to GHCR + # if: success() + # uses: docker/login-action@v1 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + # - name: Push on GHCR + # if: success() + # run: | + # make push + # make push-latest + # - name: Delete untagged images + # uses: vlaurin/action-ghcr-prune@main + # with: + # token: ${{ secrets.PERSO_ACCESS_TOKEN }} + # organization: dnum-mi + # container: basegun/basegun-backend + # dry-run: false + # untagged: true + # - name: Delete untagged images + # uses: vlaurin/action-ghcr-prune@main + # with: + # token: ${{ secrets.PERSO_ACCESS_TOKEN }} + # organization: dnum-mi + # container: basegun/basegun-frontend + # dry-run: false + # untagged: true - deploy-prod: - uses: ./.github/workflows/change-values-kube.yml - needs: build-push - with: - branch: main - namespace: basegun-prod - domain: basegun.fr - secrets: - API_OVH_TOKEN: ${{ secrets.API_OVH_TOKEN }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - JOB_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - KUBECONFIG: ${{ secrets.PREPROD_K8_CONFIG }} - X_OVH_TOKEN: ${{ secrets.PREPROD_OVH_TOKEN }} + # deploy-prod: + # uses: ./.github/workflows/change-values-kube.yml + # needs: build-push + # with: + # branch: main + # namespace: basegun-prod + # domain: basegun.fr + # secrets: + # API_OVH_TOKEN: ${{ secrets.API_OVH_TOKEN }} + # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # JOB_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # KUBECONFIG: ${{ secrets.PREPROD_K8_CONFIG }} + # X_OVH_TOKEN: ${{ secrets.PREPROD_OVH_TOKEN }} - test: - runs-on: ubuntu-latest - needs: deploy-prod - steps: - - uses: actions/checkout@v2 - - name: Test DNS - if: success() - run : | - ./infra/scripts/test-alive.sh basegun.fr \ No newline at end of file + # test: + # runs-on: ubuntu-latest + # needs: deploy-prod + # steps: + # - uses: actions/checkout@v2 + # - name: Test DNS + # if: success() + # run : | + # ./infra/scripts/test-alive.sh basegun.fr \ No newline at end of file diff --git a/Makefile b/Makefile index 218f1718..641d05d1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash DOCKER := $(shell type -p docker) DC := ${DOCKER} compose -TAG := 3.3 +TAG := 4.0.0 APP_NAME := basegun REG := ghcr.io ORG := dnum-mi From 8e7e7b392c630f84713d40db402c44446c0ac7b4 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 17 Jul 2024 14:44:07 +0200 Subject: [PATCH 09/23] build: :green_heart: add CI_COMMIT_TAG to docker image names in gitlab-dso --- .gitlab-ci-dso.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci-dso.yml b/.gitlab-ci-dso.yml index bea57bb5..76842a60 100644 --- a/.gitlab-ci-dso.yml +++ b/.gitlab-ci-dso.yml @@ -25,7 +25,7 @@ read_secret: docker-build-frontend: variables: WORKING_DIR: "frontend" - IMAGE_NAMES: basegun-frontend:${CI_COMMIT_REF_SLUG} basegun-frontend:${CI_COMMIT_SHORT_SHA} + IMAGE_NAMES: basegun-frontend:${CI_COMMIT_REF_SLUG} basegun-frontend:${CI_COMMIT_SHORT_SHA} basegun-frontend:${CI_COMMIT_TAG} DOCKERFILE: "frontend/Dockerfile" BUILD_ARGS: --build-arg=VERSION=1.1.1 stage: docker-build @@ -35,7 +35,7 @@ docker-build-frontend: docker-build-backend: variables: WORKING_DIR: "backend" - IMAGE_NAMES: basegun-backend:${CI_COMMIT_REF_SLUG} basegun-backend:${CI_COMMIT_SHORT_SHA} + IMAGE_NAMES: basegun-backend:${CI_COMMIT_REF_SLUG} basegun-backend:${CI_COMMIT_SHORT_SHA} basegun-backend:${CI_COMMIT_TAG} DOCKERFILE: "backend/Dockerfile" BUILD_ARGS: --build-arg=VERSION=1.1.1 stage: docker-build From 02ab08c1efc338947119b3511b8297b5c30b68b3 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 11 Jul 2024 12:56:38 +0200 Subject: [PATCH 10/23] Show contact only to authenticated users --- frontend/src/components/ContactExpert.vue | 39 +------------------ .../src/components/authentication/User.vue | 11 ------ frontend/src/router/index.ts | 16 ++++---- 3 files changed, 10 insertions(+), 56 deletions(-) delete mode 100644 frontend/src/components/authentication/User.vue diff --git a/frontend/src/components/ContactExpert.vue b/frontend/src/components/ContactExpert.vue index 4c3a06d9..4a673712 100644 --- a/frontend/src/components/ContactExpert.vue +++ b/frontend/src/components/ContactExpert.vue @@ -1,13 +1,4 @@ - +