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' ;
4
7
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
+ }
25
22
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 ;
0 commit comments