toaster 적용

This commit is contained in:
현성필
2023-09-11 13:14:50 +09:00
parent 0a382f0d82
commit 22a1f523f3
4 changed files with 49 additions and 5 deletions
+15 -3
View File
@@ -58,6 +58,14 @@
</div> </div>
<button class="w-100 btn btn-lg btn-primary" type="button" id="actionLogin" th:text="#{loginForm.login}">Sign in</button> <button class="w-100 btn btn-lg btn-primary" type="button" id="actionLogin" th:text="#{loginForm.login}">Sign in</button>
</form> </form>
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
<strong class="mr-auto">알림</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
</div>
</div>
<div class="mt-2 text-center"> <div class="mt-2 text-center">
<span class="text-muted"><a href="/forgot_password.do">비밀번호 초기화</a></span> <span class="text-muted"><a href="/forgot_password.do">비밀번호 초기화</a></span>
</div> </div>
@@ -100,8 +108,10 @@
function fnInit() { function fnInit() {
getId(document.loginForm); getId(document.loginForm);
if (document.loginForm.message !== null && document.loginForm.message.value !== "") { let message = document.loginForm.message.value;
alert(document.loginForm.message.value); if (message) {
$('.toast-body').text(message);
$('.toast').toast('show');
} }
} }
@@ -120,7 +130,9 @@
event.stopPropagation() event.stopPropagation()
} else { } else {
if (form.password.value.length < 8) { if (form.password.value.length < 8) {
alert("[[#{validate.passLengthShort}]]"); let message = "[[#{validate.passLengthShort}]]";
$('.toast-body').text(message);
$('.toast').toast('show');
} else { } else {
form.submit(); form.submit();
} }
@@ -8,6 +8,14 @@
require.config({paths: {'vs': '/plugins/vs'}}); require.config({paths: {'vs': '/plugins/vs'}});
</script> </script>
<div class="container-fluid mt-2"> <div class="container-fluid mt-2">
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
<strong class="mr-auto">알림</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
</div>
</div>
<form name="mockRouteForm" id="mockRouteForm" <form name="mockRouteForm" id="mockRouteForm"
th:action="${mockRoute.id == null}?@{/mgmt/routes/register.do}:@{/mgmt/routes/update.do}" th:action="${mockRoute.id == null}?@{/mgmt/routes/register.do}:@{/mgmt/routes/update.do}"
th:object='${mockRoute}' method="post"> th:object='${mockRoute}' method="post">
@@ -477,7 +485,9 @@
}, },
removeResponse: function (idx) { removeResponse: function (idx) {
if (model.responses[idx].defaultResponse) { if (model.responses[idx].defaultResponse) {
alert('기본 응답은 삭제할 수 없습니다.'); let message = '기본 응답은 삭제할 수 없습니다.';
$('.toast-body').text(message);
$('.toast').toast('show');
return; return;
} }
model.responses.splice(idx, 1); model.responses.splice(idx, 1);
@@ -18,6 +18,14 @@
</div> </div>
</div> </div>
<div class="container-fluid mt-2"> <div class="container-fluid mt-2">
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
<strong class="mr-auto">알림</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
</div>
</div>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"> <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}">
<div class="card"> <div class="card">
<div class="card-header" style="min-height: 50px;"> <div class="card-header" style="min-height: 50px;">
@@ -819,9 +827,14 @@
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(model), data: JSON.stringify(model),
success: function (data) { success: function (data) {
let message = '저장되었습니다.';
$('.toast-body').text(message);
$('.toast').toast('show');
}, },
error: function (response, textStatus, errorThrown) { error: function (response, textStatus, errorThrown) {
controller.hideLoadingOverlay(); controller.hideLoadingOverlay();
$('.toast-body').text(response.responseJSON);
$('.toast').toast('show');
}, },
complete: function () { complete: function () {
controller.hideLoadingOverlay(); controller.hideLoadingOverlay();
@@ -42,6 +42,14 @@
</div> </div>
</form> </form>
</div> </div>
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0; right: 0;">
<div class="toast-header">
<strong class="mr-auto">알림</strong>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
</div>
</div>
<div class="card-footer"> <div class="card-footer">
<button type="button" class="btn btn-primary btn_update"><i class="fa-sharp fa-solid fa-floppy-disk"></i> 저장</button> <button type="button" class="btn btn-primary btn_update"><i class="fa-sharp fa-solid fa-floppy-disk"></i> 저장</button>
<a th:href="@{/}" class="btn btn-primary" th:title="#{button.cancel}"><i class="fa-sharp fa-solid fa-cancel"></i> [[#{button.cancel}]]</a> <a th:href="@{/}" class="btn btn-primary" th:title="#{button.cancel}"><i class="fa-sharp fa-solid fa-cancel"></i> [[#{button.cancel}]]</a>
@@ -73,7 +81,8 @@
$(function () { $(function () {
var resultMsg = '[[#{${resultMsg}}]]'; var resultMsg = '[[#{${resultMsg}}]]';
if (resultMsg !== "") { if (resultMsg !== "") {
alert(resultMsg); $('.toast-body').text(resultMsg);
$('.toast').toast('show');
} }
}) })
</script> </script>