Merge branch 'main' of https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.fitbot" >
|
||||
package="com.example.fitbot">
|
||||
|
||||
<uses-feature android:name="com.softbank.hardware.pepper" />
|
||||
|
||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -20,7 +24,10 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme" >
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.activities.HelpActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activities.EndScreenActivity"
|
||||
android:exported="false" />
|
||||
@@ -29,8 +36,7 @@
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:exported="true" >
|
||||
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@@ -0,0 +1,15 @@
|
||||
package com.example.fitbot.ui.activities;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.fitbot.R;
|
||||
|
||||
public class HelpActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_help);
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.HelpActivity">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@@ -1,15 +1,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Om iets met de database te doen, is het handig om een functie te maken
|
||||
// die een `app` parameter en een `pool` parameter accepteert.
|
||||
// Deze moet dan geëxporteerd worden om deze te kunnen gebruiken in `server.js`.
|
||||
// Dit is een voorbeeld van hoe je dat zou kunnen doen:
|
||||
// module.exports = function(app, pool) { ... }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Request} request The incoming request
|
||||
@@ -19,18 +8,19 @@
|
||||
*/
|
||||
function handleIncoming(request, response, app, pool)
|
||||
{
|
||||
|
||||
let query = 'SELECT * FROM Exercise WHERE ExerciseID = ?';
|
||||
let parameters = [];
|
||||
|
||||
if (!request.hasOwnProperty('uid') || typeof request.uid !== 'number')
|
||||
{
|
||||
response
|
||||
.status(400)
|
||||
.send(JSON.stringify({error: 'Missing valid UID in request'}));
|
||||
return;
|
||||
}
|
||||
query = 'SELECT * FROM Exercise';
|
||||
} else parameters.push(request.uid);
|
||||
|
||||
// Acquire database connection
|
||||
pool.getConnection()
|
||||
.then(conn => {
|
||||
conn.query('SELECT * FROM Exercise WHERE ExerciseID = ?', [request.uid])
|
||||
conn.query(query, parameters)
|
||||
.then(rows => {
|
||||
if (rows.length === 0)
|
||||
{
|
||||
@@ -53,19 +43,21 @@ function handleIncoming(request, response, app, pool)
|
||||
}));
|
||||
}
|
||||
})
|
||||
.catch(_ => {
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
response
|
||||
.status(500)
|
||||
.send(JSON.stringify({error: 'Internal server error'}));
|
||||
.send(JSON.stringify({error: 'Internal server error (Querying)'}));
|
||||
})
|
||||
.finally(() => {
|
||||
conn.end();
|
||||
});
|
||||
})
|
||||
.catch(_ => {
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
response
|
||||
.status(500)
|
||||
.send(JSON.stringify({error: 'Internal server error'}));
|
||||
.send(JSON.stringify({error: 'Internal server error (Connection)'}));
|
||||
});
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ const databaseCredentials = {
|
||||
const pool = mariadb.createPool(databaseCredentials);
|
||||
|
||||
// Register incoming HTTP request handlers
|
||||
require('incoming_request_handlers')(app, pool);
|
||||
require('./incoming_request_handlers')(app, pool);
|
||||
|
||||
// Start server
|
||||
app.listen(serverPort, () => {
|
||||
|
Reference in New Issue
Block a user