최초 커밋!
This commit is contained in:
141
front/src/main/resources/templates/user/info.html
Normal file
141
front/src/main/resources/templates/user/info.html
Normal file
@@ -0,0 +1,141 @@
|
||||
<!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">
|
||||
<style>
|
||||
label {
|
||||
display: inline-block;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.invalid-feedback {
|
||||
display: none;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.is-invalid + .invalid-feedback {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input[readonly] {
|
||||
background-color: #e9ecef;
|
||||
color: #6c757d;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<form
|
||||
method="get"
|
||||
name="reqForm"
|
||||
th:action="@{/user/info}" th:object="${userInfo}">
|
||||
<div>
|
||||
<label class="form-label d-block" for="profileImgFile">프로필 이미지</label>
|
||||
<div class="input-group w-50">
|
||||
<input accept="image/*" class="form-control"
|
||||
id="profileImgFile"
|
||||
name="profileImgFile"
|
||||
onchange="uiUtil.uploadFile('PROFILE_IMG', this);"
|
||||
type="file">
|
||||
<div class="invalid-feedback field-profileImgFile">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userId">아이디</label>
|
||||
<input id="userId" name="id" placeholder="아이디" readonly="readonly" th:field="*{id}"
|
||||
type="text">
|
||||
<div class="invalid-feedback field-id"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="nickname">닉네임</label>
|
||||
<input id="nickname" name="nickname" placeholder="닉네임" th:field="*{nickname}" type="text">
|
||||
<div class="invalid-feedback field-id"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userPwd">새 비밀번호</label>
|
||||
<input id="userPwd" name="password" placeholder="변경할 패스워드를 입력해주세요." th:field="*{password}"
|
||||
type="password">
|
||||
<div class="invalid-feedback field-password"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userPwdRe">새 비밀번호 재확인</label>
|
||||
<input id="userPwdRe" name="passwordRe" placeholder="변경할 패스워드를 재입력해주세요."
|
||||
type="password">
|
||||
<div class="invalid-feedback field-passwordRe"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userEmail">이메일</label>
|
||||
<input id="userEmail" name="email" placeholder="이메일을 입력해주세요." th:field="*{email}"
|
||||
type="text">
|
||||
<div class="invalid-feedback field-email"></div>
|
||||
</div>
|
||||
</form>
|
||||
<button onclick="updateUser();">수정하기</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const updateUser = () => {
|
||||
const f = document.reqForm;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
method: 'PATCH',
|
||||
url: '/api/front/user/update',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
if (confirm(`'${res.id}' 정보가 수정되었습니다.`)) {
|
||||
location.reload();
|
||||
}
|
||||
},
|
||||
statusCode: {
|
||||
'422': (res) => {
|
||||
const fieldErrors = res.responseJSON.fieldErrors;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
let target = $(f).find('[name=' + error.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
const showProfileImage = () => {
|
||||
const f = document.reqForm;
|
||||
const uploadFile = [[${userInfo.uploadFile}]];
|
||||
|
||||
if (uploadFile != null) {
|
||||
const input = $(f.profileImgFile);
|
||||
input.parent().append(
|
||||
`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
||||
uiUtil.showFileInfo(input, uploadFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
showProfileImage();
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
104
front/src/main/resources/templates/user/register.html
Normal file
104
front/src/main/resources/templates/user/register.html
Normal file
@@ -0,0 +1,104 @@
|
||||
<!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">
|
||||
<style>
|
||||
label {
|
||||
display: inline-block;
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.invalid-feedback {
|
||||
display: none;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.is-invalid + .invalid-feedback {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<form method="post" name="reqForm" th:action="@{/user/register}">
|
||||
<div>
|
||||
<label for="userId">아이디</label>
|
||||
<input id="userId" name="id" placeholder="아이디" type="text">
|
||||
<div class="invalid-feedback field-id"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="nickname">닉네임</label>
|
||||
<input id="nickname" name="nickname" placeholder="닉네임" type="text">
|
||||
<div class="invalid-feedback field-id"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userPwd">비밀번호</label>
|
||||
<input id="userPwd" name="password" placeholder="패스워드를 입력해주세요." type="password">
|
||||
<div class="invalid-feedback field-password"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userPwdRe">비밀번호 재확인</label>
|
||||
<input id="userPwdRe" name="passwordRe" placeholder="패스워드를 재입력해주세요." type="password">
|
||||
<div class="invalid-feedback field-passwordRe"></div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="userEmail">이메일</label>
|
||||
<input id="userEmail" name="email" placeholder="이메일을 입력해주세요." type="text">
|
||||
<div class="invalid-feedback field-email"></div>
|
||||
</div>
|
||||
</form>
|
||||
<button onclick="goSave()">가입하기</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
// 가입하기
|
||||
const goSave = () => {
|
||||
const f = document.reqForm;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/api/public/user/create',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: (res) => {
|
||||
alert('회원가입이 완료되었습니다.\n로그인 페이지로 이동합니다.');
|
||||
location.href = '/login';
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (res) {
|
||||
const resJson = res.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (res) {
|
||||
const fieldErrors = res.responseJSON.fieldErrors;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
let target = $(f).find('[name=' + error.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user