Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Clément COMBIEN!
Browse files Browse the repository at this point in the history
On a abandonné mdr
  • Loading branch information
Ttiki committed Dec 6, 2021
1 parent 55688c4 commit fc47550
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 98 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ Ajouter des données comme :
L’utilité de ce projet et de permettre de faire un suivi de son poids, sa taille, son activité sportif facilement pour la vie de tous les jours.
Grâce à cette application, les utilisateurs pourront faire attention à leur santé et possiblement renseigner les médecins lors de visites.
De plus, avec les API de certaines applications, nous pourrions synchroniser les données directement dans l’application comme avec Google Fit pour le suivi sportif, Sleep as Android pour le suivi du sommeil, etc.


## Projet original
Vous pouver visiter la page GitLab du projet original en suivant [ce lien!](https://gitlab.com/adelnoureddine/harbour-weight-tracker)
2 changes: 1 addition & 1 deletion SuiviSante.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.15.2, 2021-12-04T21:24:00. -->
<!-- Written by QtCreator 4.15.2, 2021-12-05T19:24:53. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
Binary file modified icons/108x108/SuiviSante.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/128x128/SuiviSante.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/172x172/SuiviSante.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/86x86/SuiviSante.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion qml/SuiviSante.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ ApplicationWindow
METRIC_CODE INTEGER NOT NULL,
METRIC_DATE DATE NOT NULL,
CATEGORIE VARCHAR(20) NOT NULL,
VAL DECIMAL(3,2) NOT NULL,
VAL DECIMAL(3,2),
VAL2 DECIMAL(3,2),
VAL3 DECIMAL(3,2),
DATEH1 INT,
DATEM1 INT,
DATEH2 INT,
DATEM2 INT,
DATEH3 INT,
DATEM3 INT,
PRIMARY KEY(USER_CODE,METRIC_CODE),
FOREIGN KEY(USER_CODE) REFERENCES USERS(USER_CODE)
);';

