Files
eapim-admin/WebContent/jsp/onl/apim/approval/portalAppApprovalManPopup.jsp
T
Rinjae 0f36718534 삭제 요청 처리 기능 추가 및 오류 메시지 처리 강화
- 승인 요청 삭제 버튼 추가 및 확인 경고문 삽입
- 삭제 가능 여부 검증 로직 추가 및 네이티브 쿼리 대체 처리
- 오류 메시지 파싱 로직 및 상세 조회 실패 시 UI 처리 개선
2026-08-24 13:16:39 +09:00

513 lines
24 KiB
Plaintext

<%@ page import="com.eactive.eai.rms.common.util.CommonConstants" %>
<%@ page import="com.eactive.eai.rms.common.login.LoginVo" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
%>
<html>
<head>
<title>승인 요청 상세</title>
<style>
.table_row tbody tr.highlight_new {
background-color: #e6f3ff !important;
}
.table_row tbody tr.highlight_delete {
background-color: #ffe6e6 !important;
}
.table_row tbody tr.highlight_new td.status {
color: #4a90e2;
font-weight: normal;
}
.table_row tbody tr.highlight_delete td.status {
color: #e74c3c;
font-weight: normal;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript">
<%
LoginVo loginVo = (LoginVo) session.getAttribute(CommonConstants.LOGIN);
%>
var loginUser = '<%= loginVo.getUserId() %>';
var url = '<c:url value="/onl/apim/approval/portalApprovalMan.json" />';
var url_view = '<c:url value="/onl/apim/approval/portalApprovalMan.view" />';
function dateFormat(cellvalue) {
if ( cellvalue == null || cellvalue.length < 8 )
return '';
return cellvalue.substr(0 ,4) + '-' +
cellvalue.substr(4, 2) + '-' +
cellvalue.substr(6, 2) ;
}
$(document).ready(function () {
var key = "${param.id}";
if (key) {
detail(key);
}
$("#expectEndDate").datepicker().inputmask("yyyy-mm-dd", {'autoUnmask': true});
$("#btn_app_approve").click(function () {
var isDeleteReq = (currentRequestType === 'DELETE');
var gwAction = (isDeleteReq && $('#chkGwDelete').is(':checked')) ? 'DELETE' : 'BLOCK';
var confirmMsg = isDeleteReq
? "해지 승인 시 포털 인증키(Credential)는 삭제되며,\n게이트웨이 클라이언트는 [" + (gwAction === 'DELETE' ? "완전 삭제" : "차단(비활성화)") + "] 처리됩니다.\n승인하시겠습니까?"
: "승인하시겠습니까?";
if (confirm(confirmMsg)) {
$.ajax({
type: "POST",
url: url,
data: {cmd: "APPROVE", id: key, gwAction: gwAction},
success: function (args) {
<%--alert("<%= localeMessage.getString("approval.approveSuccess") %>");--%>
alert("승인되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(e.responseText);
}
});
}
});
$("#btn_app_reject").click(function () {
var rejectReason = prompt("반려 사유를 입력해 주세요");
if (rejectReason != null) {
$.ajax({
type: "POST",
url: url,
data: {cmd: "REJECT", id: key, rejectReason: rejectReason},
success: function (args) {
alert("반려되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(e.responseText);
}
});
}
});
$("#btn_app_force_reject").click(function () {
if (!confirm("승인자 목록에 삭제된 사용자가 있어 승인 진행이 불가능한 건입니다.\n강제 반려하시겠습니까?")) {
return;
}
var rejectReason = prompt("강제 반려 사유를 입력해 주세요");
if (rejectReason != null) {
$.ajax({
type: "POST",
url: url,
data: {cmd: "FORCE_REJECT", id: key, rejectReason: rejectReason},
success: function (args) {
alert("강제 반려되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(e.responseText);
}
});
}
});
$('#btn_app_redeploy').click(function () {
if (confirm("재배포 하시겠습니까?")) {
$.ajax({
type: "POST",
url: url,
data: {cmd: "REDEPLOY", id: key},
success: function (args) {
alert("요청되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(e.responseText);
}
});
}
});
$("#btn_modify").click(function () {
if (confirm("수정하시겠습니까?")) {
$.ajax({
type: "POST",
url: url,
data: {cmd: "UPDATE", id: key, expectEndDate: $("#expectEndDate").val().replaceAll('-','')},
success: function (args) {
alert("수정되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(e.responseText);
}
});
}
});
$("#btn_app_delete").click(function () {
if (!confirm("이 승인 요청을 삭제하시겠습니까?\n삭제 후에는 복구할 수 없습니다.")) {
return;
}
$.ajax({
type: "POST",
url: url,
data: {cmd: "DELETE", id: key},
success: function (args) {
alert("삭제되었습니다.");
if (window.dialogArguments && window.dialogArguments.self) {
window.dialogArguments.self.location.reload();
} else if (window.opener) {
window.opener.location.reload();
}
window.close();
},
error: function (e) {
alert(approvalErrorMessage(e));
}
});
});
$("#btn_close").click(function () {
window.close();
});
});
function approvalErrorMessage(e) {
try {
var json = JSON.parse(e.responseText);
return json.errorMsg || e.responseText;
} catch (ex) {
return e.responseText;
}
}
// 요청자(PTL_USER) row 가 삭제되면 상세 조회 자체가 불가능하다. 이 경우 삭제만 가능하도록 노출한다.
function showLoadFailure(message) {
$("#approvalSubject").text("상세 정보를 조회할 수 없는 승인 요청");
$("#approvalDetail").text(message);
$("#btn_modify, #btn_app_approve, #btn_app_reject, #btn_app_force_reject, #btn_app_redeploy").hide();
$("#gwActionSection, #gwActionResult").hide();
document.getElementById("btn_app_delete").style.display = "";
}
var currentRequestType = null; // 현재 신청 유형 (DELETE 승인 시 GW 처리방식 선택 노출용)
// 값이 있을 때만 행을 노출한다. (해지 신청처럼 해당 항목이 없는 유형에서 빈 행이 남지 않도록)
function setOptionalRow(rowId, spanId, value) {
if (value) {
$("#" + spanId).text(value);
$("#" + rowId).show();
} else {
$("#" + spanId).text("");
$("#" + rowId).hide();
}
}
function detail(key) {
$.ajax({
type: "POST",
url: url,
dataType: "json",
data: {cmd: 'DETAIL', id: key},
success: function (json) {
var data = json;
if (data.approvalStatus.code == 'END') {
$('#btn_modify').hide();
$('#expectEndDate').hide();
$('#spExpectEndDate').show();
$('#spExpectEndDate').text(dateFormat(data.expectEndDate));
} else {
$('#btn_modify').show();
$('#expectEndDate').show();
$('#spExpectEndDate').hide();
}
$("#approvalType").text(data.approvalType === 'USER' ? "법인사용자" : "API 사용");
$("#approvalStatus").text(data.approvalStatus.description);
$("#requesterName").text(data.requester.userName);
$("#approvalSubject").text(data.approvalSubject);
$("#approvalDetail").html(data.approvalDetail);
$("#createdDate").text(data.createdDate).inputmask("9999-99-99 99:99:99.999", {'autoUnmask': true});
$("#expectEndDate").val(data.expectEndDate);
var isCurrentApprover = data.approvers.some(approver =>
approver.approverStatus === 'CURRENT' &&
approver.user && approver.user.USERID === loginUser
);
if (isCurrentApprover) {
document.getElementById("btn_app_approve").style.display = "";
document.getElementById("btn_app_reject").style.display = "";
} else {
document.getElementById("btn_app_approve").style.display = "none";
document.getElementById("btn_app_reject").style.display = "none";
}
// API 이용해지(DELETE) 건: 승인 가능 상태의 현재 승인자에게만 GW 처리방식 선택 노출
currentRequestType = data.requestType;
var inProgress = data.approvalStatus.code === 'REQUESTED' || data.approvalStatus.code === 'PROCESSING';
if (data.requestType === 'DELETE' && isCurrentApprover && inProgress) {
$("#gwActionSection").show();
} else {
$("#gwActionSection").hide();
}
// 처리 완료된 해지 건은 어떤 방식으로 실행됐는지 표시
if (data.requestType === 'DELETE' && data.gwAction) {
$("#gwActionResult").text("GW 처리방식: " + (data.gwAction === 'DELETE' ? "완전 삭제" : "차단(비활성화)")).show();
} else {
$("#gwActionResult").hide();
}
// 삭제된 승인자(USERID 없음)로 진행 불가한 건: 요청됨/진행중 상태면 승인자가 아니어도 강제 반려 허용
var hasDeletedApprover = data.approvers.some(approver =>
!approver.user || !approver.user.USERID
);
var isProgressStatus = data.approvalStatus.code === 'REQUESTED' || data.approvalStatus.code === 'PROCESSING';
document.getElementById("btn_app_force_reject").style.display =
(hasDeletedApprover && isProgressStatus && !isCurrentApprover) ? "" : "none";
if (data.approvalStatus.code === 'FAILED') {
document.getElementById("btn_app_redeploy").style.display = "";
}
var approversHtml = "";
data.approvers.sort((a, b) => a.ordinal - b.ordinal);
for (var i = 0; i < data.approvers.length; i++) {
var approver = data.approvers[i];
approversHtml += "<tr>";
approversHtml += "<td>" + approver.user.USERNAME + "</td>";
approversHtml += "<td>" + approver.approverStatusDescription + "</td>";
approversHtml += "<td>" + (approver.approvedDate ? new Date(approver.approvedDate).toLocaleString() : "") + "</td>";
approversHtml += "</tr>";
}
$("#approversTable tbody").html(approversHtml);
$("#clientName").text(data.clientName);
// 신청서에 담긴 Client 등록 정보(승인 시 GW 클라이언트로 반영되는 값). 값이 있을 때만 노출
setOptionalRow("appDescriptionRow", "appDescription", data.appDescription);
setOptionalRow("ipWhitelistRow", "ipWhitelist", data.ipWhitelist);
setOptionalRow("callbackUrlRow", "callbackUrl", data.callbackUrl);
// 신청 사유. 해지 신청은 사유 입력이 필수이므로 "해지 사유"로 표기하고, 그 외 유형은 "신청 사유"
if (data.requestReason) {
$("#requestReasonLabel").text(data.requestType === 'DELETE' ? "해지 사유" : "신청 사유");
$("#requestReason").text(data.requestReason);
$("#requestReasonRow").show();
} else {
$("#requestReason").text("");
$("#requestReasonRow").hide();
}
var apiServiceHtml = "";
for (var i = 0; i < data.apiServices.length; i++) {
var apiService = data.apiServices[i];
apiServiceHtml += "<tr>";
apiServiceHtml += "<td>" + apiService.groupName + "</td>";
apiServiceHtml += "</tr>";
}
$("#apiServiceTable tbody").html(apiServiceHtml);
var apisHtml = "";
for (var i = 0; i < data.apis.length; i++) {
var api = data.apis[i];
var apiGroupName = data.apiGroupNameList[i];
var isNew = false;
var isDelete = false;
if ((data.requestType === 'MODIFY' || data.requestType === 'PROD_MODIFY') && data.prevApisList && data.prevApisList.length > 0) {
isNew = !data.prevApisList.some(prevApi => prevApi.apiId === api.apiId);
}
if ((data.requestType === 'DELETE' || data.requestType === 'PROD_DELETE') && data.prevApisList && data.prevApisList.lenght > 0) {
isDelete = true;
isNew = false;
}
var trClass = "";
if (isNew) trClass = "highlight_new";
if (isDelete) trClass = "highlight_delete";
apisHtml += "<tr " + (trClass ? "class='" + trClass + "'" : "") + ">";
apisHtml += "<td>" + apiGroupName + "</td>";
apisHtml += "<td>" + api.apiName + "</td>";
apisHtml += "<td class='status'>" + (isNew ? "추가" : "") + (isDelete ? "삭제" : "") + "</td>";
apisHtml += "</tr>";
}
if ((data.requestType === 'MODIFY' || data.requestType === 'PROD_MODIFY') && data.prevApisList && data.prevApisList.length > 0) {
data.prevApisList.forEach(function(prevApi, index) {
var isDeleted = !data.apis.some(api => api.apiId === prevApi.apiId);
if (isDeleted) {
apisHtml += "<tr class='highlight_delete'>";
apisHtml += "<td>" + data.prevApiGroupNameList[index] + "</td>";
apisHtml += "<td>" + prevApi.apiName + "</td>";
apisHtml += "<td class='status'>삭제</td>";
apisHtml += "</tr>";
}
});
}
$("#apisTable tbody").html(apisHtml);
},
error: function (e) {
var message = approvalErrorMessage(e);
alert(message);
showLoadFailure(message);
}
});
}
</script>
</head>
<body>
<div class="popup_box">
<div class="title" id="approvalSubject" style="margin-top: 15px;"></div>
<%--제목--%>
<div class="popup_content">
<table class="table_row" cellspacing="0">
<tr>
<th style="width:20%;">승인 유형</th>
<td style="width:30%;"><span id="approvalType"></span></td>
<th style="width:20%;">승인 상태</th>
<td style="width:30%;"><span id="approvalStatus"></span></td>
</tr>
<tr>
<th>요청자</th>
<td><span id="requesterName"></span></td>
<th>생성일</th>
<td><span id="createdDate"></span></td>
</tr>
<tr>
<th>상세 내용</th>
<td>
<div id="approvalDetail" style="white-space: pre-wrap;"></div>
</td>
<th>예상완료일</th>
<td>
<input type="text" id="expectEndDate" style="width: 120px; text-align:center"/>
<span id="spExpectEndDate"></span>
</td>
</tr>
</table>
<div class="title">Client 정보</div>
<table id="client" class="table_row" cellspacing="0">
<colgroup>
<col style="width:20%"/>
<col style="width:80%"/>
</colgroup>
<tr>
<th style="width:20%;">이름</th>
<td><span id="clientName"></span></td>
</tr>
<tr id="appDescriptionRow" style="display:none;">
<th style="width:20%;">앱 설명</th>
<td><span id="appDescription" style="white-space: pre-wrap;"></span></td>
</tr>
<tr id="ipWhitelistRow" style="display:none;">
<th style="width:20%;">IP 화이트리스트</th>
<td><span id="ipWhitelist" style="white-space: pre-wrap;"></span></td>
</tr>
<tr id="callbackUrlRow" style="display:none;">
<th style="width:20%;">Callback URL</th>
<td><span id="callbackUrl" style="white-space: pre-wrap;"></span></td>
</tr>
<tr id="requestReasonRow" style="display:none;">
<th style="width:20%;"><span id="requestReasonLabel">신청 사유</span></th>
<td><span id="requestReason" style="white-space: pre-wrap;"></span></td>
</tr>
</table>
<div class="title">API 목록</div>
<table id="apisTable" class="table_row" cellspacing="0">
<thead>
<tr>
<th>서비스명</th>
<th>API 이름</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="title">승인자 목록</div>
<table id="approversTable" class="table_row" cellspacing="0">
<thead>
<tr>
<th>승인자</th>
<th>상태</th>
<th>승인/거절 일시</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div id="gwActionSection" style="display:none; margin: 12px 0 0 4px; color: #c0392b;">
<label style="cursor:pointer;">
<input type="checkbox" id="chkGwDelete"/>
GW 인증정보 완전 삭제 (미체크 시 차단 처리 &mdash; 인증정보 보존, 복구 가능)
</label>
</div>
<div id="gwActionResult" style="display:none; margin: 12px 0 0 4px; font-weight: bold;"></div>
<div class="popup_button">
<button type="button" class="cssbtn" id="btn_modify" level="W"><i
class="material-icons">save</i>수정
</button>
<button type="button" class="cssbtn" style="display: none;" id="btn_app_approve" level="W"><i
class="material-icons">check</i>승인
</button>
<button type="button" class="cssbtn" style="display: none;" id="btn_app_reject" level="W"><i
class="material-icons">close</i>반려
</button>
<button type="button" class="cssbtn" style="display: none;" id="btn_app_force_reject" level="W"><i
class="material-icons">block</i>강제 반려
</button>
<button type="button" class="cssbtn" style="display: none;" id="btn_app_delete" level="W"><i
class="material-icons">delete</i>삭제
</button>
<button type="button" class="cssbtn" style="display: none;" id="btn_app_redeploy" level="W"><i
class="material-icons">close</i>재처리
</button>
<button type="button" class="cssbtn" id="btn_close" level="R"><i
class="material-icons">cancel</i> <%= localeMessage.getString("button.close") %>
</button>
</div>
</div>
</body>
</html>