Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/fedingo/MCPS-FridgePI
Browse files Browse the repository at this point in the history
  • Loading branch information
fedingo committed May 29, 2018
2 parents e9dc184 + e76ee21 commit c69a9d7
Show file tree
Hide file tree
Showing 15 changed files with 2,544 additions and 197 deletions.
2,444 changes: 2,444 additions & 0 deletions ClientApp/README.md

Large diffs are not rendered by default.

76 changes: 1 addition & 75 deletions ClientApp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ render() {
password: this.state.password,
userInsert: this.userInsert,
passwordInsert: this.passwordInsert,
host: "http://localhost:80/"
host: "http://192.168.43.99:8000/"
};
// host: "http://192.168.1.197:8000/"

return (
!this.state.isAuthenticating &&
Expand Down Expand Up @@ -93,76 +92,3 @@ render() {
}

export default withRouter(App);





/*
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import axios from 'axios'
import DocumentTitle from 'react-document-title'
import {Link} from 'react-router'
// As a quick reminder, our goal is to get back a user’s name from the /users/:username endpoint
class App extends Component {
constructor () {
super()
this.state = {
username:''
}
this.handleClick = this.handleClick.bind(this)
}
handleClick () {
this.setState({
showComponent: true,
title: 'Lista'
});
axios.get('https://api.github.com/users/sever567')
.then(response => this.setState({username: response.data.login}))
console.log('Success!')
}
handleSubmit(event) {
event.preventDefault();
window.location = "http://localhost:3000/Login";
}
render() {
return (
<DocumentTitle title={this.state.title}>
<div>
<h1 className="title_page">FridgePI</h1>
<div className='button__container'>
<div className='list_container'>
<ul>
<li>{this.state.username}</li>
<li>{this.state.username}</li>
<li>{this.state.username}</li>
<li>{this.state.username}</li>
<li>{this.state.username}</li>
<li>{this.state.username}</li>
</ul>
</div>
<button className='button' onClick={this.handleClick}>Aggiorna</button>
<Link onClick ={this.handleSubmit} >link</Link>
</div>
</div>
</DocumentTitle>
);
}
}
export default App
*/
2 changes: 1 addition & 1 deletion ClientApp/src/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export default ({ childProps }) =>
<AppliedRoute path="/lista" exact component={NewNote} props={childProps} />
<AppliedRoute path="/recipes" exact component={Recipes} props={childProps} />

{ /* Finally, catch all unmatched routes */ }
{ /* Catch all unmatched routes */ }
<Route component={NotFound} />
</Switch>;
60 changes: 1 addition & 59 deletions ClientApp/src/containers/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ handleSubmit = async event => {
this.setState({ isLoading: true });
try {
this.props.userHasAuthenticated(true);

console.log(this.state.email);
console.log(this.state.password);
this.props.userInsert(this.state.email);
Expand All @@ -50,7 +50,6 @@ handleSubmit = async event => {
password: this.state.password
}
})
// axios.get('http://192.168.1.105:8000/authenticate?username=topolino&password=pippo')
.then(response =>{ this.setState({api: response.data.code})


Expand Down Expand Up @@ -110,60 +109,3 @@ handleSubmit = async event => {
);
}
}




/*
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import axios from 'axios'
import DocumentTitle from 'react-document-title'
// As a quick reminder, our goal is to get back a user’s name from the /users/:username endpoint
class login extends Component {
constructor () {
super()
this.state = {
username:''
}
this.handleClick = this.handleClick.bind(this)
}
handleClick () {
this.setState({
showComponent: true,
title: 'Lista'
});
axios.get('https://api.github.com/users/sever567')
.then(response => this.setState({username: response.data.login}))
console.log('Success!')
}
render() {
return (
<DocumentTitle title={this.state.title}>
<div>
<h1 className="title_page">ABC</h1>
<div className='button__container'>
<div className='list_container'>
<ul>
<li>{this.state.username}</li>
</ul>
</div>
<button className='button' onClick={this.handleClick}>cazzo</button>
</div>
</div>
</DocumentTitle>
);
}
}
export default login
*/
20 changes: 3 additions & 17 deletions ClientApp/src/containers/NewNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export default class NewNote extends Component {
this.handleChangeTextShelf = this.handleChangeTextShelf.bind(this);
this.handleSubmitCode = this.handleSubmitCode.bind(this);
this.handleClickRicette = this.handleClickRicette.bind(this);


}

validateForm() {
Expand Down Expand Up @@ -53,12 +51,9 @@ export default class NewNote extends Component {
password: this.props.password
}
})
// axios.get('http://192.168.1.105:8000/authenticate?username=topolino&password=pippo')
.then(response =>{
this.setState({lista: response.data.result})
if(response.data.code===200){
console.log('Success!');
// console.log(this.state.lista[0].list[0]);

listTag.innerHTML="";
for(var k=0; k<this.state.lista.length;k++){
Expand All @@ -67,6 +62,8 @@ export default class NewNote extends Component {
for(var i=0; i<this.state.lista[k].list.length; i++)
listTag.innerHTML += "<li>"+ this.state.lista[k].list[i]+"</li>";
listTag.innerHTML+="</ul>";

console.log('Success!');
}
}
else {
Expand Down Expand Up @@ -101,7 +98,6 @@ export default class NewNote extends Component {
deviceID: this.state.value
}
})
// axios.get('http://192.168.1.105:8000/authenticate?username=topolino&password=pippo')
.then(response =>{
this.setState({lista2: response.data.result})
if(response.data.code===200){
Expand All @@ -127,22 +123,15 @@ export default class NewNote extends Component {

return (
<div className="NewNote">



<h1 className="title_page">My Fridge</h1>

<div className='button__container'>
<div className='list_container'>

<ul id="tabellina">

</ul>
</div>
<button className='button' onClick={this.handleClick}>Aggiorna</button>
<button className='button' onClick={this.handleClick}>Update</button>
<button className='button' onClick={this.handleClickRicette}>Recipes</button>
</div>

<form onSubmit={this.handleSubmitCode} className="text-center">
<label>
<h3 className="textTitle">Insert a new device: </h3>
Expand All @@ -151,10 +140,7 @@ export default class NewNote extends Component {
</label> <br/>
<input className="submitButton" type="submit" value="Submit" />
</form>

</div>
);
}
}

//<li>{this.props.location.state.password} </li>
32 changes: 1 addition & 31 deletions ClientApp/src/containers/Recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class NewNote extends Component {
this.onClickbutton = this.onClickbutton.bind(this);
}


onClickbutton(event){
alert("ciao");
}
Expand All @@ -34,12 +33,10 @@ export default class NewNote extends Component {
password: this.props.password,
}
})
// axios.get('http://192.168.1.105:8000/authenticate?username=topolino&password=pippo')
.then(response =>{
this.setState({content: response.data.result})
if(response.data.code===200){
console.log('Success!');

listContainer.innerHTML="";

for(var i=0; i<this.state.content.length;i++)
Expand All @@ -55,40 +52,15 @@ export default class NewNote extends Component {
"<a class=\"linkButton\" href=\""+this.state.content[i].source_url+"\">Open Recipe "+
"<span class=\"glyphicon glyphicon-search\" ></span> </a>"+
"";

/* listContainer.innerHTML="";
for(var i=0; i<this.state.content.length;i++){
var imageReveal = this.state.content[i].image_url;
listContainer.innerHTML+="<div class=\"immagini\" width=\"30\%\">";
listContainer.innerHTML+="<b>"+this.state.content[i].title+"</b> "+
"<a class=\"linkButton\" href=\""+this.state.content[i].source_url+"\">Cazzo "+
"<span class=\"glyphicon glyphicon-search\" ></span> </a><br></br> ";
listContainer.innerHTML+="<Image src=\"" + imageReveal + " \" width=\"50\%\"/>"+"</div>";
//<Glyphicon glyph="align-left" />
/* listContainer.innerHTML+="<img src=";
listContainer.innerHTML+="\"";
listContainer.innerHTML+=this.state.content[0].image_url;
listContainer.innerHTML+="\" alt=\"ciao\"/>";
*/


//href=\""+this.state.content[i].source_url+"\"
//listContainer.innerHTML+="</div>";
}
}
else {
console.log("Log in or Sign up");
console.log("Erroe in Recipes");
}
})


}


render() {
return (
<div className="NewNote">
Expand All @@ -98,10 +70,8 @@ export default class NewNote extends Component {
<div className="container_img" id="container1">

</div>
<button className='button' onClick={this.handleRecipes}>Aggiorna</button>
<button className='button' onClick={this.handleRecipes}>Update</button>
</div>
);
}
}

//<li>{this.props.location.state.password} </li>
10 changes: 0 additions & 10 deletions ClientApp/src/registerServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// In production, we register a service worker to serve assets from local cache.

// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.

// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.

const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
Expand Down
Binary file added Documents/FridgePi.pdf
Binary file not shown.
Binary file added Documents/FridgePi.pptx
Binary file not shown.
Binary file added Documents/MCPS-poster.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documents/MCPS-poster.pdf
Binary file not shown.
39 changes: 39 additions & 0 deletions PiCode/camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

#!/usr/bin/python
from picamera import PiCamera
from time import sleep
import sys
from sendimage import *


ip = sys.argv[1]
dev = sys.argv[2]

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.IN)
GPIO.setup(31,GPIO.OUT)
GPIO.output(31,0)
camera = PiCamera()

while True:
while GPIO.input(7) != 0:
if GPIO.input(7) == 0:
GPIO.output(31,1)
time.sleep(3)

camera.start_preview()
sleep(3)
camera.capture('./image.jpg')
camera.stop_preview()

print('immagine fatta')
sleep(3)

print('invio immagine')
send(ip,dev)
print('immagine inviata')
GPIO.output(31,0)

14 changes: 14 additions & 0 deletions PiCode/sendimages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import requests


def send(ip, dev):
url = 'http://'+str(ip)+'/sendImage'
files = {'image': open('image.jpg', 'rb'), 'device': dev}
requests.post(url, files=files)






Loading

0 comments on commit c69a9d7

Please sign in to comment.