// var createMetricsTable = 'DROP TABLE METRICS;';
db.transaction(
function(tx){
tx.executeSql(createMetricsTable);
Expand Down
26 changes: 23 additions & 3 deletions qml/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,36 @@ function info_user(user_code) {
if (rs.rows.length > 0) {
user_weight = parseFloat(rs.rows.item(0).VAL);
user_bmi = parseFloat(rs.rows.item(0).VAL2);

}

//Récupérer les informations sur le poids de l'utilisateur dans la BD
rs = tx.executeSql('SELECT * FROM METRICS WHERE USER_CODE=? AND CATEGORIE=? AND METRIC_CODE=?',[user_code,"SLEEP",metric_code]);
if (rs.rows.length > 0) {
user_sleepTime = parseFloat(rs.rows.item(0).VAL);
user_wakeTime = parseFloat(rs.rows.item(0).VAL2);
user_totalTime = parseFloat(rs.rows.items(0).VAL3);
var hours, minutes;
hours = parseFloat(rs.rows.item(0).DATEH1);
minutes = parseFloat(rs.rows.item(0).DATEM1);
user_sleepTime = new Date(0,0,0,hours, minutes,0)
hours = parseFloat(rs.rows.item(0).DATEH2);
minutes = parseFloat(rs.rows.item(0).DATEM2);
user_wakeTime = new Date(0,0,0,hours, minutes,0)
hours = parseFloat(rs.rows.item(0).DATEH3);
minutes = parseFloat(rs.rows.item(0).DATEM3);
user_totalTime = new Date(0,0,0,hours, minutes,0)
}

//Debug data print to display current user & its last data
print("New user : \n",
"User first name : " + user_first_name + "\n",
"User last name : " + user_lastname + "\n",
"User height : " + user_height + "\n",
"User last weight : " + user_weight + "\n",
"User last BMI : " + user_bmi + "\n",
"User last sleeping time : " + user_sleepTime + "\n",
"User last waking time : " + user_wakeTime + "\n",
"User last total sleeping time : " + user_totalTime + "\n")


arrayData = {
firstname: user_first_name,
lastname: user_lastname,
Expand Down
20 changes: 20 additions & 0 deletions qml/pages/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ Page {

onLinkActivated: Qt.openUrlExternally("https://gitlab.com/adelnoureddine/harbour-weight-tracker")
}
Text {
text: "OR"
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeSmall
//linkColor: Theme.highlightColor

//onLinkActivated: Qt.openUrlExternally("https://github.com/Stonks-Life-Inc/SuiviSante")
}
Text {
text: "<a href=\"https://github.com/Stonks-Life-Inc/SuiviSante\">" + qsTr("View source code on GitHub") + "</a>"
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeSmall
linkColor: Theme.highlightColor

onLinkActivated: Qt.openUrlExternally("https://github.com/Stonks-Life-Inc/SuiviSante")
}

SectionHeader {
text: qsTr("Health sources")
Expand Down
83 changes: 53 additions & 30 deletions qml/pages/AddMetric.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,37 @@ Page {
property string user_code;

property variant wtData;
property string sleepTimeVal;
property string wakeTimeVal;
property string sleepTotal;
property date sleepTimeVal;
property date wakeTimeVal;
property int sleepTotalValH;
property int sleepTotalValM;

function load() {
wtData = WtUtils.info_user(user_code);

WtUtils.getProfiles();
//WtUtils.getProfiles();
}

function calculateBMI() {

var user_height = WtUtils.height / 100
function calculateBMI(weight) {
var bmi;
var user_height = wtData.height / 100
var height_square = (user_height * user_height)
if ((WtUtils.weight > 0) && (user_height > 0)) {
bmi = WtUtils.weight / height_square;
// recommended_min_weight = 18.5 * height_square
// recommended_max_weight = 24.9 * height_square
// recommended_weight_description = "The recommended weight for your height is between " + recommended_min_weight.toFixed(2) + " kg and " + recommended_max_weight.toFixed(2) + " kg"
// calculate_bmi_category();
}
bmi = weight / height_square;
print("BMI = " + bmi)
return bmi
}

function calculateSleepTotal(sleepTime, wakeTime) {

//TODO: Sleep total time calc
sleepTotalValH = wakeTime.getHours() - sleepTime.getHours()
sleepTotalValM = wakeTime.getMinutes() - sleepTime.getMinutes()

print(totalSleepTimeHOUR, totalSleepTimeMIN, totalSleepTimeVal)

}

function addSleepMetric(sleepTime, wakeTime){
function addSleepMetric(){
print("Adding new sleep")
//load user_code from homepage, if(depth==3)adding from history else from homepage
//if(depth==3) user_code=previousPage().rootPage.user_code;
Expand All @@ -57,21 +59,30 @@ Page {
}
var date = new Date();
date = Qt.formatDate(date, "yyyy-MM-dd");
//sleepTotal = calculateSleepTotal(sleepTime, wakeTime)
rs = tx.executeSql('INSERT INTO METRICS VALUES (?,?,?,?,?,?,?)',[user_code,metric_code,date,"SLEEP",sleepTime, wakeTime, sleepTotal]);
//var sleepTotalVal = calculateSleepTotal(sleepTimeVal, wakeTimeVal)
rs = tx.executeSql('INSERT INTO METRICS VALUES (?,?,?,?,null,null,null,?,?,?,?,?,?)',[user_code,metric_code,date,"SLEEP",sleepTimeVal.getHours(),sleepTimeVal.getMinutes(), wakeTimeVal.getHours(), wakeTimeVal.getMinutes(), sleepTotalValH, sleepTotalValM]);
rs = tx.executeSql('SELECT * FROM METRICS WHERE USER_CODE=?',[user_code]);
//Debug print to display added data
print("New sleep data : \n",
"User code : " + user_code + "\n",
"Metric code : " + metric_code + "\n",
"Date : " + date + "\n",
"Type : SLEEP \n",
"Sleeping time : " + sleepTimeVal.getHours() + ":" + sleepTimeVal.getMinutes() + "\n",
"Waking time : " + wakeTimeVal.getHours() + ":" + wakeTimeVal.getMinutes() + "\n",
"Total sleep time : " + sleepTotalValH + ":" + sleepTotalValM + "\n")
}
)
//reload homepage if adding from homepage or history if adding metric from history page
previousPage().load();
//reload homepage if add from history page
if(depth==3) previousPage().rootPage.load();
if(depth==3) previousPage().load();
navigateBack(PageStackAction.Animated);
}


function addWeightMetric(value){
print(user_code)
var imc = calculateBMI()
value = value.replace(',', '.');
//load user_code from homepage, if(depth==3)adding from history else from homepage
//if(depth==3) user_code=previousPage().rootPage.user_code;
Expand All @@ -88,15 +99,23 @@ Page {
var date = new Date();
date = Qt.formatDate(date, "yyyy-MM-dd");

var imc = calculateBMI()
rs = tx.executeSql('INSERT INTO METRICS VALUES (?,?,?,?,?,?,null)',[user_code,metric_code,date,"WEIGHT",value, imc]);
imc = calculateBMI(value)

rs = tx.executeSql('INSERT INTO METRICS VALUES (?,?,?,?,?,?,null,null,null,null,null,null,null)',[user_code,metric_code,date,"WEIGHT",value, imc]);
rs = tx.executeSql('SELECT * FROM METRICS WHERE USER_CODE=?',[user_code]);
print("New weight data : \n",
"User code : " + user_code + "\n",
"Metric code : " + metric_code + "\n",
"Date : " + date + "\n",
"Type : WEIGHT \n",
"Weight : " + value + "\n",
"IMC : " + imc + "\n")
}
)
//reload homepage if adding from homepage or history if adding metric from history page
previousPage().load();
//reload homepage if add from history page
if(depth==3) previousPage().rootPage.load();
if(depth==3) previousPage().load();
navigateBack(PageStackAction.Animated);
}

Expand Down Expand Up @@ -186,7 +205,7 @@ Page {
}
onAccepted: {
addWeightMetric(weightMetricField.text)
rootPage.load();
page.load();
}
}
}
Expand All @@ -199,7 +218,7 @@ Page {

Dialog {
canAccept: sleepTime.text!="Choose a sleeping time" && wakeTime.text!="Choose a waking time"
acceptDestination: page
//acceptDestination: page
acceptDestinationAction: PageStackAction.Pop

Flickable {
Expand All @@ -223,10 +242,11 @@ Page {
var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", {
hour: 22,
minute: 30,
hourMode: DateTime.TwelveHours
hourMode: DateTime.TwentyFourHours
})
dialog.accepted.connect(function() {
sleepTimeVal = dialog.timeText
sleepTimeVal = dialog.time
print(sleepTimeVal.getHours() + ":" + sleepTimeVal.getMinutes())
sleepTime.text = "Choose a sleeping time: " + dialog.timeText
})
}
Expand All @@ -239,24 +259,27 @@ Page {
var dialog = pageStack.push("Sailfish.Silica.TimePickerDialog", {
hour: 8,
minute: 30,
hourMode: DateTime.TwelveHours
hourMode: DateTime.TwentyFourHours
})
dialog.accepted.connect(function() {
wakeTimeVal = dialog.timeText
wakeTimeVal = dialog.time
print(wakeTimeVal.getHours() + ":" + wakeTimeVal.getMinutes())
wakeTime.text = "Choose a waking time: " + dialog.timeText
})
}
}
}
}
onAccepted: {
addSleepMetric(sleepTimeVal, wakeTimeVal)
rootPage.load();
addSleepMetric()
page.load();

}
}
}
Component.onCompleted:{
user_code = WtUtils.getLastUser()
load()
print(user_code)
}
}
Expand Down
Loading

0 comments on commit fc47550

Please sign in to comment.