From a56e8ccb5cae107145369600b82a02ee4a365f77 Mon Sep 17 00:00:00 2001 From: cami Date: Wed, 21 Jul 2021 02:21:00 +0200 Subject: [PATCH 1/3] Renamed behavior to study --- frontend/src/App.js | 4 +- frontend/src/components/HeroSection.js | 2 +- frontend/src/components/pages/Login.js | 2 +- frontend/src/components/pages/Study.js | 123 +++++++++++++++++++++++ frontend/src/components/pages/Umfrage.js | 2 +- 5 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 frontend/src/components/pages/Study.js diff --git a/frontend/src/App.js b/frontend/src/App.js index 20f00f1..415c951 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -12,7 +12,7 @@ import Manual from "./components/pages/Manual"; import Secret from "./components/pages/Secret"; import Umfrage from "./components/pages/Umfrage"; import PrivateRoute from "./auth/PrivateRoute"; -import BehaviorNormal from "./components/pages/BehaviorNormal"; +import Study from "./components/pages/Study"; function App() { return ( @@ -28,7 +28,7 @@ function App() { - + diff --git a/frontend/src/components/HeroSection.js b/frontend/src/components/HeroSection.js index be197eb..1767dc4 100644 --- a/frontend/src/components/HeroSection.js +++ b/frontend/src/components/HeroSection.js @@ -17,7 +17,7 @@ function HeroSection() { className="btns" buttonStyle="btn--primary" buttonSize="btn--large" - newTo="behavior" + newTo="study" > Zur Studie diff --git a/frontend/src/components/pages/Login.js b/frontend/src/components/pages/Login.js index 46dd4c5..c6ea7f8 100644 --- a/frontend/src/components/pages/Login.js +++ b/frontend/src/components/pages/Login.js @@ -70,7 +70,7 @@ export default function Login() { ) : ( <> - + )} diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js new file mode 100644 index 0000000..a6bbeab --- /dev/null +++ b/frontend/src/components/pages/Study.js @@ -0,0 +1,123 @@ +import React, { useEffect } from "react"; +import "../../App.css"; +import Footer from "../../Footer"; +import InputField from "../InputField"; +import SubmitField from "../SubmitField"; +import { Logger } from "@behametrics/logger-web"; +import BehaviorStudyInfo from "../BehaviorStudyInfo"; +import BehaviorNormal from "../BehaviorNormal"; + +export default function Study() { + let username = ""; + const setUsername = (tmp_username) => { + username = tmp_username; + }; + + let password = ""; + const setPassword = (tmp_password) => { + password = tmp_password; + }; + + let logger = new Logger({ + //inputs: ["cursor", "wheel", "keyboard", "touch"], + inputs: ["keyboard"], + // apiUrl: "https://behavior.marcocamenzind.ch", + apiUrl: "http://localhost:5000", + logToConsole: true, + }); + + logger.init(); + + const handleLoggerOff = () => { + logger.stop(); + console.log("Logger ausgeschaltet"); + }; + + const handleLoggerOn = () => { + logger.start(); + console.log("start logging "); + }; + + const handlePasswordChange = (e) => { + setPassword(e.target.value); + }; + + const handleUsernameChange = (e) => { + setUsername(e.target.value); + }; + + const handleOnPasteEvent = (e) => { + e.preventDefault(); + return false; + }; + + const onSubmitClick = (e) => { + e.preventDefault(); + let opts = { + username: username, + password: password, + }; + fetch("/api/protected/behavior", { + method: "post", + body: JSON.stringify(opts), + }).then((response) => { + console.log(response.status); + if (response.status === 401) { + response.json().then((resp) => { + console.log("nicht so wirklich gut"); + // setErrorMessage(resp.message); + }); + } else { + response.json().then((token) => { + console.log("Alles gut :-)"); + }); + } + }); + }; + + return ( + <> +
+

Studie

+ + {" "} +
+ + {" "} + +
+ + + + + +
+