diff --git a/.github/workflows/featureRelease.yml b/.github/workflows/featureRelease.yml new file mode 100644 index 00000000..2ddfb07c --- /dev/null +++ b/.github/workflows/featureRelease.yml @@ -0,0 +1,40 @@ +name: Latest Release + +on: + push: + branches: + - 'feature/**' + paths: + - 'webapp_frontend/**' + - 'webapp_provider/**' + +jobs: + Build_Docker_Image_on_Push: + runs-on: ubuntu-latest + steps: + - + name: Set up Project + uses: actions/checkout@v2 + - + name: Set up Node.js environment + uses: actions/setup-node@v2.1.2 + with: + node-version: 12 + - + name: Build frontend + run: | + cd webapp_frontend + npm i + npm run-script build + cp -r build ../webapp_provider/public + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PW }} + - + name: Build and push + run: | + docker build -t filefighter/frontend:feature webapp_provider/ + docker push filefighter/frontend:feature \ No newline at end of file diff --git a/.github/workflows/latestRelease.yml b/.github/workflows/latestRelease.yml index 51314789..63333d83 100644 --- a/.github/workflows/latestRelease.yml +++ b/.github/workflows/latestRelease.yml @@ -1,6 +1,12 @@ name: Latest Release -on: push +on: + push: + branches: + - 'master' + paths: + - 'webapp_frontend/**' + - 'webapp_provider/**' jobs: Build_Docker_Image_on_Push: diff --git a/.github/workflows/stableRelease.yml b/.github/workflows/stableRelease.yml index 33ccfcef..56aeb2cc 100644 --- a/.github/workflows/stableRelease.yml +++ b/.github/workflows/stableRelease.yml @@ -2,8 +2,14 @@ name: Stable Release on: push: + branches: + - 'master' tags: - 'v*.*.*' + paths: + - 'webapp_frontend/**' + - 'webapp_provider/**' + jobs: Build_Docker_Image_on_new_Tag: runs-on: ubuntu-latest diff --git a/webapp_frontend/package-lock.json b/webapp_frontend/package-lock.json index 9c69aeb0..1151a832 100644 --- a/webapp_frontend/package-lock.json +++ b/webapp_frontend/package-lock.json @@ -2523,6 +2523,14 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==" }, + "axios": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", + "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", diff --git a/webapp_frontend/package.json b/webapp_frontend/package.json index e2c8742a..eaa7246f 100644 --- a/webapp_frontend/package.json +++ b/webapp_frontend/package.json @@ -10,6 +10,7 @@ "@types/node": "^12.12.64", "@types/react": "^16.9.51", "@types/react-dom": "^16.9.8", + "axios": "^0.20.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.3", diff --git a/webapp_frontend/src/App.tsx b/webapp_frontend/src/App.tsx deleted file mode 100644 index edf4a0b7..00000000 --- a/webapp_frontend/src/App.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react'; -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( -
-
-

- Hello World -

- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
-
- ); -} - -export default App; diff --git a/webapp_frontend/src/api.ts b/webapp_frontend/src/api.ts new file mode 100644 index 00000000..f6c2160c --- /dev/null +++ b/webapp_frontend/src/api.ts @@ -0,0 +1,21 @@ +import Axios from "axios"; + +const uri = "http://localhost:8080"; + +interface BackendHealthData { + uptimeInSeconds: number +} + +function callBackendHealth():Promise{ + return new Promise((resolve, reject) => { + Axios.get(`${uri}/health`) + .then((data) => { + resolve(data.data); + }) + .catch(((error) => { + reject(error); + })); + }); +} + +export {callBackendHealth} \ No newline at end of file diff --git a/webapp_frontend/src/App.css b/webapp_frontend/src/components/App.css similarity index 100% rename from webapp_frontend/src/App.css rename to webapp_frontend/src/components/App.css diff --git a/webapp_frontend/src/App.test.tsx b/webapp_frontend/src/components/App.test.tsx similarity index 100% rename from webapp_frontend/src/App.test.tsx rename to webapp_frontend/src/components/App.test.tsx diff --git a/webapp_frontend/src/components/App.tsx b/webapp_frontend/src/components/App.tsx new file mode 100644 index 00000000..fc4c1ab4 --- /dev/null +++ b/webapp_frontend/src/components/App.tsx @@ -0,0 +1,45 @@ +import React, {ReactElement, useEffect, useState} from 'react'; +import logo from '../logo.svg'; +import './App.css'; +import {callBackendHealth} from "../api"; + +function App():ReactElement { + const [backendLiveTime, setBackendLiveTime] = useState("Init"); + + useEffect(() => { + updateVariables() + }); + + function updateVariables(): void { + Promise.all([callBackendHealth()]) + .then(([backendHealthData]) => { + setBackendLiveTime(backendHealthData.uptimeInSeconds) + }) + } + + return ( +
+
+

+ Hello World +

+ logo +

+ Edit src/App.tsx and save to reload. +

+ + Learn React + + +

{backendLiveTime}

+
+
+ ); +} + +export default App; diff --git a/webapp_frontend/src/index.tsx b/webapp_frontend/src/index.tsx index f5185c1e..a9d79a08 100644 --- a/webapp_frontend/src/index.tsx +++ b/webapp_frontend/src/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; -import App from './App'; +import App from './components/App'; import * as serviceWorker from './serviceWorker'; ReactDOM.render(