[삭제] 미사용 파일 삭제 - AdminRole, AdminPrivilege, UserRole, Users, UserPrivilege
This commit is contained in:
@@ -1,430 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<span style="color:red; background-color: black;font-size: 30px;"> ** 화면 깨짐 주의 **</span>
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="역할 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">역할 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control"
|
||||
placeholder="ROLE_ 로 시작하는 역할 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="privilegeIds">권한</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-select text-secondary" id="privilegeIds" name="privilegeIds"
|
||||
multiple style="height: 200px;">
|
||||
<option th:each="privilege : ${privileges}" th:value="${privilege.id}"
|
||||
class="fw-bold"
|
||||
th:text="${privilege.id + ' (' + privilege.description + ')'}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold field-privilegeIds"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">역할 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminRole/get/recursiveItems',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.items;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '관리자 역할',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminRole/get/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.item;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
$('#privilegeIds').val(item.privilegeIds);
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.role.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree(response.item.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
$('#privilegeIds').val([]);
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/switchOrderNo',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(updateList),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<th:block layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
const link1 = document.createElement('link');
|
||||
link1.rel = 'stylesheet';
|
||||
link1.href = /*[[@{/static/library/bootstrap/bootstrap.min.css}]]*/'';
|
||||
head.appendChild(link1);
|
||||
|
||||
const link2 = document.createElement('link');
|
||||
link2.rel = 'stylesheet';
|
||||
link2.href =/*[[@{/static/library/bootstrap/bootstrap-icons.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link3 = document.createElement('link');
|
||||
link3.rel = 'stylesheet';
|
||||
link3.href =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link4 = document.createElement('script');
|
||||
link4.type = 'text/javascript';
|
||||
link4.src =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.js}]]*/'';
|
||||
head.appendChild(link4);
|
||||
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,414 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<span style="color:red; background-color: black;font-size: 30px;"> ** 화면 깨짐 주의 **</span>
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="권한 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">권한 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control" placeholder="공백없이 권한 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">권한 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminPrivilege/get/recursiveItems',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.items;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '관리자 권한',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminPrivilege/get/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.item;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree(response.item.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/switchOrderNo',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(updateList),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (data) {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<th:block layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
const link1 = document.createElement('link');
|
||||
link1.rel = 'stylesheet';
|
||||
link1.href = /*[[@{/static/library/bootstrap/bootstrap.min.css}]]*/'';
|
||||
head.appendChild(link1);
|
||||
|
||||
const link2 = document.createElement('link');
|
||||
link2.rel = 'stylesheet';
|
||||
link2.href =/*[[@{/static/library/bootstrap/bootstrap-icons.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link3 = document.createElement('link');
|
||||
link3.rel = 'stylesheet';
|
||||
link3.href =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link4 = document.createElement('script');
|
||||
link4.type = 'text/javascript';
|
||||
link4.src =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.js}]]*/'';
|
||||
head.appendChild(link4);
|
||||
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,388 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="권한 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">권한 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control" placeholder="공백없이 권한 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">권한 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userPrivileges',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.userPrivileges;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '사용자 권한',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userPrivileges/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.userPrivilege;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/userPrivileges/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree(response.userPrivilege.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: '/api/userPrivileges/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'PATCH',
|
||||
url: '/api/userPrivileges/sort',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
sortUserPrivileges: updateList
|
||||
}),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (data) {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,404 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="역할 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">역할 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control"
|
||||
placeholder="ROLE_ 로 시작하는 역할 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="privilegeIds">권한</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-select text-secondary" id="privilegeIds" name="privilegeIds"
|
||||
multiple style="height: 200px;">
|
||||
<option th:each="privilege : ${privileges}" th:value="${privilege.id}"
|
||||
class="fw-bold"
|
||||
th:text="${privilege.id + ' (' + privilege.description + ')'}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold field-privilegeIds"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">역할 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userRoles',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.userRoles;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '사용자 역할',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userRoles/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.userRole;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
$('#privilegeIds').val(item.privileges);
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/userRoles/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree(response.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: '/api/userRole/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
$('#privilegeIds').val([]);
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'PATCH',
|
||||
url: '/api/userRoles/sort',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
sortUserRoles: updateList
|
||||
}),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,216 +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 method="post" name="reqForm" th:action="@{/settings/users}" 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="id">ID</option>
|
||||
<option value="email">Email</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-2 col-form-label" for="searchRole">권한</label>
|
||||
<select class="form-select d-inline w-50" id="searchRole" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></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"><a class="order-able" data-sort-field="id" href="#">ID</a></th>
|
||||
<th class="text-secondary" scope="col">권한</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="nickname" href="#">닉네임</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="signUpType" href="#">가입유형</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="email" href="#">Email</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountDisabled" href="#">활성화</a>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountLocked" href="#">계정잠김</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="createdAt" href="#">등록일</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="listTBody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="row paging"></div>
|
||||
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const getUsers = (pageNo) => {
|
||||
const f = document.reqForm;
|
||||
f.page.value = pageNo;
|
||||
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/settings/users',
|
||||
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-id="${ct.id}">
|
||||
<th scope="row">
|
||||
${idx + (pageNo * f.size.value) + 1}
|
||||
</th>
|
||||
<td><a href="javascript:goUpdate('${ct.id}')">${ct.id}</a></td>
|
||||
<td>
|
||||
${ct.roles.map(r => r.id).join(', ')}
|
||||
</td>
|
||||
<td>${ct.nickname}</td>
|
||||
<td>${ct.signUpType}</td>
|
||||
<td>${ct.email}</td>
|
||||
<td>${ct.accountDisabled ? 'N' : 'Y'}</td>
|
||||
<td>${ct.accountLocked ? 'Y' : 'N'}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.createdAt)}</td>
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
if (!$(response.content).length) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td colspan="9" 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();
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 최초 리스트 로드
|
||||
getUsers(0);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 검색
|
||||
function goSearch() {
|
||||
const f = document.reqForm;
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.reqForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchRole.value = '';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(id) {
|
||||
location.href = '/settings/users/' + id;
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
function toggleCheckbox(oj) {
|
||||
$('input[name=checkedIds]').prop("checked", oj.checked);
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
if (!$('input[name=checkedIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.reqForm;
|
||||
f.action = '/settings/admins/delete';
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.reqForm;
|
||||
f.action = '/settings/admins/excel';
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,165 +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="@{/settings/users/update}">
|
||||
|
||||
<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="id">ID *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control" id="id" name="id" readonly="readonly"
|
||||
th:value="${id}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="email">Email *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control" id="email" name="email" type="email"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="roleIds">권한 *</label>
|
||||
<div class="input-group w-50">
|
||||
<select class="form-control" multiple name="roles">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" name="accountDisabled">
|
||||
<option value="true">비활성화</option>
|
||||
<option value="false">활성화</option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="accountLocked1">계정잠김 여부 *</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" name="accountLocked">
|
||||
<option value="true">Locked</option>
|
||||
<option value="false">Unlocked</option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="loginFailCnt">로그인 실패 회수</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control" id="loginFailCnt" name="loginFailCnt" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</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="updateUser();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const getUser = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
$.ajax({
|
||||
'method': 'GET',
|
||||
'url': '/api/settings/users/' + f.id.value,
|
||||
success(res) {
|
||||
console.log(res);
|
||||
|
||||
showAudit(res.id, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
|
||||
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
|
||||
|
||||
f.email.value = res.email;
|
||||
f.roles.value = res.roles.map((el) => el.id);
|
||||
f.accountDisabled.value = res.accountDisabled;
|
||||
f.accountLocked.value = res.accountLocked;
|
||||
f.loginFailCnt.value = res.loginFailCnt;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 상세정보 얻기
|
||||
getUser();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const updateUser = () => {
|
||||
const f = document.reqForm;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
'method': 'PATCH',
|
||||
'url': '/api/settings/users/update',
|
||||
'data': obj,
|
||||
success(res) {
|
||||
if (confirm(`'${res.id}' 정보가 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
|
||||
history.back();
|
||||
}
|
||||
},
|
||||
statusCode: {
|
||||
'422': (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>
|
||||
Reference in New Issue
Block a user