Skip to content

Commit

Permalink
Merge pull request #756 from MetaCell/feature/CH-140
Browse files Browse the repository at this point in the history
Library updates and small fixes
  • Loading branch information
filippomc authored Jul 30, 2024
2 parents e0ba439 + 993b04a commit f403e8c
Show file tree
Hide file tree
Showing 122 changed files with 3,753 additions and 10,656 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Python 3.9 must be installed.
It is recommended to setup a virtual environment.
With conda:
```bash
conda create --name ch python=3.9
conda create --name ch python=3.12
conda activate ch
```

Expand Down
4 changes: 2 additions & 2 deletions application-templates/base/test/e2e/landing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("End to end test", () => {
return el.textContent;
});

expect(await page.title()).toEqual("Samples");
expect(title).toEqual("Sample React application is working!");
expect(await page.title()).not.toBeNull();
expect(title).not.toBeNull();
});
});
20 changes: 0 additions & 20 deletions application-templates/webapp/frontend/.babelrc

This file was deleted.

1 change: 0 additions & 1 deletion application-templates/webapp/frontend/.dockerignore

This file was deleted.

2 changes: 0 additions & 2 deletions application-templates/webapp/frontend/.eslintignore

This file was deleted.

19 changes: 19 additions & 0 deletions application-templates/webapp/frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs', 'src/rest/*'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'@typescript-eslint/no-explicit-any': 'off',
}
}
49 changes: 0 additions & 49 deletions application-templates/webapp/frontend/.eslintrc.yml

This file was deleted.

4 changes: 0 additions & 4 deletions application-templates/webapp/frontend/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion application-templates/webapp/frontend/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions application-templates/webapp/frontend/build.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions application-templates/webapp/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CloudHarness sample application</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
60 changes: 0 additions & 60 deletions application-templates/webapp/frontend/package.json

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions application-templates/webapp/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import './styles/style.less';

import RestTest from './components/RestTest';
import Version from './components/Version';


const Main = () => (
<>
<img src="/assets/icon.png" />
<h1>Sample React application is working!</h1>
<img src="/logo.png" width="800" />
<h1>__APP_NAME__ React application is working!</h1>
<Version />
<RestTest />
<p>See api documentation <a href="/api/ui">here</a></p>
<p>See api documentation <a href="/api/ui/">here</a></p>
</>
);
)


export default Main;
export default Main;
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React, { useState, useEffect } from 'react';
import { useState, useEffect } from 'react';


import { TestApi } from '../rest/api'
import { TestApi } from '../rest/apis/TestApi'
const test = new TestApi();



const RestTest = () => {
const [result, setResult] = useState(null);
const [result, setResult] = useState<any>(null);
useEffect(() => {
test.ping().then(r => setResult(r), () => setResult({ data: "API error"}));
test.ping().then((r) => setResult(r), () => setResult( "API error"));
}, []);


return result ? <p>Backend answered: { result.data } </p> : <p>Backend did not answer</p>
return result ? <p>Backend answered: { result } </p> : <p>Backend did not answer</p>
}

export default RestTest;
19 changes: 19 additions & 0 deletions application-templates/webapp/frontend/src/components/Version.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useState, useEffect } from 'react';



const Version = () => {
const [result, setResult] = useState<any>(null);
useEffect(() => {
fetch("/proxy/common/api/version", {
headers: {
'Accept': 'application/json'
}
}).then(r => r.json().then(j => setResult(j)), () => setResult("API error"));
}, []);


return result ? <p>Tag: { result?.tag } - Build: {result?.build} </p> : <p>Backend did not answer</p>
}

export default Version;
5 changes: 5 additions & 0 deletions application-templates/webapp/frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
text-align: center;
background-color: '#eeeeee';
font-family: Roboto, Helvetica, sans-serif;
}
10 changes: 0 additions & 10 deletions application-templates/webapp/frontend/src/index.ejs

This file was deleted.

6 changes: 0 additions & 6 deletions application-templates/webapp/frontend/src/index.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions application-templates/webapp/frontend/src/styles/style.less

This file was deleted.

2 changes: 0 additions & 2 deletions application-templates/webapp/frontend/src/utils/history.js

This file was deleted.

22 changes: 0 additions & 22 deletions application-templates/webapp/frontend/tsconfig.json

This file was deleted.

42 changes: 42 additions & 0 deletions application-templates/webapp/frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'



// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')

const theDomain = env && env.DOMAIN ? env.DOMAIN : 'localhost:5000';

console.log('Dev server address: ', theDomain);

const proxyTarget = theDomain;
const replaceHost = (uri: string, appName: string) => {
const host = (uri.includes("samples.") && uri.replace("samples.", appName + '.')) || uri;
console.log('Proxy target: ', host);
return host;
}


return {
plugins: [react()],
server: {
port: 9000,
proxy: {
'/api/': {
target: replaceHost( proxyTarget, 'samples'),
secure: false,
changeOrigin: true,
},
'/proxy/common/api': {
target: replaceHost( proxyTarget, 'common'),
secure: false,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy\/common\/api/, '/api')
}
}
}}}
)
Loading

0 comments on commit f403e8c

Please sign in to comment.