Finish logic of View after detect result is returned.
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/App.vue
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/App.vue
									
									
									
									
									
								
							@ -2,13 +2,20 @@
 | 
				
			|||||||
  <header>
 | 
					  <header>
 | 
				
			||||||
    <nav-bar></nav-bar>
 | 
					    <nav-bar></nav-bar>
 | 
				
			||||||
  </header>
 | 
					  </header>
 | 
				
			||||||
  <main>
 | 
					  <main class="container">
 | 
				
			||||||
    <image-form @detect-responsed="onDetectResponsed"></image-form>
 | 
					    <image-form @detect-responsed="onDetectResponsed"></image-form>
 | 
				
			||||||
 | 
					    <detect-result
 | 
				
			||||||
 | 
					      :visible="detectResult.visible"
 | 
				
			||||||
 | 
					      :diseaseName="detectResult.diseaseName"
 | 
				
			||||||
 | 
					      :imageUrl="detectResult.imageUrl"
 | 
				
			||||||
 | 
					      :trustworthiness="detectResult.trustworthiness"
 | 
				
			||||||
 | 
					    ></detect-result>
 | 
				
			||||||
    <news-album></news-album>
 | 
					    <news-album></news-album>
 | 
				
			||||||
  </main>
 | 
					  </main>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
 | 
					import DetectResult from "./components/DetectResult.vue";
 | 
				
			||||||
import ImageForm from "./components/ImageForm.vue";
 | 
					import ImageForm from "./components/ImageForm.vue";
 | 
				
			||||||
import NavBar from "./components/NavBar.vue";
 | 
					import NavBar from "./components/NavBar.vue";
 | 
				
			||||||
import NewsAlbum from "./components/NewsAlbum.vue";
 | 
					import NewsAlbum from "./components/NewsAlbum.vue";
 | 
				
			||||||
@ -16,13 +23,25 @@ import NewsAlbum from "./components/NewsAlbum.vue";
 | 
				
			|||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "App",
 | 
					  name: "App",
 | 
				
			||||||
  components: {
 | 
					  components: {
 | 
				
			||||||
 | 
					    DetectResult,
 | 
				
			||||||
    ImageForm,
 | 
					    ImageForm,
 | 
				
			||||||
    NavBar,
 | 
					    NavBar,
 | 
				
			||||||
    NewsAlbum,
 | 
					    NewsAlbum,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  data() {
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					      detectResult: {
 | 
				
			||||||
 | 
					        diseaseName: "",
 | 
				
			||||||
 | 
					        imageUrl: "",
 | 
				
			||||||
 | 
					        trustworthiness: 0.0,
 | 
				
			||||||
 | 
					        visible: false,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    onDetectResponsed(res) {
 | 
					    onDetectResponsed(res) {
 | 
				
			||||||
      console.log(res);
 | 
					      this.detectResult = res.data;
 | 
				
			||||||
 | 
					      this.detectResult.visible = true;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -1,18 +1,29 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <div class="col" :hidden="!visible">
 | 
					  <section class="py-1 text-center container">
 | 
				
			||||||
 | 
					    <div class="row py-lg-3">
 | 
				
			||||||
 | 
					      <div class="col-lg-6 col-md-8 mx-auto" :hidden="!visible">
 | 
				
			||||||
        <h1 class="mb-3 text-center">Detect Result</h1>
 | 
					        <h1 class="mb-3 text-center">Detect Result</h1>
 | 
				
			||||||
    <img :src="imageUrl" :alt="'Disease ' + diseaseName" />
 | 
					        <img
 | 
				
			||||||
    <p>Trustworthiness: {{ trustworthiness }}</p>
 | 
					          class="img-thumbnail my-2 w-25"
 | 
				
			||||||
 | 
					          :src="imageUrl"
 | 
				
			||||||
 | 
					          :alt="'Disease ' + diseaseName"
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
 | 
					        <h3 class="my-1">{{ diseaseName }}</h3>
 | 
				
			||||||
 | 
					        <p class="my-1 lead text-muted">
 | 
				
			||||||
 | 
					          Trustworthiness: {{ trustworthiness }}
 | 
				
			||||||
 | 
					        </p>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </section>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    visible: { tyep: Boolean, default: false },
 | 
					 | 
				
			||||||
    diseaseName: { type: String },
 | 
					    diseaseName: { type: String },
 | 
				
			||||||
    trustworthiness: { type: Number },
 | 
					 | 
				
			||||||
    imageUrl: { type: String },
 | 
					    imageUrl: { type: String },
 | 
				
			||||||
 | 
					    trustworthiness: { type: Number },
 | 
				
			||||||
 | 
					    visible: { tyep: Boolean, default: false },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
				
			|||||||
@ -55,7 +55,7 @@ export default {
 | 
				
			|||||||
      };
 | 
					      };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      axios.post(this._uploadImgUrl(), formData, config).then((res) => {
 | 
					      axios.post(this._uploadImgUrl(), formData, config).then((res) => {
 | 
				
			||||||
        console.log(res.status);
 | 
					        this.$emit("detect-responsed", res);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user