Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/resultats #31

Merged
merged 5 commits into from
Mar 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 161 additions & 20 deletions frontend/src/components/Upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,49 @@
<p>Analyse...</p>
</div>
</div>
<div class="footer-background footer-text">
Basegun est un outil d'aide à la décision. Il ne remplace en aucun cas l'avis d'un expert.
</div>
</div>
<div class="result" v-else>
<p class="result-text">{{ resultText }}</p>
<img class="result-img img-fluid" :src="imgName" alt="Image téléversée">
<div>
<button class="btn btn-primary btn-margin" @click="reloadPage">Recommencer</button>
<div class="result-image">
<img class="img-fluid" :src="imgName" alt="Image téléversée">
</div>
<div class="fr-callout custom-callout">
<div v-if="confidence < 40">
<div class="callout-head">
<span class="fr-icon-error-line"></span>
<p class="fr-tag fr-tag--sm error-tag">Indice de fiabilité insuffisant</p>
</div>
<p>Nous n'avons pas suffisamment d'éléments pour fournir une réponse fiable. Nous vous conseillons de faire appel à un expert.</p>
</div>
<div v-else>
<div v-if="confidence > 70">
<div class="callout-head">
<span class="fr-icon-success-line"></span>
<p class="fr-tag fr-tag--sm success-tag">Indice de fiabilité : {{ Math.floor(confidence) }}%</p>
</div>
</div>
<div v-else>
<span class="fr-icon-warning-line"></span>
<p class="fr-tag fr-tag--sm warning-tag">Indice de fiabilité : {{ Math.floor(confidence) }}%</p>
<p class="warning-text">Nous vous conseillons de faire appel à un expert pour confirmer cette réponse.</p>
</div>
<p class="fr-callout__title">Catégorie {{ cleanCategory }}</p>
<p class="fr-callout__text">Type d'arme : {{ cleanLabel }}</p>
</div>
</div>
<div class="blank"></div>
<div class="footer-background footer-actions">
<div class="action-group" @click="reloadPage">
<span class="fr-fi-refresh-line" aria-hidden="true"></span>
<p class="action-group-text">RECOMMENCER</p>
</div>
<div class="action-group">
<span class="fr-fi-information-line" aria-hidden="true"></span>
<p class="action-group-text">A PROPOS</p>
</div>
</div>
</div>
<div class="warning-bottom">
Basegun est un outil d'aide à la décision. Il ne remplace en aucun cas l'avis d'un expert.
</div>
</div>
</template>
Expand All @@ -91,7 +124,59 @@
resultText: null,
imgName: null,
baseUrl: import.meta.env.BASE_URL,
labelButton: "Démarrer"
labelButton: "Démarrer",
label: null,
confidence: null,
results: {
revolver: {
displayLabel: "revolver",
category: "B ou D"
},
pistolet_semi_auto_moderne: {
displayLabel: "pistolet semi-automatique moderne",
category: "B"
},
pistolet_a_percussion_silex: {
displayLabel: "pistolet à percussion ou à silex",
category: "D"
},
autre_pistolet: {
displayLabel: "pistolet",
category: "B ou D"
},
epaule_a_percussion_silex: {
displayLabel: "arme d'épaule à percussion ou à silex",
category: "D"
},
epaule_a_un_coup: {
displayLabel: "arme d'épaule à un coup par canon",
category: "C"
},
epaule_a_levier_sous_garde: {
displayLabel: "arme d'épaule à levier de sous-garde",
category: "B ou C"
},
epaule_a_verrou: {
displayLabel: "arme d'épaule à verrou",
category: "B ou C"
},
epaule_a_pompe: {
displayLabel: "arme d'épaule à pompe",
category: "B ou C"
},
autre_epaule: {
displayLabel: "arme d'épaule non manuelle",
category: "A, B ou C"
}
}
}
},
computed: {
cleanLabel() {
return this.results[`${this.label}`].displayLabel
},
cleanCategory() {
return this.results[`${this.label}`].category
}
},
methods: {
Expand All @@ -107,6 +192,8 @@

axios.post('/upload', fd)
.then(res => {
this.label = res.data.label
this.confidence = res.data.confidence
this.resultText = "Type d'arme : " + res.data.label + " " + res.data.confidence + "%"
this.imgName = import.meta.env.BASE_URL + "temp/" +
res.data.file_name.substring(res.data.file_name.lastIndexOf("/")+1)
Expand All @@ -127,18 +214,27 @@
</script>

<style scoped>
.btn-margin {
margin: 10px 0;
}
.result {
margin: 0 auto;
max-width: 1000px;
}
.result-text {
background-color: #ececfe;
padding: 20px 0;
font-size: 24px;
font-weight: bold;
.result-image {
text-align: center;
margin: 0 auto
}
@media (min-width: 768px) {
.result-image {
max-width: 600px;
}
.custom-callout {
max-width: 600px;
margin: 12px auto
}
}
@media (max-width: 768px) {
.custom-callout {
margin: 12px
}
}
.centered {
position: fixed;
Expand All @@ -155,14 +251,59 @@
.accueil-subtitle {
font-size: 14px;
}
.warning-bottom {
.footer-background {
position: fixed;
top: 100%;
left: 50%;
transform: translate(-50%, -100%);
padding: 20px 10px;
text-align: center;
background-color: #f5f5fe;
width: 100%;
}
</style>
.footer-text {
padding: 20px 10px;
text-align: center;
}
.success-tag {
color: #297254;
background-color: #9ef9be;
margin-left: 5px;
}
.error-tag {
color: #ce0500;
background-color: #ffe9e9;
margin-left: 5px;
}
.warning-tag {
color: #b34000;
background-color: #ffe8e5;
margin-left: 5px;
}
.warning-text {
font-size: 12px;
font-style: italic;
line-height: 1rem;
margin-bottom: 12px;
}
.callout-head {
display: flex;
align-items: center;
}
.footer-actions {
display: flex;
justify-content: space-around;
color: #000091
}
.action-group {
text-align: center;
cursor: pointer;
margin: 8px 0
}
.action-group-text {
font-size: 12px;
font-weight: bold;
margin: 0
}
.blank {
height: 80px
}
</style>