Showing
2 changed files
with
104 additions
and
0 deletions
... | @@ -4,6 +4,8 @@ import { ChakraProvider } from '@chakra-ui/react' | ... | @@ -4,6 +4,8 @@ import { ChakraProvider } from '@chakra-ui/react' |
4 | import Index from './components/Index' | 4 | import Index from './components/Index' |
5 | import SignIn from './components/SignIn' | 5 | import SignIn from './components/SignIn' |
6 | import DockerContainerCreate from './components/DockerContainerCreate' | 6 | import DockerContainerCreate from './components/DockerContainerCreate' |
7 | +import DockerContainerList from './components/DockerContainerList' | ||
8 | +import 'semantic-ui-css/semantic.min.css' | ||
7 | 9 | ||
8 | const App = () => { | 10 | const App = () => { |
9 | return ( | 11 | return ( |
... | @@ -13,6 +15,7 @@ const App = () => { | ... | @@ -13,6 +15,7 @@ const App = () => { |
13 | <Route exact path="/" component={Index}/> | 15 | <Route exact path="/" component={Index}/> |
14 | <Route exact path="/sign-in" component={SignIn}/> | 16 | <Route exact path="/sign-in" component={SignIn}/> |
15 | <Route exact path="/docker/container/create" component={DockerContainerCreate}/> | 17 | <Route exact path="/docker/container/create" component={DockerContainerCreate}/> |
18 | + <Route exact path="/docker/container/list" component={DockerContainerList}/> | ||
16 | <Redirect path="*" to="/"/> | 19 | <Redirect path="*" to="/"/> |
17 | </Switch> | 20 | </Switch> |
18 | </BrowserRouter> | 21 | </BrowserRouter> | ... | ... |
1 | +import React, { useState, useEffect } from 'react' | ||
2 | +import { useHistory, Redirect } from 'react-router-dom' | ||
3 | +import { | ||
4 | + Container, | ||
5 | + Heading, | ||
6 | + Button, | ||
7 | + Segment, | ||
8 | + Message, | ||
9 | + Form, | ||
10 | + Input, | ||
11 | + Transition, | ||
12 | + Select, | ||
13 | + Checkbox, | ||
14 | + FormControl, | ||
15 | + FormLabel, | ||
16 | + FormErrorMessage, | ||
17 | + FormHelperText, | ||
18 | + VStack, | ||
19 | + Stack, | ||
20 | + StackDivider, | ||
21 | + Box, | ||
22 | + Text, | ||
23 | + List, ListItem, ListIcon, OrderedList, UnorderedList, | ||
24 | +} from '@chakra-ui/react' | ||
25 | +import { | ||
26 | + Divider, | ||
27 | +} from 'semantic-ui-react' | ||
28 | +import http from '../utils/http' | ||
29 | + | ||
30 | +const DockerContainerList = () => { | ||
31 | + const [containers, setContainers] = useState([]) | ||
32 | + const [isError, setError] = useState(false) | ||
33 | + const [message, setMessage] = useState('') | ||
34 | + | ||
35 | + const getContainerList = () => { | ||
36 | + http.get('/docker/container/list').then(response => { | ||
37 | + const { status, data, message } = response.data | ||
38 | + if (status) { | ||
39 | + const { containers } = data | ||
40 | + setContainers(containers) | ||
41 | + } else { | ||
42 | + setError(true) | ||
43 | + setMessage(message) | ||
44 | + } | ||
45 | + }) | ||
46 | + } | ||
47 | + | ||
48 | + useEffect(() => { | ||
49 | + getContainerList() | ||
50 | + }, []) | ||
51 | + | ||
52 | + return ( | ||
53 | + <Container> | ||
54 | + <Divider hidden/> | ||
55 | + <Heading>Container List</Heading> | ||
56 | + | ||
57 | + <Divider hidden/> | ||
58 | + | ||
59 | + <UnorderedList> | ||
60 | + {containers.map((container, key) => ( | ||
61 | + <ListItem key={key}> | ||
62 | + {container.name} | ||
63 | + </ListItem> | ||
64 | + ))} | ||
65 | + </UnorderedList> | ||
66 | + | ||
67 | + <Stack | ||
68 | + divider={<StackDivider borderColor="gray.200"/>} | ||
69 | + spacing={4} | ||
70 | + align="stretch" | ||
71 | + > | ||
72 | + | ||
73 | + | ||
74 | + <FormControl id="container" isRequired> | ||
75 | + <FormLabel>Container Name</FormLabel> | ||
76 | + <Input | ||
77 | + type="email" | ||
78 | + placeholder="Container Name" | ||
79 | + /> | ||
80 | + </FormControl> | ||
81 | + | ||
82 | + <FormControl id="image"> | ||
83 | + <FormLabel>Image</FormLabel> | ||
84 | + <Select placeholder="생성할 컨테이너의 OS를 설정해주세요"> | ||
85 | + <option value="ubuntu 18.04">Ubuntu 18.04.5 LTS</option> | ||
86 | + <option value="ubuntu 20.04">Ubuntu 20.04.2 LTS</option> | ||
87 | + </Select> | ||
88 | + </FormControl> | ||
89 | + | ||
90 | + </Stack> | ||
91 | + | ||
92 | + <Stack> | ||
93 | + | ||
94 | + </Stack> | ||
95 | + | ||
96 | + | ||
97 | + </Container> | ||
98 | + ) | ||
99 | +} | ||
100 | + | ||
101 | +export default DockerContainerList |
-
Please register or login to post a comment