ch4n3.yoon

[Edit] 디자인 수정

...@@ -9,6 +9,7 @@ import DockerImageCreate from './components/DockerImageCreate' ...@@ -9,6 +9,7 @@ import DockerImageCreate from './components/DockerImageCreate'
9 import DockerImageList from './components/DockerImageList' 9 import DockerImageList from './components/DockerImageList'
10 import DockerContainerCreate from './components/DockerContainerCreate' 10 import DockerContainerCreate from './components/DockerContainerCreate'
11 import DockerContainerList from './components/DockerContainerList' 11 import DockerContainerList from './components/DockerContainerList'
12 +import DockerDockerfileList from './components/DockerDockerfileList'
12 import 'semantic-ui-css/semantic.min.css' 13 import 'semantic-ui-css/semantic.min.css'
13 14
14 const App = () => { 15 const App = () => {
...@@ -26,6 +27,9 @@ const App = () => { ...@@ -26,6 +27,9 @@ const App = () => {
26 component={DockerContainerCreate}/> 27 component={DockerContainerCreate}/>
27 <Route exact path="/docker/container/list" 28 <Route exact path="/docker/container/list"
28 component={DockerContainerList}/> 29 component={DockerContainerList}/>
30 + <Route exact path="/docker/dockerfile/list"
31 + component={DockerDockerfileList}/>
32 +
29 <Redirect path="*" to="/"/> 33 <Redirect path="*" to="/"/>
30 </Switch> 34 </Switch>
31 </BrowserRouter> 35 </BrowserRouter>
......
...@@ -6,7 +6,6 @@ import { ...@@ -6,7 +6,6 @@ import {
6 Button, 6 Button,
7 Segment, 7 Segment,
8 Message, 8 Message,
9 - Divider,
10 Form, 9 Form,
11 Input, 10 Input,
12 Transition, 11 Transition,
...@@ -17,10 +16,14 @@ import { ...@@ -17,10 +16,14 @@ import {
17 FormErrorMessage, 16 FormErrorMessage,
18 FormHelperText, 17 FormHelperText,
19 VStack, 18 VStack,
19 + Stack,
20 StackDivider, 20 StackDivider,
21 Box, 21 Box,
22 - Text, 22 + Text, AlertDialogOverlay, AlertDialogContent, Alert, AlertIcon, AlertDialog,
23 } from '@chakra-ui/react' 23 } from '@chakra-ui/react'
24 +import {
25 + Divider,
26 +} from 'semantic-ui-react'
24 import http from '../utils/http' 27 import http from '../utils/http'
25 28
26 const DockerContainerCreate = () => { 29 const DockerContainerCreate = () => {
...@@ -85,12 +88,13 @@ const DockerContainerCreate = () => { ...@@ -85,12 +88,13 @@ const DockerContainerCreate = () => {
85 const { username, password, port } = response.data.data 88 const { username, password, port } = response.data.data
86 setLoading(false) 89 setLoading(false)
87 90
88 - if (!status) { 91 + if (status) {
89 - setError(message)
90 - } else {
91 setSuccess(true) 92 setSuccess(true)
92 - setSsh( 93 + setTimeout(3000, () => {
93 - `ssh ${username}@${window.location.hostname} -p ${port} # (password : ${password})`) 94 + history.push('/docker/container/list')
95 + })
96 + } else {
97 + setError(message)
94 } 98 }
95 99
96 // setTimeout(() => setSuccess(false), 10000); 100 // setTimeout(() => setSuccess(false), 10000);
...@@ -122,20 +126,20 @@ const DockerContainerCreate = () => { ...@@ -122,20 +126,20 @@ const DockerContainerCreate = () => {
122 return ( 126 return (
123 <Container> 127 <Container>
124 <Divider hidden/> 128 <Divider hidden/>
125 - <Heading>Create Docker Container</Heading>
126 129
127 - <VStack 130 + <Stack
128 - divider={<StackDivider borderColor="gray.200"/>} 131 + divider={<Divider hidden/>}
129 spacing={4} 132 spacing={4}
130 align="stretch" 133 align="stretch"
131 > 134 >
135 + <Heading>Create Docker Container</Heading>
136 +
132 <FormControl id="container" isRequired> 137 <FormControl id="container" isRequired>
133 <FormLabel>Container Name</FormLabel> 138 <FormLabel>Container Name</FormLabel>
134 <Input 139 <Input
135 type="email" 140 type="email"
136 placeholder='Container Name' 141 placeholder='Container Name'
137 /> 142 />
138 - <FormHelperText>컨테이너 이름을 입력해주세요.</FormHelperText>
139 </FormControl> 143 </FormControl>
140 144
141 <FormControl id="image"> 145 <FormControl id="image">
...@@ -146,14 +150,26 @@ const DockerContainerCreate = () => { ...@@ -146,14 +150,26 @@ const DockerContainerCreate = () => {
146 </Select> 150 </Select>
147 </FormControl> 151 </FormControl>
148 152
149 - <Button size="md" colorScheme="green" mt="24px" 153 + <Button size="md" colorScheme="teal" mt="24px"
150 onClick={() => createContainer()} 154 onClick={() => createContainer()}
151 > 155 >
152 Create Container 156 Create Container
153 </Button> 157 </Button>
154 - </VStack> 158 + </Stack>
155 -
156 159
160 + <AlertDialog
161 + isOpen={isSuccess}
162 + onClose={() => setSuccess(false)}
163 + >
164 + <AlertDialogOverlay>
165 + <AlertDialogContent>
166 + <Alert status="success">
167 + <AlertIcon />
168 + Successfully created !
169 + </Alert>
170 + </AlertDialogContent>
171 + </AlertDialogOverlay>
172 + </AlertDialog>
157 </Container> 173 </Container>
158 ) 174 )
159 } 175 }
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
24 } from '@chakra-ui/react' 24 } from '@chakra-ui/react'
25 import { 25 import {
26 Divider, 26 Divider,
27 + Grid,
27 } from 'semantic-ui-react' 28 } from 'semantic-ui-react'
28 import http from '../utils/http' 29 import http from '../utils/http'
29 30
...@@ -32,6 +33,8 @@ const DockerContainerList = () => { ...@@ -32,6 +33,8 @@ const DockerContainerList = () => {
32 const [isError, setError] = useState(false) 33 const [isError, setError] = useState(false)
33 const [message, setMessage] = useState('') 34 const [message, setMessage] = useState('')
34 35
36 + const history = useHistory()
37 +
35 const getContainerList = () => { 38 const getContainerList = () => {
36 http.get('/docker/container/list').then(response => { 39 http.get('/docker/container/list').then(response => {
37 const { status, data, message } = response.data 40 const { status, data, message } = response.data
...@@ -54,6 +57,20 @@ const DockerContainerList = () => { ...@@ -54,6 +57,20 @@ const DockerContainerList = () => {
54 <Divider hidden/> 57 <Divider hidden/>
55 <Heading>Container List</Heading> 58 <Heading>Container List</Heading>
56 59
60 + <Grid>
61 + <Grid.Column
62 + floated='right' width={3}
63 + >
64 + <Button
65 + size='xs'
66 + colorScheme='blue'
67 + onClick={() => history.push('/docker/container/create')}
68 + >
69 + New Container
70 + </Button>
71 + </Grid.Column>
72 + </Grid>
73 +
57 <Divider hidden/> 74 <Divider hidden/>
58 75
59 <UnorderedList> 76 <UnorderedList>
......
1 +import React, { useEffect, useState } from 'react'
2 +import {
3 + Container,
4 + Heading,
5 + Button,
6 + Text,
7 + Box,
8 +} from '@chakra-ui/react'
9 +import {
10 + Divider, Grid,
11 + Header,
12 +} from 'semantic-ui-react'
13 +import http from '../utils/http'
14 +import { useHistory } from 'react-router-dom'
15 +
16 +const ImageBlock = ({ title, desc, ...rest }) => {
17 + return (
18 + <Box p={5} shadow="md" borderWidth="1px" {...rest}>
19 + <Heading fontSize="xl">{title}</Heading>
20 + <Text mt={4}>{desc}</Text>
21 + </Box>
22 + )
23 +}
24 +
25 +const DockerDockerfileList = () => {
26 + const [token, setToken] = useState('')
27 + const [images, setImages] = useState([])
28 +
29 + const history = useHistory()
30 +
31 + const setTokenFromLocalStorage = () => {
32 + const token = localStorage.getItem('token')
33 + setToken(token)
34 + }
35 +
36 + const getImages = () => {
37 + http.get('/image/list', {
38 + headers: {
39 + Authorization: `token ${token}`,
40 + },
41 + }).then(response => {
42 + const { success, code, data, message } = response.data
43 + if (success) {
44 + const { count, data } = data
45 + setImages(data)
46 + }
47 + })
48 + }
49 +
50 + useEffect(() => {
51 + setTokenFromLocalStorage()
52 + getImages()
53 + }, [])
54 +
55 + return (
56 + <Container>
57 + <Divider hidden />
58 + <Heading>Dockerfile List</Heading>
59 + <Divider hidden />
60 + <Grid>
61 + <Grid.Column
62 + floated='right' width={3}
63 + >
64 + <Button
65 + size='xs'
66 + colorScheme='blue'
67 + onClick={() => history.push('/docker/image/create')}
68 + >
69 + New Image
70 + </Button>
71 + </Grid.Column>
72 + </Grid>
73 + {images.map(image => (
74 + <ImageBlock
75 + title={image.name}
76 + desc={image.name}
77 + />
78 + ))}
79 + </Container>
80 + )
81 +}
82 +
83 +export default DockerDockerfileList
...\ No newline at end of file ...\ No newline at end of file
...@@ -95,7 +95,6 @@ const DockerImageCreate = () => { ...@@ -95,7 +95,6 @@ const DockerImageCreate = () => {
95 </AlertDialogContent> 95 </AlertDialogContent>
96 </AlertDialogOverlay> 96 </AlertDialogOverlay>
97 </AlertDialog> 97 </AlertDialog>
98 -
99 </Container> 98 </Container>
100 ) 99 )
101 } 100 }
......
...@@ -14,8 +14,12 @@ const Navigation = () => { ...@@ -14,8 +14,12 @@ const Navigation = () => {
14 const panes = [ 14 const panes = [
15 { 15 {
16 menuItem: 'Home', 16 menuItem: 'Home',
17 - render: () => <Redirect to="/"/>, 17 + render: () => <Redirect to="/" />,
18 }, 18 },
19 + /*{
20 + menuItem: 'Dockerfile',
21 + render: () => <Redirect to="/docker/dockerfile/list"/>,
22 + },*/
19 { 23 {
20 menuItem: 'Image', 24 menuItem: 'Image',
21 render: () => <Redirect to="/docker/image/list"/>, 25 render: () => <Redirect to="/docker/image/list"/>,
......