Updated some things and logger starts only once
This commit is contained in:
parent
0e222d3d52
commit
c9e987a28f
9 changed files with 36 additions and 27 deletions
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 15 KiB |
|
@ -28,10 +28,10 @@
|
|||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
<title>BA - Marco Camenzind</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<noscript>Diese Anwendung funktioniert leider nur mit JavaScript. Bitte aktivieren JavaScript in den Einstellungen</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
|
|
|
@ -12,12 +12,9 @@ import Manual from "./components/pages/Manual";
|
|||
import Secret from "./components/pages/Secret";
|
||||
import Umfrage from "./components/pages/Umfrage";
|
||||
import PrivateRoute from "./auth/PrivateRoute";
|
||||
import { useAuth } from "./auth/AuthProvider";
|
||||
import BehaviorNormal from "./components/pages/BehaviorNormal";
|
||||
|
||||
function App() {
|
||||
const [isLoggedIn] = useAuth();
|
||||
isLoggedIn ? (document.title = isLoggedIn) : (document.title = isLoggedIn);
|
||||
return (
|
||||
<>
|
||||
<Router>
|
||||
|
|
|
@ -6,6 +6,7 @@ import "@fortawesome/fontawesome-free/css/all.css";
|
|||
|
||||
function Navbar() {
|
||||
const [click, setClick] = useState(false);
|
||||
// eslint-disable-next-line
|
||||
const [button, setButton] = useState(true);
|
||||
|
||||
const handleClick = () => setClick(!click);
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import "../../App.css";
|
||||
import Footer from "../../Footer";
|
||||
import { Logger } from "@behametrics/logger-web";
|
||||
import { useAuth } from "../../auth/AuthProvider";
|
||||
import { logout, useAuth } from "../../auth/AuthProvider";
|
||||
import InputField from "../InputField";
|
||||
import SubmitField from "../SubmitField";
|
||||
import { Logger } from "@behametrics/logger-web";
|
||||
|
||||
export default function BehaviorNormal() {
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
const [isLoggedIn] = useAuth();
|
||||
|
||||
const handleUsernameChange = (e) => {
|
||||
setUsername(e.target.value);
|
||||
};
|
||||
|
@ -39,6 +41,8 @@ export default function BehaviorNormal() {
|
|||
method: "post",
|
||||
body: JSON.stringify(opts),
|
||||
}).then((response) => {
|
||||
console.log(response.status);
|
||||
console.log(isLoggedIn);
|
||||
if (response.status === 401) {
|
||||
response.json().then((resp) => {
|
||||
console.log("nicht so wirklich gut");
|
||||
|
@ -55,20 +59,20 @@ export default function BehaviorNormal() {
|
|||
let logger = new Logger({
|
||||
//inputs: ["cursor", "wheel", "keyboard", "touch"],
|
||||
inputs: ["keyboard"],
|
||||
// logToConsole: true,
|
||||
logToConsole: true,
|
||||
});
|
||||
logger.init();
|
||||
|
||||
let [isLoggedIn] = useAuth();
|
||||
const handleOff = () => {
|
||||
logger.stop();
|
||||
logout();
|
||||
console.log("Logger ausgeschaltet");
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.title = `${isLoggedIn}`;
|
||||
if (isLoggedIn === false) {
|
||||
logger.stop();
|
||||
} else {
|
||||
logger.start();
|
||||
}
|
||||
});
|
||||
logger.init().then(() => logger.start());
|
||||
console.log("start logging");
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="sitePage">
|
||||
|
@ -87,7 +91,7 @@ export default function BehaviorNormal() {
|
|||
<p onCopy={handleOnCopyEvent}>
|
||||
Das Passwort für diese Situation lautet: abcdefgeh
|
||||
</p>
|
||||
<form action="#">
|
||||
<form id="behaviorNormal" action="#">
|
||||
<InputField
|
||||
LabelName="Benutzername"
|
||||
onChange={handleUsernameChange}
|
||||
|
@ -107,12 +111,14 @@ export default function BehaviorNormal() {
|
|||
onPaste={handleOnPasteEvent}
|
||||
/>
|
||||
<SubmitField
|
||||
LabelName="Weiter zur nächsten Situation"
|
||||
LabelNa
|
||||
me="Weiter zur nächsten Situation"
|
||||
InputValue="next-situation"
|
||||
InputName="Weiter"
|
||||
onClick={onSubmitClick}
|
||||
/>
|
||||
</form>
|
||||
<button onClick={handleOff}>STOP THAT FUCKING LOGGER</button>
|
||||
</div>
|
||||
<Footer />
|
||||
</>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 466 KiB |
Binary file not shown.
Before Width: | Height: | Size: 612 KiB |
Loading…
Add table
Add a link
Reference in a new issue