Commit 14cb368e authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Merge branch 'master' of http://gitlab.sliit.lk/21_22-j-38/21_22j-38 into it18257632

parents 3997ed27 b7375c8e
......@@ -3,8 +3,8 @@ from flask import Flask, render_template, request, jsonify, make_response
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.userModel import getUser, saveUserSession, logoutUser
from API.model.color.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, \
storeResult, save_color_session_details
from API.model.color.colorModel import *
from API.model.color.colorModel import *
from flask import Flask, redirect, url_for, render_template, request, jsonify, make_response
import random
import os
......@@ -39,15 +39,20 @@ def getColorActivities2():
# Get Color result route
@app.route("/getColorActivitiesResult")
def getColorActivitiesResult():
req = request.get_json()
userId = req['userId']
# print("data_dic")
@app.route("/getColorActivitiesResult/<userId>", methods=['GET'])
def getColorActivitiesResult(userId):
result = get_color_activity_result(userId)
assert userId == request.view_args['userId']
result = get_color_result(userId)
return result
response = {
"data": result,
"message": "Success",
"status": 200
}
body = jsonify(response)
return make_response(body)
# return userId
# Predict route
......@@ -238,4 +243,4 @@ def reading_result(userId):
if __name__ == "__main__":
app.run(host='192.168.1.101')
app.run(host='192.168.8.100')
......@@ -12,7 +12,7 @@ def create_con():
database="helply",
host="127.0.0.1",
user="root",
password="12345678"
password="rp19970520"
)
return db
......
......@@ -129,3 +129,7 @@ def sendPredictData(audioFile, name):
print(f"data: {data}")
return jsonify(data)
def get_color_result(userId):
qry = 'SELECT date, time, value, result FROM coloractivityresult WHERE userId = "{}"'.format(userId)
return get_data(qry)
\ No newline at end of file
......@@ -6,7 +6,14 @@ import client from '../screen/client/Client';
const userId = 1;
// const [tableContent, setTableContent] = useState();
const CONTENT = {
tableHead: ['Date', 'Time', 'Name', 'Result'],
tableData: [],
};
const CONTENT2 = {
tableHead: ['Date', 'Time', 'Name', 'Result'],
tableData: [
['1 jan 2022', '2s', 'Red', 'Good'],
......@@ -16,7 +23,6 @@ const CONTENT = {
['5 jan 2022', '2s', 'Blue', 'Good'],
['6 jan 2022', '2s', 'Yellow', 'Good'],
],
};
......@@ -24,22 +30,15 @@ export default function App() {
function getResult(userId) {
var data = {
userId: userId,
user: "userId",
}
data = JSON.stringify(data);
console.log(data);
client.post('getColorActivitiesResult', data, {
client.get('getColorActivitiesResult/'+userId, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}).then((response) => {
console.log(response.data);
CONTENT.tableData = response.data.data
console.log(CONTENT.tableData);
console.log(CONTENT2.tableData);
}).catch(err => {
console.log(err);
});
......@@ -59,14 +58,14 @@ export default function App() {
data={CONTENT.tableHead}
flexArr={[1, 1, 1, 1]}
style={styles.head}
// textStyle={styles.text}
textStyle={styles.text}
/>
<TableWrapper style={styles.wrapper}>
<Rows
data={CONTENT.tableData}
data={CONTENT2.tableData}
flexArr={[1, 1, 1, 1]}
style={styles.row}
// textStyle={styles.text}
textStyle={styles.text}
/>
</TableWrapper>
</Table>
......@@ -82,5 +81,5 @@ const styles = StyleSheet.create({
wrapper: { flexDirection: 'row' },
title: { flex: 1, },
row: { height: 40 },
// text: { textAlign: 'center', fontSize: 20, color: '#fff', },
text: { textAlign: 'center', fontSize: 20, color: '#fff', },
});
\ No newline at end of file
......@@ -12,7 +12,7 @@ export default function Home({ navigation }){
React.useEffect(() => {
AsyncStorage.removeItem('colorToken');
// AsyncStorage.removeItem('colorToken');
const unsubscribe = navigation.addListener("focus", () => {
Orientation.unlockAllOrientations();
......
......@@ -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.1.101:5000/',
baseURL: 'http://192.168.8.100:5000/',
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