bluejoyq

complete connection

...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
2 "devToolsPort": 19002, 2 "devToolsPort": 19002,
3 "expoServerPort": 19000, 3 "expoServerPort": 19000,
4 "packagerPort": 19001, 4 "packagerPort": 19001,
5 - "packagerPid": 31648, 5 + "packagerPid": 11640,
6 - "expoServerNgrokUrl": null, 6 + "expoServerNgrokUrl": "https://cx-ky7.anonymous.searchguide.exp.direct",
7 - "packagerNgrokUrl": null, 7 + "packagerNgrokUrl": "https://packager.cx-ky7.anonymous.searchguide.exp.direct",
8 - "ngrokPid": null 8 + "ngrokPid": 8960
9 } 9 }
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
3 "lanType": "ip", 3 "lanType": "ip",
4 "dev": true, 4 "dev": true,
5 "minify": false, 5 "minify": false,
6 - "urlRandomness": "83-zd2", 6 + "urlRandomness": "cx-ky7",
7 "https": false 7 "https": false
8 } 8 }
......
...@@ -13,7 +13,7 @@ export default RateBar = (props) => { ...@@ -13,7 +13,7 @@ export default RateBar = (props) => {
13 {props.score.msg.length ? 13 {props.score.msg.length ?
14 <> 14 <>
15 <View style={styles.container}> 15 <View style={styles.container}>
16 - <Text style={styles.Text}>점수</Text> 16 + <Text style={styles.Text}> 점수 : {props.score.full}</Text>
17 <View style={styles.colorContainer}> 17 <View style={styles.colorContainer}>
18 <View style={styles.textContainer}> 18 <View style={styles.textContainer}>
19 <View style={styles.colorA}></View><Text>키워드 점수</Text> 19 <View style={styles.colorA}></View><Text>키워드 점수</Text>
...@@ -55,6 +55,7 @@ export default RateBar = (props) => { ...@@ -55,6 +55,7 @@ export default RateBar = (props) => {
55 <HelperText type={'info'} visible={click==1} style={{fontSize:20}}>키워드 : {props.score.key}</HelperText> 55 <HelperText type={'info'} visible={click==1} style={{fontSize:20}}>키워드 : {props.score.key}</HelperText>
56 <HelperText type={'info'} visible={click==2} style={{fontSize:20}}>맞춤법 : {props.score.fix}</HelperText> 56 <HelperText type={'info'} visible={click==2} style={{fontSize:20}}>맞춤법 : {props.score.fix}</HelperText>
57 </View> 57 </View>
58 + <Text>눌러서 각각의 점수를 알아보세요!</Text>
58 </> 59 </>
59 : <PromptSearchRate />} 60 : <PromptSearchRate />}
60 </Surface> 61 </Surface>
......
1 -import React from 'react'; 1 +import React, {useEffect} from 'react';
2 import { Surface, Text } from 'react-native-paper'; 2 import { Surface, Text } from 'react-native-paper';
3 import { StyleSheet } from 'react-native'; 3 import { StyleSheet } from 'react-native';
4 +import {connect} from 'react-redux';
5 +import {load } from '../../reducers/search';
6 +import PromptSearchRate from '../PromptSearch/PromptSearchRate';
4 7
5 -export default RateLine = () => ( 8 +
9 +const RateLine = ({load,pastScore }) => {
10 + useEffect(()=>{
11 + const get = async () => {
12 + await load();
13 + }
14 + get();
15 + }, [load]);
16 +
17 + return (
6 <Surface style={styles.surface}> 18 <Surface style={styles.surface}>
7 - <Text>Surface</Text> 19 + {pastScore.length ?
20 + pastScore.map((elem,index)=> (
21 + <Text key={index}>{elem}</Text>
22 + )) : <PromptSearchRate />
23 + }
8 </Surface> 24 </Surface>
9 -); 25 + );
26 +}
27 +
28 +
10 29
11 const styles = StyleSheet.create({ 30 const styles = StyleSheet.create({
12 surface: { 31 surface: {
...@@ -20,3 +39,16 @@ const styles = StyleSheet.create({ ...@@ -20,3 +39,16 @@ const styles = StyleSheet.create({
20 marginBottom: 10, 39 marginBottom: 10,
21 }, 40 },
22 }); 41 });
42 +
43 +const RateLineContainer = ( {load,pastScore } ) => (
44 + <RateLine load={load} pastScore={pastScore} />
45 +);
46 +
47 +export default connect(
48 + ({search})=>({
49 + pastScore:search.pastScore
50 + }),
51 + {
52 + load
53 + }
54 +)(RateLineContainer);
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -22,11 +22,17 @@ const RateSentence = ({originalText, fixedText, keywordText }) => { ...@@ -22,11 +22,17 @@ const RateSentence = ({originalText, fixedText, keywordText }) => {
22 return ( 22 return (
23 <Surface style={styles.surface} onTouchStart={calCount} > 23 <Surface style={styles.surface} onTouchStart={calCount} >
24 { keywordText ? 24 { keywordText ?
25 + <>
25 <View> 26 <View>
26 {count == 0 && ( <SentenceInfo Text={originalText} info={'원래 검색 문장'} color={'#B71C1C'} />) } 27 {count == 0 && ( <SentenceInfo Text={originalText} info={'원래 검색 문장'} color={'#B71C1C'} />) }
27 {count == 1 && ( <SentenceInfo Text={fixedText} info={'맞춤법 교정 문장'} color={'#2196F3'} />) } 28 {count == 1 && ( <SentenceInfo Text={fixedText} info={'맞춤법 교정 문장'} color={'#2196F3'} />) }
28 {count == 2 && ( <SentenceInfo Text={keywordText} info={'키워드 교정 문장'} color={'#00a676'} />) } 29 {count == 2 && ( <SentenceInfo Text={keywordText} info={'키워드 교정 문장'} color={'#00a676'} />) }
29 </View> 30 </View>
31 + <View style={{flexDirection:'column-reverse', height:50}}>
32 + <Text >눌러서 변화 과정을 지켜보세요!</Text>
33 + </View>
34 +
35 + </>
30 : <PromptSearchRate /> 36 : <PromptSearchRate />
31 } 37 }
32 38
......
1 const axios = require('axios') 1 const axios = require('axios')
2 -const filter = require('./filter') 2 +import filter from './filter';
3 3
4 export const sendSearch = async(searchText) => { 4 export const sendSearch = async(searchText) => {
5 - console.log(searchText)
6 return new Promise((resolve,reject) => { 5 return new Promise((resolve,reject) => {
7 let isBlank_reg = "/\s\g" 6 let isBlank_reg = "/\s\g"
8 if(searchText=== "" || searchText.length > 30 ){ 7 if(searchText=== "" || searchText.length > 30 ){
9 - resolve(JSON.stringify({ "return_code" : -1, "error_code": "검색 단어를 확인해 주세요!" })); 8 + resolve({ "return_code" : -1, "error_code": "검색 단어를 확인해 주세요!" });
10 } else{ 9 } else{
11 axios( 10 axios(
12 { 11 {
...@@ -14,7 +13,7 @@ export const sendSearch = async(searchText) => { ...@@ -14,7 +13,7 @@ export const sendSearch = async(searchText) => {
14 "Accept": "application/json", 13 "Accept": "application/json",
15 "Content-Type": "application/json", 14 "Content-Type": "application/json",
16 }, 15 },
17 - url: 'http://1.201.142.118:80/api/cliConnection', 16 + url: 'http://34.84.91.190:80/api/cliConnection',
18 data: { 17 data: {
19 data:{ 18 data:{
20 text: searchText.replace(/\s{1,}/g,' ') 19 text: searchText.replace(/\s{1,}/g,' ')
...@@ -24,19 +23,14 @@ export const sendSearch = async(searchText) => { ...@@ -24,19 +23,14 @@ export const sendSearch = async(searchText) => {
24 } 23 }
25 ) 24 )
26 .then((response)=>{ 25 .then((response)=>{
27 - resolve(JSON.stringify(filter(response.data))) 26 + resolve(filter(response.data))
27 + return true;
28 }) 28 })
29 .catch(error => { 29 .catch(error => {
30 - console.error(error); 30 + throw new Error(err)
31 }); 31 });
32 } 32 }
33 setTimeout( () => { 33 setTimeout( () => {
34 - try { 34 + throw new Error( "time out" );} ,10000)
35 - throw new Error( "ERROR" );
36 - }
37 - catch (err) {
38 - resolve(JSON.stringify({ "return_code" : -1, "error_code" : err.message }));
39 - return false;
40 - }},10000)
41 }) 35 })
42 } 36 }
...\ No newline at end of file ...\ No newline at end of file
......
1 import * as SQLite from 'expo-sqlite'; 1 import * as SQLite from 'expo-sqlite';
2 -import { Modal } from 'react-native';
3 import { openDatabase,transaction,executeSql } from 'expo-sqlite'; 2 import { openDatabase,transaction,executeSql } from 'expo-sqlite';
4 -import { rejects } from 'assert';
5 3
6 4
7 let sqlite = {}; 5 let sqlite = {};
......
1 -
2 -
3 -const TOGGLE = 'loading/TOGGLE';
4 -
5 -export const toggle = () => ({ type: TOGGLE})
6 -
7 -const initialState = {
8 - isLoading: false,
9 -};
10 -
11 -export default loading = (state = initialState, action) => {
12 - switch (action.type) {
13 - case TOGGLE:
14 - return {...state, isLoading: !state.isLoading };
15 - default:
16 - return state;
17 - }
18 -}
...\ No newline at end of file ...\ No newline at end of file
1 import {sendSearch} from '../lib/api' 1 import {sendSearch} from '../lib/api'
2 +import {Alert} from 'react-native'
2 import {readTest} from '../lib/readTest'; 3 import {readTest} from '../lib/readTest';
4 +import sqlite from '../lib/sqlite';
3 5
6 +const LOAD = 'search/LOAD';
4 const CHANGE = 'search/CHANGE'; 7 const CHANGE = 'search/CHANGE';
5 const SUCCESS = 'search/SUCCESS'; 8 const SUCCESS = 'search/SUCCESS';
6 const FAILURE = 'search/FAILURE'; 9 const FAILURE = 'search/FAILURE';
...@@ -11,16 +14,32 @@ export const change = (text) => ({ ...@@ -11,16 +14,32 @@ export const change = (text) => ({
11 text, 14 text,
12 }) 15 })
13 16
17 +export const load = () => async (dispatch) =>{
18 + let past = await sqlite.select();
19 + past = await past.map( elem => elem.score );
20 + dispatch({type:LOAD, past: past})
21 +}
22 +
14 export const submit = (text) => async (dispatch) => { 23 export const submit = (text) => async (dispatch) => {
15 dispatch( {type:START}); 24 dispatch( {type:START});
16 try{ 25 try{
17 - /*const response = await sendSearch(text);*/ 26 + const response = await sendSearch(text.nativeEvent.text);
18 - const response = await readTest(); // 테스트용입니당~ 27 + let tempScore = scoring(response.return_data).full;
28 + await sqlite.insert(tempScore);
29 + let past = await sqlite.select();
30 + past = past.map( elem => elem.score );
19 //dispatch( { type:SUCCESS, result:response } 31 //dispatch( { type:SUCCESS, result:response }
20 - setTimeout(()=>dispatch( { type:SUCCESS, result:response }),500); // 셋타임아웃도 테스트용 32 + dispatch( { type:SUCCESS, result:response, past: past})
21 } 33 }
22 catch(err){ 34 catch(err){
23 - dispatch({ type:FAILURE, result:response }) 35 + console.log(err);
36 + /* Alert.alert(
37 + 'error',
38 + [
39 + {text: '확인', onPress: () => {}},
40 + ],
41 + ) */
42 + dispatch({ type:FAILURE })
24 } 43 }
25 } 44 }
26 45
...@@ -33,6 +52,7 @@ const initialState = { ...@@ -33,6 +52,7 @@ const initialState = {
33 } 52 }
34 }, 53 },
35 isLoading: false, 54 isLoading: false,
55 + pastScore: [10,10,10,10,10,10],
36 }; 56 };
37 57
38 export default ToggleLoading = (state = initialState, action) => { 58 export default ToggleLoading = (state = initialState, action) => {
...@@ -40,11 +60,13 @@ export default ToggleLoading = (state = initialState, action) => { ...@@ -40,11 +60,13 @@ export default ToggleLoading = (state = initialState, action) => {
40 case CHANGE: 60 case CHANGE:
41 return {...state, query: action.text}; 61 return {...state, query: action.text};
42 case SUCCESS: 62 case SUCCESS:
43 - return {...state, isLoading:false,result: action.result}; 63 + return {...state, isLoading:false,result: action.result, pastScore: action.past};
44 case FAILURE: 64 case FAILURE:
45 return {...state, isLoading:false}; 65 return {...state, isLoading:false};
46 case START: 66 case START:
47 return {...state, query:'',isLoading:true} 67 return {...state, query:'',isLoading:true}
68 + case LOAD:
69 + return {...state,pastScore: action.past}
48 default: 70 default:
49 return state; 71 return state;
50 } 72 }
......