Showing
4 changed files
with
166 additions
and
42 deletions
This diff is collapsed. Click to expand it.
| ... | @@ -11,19 +11,86 @@ import TableCell from '@material-ui/core/TableCell' | ... | @@ -11,19 +11,86 @@ import TableCell from '@material-ui/core/TableCell' |
| 11 | import {withStyles} from '@material-ui/core/styles'; | 11 | import {withStyles} from '@material-ui/core/styles'; |
| 12 | import curcularProgress from '@material-ui/core/CircularProgress'; | 12 | import curcularProgress from '@material-ui/core/CircularProgress'; |
| 13 | import CircularProgress from '@material-ui/core/CircularProgress'; | 13 | import CircularProgress from '@material-ui/core/CircularProgress'; |
| 14 | +import AppBar from '@material-ui/core/AppBar' | ||
| 15 | +import Toolbar from '@material-ui/core/Toolbar'; | ||
| 16 | +import IconButton from '@material-ui/core/IconButton'; | ||
| 17 | +import Typography from '@material-ui/core/Typography'; | ||
| 18 | +import InputBase from '@material-ui/core/InputBase'; | ||
| 19 | +import { fade } from '@material-ui/core/styles/colorManipulator'; | ||
| 20 | +import MenuIcon from '@material-ui/icons/Menu'; | ||
| 21 | +import SearchIcon from '@material-ui/icons/Search'; | ||
| 22 | + | ||
| 14 | 23 | ||
| 15 | const styles = theme => ({ | 24 | const styles = theme => ({ |
| 16 | root: { | 25 | root: { |
| 17 | width: '100%', | 26 | width: '100%', |
| 18 | - marginTop: theme.spacing.unit * 3, | 27 | + minWidth:1080 |
| 19 | - overflowX: "auto" | ||
| 20 | }, | 28 | }, |
| 21 | table: { | 29 | table: { |
| 22 | - minWidth:1000 | 30 | + marginLeft:18, |
| 31 | + marginRight:18 | ||
| 32 | + }, | ||
| 33 | + menu: { | ||
| 34 | + marginTop:15, | ||
| 35 | + marginBottom:15, | ||
| 36 | + display:'flex', | ||
| 37 | + justifyContent:'center' | ||
| 23 | }, | 38 | }, |
| 24 | progress:{ | 39 | progress:{ |
| 25 | - margin: theme.spacing.unit * 2 | 40 | + margin: theme.spacing(2) |
| 26 | - } | 41 | + }, |
| 42 | + menuButton: { | ||
| 43 | + marginRight: theme.spacing(2), | ||
| 44 | + }, | ||
| 45 | + tableHead: { | ||
| 46 | + fontSize: '2.0rem', | ||
| 47 | + }, | ||
| 48 | + title: { | ||
| 49 | + flexGrow: 1, | ||
| 50 | + display: 'none', | ||
| 51 | + [theme.breakpoints.up('sm')]: { | ||
| 52 | + display: 'block', | ||
| 53 | + }, | ||
| 54 | + }, | ||
| 55 | + search: { | ||
| 56 | + position: 'relative', | ||
| 57 | + borderRadius: theme.shape.borderRadius, | ||
| 58 | + backgroundColor: fade(theme.palette.common.white, 0.15), | ||
| 59 | + '&:hover': { | ||
| 60 | + backgroundColor: fade(theme.palette.common.white, 0.25), | ||
| 61 | + }, | ||
| 62 | + marginLeft: 0, | ||
| 63 | + width: '100%', | ||
| 64 | + [theme.breakpoints.up('sm')]: { | ||
| 65 | + marginLeft: theme.spacing(1), | ||
| 66 | + width: 'auto', | ||
| 67 | + }, | ||
| 68 | + }, | ||
| 69 | + searchIcon: { | ||
| 70 | + padding: theme.spacing(0, 2), | ||
| 71 | + height: '100%', | ||
| 72 | + position: 'absolute', | ||
| 73 | + pointerEvents: 'none', | ||
| 74 | + display: 'flex', | ||
| 75 | + alignItems: 'center', | ||
| 76 | + justifyContent: 'center', | ||
| 77 | + }, | ||
| 78 | + inputRoot: { | ||
| 79 | + color: 'inherit', | ||
| 80 | + }, | ||
| 81 | + inputInput: { | ||
| 82 | + padding: theme.spacing(1, 1, 1, 0), | ||
| 83 | + // vertical padding + font size from searchIcon | ||
| 84 | + paddingLeft: `calc(1em + ${theme.spacing(4)}px)`, | ||
| 85 | + transition: theme.transitions.create('width'), | ||
| 86 | + width: '100%', | ||
| 87 | + [theme.breakpoints.up('sm')]: { | ||
| 88 | + width: '12ch', | ||
| 89 | + '&:focus': { | ||
| 90 | + width: '20ch', | ||
| 91 | + }, | ||
| 92 | + }, | ||
| 93 | + }, | ||
| 27 | }) | 94 | }) |
| 28 | 95 | ||
| 29 | const students = [ | 96 | const students = [ |
| ... | @@ -56,14 +123,16 @@ class App extends Component{ | ... | @@ -56,14 +123,16 @@ class App extends Component{ |
| 56 | super(props); | 123 | super(props); |
| 57 | this.state = { | 124 | this.state = { |
| 58 | students: '', | 125 | students: '', |
| 59 | - completed: 0 | 126 | + completed: 0, |
| 127 | + searchKeyword:'' | ||
| 60 | } | 128 | } |
| 61 | } | 129 | } |
| 62 | 130 | ||
| 63 | stateRefresh = () => { | 131 | stateRefresh = () => { |
| 64 | this.setState({ | 132 | this.setState({ |
| 65 | students: '', | 133 | students: '', |
| 66 | - completed: 0 | 134 | + completed: 0, |
| 135 | + searchKeyword:'' | ||
| 67 | }); | 136 | }); |
| 68 | this.callApi() | 137 | this.callApi() |
| 69 | .then(res => this.setState({students: res})) | 138 | .then(res => this.setState({students: res})) |
| ... | @@ -89,36 +158,20 @@ class App extends Component{ | ... | @@ -89,36 +158,20 @@ class App extends Component{ |
| 89 | this.setState({completed:completed >= 100 ?0:completed +1}); | 158 | this.setState({completed:completed >= 100 ?0:completed +1}); |
| 90 | } | 159 | } |
| 91 | 160 | ||
| 92 | - render(){ | 161 | + handleValueChange =(e)=>{ |
| 93 | - | 162 | + let nextState ={}; |
| 94 | - const {classes}= this.props; | 163 | + nextState[e.target.st_Name]=e.target.value; |
| 95 | - | 164 | + this.setState(nextState); |
| 96 | - return ( | 165 | + } |
| 97 | - <div> | ||
| 98 | - <Paper className={classes.root}> | ||
| 99 | - <Table className={classes.table}> | ||
| 100 | 166 | ||
| 101 | - <TableHead> | 167 | + render(){ |
| 102 | - <TableRow> | ||
| 103 | - <TableCell>코드번호</TableCell> | ||
| 104 | - <TableCell>이름</TableCell> | ||
| 105 | - <TableCell>학번</TableCell> | ||
| 106 | - <TableCell>전공</TableCell> | ||
| 107 | - <TableCell>중간</TableCell> | ||
| 108 | - <TableCell>기말</TableCell> | ||
| 109 | - <TableCell>과제</TableCell> | ||
| 110 | - <TableCell>출석</TableCell> | ||
| 111 | - <TableCell>학점</TableCell> | ||
| 112 | - <TableCell>설정</TableCell> | ||
| 113 | - </TableRow> | ||
| 114 | - </TableHead> | ||
| 115 | 168 | ||
| 116 | - <TableBody> | 169 | + const filteredComponents = (data)=>{ |
| 117 | - { | 170 | + data=data.filter((c) =>{ |
| 118 | - this.state.students ? | 171 | + return c.st_Name.indexOf(this.state.searchKeyword) > -1; |
| 119 | - this.state.students.map(c=>{ | 172 | + }); |
| 120 | - return ( | 173 | + return data.map((c)=>{ |
| 121 | - <Student stateRefresh={this.stateRefresh} | 174 | + return <Student stateRefresh={this.stateRefresh} |
| 122 | key={c.st_Code} | 175 | key={c.st_Code} |
| 123 | st_Code={c.st_Code} | 176 | st_Code={c.st_Code} |
| 124 | st_Name={c.st_Name} | 177 | st_Name={c.st_Name} |
| ... | @@ -128,10 +181,63 @@ class App extends Component{ | ... | @@ -128,10 +181,63 @@ class App extends Component{ |
| 128 | st_Finalscore={c.st_Finalscore} | 181 | st_Finalscore={c.st_Finalscore} |
| 129 | st_Assignscore={c.st_Assignscore} | 182 | st_Assignscore={c.st_Assignscore} |
| 130 | st_Attendscore={c.st_Attendscore} | 183 | st_Attendscore={c.st_Attendscore} |
| 131 | - st_Score={c.st_Score} | 184 | + st_Score={c.st_Score}/> |
| 185 | + }); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + const {classes}= this.props; | ||
| 189 | + const cellList=["코드번호","이름","학번","전공","중간","기말","과제","출석","설정"]; | ||
| 190 | + return ( | ||
| 191 | + <div className={classes.root}> | ||
| 192 | + <AppBar position="static"> | ||
| 193 | + <Toolbar> | ||
| 194 | + <IconButton | ||
| 195 | + edge="start" | ||
| 196 | + className={classes.menuButton} | ||
| 197 | + color="inherit" | ||
| 198 | + aria-label="open drawer" | ||
| 199 | + > | ||
| 200 | + <MenuIcon /> | ||
| 201 | + </IconButton> | ||
| 202 | + <Typography className={classes.title} variant="h6" noWrap> | ||
| 203 | + 학생 성적 관리 프로그램 | ||
| 204 | + </Typography> | ||
| 205 | + <div className={classes.search}> | ||
| 206 | + <div className={classes.searchIcon}> | ||
| 207 | + <SearchIcon /> | ||
| 208 | + </div> | ||
| 209 | + <InputBase | ||
| 210 | + placeholder="검색하기" | ||
| 211 | + classes={{ | ||
| 212 | + root: classes.inputRoot, | ||
| 213 | + input: classes.inputInput, | ||
| 214 | + }} | ||
| 215 | + name="searchKeyword" | ||
| 216 | + value={this.state.searchKeyword} | ||
| 217 | + onChange={this.handleValueChange} | ||
| 218 | + //inputProps={{ 'aria-label': 'search' }} | ||
| 132 | /> | 219 | /> |
| 133 | - ); | 220 | + </div> |
| 134 | - }) : | 221 | + </Toolbar> |
| 222 | + </AppBar> | ||
| 223 | + <div className={classes.menu}> | ||
| 224 | + <StudentAdd stateRefresh={this.stateRefresh}/> | ||
| 225 | + </div> | ||
| 226 | + | ||
| 227 | + <Paper className={classes.paper}> | ||
| 228 | + <Table className={classes.table}> | ||
| 229 | + | ||
| 230 | + <TableHead> | ||
| 231 | + <TableRow> | ||
| 232 | + {cellList.map(c => { | ||
| 233 | + return <TableCell className={classes.TableHead}>{c}</TableCell> | ||
| 234 | + })} | ||
| 235 | + </TableRow> | ||
| 236 | + </TableHead> | ||
| 237 | + <TableBody> | ||
| 238 | + {this.state.students ? | ||
| 239 | + filteredComponents(this.state.students): | ||
| 240 | + | ||
| 135 | <TableRow> | 241 | <TableRow> |
| 136 | <TableCell colSpan="9" allign="center"> | 242 | <TableCell colSpan="9" allign="center"> |
| 137 | <CircularProgress className={classes.progress} variant="determinate" value={this.state.completed}/> | 243 | <CircularProgress className={classes.progress} variant="determinate" value={this.state.completed}/> |
| ... | @@ -139,12 +245,8 @@ class App extends Component{ | ... | @@ -139,12 +245,8 @@ class App extends Component{ |
| 139 | </TableRow> | 245 | </TableRow> |
| 140 | } | 246 | } |
| 141 | </TableBody> | 247 | </TableBody> |
| 142 | - | ||
| 143 | </Table> | 248 | </Table> |
| 144 | - | ||
| 145 | </Paper> | 249 | </Paper> |
| 146 | - | ||
| 147 | - <StudentAdd stateRefresh={this.stateRefresh}/> | ||
| 148 | </div> | 250 | </div> |
| 149 | 251 | ||
| 150 | 252 | ... | ... |
| ... | @@ -4,6 +4,22 @@ | ... | @@ -4,6 +4,22 @@ |
| 4 | "lockfileVersion": 1, | 4 | "lockfileVersion": 1, |
| 5 | "requires": true, | 5 | "requires": true, |
| 6 | "dependencies": { | 6 | "dependencies": { |
| 7 | + "@babel/runtime": { | ||
| 8 | + "version": "7.12.5", | ||
| 9 | + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz", | ||
| 10 | + "integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==", | ||
| 11 | + "requires": { | ||
| 12 | + "regenerator-runtime": "^0.13.4" | ||
| 13 | + } | ||
| 14 | + }, | ||
| 15 | + "@material-ui/icons": { | ||
| 16 | + "version": "4.11.2", | ||
| 17 | + "resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.11.2.tgz", | ||
| 18 | + "integrity": "sha512-fQNsKX2TxBmqIGJCSi3tGTO/gZ+eJgWmMJkgDiOfyNaunNaxcklJQFaFogYcFl0qFuaEz1qaXYXboa/bUXVSOQ==", | ||
| 19 | + "requires": { | ||
| 20 | + "@babel/runtime": "^7.4.4" | ||
| 21 | + } | ||
| 22 | + }, | ||
| 7 | "@types/http-proxy": { | 23 | "@types/http-proxy": { |
| 8 | "version": "1.17.4", | 24 | "version": "1.17.4", |
| 9 | "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.4.tgz", | 25 | "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.4.tgz", |
| ... | @@ -833,6 +849,11 @@ | ... | @@ -833,6 +849,11 @@ |
| 833 | "util-deprecate": "~1.0.1" | 849 | "util-deprecate": "~1.0.1" |
| 834 | } | 850 | } |
| 835 | }, | 851 | }, |
| 852 | + "regenerator-runtime": { | ||
| 853 | + "version": "0.13.7", | ||
| 854 | + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", | ||
| 855 | + "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==" | ||
| 856 | + }, | ||
| 836 | "require-directory": { | 857 | "require-directory": { |
| 837 | "version": "2.1.1", | 858 | "version": "2.1.1", |
| 838 | "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", | 859 | "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", | ... | ... |
| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | "dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"" | 7 | "dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"" |
| 8 | }, | 8 | }, |
| 9 | "dependencies": { | 9 | "dependencies": { |
| 10 | + "@material-ui/icons": "^4.11.2", | ||
| 10 | "body-parser": "^1.19.0", | 11 | "body-parser": "^1.19.0", |
| 11 | "config": "^3.3.3", | 12 | "config": "^3.3.3", |
| 12 | "express": "4.17.1", | 13 | "express": "4.17.1", | ... | ... |
-
Please register or login to post a comment