Showing
3 changed files
with
76 additions
and
0 deletions
... | @@ -61,6 +61,23 @@ function showRequest(request_rows){ | ... | @@ -61,6 +61,23 @@ function showRequest(request_rows){ |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | +function showImage(request_rows){ | ||
65 | + var image = request_rows.result; | ||
66 | + | ||
67 | + $("#student-image-table > tbody").empty(); | ||
68 | + for(var i = 0; i < image.length; i++){ | ||
69 | + var bytes, blob; | ||
70 | + bytes = new Uint8Array(image[i].image); | ||
71 | + blob = new Blob([bytes], {type:'image/bmp'}); | ||
72 | + var url = URL.createObjectURL(blob); | ||
73 | + | ||
74 | + if($('#request' + image[i].image).length <= 0){ | ||
75 | + $("#student-image-table > tbody:last").append('<tr id="request' + image[i].image + '"><td><img src="' + url + '"/></td>' + '<td>' + image[i].timestamp + '</td></tr>') | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | +} | ||
80 | + | ||
64 | function checkAttendance(){ | 81 | function checkAttendance(){ |
65 | var lecture_id = '0' | 82 | var lecture_id = '0' |
66 | var url = '/lecture_student/' + lecture_id; | 83 | var url = '/lecture_student/' + lecture_id; |
... | @@ -129,6 +146,31 @@ function checkRequest(){ | ... | @@ -129,6 +146,31 @@ function checkRequest(){ |
129 | showRequest(request_rows) | 146 | showRequest(request_rows) |
130 | } | 147 | } |
131 | 148 | ||
149 | +function checkImage(){ | ||
150 | + var lecture_id = '0' | ||
151 | + var url = '/admin/image/' + lecture_id; | ||
152 | + | ||
153 | + var request_rows; | ||
154 | + $.ajax({ | ||
155 | + async: false, | ||
156 | + type: "GET", | ||
157 | + url: url, | ||
158 | + success: function(rows){ | ||
159 | + request_rows = rows | ||
160 | + return 0; | ||
161 | + }, | ||
162 | + error: function(xhr, status, err){ | ||
163 | + var err = ''; | ||
164 | + $.each(JSON.parse(xhr.responseText), function(i, item){ | ||
165 | + err += '<li>' + item.msg + '</li>'; | ||
166 | + }); | ||
167 | + return 0; | ||
168 | + } | ||
169 | + }); | ||
170 | + | ||
171 | + showImage(request_rows) | ||
172 | +} | ||
173 | + | ||
132 | function addRequest(){ | 174 | function addRequest(){ |
133 | var lecture_id = '0' | 175 | var lecture_id = '0' |
134 | var url = '/admin/request/' + lecture_id; | 176 | var url = '/admin/request/' + lecture_id; | ... | ... |
... | @@ -128,6 +128,28 @@ router.post('/request/:lecture_id', function(req, res, next) { | ... | @@ -128,6 +128,28 @@ router.post('/request/:lecture_id', function(req, res, next) { |
128 | }); | 128 | }); |
129 | }); | 129 | }); |
130 | 130 | ||
131 | +router.get('/image/:lecture_id', function(req, res, next) { | ||
132 | + var lecture_id = req.params.lecture_id; | ||
133 | + | ||
134 | + pool.getConnection(function(err, conn){ | ||
135 | + conn.query('select r.image, r.width AS width, r.height AS height, CONVERT_TZ(r.timestamp, "+00:00", "+09:00") AS timestamp FROM undefined_image r WHERE (r.lecture_id=?) AND (DATE(timestamp) = CURDATE()) ORDER BY timestamp DESC;', [lecture_id], function (err, rows){ | ||
136 | + if (err){ | ||
137 | + console.log(err); | ||
138 | + return res.status(500).json({error: err}); | ||
139 | + } | ||
140 | + if (!rows) return res.status(400).json({error: 'not found'}); | ||
141 | + var msg = { | ||
142 | + status: 'success', | ||
143 | + err: '', | ||
144 | + result: rows, | ||
145 | + length: rows.length | ||
146 | + }; | ||
147 | + res.json(msg); | ||
148 | + }); | ||
149 | + conn.release(); | ||
150 | + }); | ||
151 | +}); | ||
152 | + | ||
131 | 153 | ||
132 | 154 | ||
133 | module.exports = router; | 155 | module.exports = router; | ... | ... |
... | @@ -34,6 +34,18 @@ block content | ... | @@ -34,6 +34,18 @@ block content |
34 | th(scope="col") 출석 상태 | 34 | th(scope="col") 출석 상태 |
35 | th(scope="col") 출석 처리 | 35 | th(scope="col") 출석 처리 |
36 | tbody(id="requestTbody") | 36 | tbody(id="requestTbody") |
37 | + <br/> | ||
38 | + <br/> | ||
39 | + button(type="button" class="btn btn-primary" onclick="checkUndefinedImage()") 미인증 사진 확인 | ||
40 | + <br/> | ||
41 | + <br/> | ||
42 | + div(class="container-fluid-3") | ||
43 | + table(id="student-image-table" class="table") | ||
44 | + thead(class="thead-dark") | ||
45 | + tr(class="col") | ||
46 | + th(scope="col") 사진 | ||
47 | + th(scope="col") 등록 시간 | ||
48 | + tbody(id="imageTbody") | ||
37 | 49 | ||
38 | 50 | ||
39 | 51 | ... | ... |
-
Please register or login to post a comment