2021-12-10 18:30:01 +01:00
|
|
|
<template>
|
|
|
|
<main>
|
|
|
|
<Loader v-if="loading" />
|
|
|
|
<InputFile label="YOUR PICTURE" :edit="image && image.file" @set="(value) => handlePhotoChange(value)" />
|
2021-12-17 18:06:18 +01:00
|
|
|
<div id="con">
|
|
|
|
<Button v-if="result === null" text="CONTINUE" :disabled="image === null" :icon="['fas', 'arrow-right']" @click.native="() => getResult()" />
|
|
|
|
<template v-else>
|
|
|
|
<!-- @MACIEJ tutaj wstaw nowy komponent, do ktorego np. przeslesz rozny tekst i typ (success, fail) zaleznie od zmiennej result. Ma wyswietlac czy jest kotek czy nie -->
|
|
|
|
<!-- @temp -->
|
2021-12-18 17:55:30 +01:00
|
|
|
<Result :result="result" />
|
|
|
|
<div id="buttons">
|
|
|
|
<Button id="again" text="TRY AGAIN" :icon="['fas', 'redo']" @click.native="getResult" />
|
2022-01-24 16:29:16 +01:00
|
|
|
<Button id="try" text="PICK ANOTHER" :icon="['fas', 'arrow-right']" @click.native="clear" />
|
2021-12-18 17:55:30 +01:00
|
|
|
</div>
|
2021-12-17 18:06:18 +01:00
|
|
|
</template>
|
|
|
|
</div>
|
2021-12-10 18:30:01 +01:00
|
|
|
</main>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
image: null,
|
|
|
|
result: null,
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handlePhotoChange (value) {
|
|
|
|
this.image = value
|
|
|
|
},
|
|
|
|
clear () {
|
|
|
|
this.image = null
|
|
|
|
this.result = null
|
|
|
|
},
|
2022-01-18 19:48:10 +01:00
|
|
|
async getResult () {
|
2021-12-10 18:30:01 +01:00
|
|
|
this.loading = true
|
2022-01-18 19:48:10 +01:00
|
|
|
|
|
|
|
const formData = new FormData()
|
|
|
|
formData.append('image', this.image.file)
|
|
|
|
|
|
|
|
const res = await this.$store.dispatch('axios/file', ['/image/check', formData])
|
|
|
|
this.result = res.data.is_cat === '1'
|
|
|
|
this.loading = false
|
2021-12-10 18:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|