Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 0f06d3b

Browse files
authored
Feature/basic structur (#6)
* added some modules and folders * fixed hostname always being localhost * removed getting the backend port FF-140 * removed unused vars * made the BE uri a constant that is connected to the current env (dev or prod)
1 parent 3b39f14 commit 0f06d3b

File tree

14 files changed

+22305
-52
lines changed

14 files changed

+22305
-52
lines changed

webapp_frontend/package-lock.json

Lines changed: 22206 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp_frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@storybook/preset-create-react-app": "^3.1.5",
5555
"@storybook/react": "^6.0.28",
5656
"babel-loader": "8.1.0",
57+
"prettier": "^2.1.2",
5758
"react-is": "^17.0.1",
5859
"react-test-renderer": "^17.0.1"
5960
}

webapp_frontend/public/backend.cfg

Lines changed: 0 additions & 1 deletion
This file was deleted.

webapp_frontend/src/api.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Axios, {} from "axios";
2+
import {constants} from "../constants";
3+
4+
const hostname:string =constants.url.API_URL;
5+
6+
7+
interface BackendHealthData {
8+
uptimeInSeconds: number;
9+
userCount: number
10+
}
11+
12+
function callBackendHealth():Promise<BackendHealthData>{
13+
return new Promise((resolve, reject) => {
14+
Axios.get(`${hostname}/health`)
15+
.then((data) => {
16+
resolve(data.data);
17+
})
18+
.catch(((error) => {
19+
reject(error);
20+
}));
21+
});
22+
}
23+
24+
export { callBackendHealth}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
function test(){
4+
return null
5+
}
6+
7+
export default test;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
interface constants {
3+
url: { API_URL: string }
4+
}
5+
6+
7+
const prod: constants = {
8+
url: {
9+
API_URL: window.location.hostname,
10+
}
11+
}
12+
13+
const dev: constants = {
14+
url: {
15+
API_URL: 'http://filefighter.ddns.net:7000/',
16+
}
17+
};
18+
export const constants = process.env.NODE_ENV === 'development' ? dev : prod;

webapp_frontend/src/components/App.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import React, {ReactElement, useEffect, useState} from 'react';
22
import logo from '../assets/images/logos/logo.png';
33
import './App.css';
4-
import {setBackendPort, callBackendHealth} from "../api";
4+
import {callBackendHealth} from "../background/api/api";
55

66

77
import {Button, Table, Container} from 'react-bootstrap';
8+
import Header from "./basicElements/Header";
89

910
function App():ReactElement {
11+
12+
13+
1014
const [backendLiveTime, setBackendLiveTime] = useState<number | string>("not reachable");
1115
const [backendUserCount, setBackendUserCount] = useState<number | string>("not reachable");
1216

@@ -15,14 +19,7 @@ function App():ReactElement {
1519

1620

1721
useEffect(() => {
18-
Promise.resolve(setBackendPort())
19-
.then((backendPort:string) => {
20-
console.log("[APP] Backend-Port = " + backendPort)
21-
callInitialBackendRequests()
22-
})
23-
.catch((error:any) => {
24-
alert("Error: Problems with backend.cfg - " + error)
25-
})
22+
callInitialBackendRequests()
2623
// eslint-disable-next-line react-hooks/exhaustive-deps
2724
},[]);
2825

@@ -40,7 +37,7 @@ function App():ReactElement {
4037

4138
return (
4239
<div className="App">
43-
<header className=""> </header>
40+
<Header></Header>
4441
<Container>
4542
<h1>
4643
FileFighter
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React, {ReactElement} from "react";
2+
import App from "./App";
3+
4+
function Constants():ReactElement{
5+
// userinfos
6+
// url + host of backend
7+
8+
9+
10+
11+
return(<App></App>)
12+
13+
14+
}
15+
16+
export default Constants;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React, {ReactElement} from 'react';
2+
3+
function Footers():ReactElement {
4+
return(<div>hallo</div>);
5+
}
6+
7+
export default Footers;
8+

0 commit comments

Comments
 (0)