[삭제] 미사용 파일 삭제 - Article, Email

This commit is contained in:
김현주
2025-07-11 10:21:45 +09:00
parent 45250c126a
commit f1d6ec02e8
202 changed files with 1 additions and 7982 deletions

View File

@@ -1,333 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form autocomplete="off" method="get" name="reqForm" th:action="@{/board/articles}"
th:object="${reqVO}">
<!-- hidden parameters -->
<input name="sort" th:field="*{sort}" type="hidden"/>
<input name="page" th:field="*{page}" type="hidden"/>
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
<div class="col-5">
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
<select class="form-select d-inline w-25" id="searchField"
th:field="*{searchField}">
<option selected value="">선택</option>
<option value="title">제목</option>
<option value="updatedBy">작성자</option>
</select> <label>
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
style="width: 250px;" th:field="*{searchValue}"
type="text">
</label>
</div>
<div class="col">
<label class="col-sm-3 col-form-label" for="searchOpen">공개여부</label>
<select class="form-select d-inline w-25" id="searchOpen"
th:field="*{searchOpen}">
<option selected value="">전체</option>
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSearch();"
type="button">
<i class="bi bi-search"></i>
</button>
<button class="btn btn-outline-secondary" onclick="goInit();" type="button">
초기화
</button>
</div>
</div>
<div class="row">
<div class="col text-start">
<div class="fw-bolder text-muted">
TOTAL. <span id="totalElements"></span>
</div>
</div>
<div class="col text-end">
<i class="bi bi-list-ol"></i> <label>
<select
class="form-select form-select-sm" id="pageSize" name="size"
onchange="goSearch()"
th:field="*{size}">
<option
th:each="item : ${pageRows}"
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
</select>
</label>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" style="width:40px;"><label>
<input class="form-check-input"
onchange="toggleCheckbox(this);" type="checkbox"/></label>
</th>
<th scope="col" style="width:60px;"></th>
<th scope="col">
<a class="order-able" data-sort-field="title"
href="#">제목</a>
</th>
<th scope="col">
<a class="order-able text-center d-inline-block w-100" data-sort-field="visible"
href="#">공개여부</a></th>
<th scope="col">
<a class="order-able" data-sort-field="startDate"
href="#">게시일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="endDate"
href="#">종료일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedBy"
href="#">최근 수정자</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedAt"
href="#">최근 수정일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="orderNo"
href="#">정렬번호</a></th>
</tr>
</thead>
<tbody class="sortable" id="listTBody">
</tbody>
</table>
</form>
<div class="row paging"></div>
<div class="row">
<div class="col text-start">
<button class="btn btn-outline-secondary" onclick="goExcel();" type="button">
<i class="bi bi-file-earmark-spreadsheet"></i> 엑셀 다운로드
</button>
</div>
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSave();"
type="button">
<i class="bi bi-save2"></i> 등록
</button>
<button class="btn btn-outline-secondary" onclick="goRemove();" type="button">
<i class="bi bi-ui-checks-grid"></i> 삭제
</button>
<button class="btn btn-outline-secondary" onclick="uiUtil.sortable.update();" type="button">
<i class="bi bi-distribute-vertical"></i> 정렬 변경
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<script>
const INIT_SORT = 'orderNo,DESC';
const getArticles = (pageNo) => {
const f = document.reqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/board/articles',
data: dataOj,
success(response) {
console.log(response);
$('#totalElements').text(response.totalElements);
// List 구성하기
const tbody = $('#listTBody');
tbody.empty();
$(response.content).each((idx, ct) => {
tbody.append(
`
<tr data-order-no="${ct.orderNo}"
data-id="${ct.id}">
<th
scope="row">${idx + (pageNo * f.size.value) + 1}</th>
<td><label>
<input class="form-check-input"
name="selectIds" type="checkbox" value="${ct.id}"/></label></td>
<td><img
src="${ct.uploadFile ? uiUtil.getFileReferURL('inline', ct.uploadFile)
: '/static/ui/img/default-img.jpg'}"
style="width: 25px;"
class="img-thumbnail"/></td>
<td><a href="javascript:goUpdate(${ct.id})">${ct.title}</a></td>
<td class="text-secondary text-center">${ct.visible ? 'Y' : 'N'}</td>
<td>${uiUtil.isoStrToReadable(ct.startDate)}</td>
<td>${uiUtil.isoStrToReadable(ct.endDate)}</td>
<td>${ct.updatedBy}</td>
<td>${uiUtil.isoStrToReadable(ct.updatedAt)}</td>
<td class="text-center">${ct.orderNo} <i
class="bi bi-distribute-vertical handle float-end fw-bold"
style="cursor: move"></i></td>
</tr>
`
);
});
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
</tr>
`);
}
// Pagination 구성하기
const paging = $('.paging');
paging.empty();
paging.append(
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
(movePageNo) => {
f.page.value = movePageNo;
goSearch();
}));
// 리스트 상단 정렬 notation 및 갱신 기능 적용
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
f.page.value = targetPage;
f.sort.value = targetSort;
goSearch();
});
// sort 기능 적용
uiUtil.sortable.init(
// 드래그 가능 범위 지정 셀렉터
'.sortable',
// 드래그 핸들바 지정 셀렉터
'.handle',
// 현재 정렬이 orderNo,DESC 여부 검사 로직
() => {
return $('input[name=sort]').val() === INIT_SORT
},
// orderNo,DESC 로 정렬 변경 로직
() => {
f.sort.value = INIT_SORT;
getArticles(0);
},
// 정렬변경 수행 로직
(updateData) => {
$.ajax({
method: 'PATCH',
url: '/api/board/articles/sort',
data: JSON.stringify(updateData),
contentType: "application/json; charset=utf-8;",
dataType: "json",
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: function () {
alert('[[#{operation.orderNo.updated}]]');
getArticles(f.page.value);
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (response) {
}
}
})
}
);
}
})
}
// 최초 리스트 로드
getArticles(document.reqForm.page.value);
</script>
<script th:inline="javascript">
const goSearch = () => {
const f = document.reqForm;
f.method = 'GET';
f.submit();
}
// 초기화
function goInit() {
const f = document.reqForm;
f.searchField.value = '';
f.searchValue.value = '';
f.searchOpen.value = '';
}
// 저장페이지 이동
function goSave() {
location.href = '/board/articles/create';
}
// 수정페이지 이동
function goUpdate(itemId) {
location.href = '/board/articles/' + itemId;
}
function goExcel() {
const f = document.reqForm;
const data = $(f).serializeObject();
// size 를 제거하면 전체 목록을 가져온다.
delete data.size;
location.href = '/api/board/articles/excel?' + new URLSearchParams(data).toString();
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=selectIds]').prop("checked", oj.checked);
}
function goRemove() {
if (!$('input[name=selectIds]').is(':checked')) {
alert(/*[[#{operation.common.remove.choose}]]*/);
return;
}
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
const f = document.reqForm;
const data = $(f).serializeObject();
$.ajax({
'method': 'DELETE',
'url': '/api/board/articles/remove',
'data': {
'selectIds': data.selectIds
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert('선택한 아이템이 삭제되었습니다.');
f.method = 'GET';
f.submit();
}
});
}
}
</script>
</section>
</html>

View File

@@ -1,193 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/articles/create}">
<div class="container">
<div class="row mb-3">
<label class="form-label" for="title">제목 *</label>
<div class="input-group w-50">
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<a class="input-button" data-toggle title="toggle">
<i class="icon-calendar"></i>
</a>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="open">공개여부</label>
<div class="input-group w-25">
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="content">내용 *</label>
<div class="input-group w-100">
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="mb-3 mt-4">
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
<div class="input-group w-50" style="float: left">
<input accept="image/*" class="form-control" id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);" type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
<!-- <input type="text" class="form-control" name="repImgAlt"-->
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
<!-- </div>-->
<div style="clear: both"></div>
</div>
<div class="mb-3 mt-4 publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</div>
</form>
<div class="row">
<div class="col">
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
<i class="bi bi-arrow-left"></i>
</button>
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
<i class="bi bi-justify"></i>
</button>
</div>
<div class="col">
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
<i class="bi bi-save2"></i> 저장
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
$.ajax({
'method': 'POST',
'url': '/api/board/articles/create',
'data': obj,
success: (res) => {
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
history.back();
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
<script>
function addFileInput() {
$('.publicFileInputs').append(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
}
</script>
<script th:inline="javascript">
// init tinymce editor
initEditor('#content');
</script>
<script>
// date time picker
$(".flatpickr").flatpickr({
dateFormat: "Y-m-d\\TH:i",
// altInput: true,
// altFormat: "Y-m-d H:i",
monthSelectorType: 'static',
enableTime: true,
time_24hr: true
});
</script>
<script>
const goPrev = () => {
history.back();
}
const gotoList = () => {
location.href = '/board/articles';
}
</script>
</section>
</html>

View File

@@ -1,249 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/articles/update}">
<input name="id" th:value="${id}" type="hidden">
<input name="orderNo" type="hidden">
<div class="container">
<div class="row">
<!-- audit area -->
<div th:replace="common/components :: auditArea"></div>
</div>
<div class="row mb-3">
<label class="form-label" for="title">제목 *</label>
<div class="input-group w-50">
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="open">공개여부</label>
<div class="input-group w-25">
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="content">내용 *</label>
<div class="input-group w-100">
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="mb-3 mt-4">
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
<div class="input-group w-50" style="float: left">
<input accept="image/*" class="form-control"
id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
<!-- <input type="text" class="form-control" name="repImgAlt"-->
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
<!-- </div>-->
<div style="clear: both;"></div>
</div>
<div class="mb-3 mt-4 publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</div>
</form>
<div class="row">
<div class="col">
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
<i class="bi bi-arrow-left"></i>
</button>
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
<i class="bi bi-justify"></i>
</button>
</div>
<div class="col">
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
<i class="bi bi-save2"></i> 저장
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
const goPrev = () => {
history.back();
}
const gotoList = () => {
location.href = '/board/articles';
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script th:inline="javascript">
// date time picker
$(".flatpickr").flatpickr({
enableTime: true,
dateFormat: "Y-m-d\\TH:i",
monthSelectorType: 'static',
time_24hr: true
});
</script>
<script>
const getArticle = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/board/articles/' + f.id.value,
success(res) {
console.log(res);
showAudit(res.title, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
initEditor('#content', (editor) => {
editor.on('init', function () {
setTimeout(() => {
tinymce.get('content').setContent(uiUtil.unescapeHtml(res.content));
}, 0);
});
});
f.title.value = uiUtil.unescapeHtml(res.title);
f.startDate.value = res.startDate.substring(0, 16);
f.endDate.value = res.endDate.substring(0, 16);
f.visible.value = res.visible;
f.orderNo.value = res.orderNo;
res.uploadFiles.forEach((uploadFile) => {
switch (uploadFile.type.name) {
// 대표 이미지
case 'EXAMPLE_REP':
const input = $(f.representImgFile);
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(input, uploadFile, true);
break;
// 다건 첨부 파일
case 'EXAMPLE_PUBLIC':
let inputGroup = addFileInput();
inputGroup.append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
break;
}
});
}
});
}
// 상세정보 얻기
getArticle();
</script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
'method': 'PUT',
'url': '/api/board/articles/update',
'data': obj,
success: (res) => {
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
history.back();
}
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
</section>
</html>

View File

@@ -1,333 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form autocomplete="off" method="get" name="reqForm" th:action="@{/board/secArticles}"
th:object="${reqVO}">
<!-- hidden parameters -->
<input name="sort" th:field="*{sort}" type="hidden"/>
<input name="page" th:field="*{page}" type="hidden"/>
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
<div class="col-5">
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
<select class="form-select d-inline w-25" id="searchField"
th:field="*{searchField}">
<option selected value="">선택</option>
<option value="title">제목</option>
<option value="updatedBy">작성자</option>
</select> <label>
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
style="width: 250px;" th:field="*{searchValue}"
type="text">
</label>
</div>
<div class="col">
<label class="col-sm-3 col-form-label" for="searchOpen">공개여부</label>
<select class="form-select d-inline w-25" id="searchOpen"
th:field="*{searchOpen}">
<option selected value="">전체</option>
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSearch();"
type="button">
<i class="bi bi-search"></i>
</button>
<button class="btn btn-outline-secondary" onclick="goInit();" type="button">
초기화
</button>
</div>
</div>
<div class="row">
<div class="col text-start">
<div class="fw-bolder text-muted">
TOTAL. <span id="totalElements"></span>
</div>
</div>
<div class="col text-end">
<i class="bi bi-list-ol"></i> <label>
<select
class="form-select form-select-sm" id="pageSize" name="size"
onchange="goSearch()"
th:field="*{size}">
<option
th:each="item : ${pageRows}"
th:text="${item.codeText}" th:value="${item.codeValue}"></option>
</select>
</label>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" style="width:40px;"><label>
<input class="form-check-input"
onchange="toggleCheckbox(this);" type="checkbox"/></label>
</th>
<th scope="col" style="width:60px;"></th>
<th scope="col">
<a class="order-able" data-sort-field="title"
href="#">제목</a>
</th>
<th scope="col">
<a class="order-able text-center d-inline-block w-100" data-sort-field="visible"
href="#">공개여부</a></th>
<th scope="col">
<a class="order-able" data-sort-field="startDate"
href="#">게시일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="endDate"
href="#">종료일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedBy"
href="#">최근 수정자</a></th>
<th scope="col">
<a class="order-able" data-sort-field="updatedAt"
href="#">최근 수정일</a></th>
<th scope="col">
<a class="order-able" data-sort-field="orderNo"
href="#">정렬번호</a></th>
</tr>
</thead>
<tbody class="sortable" id="listTBody">
</tbody>
</table>
</form>
<div class="row paging"></div>
<div class="row">
<div class="col text-start">
<button class="btn btn-outline-secondary" onclick="goExcel();" type="button">
<i class="bi bi-file-earmark-spreadsheet"></i> 엑셀 다운로드
</button>
</div>
<div class="col text-end">
<button class="btn btn-outline-secondary" onclick="goSave();"
type="button">
<i class="bi bi-save2"></i> 등록
</button>
<button class="btn btn-outline-secondary" onclick="goRemove();" type="button">
<i class="bi bi-ui-checks-grid"></i> 삭제
</button>
<button class="btn btn-outline-secondary" onclick="uiUtil.sortable.update();" type="button">
<i class="bi bi-distribute-vertical"></i> 정렬 변경
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<script>
const INIT_SORT = 'orderNo,DESC';
const getArticles = (pageNo) => {
const f = document.reqForm;
f.page.value = pageNo;
let dataOj = $(f).serializeObject();
$.ajax({
method: 'GET',
url: '/api/board/secArticles',
data: dataOj,
success(response) {
console.log(response);
$('#totalElements').text(response.totalElements);
// List 구성하기
const tbody = $('#listTBody');
tbody.empty();
$(response.content).each((idx, ct) => {
tbody.append(
`
<tr data-order-no="${ct.orderNo}"
data-id="${ct.id}">
<th
scope="row">${idx + (pageNo * f.size.value) + 1}</th>
<td><label>
<input class="form-check-input"
name="selectIds" type="checkbox" value="${ct.id}"/></label></td>
<td><img
src="${ct.uploadFile ? uiUtil.getFileReferURL('inline', ct.uploadFile)
: '/static/ui/img/default-img.jpg'}"
style="width: 25px;"
class="img-thumbnail"/></td>
<td><a href="javascript:goUpdate(${ct.id})">${ct.title}</a></td>
<td class="text-secondary text-center">${ct.visible ? 'Y' : 'N'}</td>
<td>${uiUtil.isoStrToReadable(ct.startDate)}</td>
<td>${uiUtil.isoStrToReadable(ct.endDate)}</td>
<td>${ct.updatedBy}</td>
<td>${uiUtil.isoStrToReadable(ct.updatedAt)}</td>
<td class="text-center">${ct.orderNo} <i
class="bi bi-distribute-vertical handle float-end fw-bold"
style="cursor: move"></i></td>
</tr>
`
);
});
if (!$(response.content).length) {
tbody.append(`
<tr>
<td colspan="10" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
</tr>
`);
}
// Pagination 구성하기
const paging = $('.paging');
paging.empty();
paging.append(
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
(movePageNo) => {
f.page.value = movePageNo;
goSearch();
}));
// 리스트 상단 정렬 notation 및 갱신 기능 적용
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
f.page.value = targetPage;
f.sort.value = targetSort;
goSearch();
});
// sort 기능 적용
uiUtil.sortable.init(
// 드래그 가능 범위 지정 셀렉터
'.sortable',
// 드래그 핸들바 지정 셀렉터
'.handle',
// 현재 정렬이 orderNo,DESC 여부 검사 로직
() => {
return $('input[name=sort]').val() === INIT_SORT
},
// orderNo,DESC 로 정렬 변경 로직
() => {
f.sort.value = INIT_SORT;
getArticles(0);
},
// 정렬변경 수행 로직
(updateData) => {
$.ajax({
method: 'PATCH',
url: '/api/board/secArticles/sort',
data: JSON.stringify(updateData),
contentType: "application/json; charset=utf-8;",
dataType: "json",
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success: function () {
alert('[[#{operation.orderNo.updated}]]');
getArticles(f.page.value);
},
statusCode: {
// error
400: function (response) {
const resJson = response.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (response) {
}
}
})
}
);
}
})
}
// 최초 리스트 로드
getArticles(document.reqForm.page.value);
</script>
<script th:inline="javascript">
const goSearch = () => {
const f = document.reqForm;
f.method = 'GET';
f.submit();
}
// 초기화
function goInit() {
const f = document.reqForm;
f.searchField.value = '';
f.searchValue.value = '';
f.searchOpen.value = '';
}
// 저장페이지 이동
function goSave() {
location.href = '/board/secArticles/create';
}
// 수정페이지 이동
function goUpdate(itemId) {
location.href = '/board/secArticles/' + itemId;
}
function goExcel() {
const f = document.reqForm;
const data = $(f).serializeObject();
// size 를 제거하면 전체 목록을 가져온다.
delete data.size;
location.href = '/api/board/secArticles/excel?' + new URLSearchParams(data).toString();
}
// 체크박스 선택/해제
function toggleCheckbox(oj) {
$('input[name=selectIds]').prop("checked", oj.checked);
}
function goRemove() {
if (!$('input[name=selectIds]').is(':checked')) {
alert(/*[[#{operation.common.remove.choose}]]*/);
return;
}
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
const f = document.reqForm;
const data = $(f).serializeObject();
$.ajax({
'method': 'DELETE',
'url': '/api/board/secArticles/remove',
'data': {
'selectIds': data.selectIds
},
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
alert('선택한 아이템이 삭제되었습니다.');
f.method = 'GET';
f.submit();
}
});
}
}
</script>
</section>
</html>

View File

@@ -1,193 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/secArticles/create}">
<div class="container">
<div class="row mb-3">
<label class="form-label" for="title">제목 *</label>
<div class="input-group w-50">
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<a class="input-button" data-toggle title="toggle">
<i class="icon-calendar"></i>
</a>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="open">공개여부</label>
<div class="input-group w-25">
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="content">내용 *</label>
<div class="input-group w-100">
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="mb-3 mt-4">
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
<div class="input-group w-50" style="float: left">
<input accept="image/*" class="form-control" id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);" type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
<!-- <input type="text" class="form-control" name="repImgAlt"-->
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
<!-- </div>-->
<div style="clear: both"></div>
</div>
<div class="mb-3 mt-4 publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</div>
</form>
<div class="row">
<div class="col">
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
<i class="bi bi-arrow-left"></i>
</button>
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
<i class="bi bi-justify"></i>
</button>
</div>
<div class="col">
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
<i class="bi bi-save2"></i> 저장
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
$.ajax({
'method': 'POST',
'url': '/api/board/secArticles/create',
'data': obj,
success: (res) => {
alert(`'${f.title.value}' 게시물이 생성되었습니다.\n이전 화면으로 이동합니다.`);
history.back();
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
<script>
function addFileInput() {
$('.publicFileInputs').append(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
}
</script>
<script th:inline="javascript">
// init tinymce editor
initEditor('#content');
</script>
<script>
// date time picker
$(".flatpickr").flatpickr({
dateFormat: "Y-m-d\\TH:i",
// altInput: true,
// altFormat: "Y-m-d H:i",
monthSelectorType: 'static',
enableTime: true,
time_24hr: true
});
</script>
<script>
const goPrev = () => {
history.back();
}
const gotoList = () => {
location.href = '/board/secArticles';
}
</script>
</section>
</html>

View File

@@ -1,253 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form
class="fw-bold"
method="post" name="reqForm" th:action="@{/board/secArticles/update}">
<input name="id" th:value="${id}" type="hidden">
<input name="orderNo" type="hidden">
<input name="createdAt" type="hidden">
<input name="createdBy" type="hidden">
<div class="container">
<div class="row">
<!-- audit area -->
<div th:replace="common/components :: auditArea"></div>
</div>
<div class="row mb-3">
<label class="form-label" for="title">제목 *</label>
<div class="input-group w-50">
<input class="form-control unescapeText" id="title" name="title"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="boardStartDate">게시일 *</label>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardStartDate" name="startDate"
placeholder="게시일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<div class="input-group w-25">
<input class="form-control flatpickr" id="boardEndDate" name="endDate"
placeholder="종료일을 선택하세요" type="text"/>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="form-label" for="open">공개여부</label>
<div class="input-group w-25">
<select class="form-select" id="open" name="visible">
<option value="true">Y</option>
<option value="false">N</option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label" for="content">내용 *</label>
<div class="input-group w-100">
<textarea class="form-control" id="content" name="content" rows="10"></textarea>
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
</div>
<div class="mb-3 mt-4">
<label class="form-label d-block" for="representImgFile">대표 이미지</label>
<div class="input-group w-50" style="float: left">
<input accept="image/*" class="form-control"
id="representImgFile"
name="representImgFile"
onchange="uiUtil.uploadFile('EXAMPLE_REP', this);"
type="file">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
<!-- <div class="input-group w-50" style="float: right; padding-left:10px;">-->
<!-- <input type="text" class="form-control" name="repImgAlt"-->
<!-- placeholder="이미지 대체 텍스트를 입력해주세요"/>-->
<!-- </div>-->
<div style="clear: both;"></div>
</div>
<div class="mb-3 mt-4 publicFileInputs">
<label class="form-label d-block" for="formFile1">다건 파일 첨부</label>
<button class="btn btn-outline-secondary d-inline-block align-top mb-2" onclick="addFileInput();"
type="button"><i class="bi bi-plus-circle"></i> 파일 추가
</button>
</div>
</div>
</form>
<div class="row">
<div class="col">
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
<i class="bi bi-arrow-left"></i>
</button>
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
<i class="bi bi-justify"></i>
</button>
</div>
<div class="col">
<button class="btn btn-primary float-end" onclick="goSave();" type="button">
<i class="bi bi-save2"></i> 저장
</button>
</div>
</div>
</section>
<section layout:fragment="script">
<!-- web editor - tinymce -->
<script referrerpolicy="origin" src="/static/library/tinymce/6.0.3/tinymce.min.js"></script>
<script src="/static/ui/editorImageUpload.js"></script>
<script>
const goPrev = () => {
history.back();
}
const gotoList = () => {
location.href = '/board/secArticles';
}
function addFileInput() {
const inputGroup = $(`
<div class="input-group w-50">
<input class="form-control mb-2" type="file" name="multipartAttachments"
onchange="uiUtil.uploadFile('EXAMPLE_PUBLIC', this);">
<div class="invalid-feedback fw-bold">
에러 메세지
</div>
</div>
`);
$('.publicFileInputs').append(inputGroup);
return inputGroup;
}
</script>
<script th:inline="javascript">
// date time picker
$(".flatpickr").flatpickr({
enableTime: true,
dateFormat: "Y-m-d\\TH:i",
monthSelectorType: 'static',
time_24hr: true
});
</script>
<script>
const getArticle = () => {
const f = document.reqForm;
$.ajax({
method: 'GET',
url: '/api/board/secArticles/' + f.id.value,
success(res) {
console.log(res);
showAudit(res.title, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
initEditor('#content', (editor) => {
editor.on('init', function () {
setTimeout(() => {
tinymce.get('content').setContent(uiUtil.unescapeHtml(res.content));
}, 0);
});
});
f.title.value = uiUtil.unescapeHtml(res.title);
f.startDate.value = res.startDate.substring(0, 16);
f.endDate.value = res.endDate.substring(0, 16);
f.visible.value = res.visible;
f.orderNo.value = res.orderNo;
f.createdAt.value = res.createdAt;
f.createdBy.value = res.createdBy;
res.uploadFiles.forEach((uploadFile) => {
switch (uploadFile.type.name) {
// 대표 이미지
case 'EXAMPLE_REP':
const input = $(f.representImgFile);
input.parent().append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(input, uploadFile, true);
break;
// 다건 첨부 파일
case 'EXAMPLE_PUBLIC':
let inputGroup = addFileInput();
inputGroup.append(
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
break;
}
});
}
});
}
// 상세정보 얻기
getArticle();
</script>
<script>
const goSave = () => {
const f = document.reqForm;
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
f.content.value = uiUtil.unescapeHtml(tinymce.get('content').getContent());
const obj = $(f).serializeObject();
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
'method': 'PUT',
'url': '/api/board/secArticles/update',
'data': obj,
success: (res) => {
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
history.back();
}
},
statusCode: {
// error
400: function (res) {
const resJson = res.responseJSON;
alert(resJson.message);
},
// validation fail
422: function (res) {
$(res.responseJSON).each((idx, oj) => {
let target = $(f).find('[name=' + oj.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
});
}
}
});
}
</script>
</section>
</html>

View File

@@ -1,88 +0,0 @@
<!DOCTYPE html>
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<section layout:fragment="content">
<form class="fw-bold" enctype="multipart/form-data" method="post"
th:action="@{/addons/email/form}" th:object="${formDto}">
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="id">To *</label>
<div class="col-sm-4">
<input class="form-control" id="id" th:classappend="${#fields.hasErrors('to')} ? 'is-invalid'" th:field="*{to}"
type="email"/>
<div class="invalid-feedback fw-bold" th:errors="*{to}" th:if="${#fields.hasErrors('to')}">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="subject">Subject *</label>
<div class="col-sm-4">
<input class="form-control" id="subject" th:classappend="${#fields.hasErrors('subject')} ? 'is-invalid'"
th:field="*{subject}"/>
<div class="invalid-feedback fw-bold" th:errors="*{subject}"
th:if="${#fields.hasErrors('subject')}">
에러 메세지
</div>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="msgType">Message Type *</label>
<div class="col-sm-4">
<input checked class="form-check-input" id="msgType" name="msgType" type="radio"
value="HTML"/>
<label class="form-check-label" for="msgType">HTML</label>
<input class="form-check-input" id="msgType2" name="msgType" type="radio" value="TEXT"/>
<label class="form-check-label" for="msgType2">TEXT</label>
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label" for="message">Message *</label>
<div class="col-sm-4">
<textarea class="form-control" id="message" th:classappend="${#fields.hasErrors('message')} ? 'is-invalid'" th:field="*{message}"
type="text"></textarea>
<div class="invalid-feedback fw-bold" th:errors="*{message}"
th:if="${#fields.hasErrors('message')}">
에러 메세지
</div>
</div>
</div>
<div class="mb-3 publicFileInputs">
<label class="form-label d-block" for="formFile1">파일 첨부</label>
<input class="form-control w-50 d-inline-block mb-2" id="formFile1" name="multipartFiles"
type="file">
<button class="btn btn-success d-inline-block align-top" onclick="addFileInput('public');"
type="button">추가
</button>
</div>
<button class="btn btn-primary" type="submit">발송</button>
</form>
<script>
function addFileInput(type) {
let tmpl = $.templates('#fileInputTmpl');
switch (type) {
case 'public':
$('.publicFileInputs').append(tmpl.render({'name': 'multipartFiles'}));
break;
case 'private':
$('.privateFileInputs').append(tmpl.render({'name': 'privateFiles'}));
break;
}
}
</script>
<script id="fileInputTmpl" type="text/x-jsrender">
<input class="form-control w-50 mb-2" type="file" name="{{:name}}"/>
</script>
</section>
</html>