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

Commit 71822a1

Browse files
committed
merged main
2 parents 928e585 + ddd30a1 commit 71822a1

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
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

.github/workflows/stableRelease.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ name: Stable Release
22

33
on:
44
push:
5-
branches:
6-
- 'master'
75
tags:
86
- 'v*.*.*'
9-
paths:
10-
- 'webapp_frontend/**'
11-
- 'webapp_provider/**'
127

138
jobs:
149
Build_Docker_Image_on_new_Tag:
@@ -40,4 +35,4 @@ jobs:
4035
run: |
4136
VERSION=${{ steps.vars.outputs.tag }}
4237
docker build -t filefighter/frontend:$VERSION webapp_provider/
43-
docker push filefighter/frontend:$VERSION
38+
docker push filefighter/frontend:$VERSION

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# WebApp
22
Frontend Web Application for FileFighter.
33
![Latest Release](https://github.com/FileFighter/WebApp/workflows/Latest%20Release/badge.svg)
4-
![Stable Release](https://github.com/FileFighter/WebApp/workflows/Stable%20Release/badge.svg)
4+
![Stable Release](https://github.com/FileFighter/WebApp/workflows/Stable%20Release/badge.svg)
5+
![CodeFactor](https://www.codefactor.io/repository/github/filefighter/webapp/badge)
56
![Docker Release](https://img.shields.io/github/v/release/filefighter/webapp?color=dark-green&label=Stable%20Version&logo=docker&style=for-the-badge)
67
![Docker Pulls](https://img.shields.io/docker/pulls/filefighter/frontend?logo=docker&style=for-the-badge)
78

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;
@@ -19,4 +35,4 @@ function callBackendHealth():Promise<BackendHealthData>{
1935
});
2036
}
2137

22-
export {callBackendHealth}
38+
export {setBackendPort, callBackendHealth}

webapp_frontend/src/components/App.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
import React, {ReactElement, useEffect, useState} from 'react';
22
import logo from '../assets/images/logos/logo.png';
33
import './App.css';
4-
import {callBackendHealth} from "../api";
4+
import {setBackendPort, callBackendHealth} from "../api";
5+
6+
57
import {Button, Table, Container} from 'react-bootstrap';
68

79
function App():ReactElement {
810
const [backendLiveTime, setBackendLiveTime] = useState<number | string>("not reachable");
911
const [backendUserCount, setBackendUserCount] = useState<number | string>("not reachable");
1012

13+
14+
15+
16+
1117
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+
})
26+
// eslint-disable-next-line react-hooks/exhaustive-deps
27+
},[]);
28+
29+
function callInitialBackendRequests():void {
1230
updateVariables()
13-
});
31+
}
1432

1533
function updateVariables(): void {
1634
Promise.all([callBackendHealth()])

0 commit comments

Comments
 (0)