Skip to content

Commit 9d33a88

Browse files
committed
second commit
1 parent 47787e4 commit 9d33a88

23 files changed

+6129
-1236
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/client/node_modules
3+
/server/node_modules

.gitignore

+24-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
/dist
1+
dist
2+
3+
# dependencies
4+
node_modules
5+
/pnp
6+
.pnp
7+
.pnp.js
8+
9+
# testing
10+
coverage
11+
12+
# production
13+
build
14+
15+
# misc
16+
.DS_Store
17+
.env.local
18+
.env.development.local
19+
.env.test.local
20+
.env.production.local
21+
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:lts-alpine as build-env
2+
3+
COPY . /src
4+
WORKDIR /src
5+
RUN yarn install && yarn build && \
6+
mv server/dist dist && \
7+
mv server/node_modules dist && \
8+
mv client/build dist/public && \
9+
mv dist /app
10+
11+
FROM node:lts-alpine as final
12+
COPY --from=build-env [ "/app", "/app" ]
13+
ENV PORT=80
14+
15+
CMD [ "node", "/app/server.js" ]

client/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
13
# dependencies
24
/node_modules
35
/.pnp

client/package.json

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
{
2-
"name": "client",
3-
"version": "0.1.0",
2+
"name": "keda-dashboard-client",
3+
"version": "0.0.1",
44
"private": true,
55
"dependencies": {
6-
"@types/jest": "24.0.13",
7-
"@types/node": "12.0.6",
8-
"@types/react": "16.8.19",
6+
"@material-ui/core": "^4.1.0",
7+
"@material-ui/icons": "^4.1.0",
8+
"@types/jest": "24.0.12",
9+
"@types/node": "11.13.8",
10+
"@types/react": "16.8.15",
911
"@types/react-dom": "16.8.4",
1012
"react": "^16.8.6",
1113
"react-dom": "^16.8.6",
12-
"react-scripts": "3.0.1",
13-
"typescript": "3.5.1"
14+
"react-scripts": "3.0.0",
15+
"typeface-roboto": "^0.0.54",
16+
"typescript": "3.4.5"
1417
},
1518
"scripts": {
1619
"start": "react-scripts start",
1720
"build": "react-scripts build",
1821
"test": "react-scripts test",
1922
"eject": "react-scripts eject"
2023
},
24+
"proxy": "http://localhost:5000",
2125
"eslintConfig": {
2226
"extends": "react-app"
2327
},

client/public/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
8+
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"/>
89
<!--
910
manifest.json provides metadata used when your web app is installed on a
1011
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/

client/src/App.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
to {
3131
transform: rotate(360deg);
3232
}
33-
}
33+
}

client/src/App.tsx

+55-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,57 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React, { Component } from 'react';
2+
import MenuIcon from '@material-ui/icons/Menu';
3+
import { CssBaseline, AppBar, Toolbar, IconButton, Typography, Container, Grid, Paper } from '@material-ui/core';
4+
import { ScaledObjectModel } from './models/ScaledObjectModel';
5+
import ScaledObjectCard from './components/ScaledObjectCard';
6+
import { Style } from 'jss';
47

5-
const App: React.FC = () => {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.tsx</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
24-
}
8+
class App extends Component<{}, { scaledObjects: ScaledObjectModel[] }> {
9+
10+
constructor(props: {}) {
11+
super(props);
12+
this.state = {
13+
scaledObjects: []
14+
};
15+
}
16+
17+
componentDidMount() {
18+
fetch('/api/scaledobjects')
19+
.then(res => res.json())
20+
.then(({ items }) => this.setState({ scaledObjects: items }));
21+
}
2522

26-
export default App;
23+
static style: Style = {
24+
container: {
25+
marginTop: '100px',
26+
}
27+
};
28+
29+
render() {
30+
return (
31+
<React.Fragment>
32+
<CssBaseline />
33+
<AppBar position="absolute" >
34+
<Toolbar>
35+
<IconButton edge="start" color="inherit" aria-label="Open drawer">
36+
<MenuIcon />
37+
</IconButton>
38+
<Typography component="h1" variant="h6" color="inherit" noWrap>
39+
KEDA Dashboard
40+
</Typography>
41+
</Toolbar>
42+
</AppBar>
43+
<Container style={App.style.container} maxWidth="lg">
44+
<Grid container spacing={3}>
45+
<Grid item xs={12} md={8} lg={9}>
46+
<Paper>
47+
{this.state.scaledObjects
48+
.map(o => <ScaledObjectCard scaledObject={o} />)}
49+
</Paper>
50+
</Grid>
51+
</Grid>
52+
</Container>
53+
</React.Fragment>
54+
);
55+
}
56+
}
57+
export default App;
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { ScaledObjectModel } from '../models/ScaledObjectModel';
3+
import { Typography } from '@material-ui/core';
4+
5+
const ScaledObjectCard: React.FunctionComponent<{ scaledObject: ScaledObjectModel }> = (props) => {
6+
return (
7+
<Typography component="h4" variant="h6" color="primary" gutterBottom>
8+
{props.scaledObject.metadata.selfLink}
9+
</Typography>
10+
);
11+
};
12+
13+
export default ScaledObjectCard;

client/src/index.css

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
body {
22
margin: 0;
3+
padding: 0;
34
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
45
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
56
sans-serif;

client/src/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import ReactDOM from 'react-dom';
33
import './index.css';
44
import App from './App';
55
import * as serviceWorker from './serviceWorker';
6+
import 'typeface-roboto';
67

78
ReactDOM.render(<App />, document.getElementById('root'));
89

910
// If you want your app to work offline and load faster, you can change
1011
// unregister() to register() below. Note this comes with some pitfalls.
1112
// Learn more about service workers: https://bit.ly/CRA-PWA
12-
serviceWorker.unregister();
13+
serviceWorker.unregister();
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface ScaledObjectModel {
2+
metadata: ScaledObjectMetadata;
3+
}
4+
5+
export interface ScaledObjectMetadata {
6+
name: string;
7+
namespace: string;
8+
selfLink: string;
9+
}

0 commit comments

Comments
 (0)