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

Commit d6bcc4e

Browse files
committed
Merged
2 parents 04a3c0c + 7b17bf5 commit d6bcc4e

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

.github/workflows/featureRelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
name: Build and push
3838
run: |
3939
docker build -t filefighter/frontend:feature webapp_provider/
40-
docker push filefighter/frontend:feature
40+
docker push filefighter/frontend:feature

webapp_frontend/public/backend.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8080

webapp_frontend/src/api.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
import Axios from "axios";
1+
import Axios, {AxiosResponse} from "axios";
22

3-
const uri = "http://localhost:8080";
3+
let uri:string;
4+
const localhost:string = "http://localhost:";
5+
const backendPortFilePath:string = "./backend.cfg";
6+
7+
function setBackendPort():Promise<string>{
8+
return new Promise((resolve, reject) => {
9+
Axios.get(backendPortFilePath)
10+
.then((data:AxiosResponse<string>) => {
11+
uri = localhost + data.data;
12+
console.log(`[API] ${uri}`)
13+
resolve(data.data);
14+
})
15+
.catch(((error:any) => {
16+
reject(error);
17+
}));
18+
});
19+
}
420

521
interface BackendHealthData {
622
uptimeInSeconds: number
@@ -18,4 +34,4 @@ function callBackendHealth():Promise<BackendHealthData>{
1834
});
1935
}
2036

21-
export {callBackendHealth}
37+
export {setBackendPort, callBackendHealth}

webapp_frontend/src/components/App.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import React, {ReactElement, useEffect, useState} from 'react';
22
import logo from '../logo.svg';
33
import './App.css';
4-
import {callBackendHealth} from "../api";
4+
import {setBackendPort, callBackendHealth} from "../api";
55

6-
function App():ReactElement {
6+
function App(): ReactElement {
77
const [backendLiveTime, setBackendLiveTime] = useState<number | string>("Init");
88

99
useEffect(() => {
10-
updateVariables()
10+
Promise.resolve(setBackendPort())
11+
.then((backendPort:string) => {
12+
console.log("[APP] Backend-Port = " + backendPort)
13+
callInitialBackendRequests()
14+
})
15+
.catch((error:any) => {
16+
alert("Error: Problems with backend.cfg - " + error)
17+
})
1118
});
1219

20+
function callInitialBackendRequests():void {
21+
updateVariables()
22+
}
1323
function updateVariables(): void {
1424
Promise.all([callBackendHealth()])
1525
.then(([backendHealthData]) => {

0 commit comments

Comments
 (0)