유희정

referesh

This diff is collapsed. Click to expand it.
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
10 "lint": "eslint ." 10 "lint": "eslint ."
11 }, 11 },
12 "dependencies": { 12 "dependencies": {
13 + "aws-sdk": "^2.589.0",
13 "d3": "^5.14.2", 14 "d3": "^5.14.2",
14 "express": "^4.17.1", 15 "express": "^4.17.1",
15 "react": "16.9.0", 16 "react": "16.9.0",
......
...@@ -5,13 +5,17 @@ import Circle from '../component/circle_component' ...@@ -5,13 +5,17 @@ import Circle from '../component/circle_component'
5 import {Table, TableWrapper, Row,Rows} from 'react-native-table-component' 5 import {Table, TableWrapper, Row,Rows} from 'react-native-table-component'
6 var date = new Date(); 6 var date = new Date();
7 date.setHours(date.getHours()+9); 7 date.setHours(date.getHours()+9);
8 - 8 +var month = date.getMonth()+1;
9 +if(month == 11){
10 + month = 12
11 +}
9 export default class HomeTab extends Component { 12 export default class HomeTab extends Component {
10 13
11 constructor(props){ 14 constructor(props){
12 super(props); 15 super(props);
13 this.state = { 16 this.state = {
14 - today : date.getFullYear() + "." + date.getMonth() + "." + date.getDate(), 17 + ID : this.props.navigation.getParam('id','pi1'),
18 + today : date.getFullYear() + "." + month + "." + date.getDate(),
15 current_weight : 0, 19 current_weight : 0,
16 table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'], 20 table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'],
17 ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'], 21 ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],
...@@ -21,11 +25,34 @@ export default class HomeTab extends Component { ...@@ -21,11 +25,34 @@ export default class HomeTab extends Component {
21 ] 25 ]
22 } 26 }
23 } 27 }
28 +
29 + get_diff_data(){
30 + return fetch('http://10.0.2.2:3000/app/get_diff_data/',{
31 + method:'POST',
32 + headers: {
33 + 'Accept': 'application/json',
34 + 'Content-Type': 'application/json',
35 + },
36 + body:JSON.stringify({
37 + ras_id : this.state.ID,
38 + date : this.state.today,
39 + }),
40 + })
41 + .then((response) => console.log(response.json()))
42 + .then((responseJson)=> {
43 + console.log(responseJson)
44 + },function(){
45 + })
46 + .catch((error) => {
47 + console.error(error);
48 + })
49 + }
50 +
24 render() { 51 render() {
25 return ( 52 return (
26 <View style={style.container}> 53 <View style={style.container}>
27 <View style={style.header}> 54 <View style={style.header}>
28 - <Text style={style.tabName}>Home</Text> 55 + <Text style={style.tabName}>Home {this.state.ID}</Text>
29 </View> 56 </View>
30 <View style={{flexDirection:'row',flex:0.8,backgroundColor: "rgba(230,230,230,0.5)"}}> 57 <View style={{flexDirection:'row',flex:0.8,backgroundColor: "rgba(230,230,230,0.5)"}}>
31 <View style={{flex:1,justifyContent:'center'}}> 58 <View style={{flex:1,justifyContent:'center'}}>
...@@ -38,7 +65,8 @@ export default class HomeTab extends Component { ...@@ -38,7 +65,8 @@ export default class HomeTab extends Component {
38 </View> 65 </View>
39 <View style={style.current_state}> 66 <View style={style.current_state}>
40 <Circle 67 <Circle
41 - title={"3.6"}> 68 + title={"3.6"}
69 + onPress={()=>{this.get_diff_data()}}>
42 </Circle> 70 </Circle>
43 </View> 71 </View>
44 <View style={style.waste_detail}> 72 <View style={style.waste_detail}>
......
...@@ -4,16 +4,40 @@ import AddButton from '../component/AddButton' ...@@ -4,16 +4,40 @@ import AddButton from '../component/AddButton'
4 4
5 var date = new Date(); 5 var date = new Date();
6 date.setHours(date.getHours()+9); 6 date.setHours(date.getHours()+9);
7 +date.setMonth(date.getMonth()+1);
7 8
8 export default class SettingTab extends Component { 9 export default class SettingTab extends Component {
9 10
10 constructor(props){ 11 constructor(props){
11 super(props); 12 super(props);
12 this.state = { 13 this.state = {
13 - ID : 'abcdefg1234' 14 + ID : 'pi1',
15 + user : 'user1'
14 } 16 }
15 } 17 }
16 18
19 + save_app_data(){
20 + return fetch('http://10.0.2.2:3000/app/save_data/',{
21 + method:'POST',
22 + headers: {
23 + 'Accept': 'application/json',
24 + 'Content-Type': 'application/json',
25 + },
26 + body:JSON.stringify({
27 + ras_id : this.state.ID,
28 + user_id : this.state.user,
29 + }),
30 + })
31 + .then((response) => console.log(response.json()))
32 + .then((responseJson)=> {
33 + console.log(responseJson)
34 + },function(){
35 + })
36 + .catch((error) => {
37 + console.error(error);
38 + })
39 + }
40 +
17 delete_id(){ 41 delete_id(){
18 this.setState({ID: ''}) 42 this.setState({ID: ''})
19 //기기연결 해제, 디비비우기 43 //기기연결 해제, 디비비우기
...@@ -54,8 +78,9 @@ export default class SettingTab extends Component { ...@@ -54,8 +78,9 @@ export default class SettingTab extends Component {
54 placeholder="New Rasberry ID" 78 placeholder="New Rasberry ID"
55 value={this.state.text} 79 value={this.state.text}
56 onChangeText={(text)=>this.setState({ID:text})}/> 80 onChangeText={(text)=>this.setState({ID:text})}/>
57 - <AddButton></AddButton>
58 </View> 81 </View>
82 + <AddButton
83 + onPress={()=>{this.save_app_data()}}/>
59 </View> 84 </View>
60 </View> 85 </View>
61 </View> 86 </View>
......