이승윤

chore: products -> category 디렉토리 변경

<% include ../includes/header.ejs %>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="_csrf" value="<%=csrfToken%>" />
<table class="table table-bordered">
<tr>
<th>카테고리명</th>
<td><input type="text" name="name" class="form-control" value="<%=product.name%>"/></td>
</tr>
<tr>
<th>섬네일</th>
<td>
<input type="file" name="thumbnail" />
<% if(product.thumbnail){ %>
<a href="/uploads/<%=product.thumbnail%>" target="_blank">업로드 이미지 보기</a>
<% } %>
</td>
</tr>
<tr>
<th>가격</th>
<td><input type="text" name="price" class="form-control" value="<%=product.price%>"/></td>
</tr>
<tr>
<th>설명</th>
<td><input type="text" name="description" class="form-control" value="<%=product.description%>"/></td>
</tr>
</table>
<button class="btn btn-primary">작성하기</button>
</form>
<% include ../includes/footer.ejs %>
\ No newline at end of file
<% include ../includes/header.ejs %>
<table class="table table-bordered table-hover">
<tr>
<th width="100px" style="text-align: center;">카테고리명</th>
<th style="text-align: center;">영상 개수</th>
<th>내용</th>
<th>삭제</th>
</tr>
<%products.forEach(function(product){%>
<tr>
<td>
<a href="/admin/products/detail/<%=product.id%>"><%=product.name%></a>
</td>
<td>
<%=product.getDate.year%> -
<%=product.getDate.month%> -
<%=product.getDate.day%>
</td>
<td>
<a href="/admin/products/delete/<%=product.id%>" class="btn btn-danger" onclick="return confirm('삭제하시겠습니까?')">삭제</a>
</td>
</tr>
<% }); %>
</table>
<a href="/admin/products/write" class="btn btn-default">작성하기</a>
<% include ../includes/footer.ejs %>
\ No newline at end of file
<% include ../includes/header.ejs %>
<div class="panel panel-default">
<div class="panel-heading">
<%=product.name%>
</div>
<div class="panel-body">
<div style="padding-bottom: 10px">
작성일 :
<%=product.getDate.year%> -
<%=product.getDate.month%> -
<%=product.getDate.day%>
</div>
<% if(product.thumbnail){%>
<p>
<img src="/uploads/<%=product.thumbnail%>" style="max-width: 100%"/>
</p>
<% } %>
<%=product.description%>
<!-- 댓글영역 -->
<div>
댓글작성하기
<form id="commentForm" action="" method="post">
<input type="hidden" name="product_id" value="<%=product.id%>" />
<textarea class="form-control" name="content"></textarea>
<button class="btn btn-primary" style="margin-top: 10px">댓글작성</button>
</form>
</div>
<!-- 댓글영역 -->
<hr />
<div id="comment_area">
<% comments.forEach(function(comment){ %>
<div>
<%=comment.content%>
( <a class='comment_delete' comment_id='<%=comment.id%>'>삭제</a> )
</div>
<% }); %>
</div>
</div>
</div>
<a href="/admin/products" class="btn btn-default">목록으로</a>
<a href="/admin/products/edit/<%=product.id%>" class="btn btn-primary">수정</a>
<% include ../includes/footer.ejs %>
<script>
(function(){
$(document).ready(function() {
$('#commentForm').submit(function(){
var $contentVal = $(this).children('textarea[name=content]').val();
if($contentVal){
$.ajax({
url: '/admin/products/ajax_comment/insert',
type: 'POST',
data: $(this).serialize(),
})
.done(function(args) {
if(args.message==="success"){
$('#comment_area').append(
'<div>' + args.content +
" ( <a class='comment_delete' comment_id='"+ args.id +"'>삭제</a> ) </div>"
);
$('#commentForm textarea[name=content]').val("");
}
})
.fail(function(args) {
console.log(args);
});
}else{
alert('댓글 내용을 입력해주세요.')
}
return false;
});
});
})();
</script>
<script>
$(document).on('click' , '.comment_delete' , function(){
if(confirm('삭제하시겠습니까?')){ //확인창 예 눌렀을 시만 진행
var $self = $(this);
$.ajax({
url: '/admin/products/ajax_comment/delete',
type: 'POST',
data: { comment_id : $self.attr('comment_id') },
})
.done(function() {
$self.parent().remove();
alert("삭제가 완료되었습니다.");
})
.fail(function(args) {
console.log(args);
});
}
});
</script>
\ No newline at end of file