Commit b71b4751 authored by A.M.R.Y Bandara 's avatar A.M.R.Y Bandara

Games home page js file

parent 070ec27b
import React, { Component } from 'react';
import { Container, Row } from 'reactstrap';
import homedata from '../../data/home.json';
import {Button} from 'react-bootstrap';
import axios from "axios";
import Loader from 'react-loader-spinner'
import Typed from 'react-typed';
import Navbar from '../global-components/navbar';
import Footer from '../global-components/footer';
import {Form, Col,Card,Table, Overlay,Modal, ButtonGroup} from 'react-bootstrap';
class Mammogram extends Component {
constructor(){
super()
this.state={
show: false,
Uploadfile: null,
result: null,
loader: false,
imgPath: null,
size: null,
level: null,
nipple: null,
umame: null
}
this.checkUser = this.checkUser.bind(this);
}
componentDidMount(){
this.setState({uname:sessionStorage.getItem('userName')});
}
handleAge = (event) => {
console.log(event.target.value)
this.setState({age:event.target.value})
}
handleGender = (event) => {
console.log(event.target.value)
this.setState({gender:event.target.value})
}
handleNewImage(e) {
let file = e.target.files[0]
this.setState({Uploadfile:file})
}
submitData(e){
this.setState({show:false})
this.setState({loader:true})
let file = this.state.Uploadfile
let currentComponent = this;
const data = new FormData();
data.append('file', file);
data.append('filename', "aa");
axios({
url: 'http://localhost:5000/checkMammogram',
method: "POST",
data:data
}).then((response) => {
currentComponent.setState({show:true})
currentComponent.setState({loader:false})
currentComponent.setState({imgPath:response.data["path"]})
currentComponent.setState({size:response.data["size"]})
if(response.data["status"] == "1"){
currentComponent.setState({result:"Malignant"})
}else if(response.data["status"] == "0"){
currentComponent.setState({result:"Benign"})
}else{
currentComponent.setState({result:"Normal"})
}
if(response.data["nipple"] == "0"){
currentComponent.setState({nipple:"Abnormal"})
}else{
currentComponent.setState({nipple:"Normal"})
}
});
}
checkUser(){
console.log(sessionStorage.getItem('userName'))
if(sessionStorage.getItem('userName') == null){
this.setState({modelShow:true})
}else{
this.props.history.push({
pathname: '/mam',
search: '?query=',
state: { img: this.state.imgPath, size:this.state.size,status:this.state.result,nipple:this.state.nipple }
})
}
}
CloseModal(){
this.setState({modelShow:!this.state.modelShow})
}
render () {
let getData = homedata.herov2
let factsInfo = homedata.results
let sectionHeadingInfo = factsInfo.sectionHeading
let getSpecialFeatures = homedata.upload
let publicUrl = process.env.PUBLIC_URL
const inlineStyle = {
backgroundImage : 'url('+publicUrl+getSpecialFeatures.bgImg+')'
}
return (
<>
<Navbar/>
<br/>
<br/>
<section id="home" className="text-center hero-section-1">
<ButtonGroup vertical>
<button className="games_btn" ><a href="#leaderboard" target="_blank" style={{color:"#fff"}}>Leader Board</a></button><br/>
<button className="games_btn" ><a href={'http://127.0.0.1:5000/addition?name='+sessionStorage.getItem('userName')} target="_blank" style={{color:"#fff"}}>Addition</a></button><br/>
<button className="games_btn" ><a href={'http://127.0.0.1:5000/substraction?name='+sessionStorage.getItem('userName')} target="_blank" style={{color:"#fff"}}>Substraction</a></button><br/>
<button className="games_btn" ><a href={'http://127.0.0.1:5000/division?name='+sessionStorage.getItem('userName')} target="_blank" style={{color:"#fff"}}>Division</a></button><br/>
<button className="games_btn" ><a href={'http://127.0.0.1:5000/multiplication?name='+sessionStorage.getItem('userName')} target="_blank" style={{color:"#fff"}}>Multiplication</a></button>
</ButtonGroup>
</section>
<br/>
<br/>
<br/>
<Footer/>
</>
)
}
}
export default Mammogram
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment