이윤영

Modify HomeTab

...@@ -80,6 +80,29 @@ export default class HomeTab extends Component { ...@@ -80,6 +80,29 @@ export default class HomeTab extends Component {
80 } 80 }
81 }; 81 };
82 82
83 + get_diff_data(){
84 + return fetch('http://10.0.2.2:3000/app/get_diff_data/',{
85 + method:'POST',
86 + headers: {
87 + 'Accept': 'application/json',
88 + 'Content-Type': 'application/json',
89 + },
90 + body:JSON.stringify({
91 + ras_id : this.state.ID,
92 + date : this.state.today,
93 + }),
94 + })
95 + .then((response) => console.log(response.json()))
96 + .then((responseJson)=> {
97 + console.log(responseJson)
98 + alert(responseJson[0].ras_id.S);
99 + },function(){
100 + })
101 + .catch((error) => {
102 + console.error(error);
103 + })
104 + }
105 +
83 render() { 106 render() {
84 // const fill = 'rgb(134, 65, 244)' 107 // const fill = 'rgb(134, 65, 244)'
85 // const data = [50, 10, 40, 95, -4, -24, null, 85, undefined, 0, 35, 53, -53, 24, 50, -20, -80] 108 // const data = [50, 10, 40, 95, -4, -24, null, 85, undefined, 0, 35, 53, -53, 24, 50, -20, -80]
......
...@@ -16,7 +16,8 @@ export default class HomeTab extends Component { ...@@ -16,7 +16,8 @@ export default class HomeTab extends Component {
16 super(props); 16 super(props);
17 this.state = { 17 this.state = {
18 ID : this.props.navigation.getParam('id','pi1'), 18 ID : this.props.navigation.getParam('id','pi1'),
19 - today : date.getFullYear() + "." + month + "." + date.getDate(), 19 + // today : date.getFullYear() + "." + month + "." + date.getDate(),
20 + today : "1576237044146.4011",
20 current_weight : get_now_weight() , 21 current_weight : get_now_weight() ,
21 table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'], 22 table_contents : [['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','4:27:52', '+0.12kg', 'Total : 1.38kg'],
22 ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'], 23 ['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],['오후','6:12:15', '+0.25kg', 'Total : 1.5 kg'],
...@@ -36,11 +37,13 @@ export default class HomeTab extends Component { ...@@ -36,11 +37,13 @@ export default class HomeTab extends Component {
36 }, 37 },
37 body:JSON.stringify({ 38 body:JSON.stringify({
38 ras_id : this.state.ID, 39 ras_id : this.state.ID,
39 - date : this.state.today, 40 + //date : this.state.today,
41 + date : "1576237047226.6567"
40 }), 42 }),
41 }) 43 })
42 .then((response) => console.log(response.json())) 44 .then((response) => console.log(response.json()))
43 .then((responseJson)=> { 45 .then((responseJson)=> {
46 + //alert(responseJson[0][0].ras_id.S);
44 console.log(responseJson) 47 console.log(responseJson)
45 },function(){ 48 },function(){
46 }) 49 })
......
...@@ -54,16 +54,15 @@ export function add_data(responseJson){ ...@@ -54,16 +54,15 @@ export function add_data(responseJson){
54 } 54 }
55 55
56 return responseJson.length; 56 return responseJson.length;
57 -} 57 +}
58 58
59 export function get_now_weight(){ 59 export function get_now_weight(){
60 let wastes = realm.objects('Waste'); 60 let wastes = realm.objects('Waste');
61 let recent = realm.objects('Waste').max('date').date; 61 let recent = realm.objects('Waste').max('date').date;
62 let recentWeight = wastes.filtered('date = 1576223063238.5166'); 62 let recentWeight = wastes.filtered('date = 1576223063238.5166');
63 - 63 + //"id == %@", id!
64 + console.log(String(wastes.lenth));
64 return recentWeight[0].weight; 65 return recentWeight[0].weight;
65 -
66 - // return "3.8"
67 } 66 }
68 67
69 export function get_recent_date(){ 68 export function get_recent_date(){
......