From 959912bd9b0eaac3b59d75a1024766be5aff4aca Mon Sep 17 00:00:00 2001
From: cami
Date: Thu, 22 Jul 2021 02:40:17 +0200
Subject: [PATCH 01/37] Refactored so that the studyEnd also has its own
component
---
frontend/src/components/BehaviorStudyEnd.js | 12 ++++++++++++
frontend/src/components/pages/Study.js | 3 ++-
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 frontend/src/components/BehaviorStudyEnd.js
diff --git a/frontend/src/components/BehaviorStudyEnd.js b/frontend/src/components/BehaviorStudyEnd.js
new file mode 100644
index 0000000..e19c613
--- /dev/null
+++ b/frontend/src/components/BehaviorStudyEnd.js
@@ -0,0 +1,12 @@
+import React from "react";
+import "../App.css";
+
+export default function BehaviorStudyEnd() {
+ return (
+ <>
+
+ Merci :-)
+
+ >
+ );
+}
diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js
index 9378c54..4d73609 100644
--- a/frontend/src/components/pages/Study.js
+++ b/frontend/src/components/pages/Study.js
@@ -9,6 +9,7 @@ import BehaviorNormal from "../BehaviorNormal";
import { Button } from "../Button";
import BehaviorPhone from "../BehaviorPhone";
import BehaviorStanding from "../BehaviorStanding";
+import BehaviorStudyEnd from "../BehaviorStudyEnd";
export default function Study() {
const _logger = useRef(0);
@@ -215,7 +216,7 @@ export default function Study() {
>
);
- const study_end = Merci :-)
;
+ const study_end = ;
return (
<>
From e7407fd40b6ba754a84d53958c2957d5927a7012 Mon Sep 17 00:00:00 2001
From: cami
Date: Thu, 22 Jul 2021 02:40:58 +0200
Subject: [PATCH 02/37] Refactoring and removing unused things
---
backend/src/app.py | 1 -
frontend/src/components/pages/Study.js | 27 +-------------------------
2 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/backend/src/app.py b/backend/src/app.py
index 6d9b201..62be6d7 100644
--- a/backend/src/app.py
+++ b/backend/src/app.py
@@ -134,7 +134,6 @@ def protected():
@app.route('/api/protected/rcv_pw', methods=['GET'])
-# @flask_praetorian.auth_required
def get_password():
pw = get_random_password()
ret = {'password': pw}
diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js
index 4d73609..c5247c9 100644
--- a/frontend/src/components/pages/Study.js
+++ b/frontend/src/components/pages/Study.js
@@ -68,7 +68,6 @@ export default function Study() {
setIsStepStart(false);
setIsStepNormal(true);
handleLoggerOn();
- // forceUpdate();
};
const handleClickAtStepNormal = () => {
@@ -87,30 +86,6 @@ export default function Study() {
handleLoggerOff();
};
- 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 :-)");
- });
- }
- });
- };
-
const study_start = (
<>
@@ -189,7 +164,7 @@ export default function Study() {
const study_standing = (
<>
-
Sofern Sie noch nicht eingeloggt sind, können Sie sich anmelden mit
ihrem gewählten Benutzernamen und dem Passwort. Sie landen dann direkt
diff --git a/frontend/src/components/pages/Privacy.js b/frontend/src/components/pages/Privacy.js
index 4091220..4464714 100644
--- a/frontend/src/components/pages/Privacy.js
+++ b/frontend/src/components/pages/Privacy.js
@@ -8,7 +8,6 @@ export default function Privacy() {
Datenschutz
- "
>
);
diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js
index 5df4c0d..071ebd8 100644
--- a/frontend/src/components/pages/Study.js
+++ b/frontend/src/components/pages/Study.js
@@ -130,24 +130,22 @@ export default function Study() {
};
const handleClickAtStepPhone = () => {
- if (checkIfValuesAreCorrect()){
- receiveRandomPassword();
- setIsStepPhone(false);
- setIsStepStanding(true);
- }
- else {
- console.log("Passwort und Benutzername stimmen nicht.")
+ if (checkIfValuesAreCorrect()) {
+ receiveRandomPassword();
+ setIsStepPhone(false);
+ setIsStepStanding(true);
+ } else {
+ console.log("Passwort und Benutzername stimmen nicht.");
}
};
const handleClickAtStepStanding = () => {
- if (checkIfValuesAreCorrect()){
- setIsStepStanding(false);
- setIsStepEnd(true);
- handleLoggerOff();
- }
- else {
- console.log("Passwort und Benutzername stimmen nicht.")
+ if (checkIfValuesAreCorrect()) {
+ setIsStepStanding(false);
+ setIsStepEnd(true);
+ handleLoggerOff();
+ } else {
+ console.log("Passwort und Benutzername stimmen nicht.");
}
};
diff --git a/frontend/src/components/pages/lizenzen.js b/frontend/src/components/pages/lizenzen.js
index 1bb415c..959f660 100644
--- a/frontend/src/components/pages/lizenzen.js
+++ b/frontend/src/components/pages/lizenzen.js
@@ -5,7 +5,7 @@ import Footer from "../../Footer";
export default function Lizenzen() {
return (
<>
-
+
Lizenzen und Bildnachweise
Nachfolgend sollen die verwendeten Bibliotheken inklusive der Lizenz
@@ -13,13 +13,31 @@ export default function Lizenzen() {
Bildnachweise notiert werden.
Verwendete Bibliotheken
-
Backend
Frontend
+
+
Backend
+
Bildnachweise
- Originalbild für die Startseite:
-
+ Originalbild für die Startseite:
https://pixabay.com/illustrations/virtual-identity-digital-identity-69996/
From 52131aa3dd339e153c96f38080565a0ca858f3b7 Mon Sep 17 00:00:00 2001
From: cami
Date: Thu, 22 Jul 2021 19:55:06 +0200
Subject: [PATCH 15/37] Refactoring..
- use STATES instead of multiple different variables
- add check if password is correct
-
---
frontend/src/App.js | 2 +-
frontend/src/components/Navbar.js | 16 +++++--
frontend/src/components/pages/Study.js | 60 +++++++++---------------
frontend/src/components/pages/Umfrage.js | 4 +-
4 files changed, 36 insertions(+), 46 deletions(-)
diff --git a/frontend/src/App.js b/frontend/src/App.js
index 415c951..26c93dc 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -9,10 +9,10 @@ import Privacy from "./components/pages/Privacy";
import Login from "./components/pages/Login";
import Register from "./components/pages/Register";
import Manual from "./components/pages/Manual";
-import Secret from "./components/pages/Secret";
import Umfrage from "./components/pages/Umfrage";
import PrivateRoute from "./auth/PrivateRoute";
import Study from "./components/pages/Study";
+import Secret from "./components/pages/Secret"
function App() {
return (
diff --git a/frontend/src/components/Navbar.js b/frontend/src/components/Navbar.js
index a30ce29..5f8b68a 100644
--- a/frontend/src/components/Navbar.js
+++ b/frontend/src/components/Navbar.js
@@ -44,11 +44,17 @@ function Navbar() {
Startseite
-
-
- Studie
-
-
+ {isLoggedIn && (
+
+
+ Studie
+
+
+ )}
Über
diff --git a/frontend/src/components/pages/Study.js b/frontend/src/components/pages/Study.js
index 071ebd8..54b8f8b 100644
--- a/frontend/src/components/pages/Study.js
+++ b/frontend/src/components/pages/Study.js
@@ -15,6 +15,15 @@ import { authFetch } from "../../auth/AuthProvider";
export default function Study() {
const _logger = useRef(0);
const [serverUsername, setServerUsername] = useState("");
+ const [genPassword, setGenPassword] = useState("");
+ const STATES = {
+ START: "start",
+ NORMAL: "normal",
+ PHONE: "phone",
+ STANDING: "standing",
+ END: "end",
+ };
+ const [state, setState] = useState(STATES.START);
useEffect(() => {
_logger.current = new Logger({
@@ -44,12 +53,6 @@ export default function Study() {
password = tmp_password;
};
- const [isStepStart, setIsStepStart] = useState(true);
- const [isStepNormal, setIsStepNormal] = useState(false);
- const [isStepPhone, setIsStepPhone] = useState(false);
- const [isStepStanding, setIsStepStanding] = useState(false);
- const [isStepEnd, setIsStepEnd] = useState(false);
-
const handleLoggerOff = () => {
_logger.current.stop();
console.log("Logger ausgeschaltet");
@@ -75,15 +78,9 @@ export default function Study() {
};
const checkIfUsernameIsCorrect = () => {
- if (serverUsername === username) {
- return true;
- } else {
- return false;
- }
+ return serverUsername === username;
};
- const [genPassword, setGenPassword] = useState("");
-
const receiveRandomPassword = () => {
fetch("/api/rcv_pw", {
method: "get",
@@ -97,43 +94,31 @@ export default function Study() {
};
const checkIfPasswordIsCorrect = () => {
- if (genPassword === password) {
- return true;
- } else {
- return false;
- }
+ return genPassword === password;
};
const checkIfValuesAreCorrect = () => {
console.log(checkIfPasswordIsCorrect());
- if (checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect()) {
- return true;
- } else {
- alert("Passt nicht");
- return false;
- }
+ return checkIfPasswordIsCorrect() && checkIfUsernameIsCorrect();
};
const handleClickAtStepStart = () => {
receiveRandomPassword();
- setIsStepStart(false);
- setIsStepNormal(true);
+ setState(STATES.NORMAL);
handleLoggerOn();
};
const handleClickAtStepNormal = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
- setIsStepNormal(false);
- setIsStepPhone(true);
+ setState(STATES.PHONE);
}
};
const handleClickAtStepPhone = () => {
if (checkIfValuesAreCorrect()) {
receiveRandomPassword();
- setIsStepPhone(false);
- setIsStepStanding(true);
+ setState(STATES.STANDING);
} else {
console.log("Passwort und Benutzername stimmen nicht.");
}
@@ -141,8 +126,7 @@ export default function Study() {
const handleClickAtStepStanding = () => {
if (checkIfValuesAreCorrect()) {
- setIsStepStanding(false);
- setIsStepEnd(true);
+ setState(STATES.END);
handleLoggerOff();
} else {
console.log("Passwort und Benutzername stimmen nicht.");
@@ -241,7 +225,7 @@ export default function Study() {
onChange={handlePasswordChange}
InputType="password"
InputName="Passwort"
- InputPlaceHolder="Benutzername"
+ InputPlaceHolder="Passwort"
onPaste={handleOnPasteEvent}
/>
Studie
- {isStepStart ? study_start : null}
- {isStepNormal ? study_normal : null}
- {isStepPhone ? study_phone : null}
- {isStepStanding ? study_standing : null}
- {isStepEnd ? study_end : null}
+ {state === STATES.START ? study_start : null}
+ {state === STATES.NORMAL ? study_normal : null}
+ {state === STATES.PHONE ? study_phone : null}
+ {state === STATES.STANDING ? study_standing : null}
+ {state === STATES.END ? study_end : null}
>
diff --git a/frontend/src/components/pages/Umfrage.js b/frontend/src/components/pages/Umfrage.js
index 33bc203..a47ec6c 100644
--- a/frontend/src/components/pages/Umfrage.js
+++ b/frontend/src/components/pages/Umfrage.js
@@ -51,8 +51,8 @@ export default function Umfrage() {
if (!Number(age)) {
setAgeErrorMessage("Das Alter muss als Zahl angegeben werden.");
- //setIsSurveyValid(false);
- // setIsAgeOk(false);
+ setIsSurveyValid(false);
+ setIsAgeOk(false);
}
if (gender === "DEFAULT" || gender === "") {
setGenderErrorMessage(
From dcd4215efa704259db3dc7c5c59ca2376731364b Mon Sep 17 00:00:00 2001
From: cami
Date: Thu, 22 Jul 2021 20:02:35 +0200
Subject: [PATCH 16/37] Renamed lizenzen.js to Lizenzen.js
---
frontend/src/App.js | 4 ++--
frontend/src/components/pages/{lizenzen.js => Lizenzen.js} | 0
2 files changed, 2 insertions(+), 2 deletions(-)
rename frontend/src/components/pages/{lizenzen.js => Lizenzen.js} (100%)
diff --git a/frontend/src/App.js b/frontend/src/App.js
index 26c93dc..9ba9375 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -4,7 +4,7 @@ import "./App.css";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "./components/pages/Home";
import Ueber from "./components/pages/Ueber";
-import Lizenzen from "./components/pages/lizenzen";
+import Lizenzen from "./components/pages/Lizenzen";
import Privacy from "./components/pages/Privacy";
import Login from "./components/pages/Login";
import Register from "./components/pages/Register";
@@ -12,7 +12,7 @@ import Manual from "./components/pages/Manual";
import Umfrage from "./components/pages/Umfrage";
import PrivateRoute from "./auth/PrivateRoute";
import Study from "./components/pages/Study";
-import Secret from "./components/pages/Secret"
+import Secret from "./components/pages/Secret";
function App() {
return (
diff --git a/frontend/src/components/pages/lizenzen.js b/frontend/src/components/pages/Lizenzen.js
similarity index 100%
rename from frontend/src/components/pages/lizenzen.js
rename to frontend/src/components/pages/Lizenzen.js
From 85e484bf0b30668b8c58c6d4b12d97b5ee5ecf30 Mon Sep 17 00:00:00 2001
From: cami
Date: Thu, 22 Jul 2021 20:18:01 +0200
Subject: [PATCH 17/37] Renaming and autoformatting
- renamed the react files to jsx
- autoformat with vscode
---
frontend/public/index.html | 5 +-
frontend/src/App.css | 1 -
frontend/src/{App.js => App.jsx} | 0
frontend/src/Footer.css | 42 --------
frontend/src/{Footer.js => Footer.jsx} | 0
.../{PrivateRoute.js => PrivateRoute.jsx} | 0
frontend/src/components/Author.js | 7 --
.../{BehaviorNormal.js => BehaviorNormal.jsx} | 0
.../{BehaviorPhone.js => BehaviorPhone.jsx} | 2 +-
frontend/src/components/BehaviorStanding.js | 14 ---
frontend/src/components/BehaviorStanding.jsx | 16 ++++
...haviorStudyEnd.js => BehaviorStudyEnd.jsx} | 7 +-
...viorStudyInfo.js => BehaviorStudyInfo.jsx} | 1 -
frontend/src/components/Button.css | 3 +-
.../src/components/{Button.js => Button.jsx} | 0
.../{ErrorMessage.js => ErrorMessage.jsx} | 0
...ratedPassword.js => GeneratedPassword.jsx} | 2 -
.../{HeroSection.js => HeroSection.jsx} | 0
.../{InputField.js => InputField.jsx} | 0
.../src/components/{Navbar.js => Navbar.jsx} | 0
.../{SubmitField.js => SubmitField.jsx} | 0
.../components/pages/{Home.js => Home.jsx} | 0
frontend/src/components/pages/Lizenzen.js | 49 ----------
frontend/src/components/pages/Lizenzen.jsx | 95 +++++++++++++++++++
.../components/pages/{Login.js => Login.jsx} | 0
.../pages/{Manual.js => Manual.jsx} | 12 +--
.../pages/{Privacy.js => Privacy.jsx} | 0
.../pages/{Register.js => Register.jsx} | 0
.../pages/{Secret.js => Secret.jsx} | 0
.../components/pages/{Study.js => Study.jsx} | 0
.../components/pages/{Ueber.js => Ueber.jsx} | 0
.../pages/{Umfrage.js => Umfrage.jsx} | 0
32 files changed, 127 insertions(+), 129 deletions(-)
rename frontend/src/{App.js => App.jsx} (100%)
rename frontend/src/{Footer.js => Footer.jsx} (100%)
rename frontend/src/auth/{PrivateRoute.js => PrivateRoute.jsx} (100%)
delete mode 100644 frontend/src/components/Author.js
rename frontend/src/components/{BehaviorNormal.js => BehaviorNormal.jsx} (100%)
rename frontend/src/components/{BehaviorPhone.js => BehaviorPhone.jsx} (88%)
delete mode 100644 frontend/src/components/BehaviorStanding.js
create mode 100644 frontend/src/components/BehaviorStanding.jsx
rename frontend/src/components/{BehaviorStudyEnd.js => BehaviorStudyEnd.jsx} (54%)
rename frontend/src/components/{BehaviorStudyInfo.js => BehaviorStudyInfo.jsx} (99%)
rename frontend/src/components/{Button.js => Button.jsx} (100%)
rename frontend/src/components/{ErrorMessage.js => ErrorMessage.jsx} (100%)
rename frontend/src/components/{GeneratedPassword.js => GeneratedPassword.jsx} (91%)
rename frontend/src/components/{HeroSection.js => HeroSection.jsx} (100%)
rename frontend/src/components/{InputField.js => InputField.jsx} (100%)
rename frontend/src/components/{Navbar.js => Navbar.jsx} (100%)
rename frontend/src/components/{SubmitField.js => SubmitField.jsx} (100%)
rename frontend/src/components/pages/{Home.js => Home.jsx} (100%)
delete mode 100644 frontend/src/components/pages/Lizenzen.js
create mode 100644 frontend/src/components/pages/Lizenzen.jsx
rename frontend/src/components/pages/{Login.js => Login.jsx} (100%)
rename frontend/src/components/pages/{Manual.js => Manual.jsx} (91%)
rename frontend/src/components/pages/{Privacy.js => Privacy.jsx} (100%)
rename frontend/src/components/pages/{Register.js => Register.jsx} (100%)
rename frontend/src/components/pages/{Secret.js => Secret.jsx} (100%)
rename frontend/src/components/pages/{Study.js => Study.jsx} (100%)
rename frontend/src/components/pages/{Ueber.js => Ueber.jsx} (100%)
rename frontend/src/components/pages/{Umfrage.js => Umfrage.jsx} (100%)
diff --git a/frontend/public/index.html b/frontend/public/index.html
index fa21ab4..8be889f 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -31,7 +31,10 @@
BA - Marco Camenzind
- Diese Anwendung funktioniert leider nur mit JavaScript. Bitte aktivieren JavaScript in den Einstellungen
+ Diese Anwendung funktioniert leider nur mit JavaScript. Bitte aktivieren
+ JavaScript in den Einstellungen