허진호

dd

......@@ -61,6 +61,23 @@ function showRequest(request_rows){
}
function showImage(request_rows){
var image = request_rows.result;
$("#student-image-table > tbody").empty();
for(var i = 0; i < image.length; i++){
var bytes, blob;
bytes = new Uint8Array(image[i].image);
blob = new Blob([bytes], {type:'image/bmp'});
var url = URL.createObjectURL(blob);
if($('#request' + image[i].image).length <= 0){
$("#student-image-table > tbody:last").append('<tr id="request' + image[i].image + '"><td><img src="' + url + '"/></td>' + '<td>' + image[i].timestamp + '</td></tr>')
}
}
}
function checkAttendance(){
var lecture_id = '0'
var url = '/lecture_student/' + lecture_id;
......@@ -129,6 +146,31 @@ function checkRequest(){
showRequest(request_rows)
}
function checkImage(){
var lecture_id = '0'
var url = '/admin/image/' + lecture_id;
var request_rows;
$.ajax({
async: false,
type: "GET",
url: url,
success: function(rows){
request_rows = rows
return 0;
},
error: function(xhr, status, err){
var err = '';
$.each(JSON.parse(xhr.responseText), function(i, item){
err += '<li>' + item.msg + '</li>';
});
return 0;
}
});
showImage(request_rows)
}
function addRequest(){
var lecture_id = '0'
var url = '/admin/request/' + lecture_id;
......
......@@ -128,6 +128,28 @@ router.post('/request/:lecture_id', function(req, res, next) {
});
});
router.get('/image/:lecture_id', function(req, res, next) {
var lecture_id = req.params.lecture_id;
pool.getConnection(function(err, conn){
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){
if (err){
console.log(err);
return res.status(500).json({error: err});
}
if (!rows) return res.status(400).json({error: 'not found'});
var msg = {
status: 'success',
err: '',
result: rows,
length: rows.length
};
res.json(msg);
});
conn.release();
});
});
module.exports = router;
......
......@@ -34,6 +34,18 @@ block content
th(scope="col") 출석 상태
th(scope="col") 출석 처리
tbody(id="requestTbody")
<br/>
<br/>
button(type="button" class="btn btn-primary" onclick="checkUndefinedImage()") 미인증 사진 확인
<br/>
<br/>
div(class="container-fluid-3")
table(id="student-image-table" class="table")
thead(class="thead-dark")
tr(class="col")
th(scope="col") 사진
th(scope="col") 등록 시간
tbody(id="imageTbody")
......