Commit ed752d11 authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

Merge branch 'it18218640' into 'master'

It18218640

See merge request !176
parents 4c764fe4 30bcb5a2
# import MySQLdb # import MySQLdb
<<<<<<< HEAD
from flask import Flask, render_template, request, jsonify, make_response from flask import Flask, render_template, request, jsonify, make_response
from API.model.color.colorModel import save_color_session_details, sendPredictData from API.model.color.colorModel import save_color_session_details, sendPredictData
from API.model.readModel import save_activity_details, save_session_details from API.model.readModel import save_activity_details, save_session_details
from API.model.userModel import getUser, saveUserSession, logoutUser from API.model.userModel import getUser, saveUserSession, logoutUser
from API.model.color.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult from API.model.color.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult, save_color_session_details
=======
from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response
import random import random
import os import os
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, \
save_color_session_details
from API.model.readModel import * from API.model.readModel import *
from API.model.userModel import * from API.model.userModel import *
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult
from API.model.readModel import get_reading_activities from API.model.readModel import get_reading_activities
from API.routers.router import funtion_one from API.routers.router import funtion_one
>>>>>>> 6ba28c5f30fd429a3ed34216b55a685d5b3615f0
# from backend.IT18218640.keyword_spotting_service import Keyword_Spotting_service # from backend.IT18218640.keyword_spotting_service import Keyword_Spotting_service
...@@ -82,15 +77,14 @@ def predict(): ...@@ -82,15 +77,14 @@ def predict():
@app.route("/colorSession", methods=['POST']) @app.route("/colorSession", methods=['POST'])
def color_session(): def color_session():
req = request.get_json()
userId = req['userId'] token = save_color_session_details(1)
token = save_color_session_details(userId, 1) response = {
data = {
"token": token, "token": token,
"message": "Success", "message": "Success",
"status": 200 "status": 200
} }
body = jsonify(data) body = jsonify(response)
return make_response(body) return make_response(body)
...@@ -203,4 +197,4 @@ def save_reading(readingToken): ...@@ -203,4 +197,4 @@ def save_reading(readingToken):
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='192.168.1.101') app.run(host='192.168.8.100')
...@@ -12,7 +12,7 @@ def create_con(): ...@@ -12,7 +12,7 @@ def create_con():
database="helply", database="helply",
host="127.0.0.1", host="127.0.0.1",
user="root", user="root",
password="12345678" password="rp19970520"
) )
return db return db
...@@ -141,7 +141,7 @@ def insert(sql_query, args): ...@@ -141,7 +141,7 @@ def insert(sql_query, args):
db = create_con() db = create_con()
cursor = db.cursor() cursor = db.cursor()
try: try:
# cursor.execute(sql_query, args) cursor.execute(sql_query, args)
db.commit() db.commit()
db.close() db.close()
return 1 return 1
......
...@@ -84,10 +84,10 @@ def get_color_activity_result(userId): ...@@ -84,10 +84,10 @@ def get_color_activity_result(userId):
return jsonify(data_dic) return jsonify(data_dic)
# store color activity session fun # store color activity session fun
def save_color_session_details(userId, status): def save_color_session_details(status):
token = getUUID() token = getUUID()
qry = 'INSERT INTO colorsession (id,userId,token,status) VALUES (NULL, %s, %s, %s)' qry = 'INSERT INTO colorsession (id,token,status) VALUES (NULL, %s, %s)'
args = (userId, token, status) args = (token, status)
insert(qry, args) insert(qry, args)
return token return token
......
...@@ -17,6 +17,7 @@ export default function Color(props) { ...@@ -17,6 +17,7 @@ export default function Color(props) {
React.useEffect(() => { React.useEffect(() => {
setType(props.route.params.type); setType(props.route.params.type);
// AsyncStorage.removeItem('colorToken');
// const type2 = props.route.params.type2; // const type2 = props.route.params.type2;
...@@ -31,35 +32,50 @@ export default function Color(props) { ...@@ -31,35 +32,50 @@ export default function Color(props) {
return unsubscribe; return unsubscribe;
}, [navigation]); }, [navigation]);
const checkColorSession = () => {
AsyncStorage.getItem('colorToken')
.then(value => {
if (value == null) {
console.log('colorToken', value);
getColorSession(value);
} else {
console.log(value);
console.log('colorToken');
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
}
})
.catch(error => {
console.log(error);
});
};
const getColorSession = () => { const getColorSession = () => {
const data = {
userId: 1, client.post('colorSession', {
}; headers: {
client.post('colorSession', JSON.stringify(data), { Accept: 'application/json',
headers: { 'Content-Type': 'application/json',
Accept: 'application/json', },
'Content-Type': 'application/json',
},
}) })
.then(res => { .then(res => {
console.log(res.data); console.log(res.data);
if (res.status == 200) { if (res.status == 200) {
// console.log(res.data); // console.log(res.data);
const colorToken = res.data.token; const colorToken = res.data.token;
try { try {
AsyncStorage.setItem('colorToken', colorToken); AsyncStorage.setItem('colorToken', colorToken);
console.log(colorToken) // console.log(colorToken)
} catch (error) { } catch (error) {
console.log(error);
}
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
}
})
.catch(error => {
console.log(error); console.log(error);
} });
};
navigation.navigate("PrimaryType", { title: 'Primary Activities', id: 1 })
}
})
.catch(error => {
console.log(error);
});
};
return ( return (
...@@ -76,7 +92,7 @@ export default function Color(props) { ...@@ -76,7 +92,7 @@ export default function Color(props) {
</View> */} </View> */}
<View style={{ marginTop: 40 }}> <View style={{ marginTop: 40 }}>
<TouchableOpacity onPress={() => { getColorSession(); }} <TouchableOpacity onPress={() => { checkColorSession(); }}
style={styles.card}> style={styles.card}>
<View style={[{ flexDirection: "row" }]}> <View style={[{ flexDirection: "row" }]}>
...@@ -192,7 +208,7 @@ const styles = StyleSheet.create({ ...@@ -192,7 +208,7 @@ const styles = StyleSheet.create({
left: 50, left: 50,
bottom: 50 bottom: 50
}, },
card : { card: {
borderWidth: 5, borderWidth: 5,
borderColor: "purple", borderColor: "purple",
marginVertical: 20, marginVertical: 20,
...@@ -211,7 +227,7 @@ const styles = StyleSheet.create({ ...@@ -211,7 +227,7 @@ const styles = StyleSheet.create({
shadowOpacity: 0.3, shadowOpacity: 0.3,
shadowRadius: 1.5, shadowRadius: 1.5,
}, },
card2 : { card2: {
borderWidth: 5, borderWidth: 5,
borderColor: "orange", borderColor: "orange",
marginVertical: 20, marginVertical: 20,
...@@ -229,7 +245,7 @@ const styles = StyleSheet.create({ ...@@ -229,7 +245,7 @@ const styles = StyleSheet.create({
}, },
shadowOpacity: 0.3, shadowOpacity: 0.3,
shadowRadius: 1.5, shadowRadius: 1.5,
},card3 : { }, card3: {
borderWidth: 5, borderWidth: 5,
borderColor: "lightblue", borderColor: "lightblue",
marginVertical: 20, marginVertical: 20,
...@@ -247,20 +263,20 @@ const styles = StyleSheet.create({ ...@@ -247,20 +263,20 @@ const styles = StyleSheet.create({
}, },
shadowOpacity: 0.3, shadowOpacity: 0.3,
shadowRadius: 1.5, shadowRadius: 1.5,
},cardTitle: { }, cardTitle: {
fontWeight: "bold", fontWeight: "bold",
color: "white", color: "white",
fontSize: 35, fontSize: 35,
marginLeft: 10, marginLeft: 10,
marginTop: 80, marginTop: 80,
},cardTitle3: { }, cardTitle3: {
fontWeight: "bold", fontWeight: "bold",
color: "white", color: "white",
fontSize: 35, fontSize: 35,
marginLeft: 35, marginLeft: 35,
marginTop: 80, marginTop: 80,
} }
,cardImage: { , cardImage: {
padding: 0, padding: 0,
flex: 0.7, flex: 0.7,
}, },
......
...@@ -2,6 +2,7 @@ import React from "react"; ...@@ -2,6 +2,7 @@ import React from "react";
import { StyleSheet, View, Text, Pressable, SafeAreaView, ScrollView, Image } from 'react-native'; import { StyleSheet, View, Text, Pressable, SafeAreaView, ScrollView, Image } from 'react-native';
import Orientation from 'react-native-orientation-locker'; import Orientation from 'react-native-orientation-locker';
import ImageButton from "../component/ImageButton"; import ImageButton from "../component/ImageButton";
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function Home({ navigation }){ export default function Home({ navigation }){
...@@ -10,6 +11,9 @@ export default function Home({ navigation }){ ...@@ -10,6 +11,9 @@ export default function Home({ navigation }){
} }
React.useEffect(() => { React.useEffect(() => {
AsyncStorage.removeItem('colorToken');
const unsubscribe = navigation.addListener("focus", () => { const unsubscribe = navigation.addListener("focus", () => {
Orientation.unlockAllOrientations(); Orientation.unlockAllOrientations();
Orientation.lockToPortrait(); Orientation.lockToPortrait();
......
...@@ -260,7 +260,7 @@ export default function Green({ navigation }) { ...@@ -260,7 +260,7 @@ export default function Green({ navigation }) {
onFinish={() => setModalVisible(false)} onFinish={() => setModalVisible(false)}
digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: 'black' }} digitStyle={{ backgroundColor: '#FFF', borderWidth: 2, borderColor: 'black' }}
digitTxtStyle={{ color: 'black' }} digitTxtStyle={{ color: 'black' }}
timeLabelStyle={{ color: 'white', fontWeight: 'bold' }} timeLabelStyle={{ color: 'green', fontWeight: 'bold' }}
separatorStyle={{ color: 'black' }} separatorStyle={{ color: 'black' }}
timeToShow={['S']} timeToShow={['S']}
timeLabels={{ s: 'Seconds' }} timeLabels={{ s: 'Seconds' }}
......
...@@ -148,7 +148,7 @@ export default function Red({ navigation }) { ...@@ -148,7 +148,7 @@ export default function Red({ navigation }) {
sendData(mainColor[0]); sendData(mainColor[0]);
audioStart(); // audioStart();
} else { } else {
...@@ -192,6 +192,8 @@ export default function Red({ navigation }) { ...@@ -192,6 +192,8 @@ export default function Red({ navigation }) {
AsyncStorage.getItem('colorToken') AsyncStorage.getItem('colorToken')
.then(res => { .then(res => {
console.log(res)
var date = new Date().getDate(); var date = new Date().getDate();
var month = new Date().getMonth() + 1; var month = new Date().getMonth() + 1;
var year = new Date().getFullYear(); var year = new Date().getFullYear();
...@@ -242,7 +244,7 @@ export default function Red({ navigation }) { ...@@ -242,7 +244,7 @@ export default function Red({ navigation }) {
const startRecording = async () => { const startRecording = async () => {
setModalVisible(true); // setModalVisible(true);
try { try {
await Voice.start('en-US'); await Voice.start('en-US');
......
...@@ -2,6 +2,6 @@ import axios from 'axios'; ...@@ -2,6 +2,6 @@ import axios from 'axios';
// export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, }); // export default axios.create({ baseURL: 'http://192.168.8.102:5000/', timeout: 15000, });
export default axios.create({ export default axios.create({
baseURL: 'http://192.168.1.101:5000/', baseURL: 'http://192.168.8.100:5000/',
timeout: 15000, timeout: 15000,
}); });
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