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

Commit d427601

Browse files
Feature first api call (#1)
* WIP - Network Error - Missing CORS-Header in BE? * Fixed Pipelines, added featureRelease.yml pipeline. * fixed cors erros, due to missing protocol in url. * Minor changes on first api call example * Deleted unused line Co-authored-by: open-schnick <[email protected]>
1 parent 6a76730 commit d427601

File tree

11 files changed

+129
-31
lines changed

11 files changed

+129
-31
lines changed

.github/workflows/featureRelease.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Latest Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'feature/**'
7+
paths:
8+
- 'webapp_frontend/**'
9+
- 'webapp_provider/**'
10+
11+
jobs:
12+
Build_Docker_Image_on_Push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
-
16+
name: Set up Project
17+
uses: actions/checkout@v2
18+
-
19+
name: Set up Node.js environment
20+
uses: actions/[email protected]
21+
with:
22+
node-version: 12
23+
-
24+
name: Build frontend
25+
run: |
26+
cd webapp_frontend
27+
npm i
28+
npm run-script build
29+
cp -r build ../webapp_provider/public
30+
-
31+
name: Login to DockerHub
32+
uses: docker/login-action@v1
33+
with:
34+
username: ${{ secrets.DOCKER_USER }}
35+
password: ${{ secrets.DOCKER_PW }}
36+
-
37+
name: Build and push
38+
run: |
39+
docker build -t filefighter/frontend:feature webapp_provider/
40+
docker push filefighter/frontend:feature

.github/workflows/latestRelease.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Latest Release
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
paths:
8+
- 'webapp_frontend/**'
9+
- 'webapp_provider/**'
410

511
jobs:
612
Build_Docker_Image_on_Push:

.github/workflows/stableRelease.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ name: Stable Release
22

33
on:
44
push:
5+
branches:
6+
- 'master'
57
tags:
68
- 'v*.*.*'
9+
paths:
10+
- 'webapp_frontend/**'
11+
- 'webapp_provider/**'
12+
713
jobs:
814
Build_Docker_Image_on_new_Tag:
915
runs-on: ubuntu-latest

webapp_frontend/package-lock.json

Lines changed: 8 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
@@ -10,6 +10,7 @@
1010
"@types/node": "^12.12.64",
1111
"@types/react": "^16.9.51",
1212
"@types/react-dom": "^16.9.8",
13+
"axios": "^0.20.0",
1314
"react": "^16.13.1",
1415
"react-dom": "^16.13.1",
1516
"react-scripts": "3.4.3",

webapp_frontend/src/App.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

webapp_frontend/src/api.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Axios from "axios";
2+
3+
const uri = "http://localhost:8080";
4+
5+
interface BackendHealthData {
6+
uptimeInSeconds: number
7+
}
8+
9+
function callBackendHealth():Promise<BackendHealthData>{
10+
return new Promise((resolve, reject) => {
11+
Axios.get(`${uri}/health`)
12+
.then((data) => {
13+
resolve(data.data);
14+
})
15+
.catch(((error) => {
16+
reject(error);
17+
}));
18+
});
19+
}
20+
21+
export {callBackendHealth}
File renamed without changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, {ReactElement, useEffect, useState} from 'react';
2+
import logo from '../logo.svg';
3+
import './App.css';
4+
import {callBackendHealth} from "../api";
5+
6+
function App():ReactElement {
7+
const [backendLiveTime, setBackendLiveTime] = useState<number | string>("Init");
8+
9+
useEffect(() => {
10+
updateVariables()
11+
});
12+
13+
function updateVariables(): void {
14+
Promise.all([callBackendHealth()])
15+
.then(([backendHealthData]) => {
16+
setBackendLiveTime(backendHealthData.uptimeInSeconds)
17+
})
18+
}
19+
20+
return (
21+
<div className="App">
22+
<header className="App-header">
23+
<p>
24+
Hello World
25+
</p>
26+
<img src={logo} className="App-logo" alt="logo"/>
27+
<p>
28+
Edit <code>src/App.tsx</code> and save to reload.
29+
</p>
30+
<a
31+
className="App-link"
32+
href="https://reactjs.org"
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
>
36+
Learn React
37+
</a>
38+
<button style={{marginTop: "20px"}} onClick={() => updateVariables()}>Test</button>
39+
<p>{backendLiveTime}</p>
40+
</header>
41+
</div>
42+
);
43+
}
44+
45+
export default App;

0 commit comments

Comments
 (0)