Files
KON/ProjectTemplate/SurveyProgress.asp

872 lines
35 KiB
Plaintext

<!-- #include Virtual="/include/Header.asp"-->
<style>
@font-face {
font-family: 'Noto-Sans';
src: url("/font/Noto_Sans_KR/NotoSansKR-Medium.otf")
}
@keyframes fadein {
0% {
opacity: 0.5;
}
100% {
opacity: 1;
}
}
body, html {
font-family: 'Noto-Sans';
height:100%;
font-weight: bold;
}
.bg-navy-1 {
background-color: #1A1A3A;
}
.bg-navy-2 {
background-color: #374669;
}
.bg-navy-3 {
background-color: #2F75B5;
}
.bg-navy-4 {
background-color: #707699;
}
.bg-gray-1{
background-color: #0000001a;
}
.bg-gray-2{
background-color: #0000000d;
}
ul.my-list {
list-style: none;
margin:0px;
padding:0px
}
ul.my-list li {
padding:1px 0px 5px 2px ;
border-bottom: 1px solid #374669;
transition: .5s;
cursor: pointer;
font-size: 15px;
}
ul.my-list li:hover {
background-color: #1A1A3A;
color: white;
padding-left:5px
}
ul.my-list li.selected {
background-color: #1A1A3A;
color: white;
padding-left:5px
}
.main-box div {
animation: .5s ease fadein;
}
.circle {
border-radius: 35px;
width:35px;
height:35px;
font-size: 15px;
line-height: 35px;
display: inline-block;
}
.list-box:hover{
color: #990000;
cursor: pointer;
transition: .3s;
}
.list-content {
font-size: 14px;
border-left:2px solid #607d8b;
background-color: #f1f1f1;
display: none;
}
.filter-box .post-it {
font-size: .9rem;
background-color: white;
position: relative;
border-right:4px solid #1A1A3A;
margin-bottom: 2px;
text-align: right;
padding-right:5px;
cursor: pointer;
transition: .5s;
}
.filter-box .post-it::before {
content:'';
position:absolute;
left:0px;
top:0px;
height:100%;
width:0%;
background-color:yellow;
transition: .5s;
z-index: -1;
}
.target-tr {
background-color: #2196f3;
color:white;
}
.target-tr button {
border:1px solid transparent;
background-color: black;
color:white;
}
tr button {
border:1px solid transparent;
background-color: #2196f3;
color:white;
}
.photo-box img {
transition: .5s ease-in;
}
.photo-box img:hover {
transform: scale(1.5);
}
.filter-td {
cursor: pointer;
position:relative;
}
.filter-option{
width: 100%;
background-color: #626782;
box-shadow: 0px 0px 2px 0px rgb(185, 176, 176);
left:0px;
top:calc(100%)
}
.filter-option p {
margin:1px 0px 1px 0px;
border:1px solid rgb(116, 116, 116);
padding:.2rem;
}
.filter-option p:hover {
background-color: yellowgreen;
}
.tr-none {
display: none;
}
.filter_photo, .filter_model {
margin-right: 10px;
cursor: pointer;
}
.filter_photo::before{
content: '파트 : ';
}
.filter_model::before{
content: '진행상황 : ';
}
.filter_prev::before{
content: '사전 조사 : ';
}
.filter_model:hover::after{
content: '해제';
color:red;
font-size: .5rem;
}
.filter_prev:hover::after{
content: '해제';
color:red;
font-size: .5rem;
}
.filter_photo:hover::after{
content: '해제';
color:red;
font-size: .5rem;
}
#h-list {
cursor: pointer;
transition:all .5s;
position: relative;
padding:.7rem;
color:white;
text-decoration: none;
}
#h-list::after {
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: 100%;
height: 5px;
content: ' ';
color: transparent;
background: rgba(255, 255, 255, 0.432);
visibility: none;
opacity: 0;
z-index: -1;
transition: all .5s
}
#h-list:hover {
color:#1A1A3A;
visibility: visible;
height: 100%;
}
#h-list:hover:after {
opacity: 1;
visibility: visible;
height: 100%;
}
#search-box {
z-index: 1030;
}
#h-list-item{
display: block;
position: absolute;
background-color: #f6f6f6;
border-radius: .5rem;
left:100%;
top:0px;
box-shadow: 0px 0px 4px 1px black;
cursor: default;
width:200px;
padding:.1rem;
transition: ease .5s;
overflow-y: auto;
}
#h-list-item[data-visible=true]{
height:350px;
visibility: visible;
}
#h-list-item[data-visible=false]{
height:0px;
visibility: hidden;
}
.hlist-item {
cursor: pointer;
}
.hlist-item[data-flag="1"]{
background-color: lightblue !important;
}
.hlist-item[data-flag="0"]{
background-color: #e6adad !important;
}
table{
font-size: 11px;
margin-bottom:3% !important;
font-weight: 100;
}
table td, th{
margin:0 !important;
vertical-align:middle !important;
}
select{
margin-top: 5px;
}
</style>
<body style="padding-top: 55px;">
<div class="fixed-top p-3 bg-white text-center h5 shadow-lg" style="font-weight: bold">
<i class="fa fa-television" aria-hidden="true"></i> Report Api를 사용한 현황 페이지
</div>
<div class="container-fluid h-100" >
<div class="row h-100">
<div class="col-lg-12 pt-1 h-100 d-flex flex-column bg-navy-2 pb-2">
<div class="p-2 text-white d-flex flex-row" id="search-box" style="font-weight: bold">
<!--
<div>
<label>
Select1
<select name="survey_part" class="form-control form-control-sm" style="display: inline-block">
<option value="1" selected='selected'>1</option>
<option value="2" selected='selected'>2</option>
<option value="3" selected='selected'>3</option>
</select>
</label>
<label>
Select2
<select name="group" class="form-control form-control-sm" style="display: inline-block">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</label>
<button name="btn_search" id="btn_search" class="btn btn-sm btn-secondary">조회</button>
</div>
-->
<div class="ml-2 position-relative d-flex align-items-center" id="progress-toolbar" >
</div>
<div class="flex-fill"></div>
<div onclick="window.location.reload()" style="cursor: pointer;" class=" text-right"><i class="fa fa-refresh" aria-hidden="true"></i> 새로고침</div>
</div>
<div class="p-2 main-box rounded bg-light h-100 d-flex flex-row shadow-sm" style="overflow-x: auto;">
<div class="p-2 flex-fill border bg-white rounded shadow-sm " style="overflow:auto;">
<div class="d-flex flex-column p-2 flex-fill" id="content" style="overflow:auto;">
<div id="progress-status" role="status" aria-live="polite"></div>
<div id="progress-reports"></div>
<div id="progress-quota-result"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
<script>
// 배포 시 이 설정 또는 앞서 선언한 window.KRIC_INTERNAL_CONFIG를 지정합니다.
// 실제 API Key를 소스 관리에 기록하지 마세요. 브라우저에 전달된 키는 열람 가능합니다.
var progressConfig = Object.assign({
apiBase: KART_BASE_URL, // 예: https://<KART_FRONT_HOST>/api/kric-internal
apiKey: KON_API_KEY,
projectType: KART_PROJECT_TYPE, // KON: 0, KIWI: 1
useExcelExport: false, // Excel 다운로드 버튼 사용 여부
pkey: "2608013_B", // 빈 값이면 기존처럼 현재 /Project/{pkey}/... 경로에서 추출
indexes: ["Q2"], // 예: ["Q1", "Q2"]
titles: [], // indexes와 같은 순서. 생략하면 서버 결과 제목 사용
banners: [], // 예: [["Q3"], ["Q4", "Q5"]]
// 빈 문자열이면 추가 응답 조건 없이 조회합니다. TEST/날짜 조건은 options에서 지정합니다.
// 예: "Q1 = 1 AND (Q2 = 2 OR Q3 = 3)"
// 예: "Q1 IN (1, 2) AND Q2 >= 20 AND Q2 < 40"
// 예: "Q1 NOT IN (1, 2)" 또는 "Q1 IS NOT NULL"
// 문자/앞자리 0을 보존할 코드는 작은따옴표로 감쌉니다. 예: "Q1 = '서울' OR Q2 = '001'"
filter: "",
options: {
percentageDecimals: 1, // 비율: 소수점 1자리. 예: 60.0 (0~14)
statisticDecimals: 2, // 평균 등 통계값: 소수점 1자리. 예: 3.5 (0~14)
// 필요할 때 아래 설정을 추가합니다. 날짜는 시작/종료를 함께 지정합니다.
// dataScope: "ACTUAL", // 실제 응답만. "TEST": 테스트만, "ALL": 둘 다
// startDate: "2026-01-01",
// endDate: "2026-12-31",
// transpose: false, // 기본: 항목이 세로, 배너가 가로. true면 행과 열을 서로 바꿉니다.
},
//loadQuotas: false // 목록을 가져오지 않음. Report만 사용할 때
loadQuotas: true // 쿼터 목록을 가져옴
}, window.KRIC_INTERNAL_CONFIG || {});
var activeProgressRequest = null;
function progressNode(tag, text, className) {
var node = document.createElement(tag);
if (text != null) node.textContent = String(text);
if (className) node.className = className;
return node;
}
// Render only basic title formatting; never copy attributes or active content.
function progressTitleNode(title, className) {
var host = progressNode("div", null, className);
var html = title == null ? "" : String(title);
// Handle entity-encoded titles without decoding text inside existing HTML tags.
for (var pass = 0; pass < 2 && !/<\/?[a-z][^>]*>/i.test(html); pass++) {
var decoder = document.createElement("textarea");
decoder.innerHTML = html;
var decoded = decoder.value;
if (decoded === html) break;
html = decoded;
}
var template = document.createElement("template");
template.innerHTML = html;
var allowed = ["B", "STRONG", "EM", "I", "U", "BR", "SPAN", "SUB", "SUP"];
var blocked = ["SCRIPT", "STYLE", "IFRAME", "OBJECT", "EMBED", "TEMPLATE", "NOSCRIPT"];
function append(parent, child) {
if (child.nodeType === 3) {
parent.appendChild(document.createTextNode(child.nodeValue));
return;
}
if (child.nodeType !== 1 || child.namespaceURI !== "http://www.w3.org/1999/xhtml" || blocked.includes(child.tagName)) return;
var target = allowed.includes(child.tagName) ? document.createElement(child.tagName.toLowerCase()) : parent;
if (target !== parent) parent.appendChild(target);
Array.from(child.childNodes).forEach(function (node) { append(target, node); });
}
Array.from(template.content.childNodes).forEach(function (node) { append(host, node); });
return host;
}
function progressStatus(message, failed) {
var node = document.getElementById("progress-status");
node.textContent = message;
node.className = failed ? "text-danger p-2" : "text-muted p-2";
}
function progressProject() {
var loc = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var pkey = progressConfig.pkey || loc.split('/')[2];
if (![0, 1].includes(progressConfig.projectType) || typeof pkey !== "string" ||
!pkey || pkey.length > 20 || /[|/\\]/.test(pkey) || pkey === "." || pkey === "..") {
throw new Error("projectType과 원본 pkey 설정을 확인해 주세요.");
}
return progressConfig.projectType + "/" + encodeURIComponent(pkey);
}
async function progressFetch(path, body, signal) {
var base = progressConfig.apiBase.replace(/\/$/, "");
if (!base || !progressConfig.apiKey) throw new Error("API 주소와 API Key를 설정해 주세요.");
var response = await fetch(base + path, {
method: body === undefined ? "GET" : "POST",
mode: "cors", credentials: "omit", cache: "no-store", signal: signal,
headers: { "Content-Type": "application/json", "X-API-Key": progressConfig.apiKey },
body: body === undefined ? undefined : JSON.stringify(body)
});
if (!response.ok) {
var error = await response.json().catch(function () { return null; });
throw new Error(error && typeof error.message === "string" ? error.message : "API 요청 실패 (" + response.status + ")");
}
return response;
}
function showLoadingBar() {
var mask = progressNode("div");
mask.id = "mask";
mask.style.cssText = "position:fixed;inset:100px 0 0;z-index:9000;background:#fff;opacity:.7;pointer-events:none";
// 취소 버튼은 로딩 중에도 사용할 수 있습니다.
document.getElementById("content").appendChild(mask);
var image = progressNode("img");
image.id = "loadingImg";
image.src = "/img/load.gif";
image.alt = "조회 중";
image.style.cssText = "position:fixed;left:calc(50% - 100px);top:40%;z-index:10000";
document.getElementById("content").appendChild(image);
}
function hideLoadingBar() {
$("#mask, #loadingImg").remove();
}
async function progressRun(work) {
if (activeProgressRequest) activeProgressRequest.abort();
var controller = new AbortController();
activeProgressRequest = controller;
$("[data-progress-action]").prop("disabled", true);
$("#progress-cancel").prop("disabled", false);
hideLoadingBar();
showLoadingBar();
progressStatus("요청 중입니다.", false);
try {
await work(controller.signal);
} catch (error) {
if (activeProgressRequest === controller) {
progressStatus(error.name === "AbortError" ? "요청을 취소했습니다. 수신한 결과는 유지합니다." : error.message, error.name !== "AbortError");
}
} finally {
if (activeProgressRequest === controller) {
activeProgressRequest = null;
hideLoadingBar();
$("[data-progress-action]").prop("disabled", false);
$("#progress-cancel").prop("disabled", true);
$("#progress-quota-view").prop("disabled", !$("#progress-quota").val());
}
}
}
function progressOptions() {
return Object.assign({ dataScope: "ACTUAL", transpose: false }, progressConfig.options || {});
}
function reportCellText(cell, row, result, excel) {
if (cell.kind === "TEXT" || cell.kind === "EMPTY") return cell.textValue || "";
if (cell.kind === "STATISTIC" || cell.kind === "MISSING") {
return excel && cell.statisticExact != null ? pointedNumber(cell.statisticExact) : (cell.statisticDisplayText || "");
}
var transposed = result.appliedOptions && result.appliedOptions.transpose === true;
var column = result.columns[cell.columnIndex];
var base = (transposed ? column && column.kind : row.kind) === "TOTAL";
if (base) return cell.countDisplayText != null ? cell.countDisplayText : String(cell.count == null ? "" : cell.count);
return excel && cell.percentExact != null ? pointedNumber(cell.percentExact) :
(cell.percentDisplayText != null ? cell.percentDisplayText : String(cell.percent == null ? "" : cell.percent));
}
function pointedNumber(value) {
var text = String(value);
if (/e/i.test(text)) text = value.toFixed(14).replace(/0+$/, "");
if (text.endsWith(".")) text += "0";
return text.includes(".") ? text : text + ".0";
}
function resultWidth(rows) {
return rows.reduce(function (width, row) {
return row.cells.reduce(function (size, cell) {
return Math.max(size, cell.columnIndex + (cell.colSpan || 1));
}, width);
}, 0);
}
function quotaCellText(cell, excel) {
if (cell.kind !== "QUOTA") return cell.textValue || "";
var text = (cell.complete == null ? 0 : cell.complete) + "/" + (cell.target == null ? 0 : cell.target);
return excel ? text + "/" + (cell.achievementDisplayText || "-") : text;
}
function makeTable(table, result, quota) {
if (!quota && result.type === "TEXT_ANALYSIS") {
var head = progressNode("tr");
["단어", "빈도"].forEach(function (text) { head.appendChild(progressNode("th", text, "bg-navy-4 text-white")); });
table.appendChild(head);
result.words.forEach(function (word) {
var tr = progressNode("tr");
tr.appendChild(progressNode("td", word.text));
tr.appendChild(progressNode("td", word.count));
table.appendChild(tr);
});
if (!result.words.length) table.appendChild(progressNode("caption", "결과가 없습니다."));
return;
}
var rows = result.headerRows.concat(result.rows);
var width = resultWidth(rows);
var covered = new Set();
rows.forEach(function (row, rowIndex) {
var tr = progressNode("tr");
var cells = new Map(row.cells.map(function (cell) { return [cell.columnIndex, cell]; }));
for (var col = 0; col < width; col++) {
var key = rowIndex + ":" + col;
if (covered.has(key)) continue;
var cell = cells.get(col);
var header = rowIndex < result.headerRows.length;
var text = cell ? (header ? (cell.textValue || "") : quota ? quotaCellText(cell, false) : reportCellText(cell, row, result, false)) : "";
var td = progressNode(header ? "th" : "td", text, header ? "bg-navy-4 text-white" : "");
if (cell) {
td.rowSpan = cell.rowSpan || 1;
td.colSpan = cell.colSpan || 1;
for (var r = 0; r < td.rowSpan; r++) {
for (var c = 0; c < td.colSpan; c++) {
if (r || c) covered.add((rowIndex + r) + ":" + (col + c));
}
}
if (quota && cell.kind === "QUOTA") {
if (cell.achievementState === "FINITE" && cell.achievementPercent != null) {
var percent = Math.max(0, Math.min(100, cell.achievementPercent));
td.style.color = cell.achievementPercent > 100 ? "#FF0000" : "#008000";
td.style.background = "linear-gradient(to right," + (cell.achievementPercent > 100 ? "#FFCCCC" : "#E4FFE4") + " " + percent + "%,#fff 0%)";
} else if (cell.achievementState === "POSITIVE_INFINITY") td.style.color = "#FF0000";
td.title = "달성률: " + (cell.achievementDisplayText || "-");
}
}
tr.appendChild(td);
}
table.appendChild(tr);
});
if (!result.rows.length) table.appendChild(progressNode("caption", "결과가 없습니다."));
}
function excelBody(result, quota) {
if (!quota && result.type === "TEXT_ANALYSIS") {
if (!result.words.length) return null;
return [{ Text: "Text", Count: "Count" }].concat(result.words.slice(0, 100).map(function (word) {
return { Text: word.text, Count: String(word.count) };
}));
}
var rows = result.headerRows.concat(result.rows);
var width = resultWidth(rows);
if (rows.length < 2 || width < 2) return null;
return rows.map(function (row, index) {
var values = {};
for (var col = 0; col < width; col++) values["c" + col] = "";
row.cells.forEach(function (cell) {
var header = index < result.headerRows.length;
var text = header ? (cell.textValue || "") : quota ? quotaCellText(cell, true) : reportCellText(cell, row, result, true);
if (header || (cell.rowSpan || 1) > 1 || (cell.colSpan || 1) > 1) {
text += "|" + (cell.rowSpan > 1 ? cell.rowSpan : "") + "|" + (cell.colSpan > 1 ? cell.colSpan : "");
}
values["c" + cell.columnIndex] = text;
});
return values;
});
}
function downloadName(header) {
var extended = /filename\*\s*=\s*([^']*)'[^']*'([^;]+)/i.exec(header || "");
if (extended) {
try { return decodeURIComponent(extended[2].trim().replace(/^"|"$/g, "")); } catch (_) { /* 일반 filename으로 대체 */ }
}
var plain = /filename\s*=\s*("([^"]*)"|[^;]+)/i.exec(header || "");
return plain ? (plain[2] || plain[1]).trim() : "result.xlsx";
}
async function downloadResult(result, title, quota, signal) {
var body = excelBody(result, quota);
if (!body) throw new Error("다운로드할 결과가 없습니다.");
var qtype = !quota && result.type === "TEXT_ANALYSIS" ? "text" : "";
var response = await progressFetch("/export/" + progressProject() + (quota ? "/quota" : "/table"), {
tables: [{ head: title, vname: quota ? "" : result.questionId, qtype: qtype, body: body }],
turn: !quota && !!(result.appliedOptions && result.appliedOptions.transpose)
}, signal);
var disposition = response.headers.get("content-disposition");
if (!disposition || /json|text\/html/i.test(response.headers.get("content-type") || "")) {
throw new Error("다운로드 응답 형식을 확인해 주세요.");
}
var blob = await response.blob();
signal.throwIfAborted();
var url = URL.createObjectURL(blob);
var link = progressNode("a");
link.href = url;
link.download = downloadName(disposition).replace(/[\\/:*?"<>|\x00-\x1f\x7f]/g, "_");
document.body.appendChild(link);
link.click();
link.remove();
setTimeout(function () { URL.revokeObjectURL(url); }, 1000);
progressStatus("Excel 파일을 다운로드했습니다.", false);
}
function renderResult(host, result, title, quota) {
host.textContent = "";
var heading = progressTitleNode(title, "bg-navy-2 text-white p-2");
var button = progressNode("button", "Excel 다운로드", "btn btn-sm btn-secondary my-2");
button.type = "button";
button.setAttribute("data-progress-action", "");
button.disabled = !!activeProgressRequest;
button.addEventListener("click", function () {
progressRun(function (signal) { return downloadResult(result, title, quota, signal); });
});
host.appendChild(heading);
if(progressConfig.useExcelExport){
host.appendChild(button);
}
var table = progressNode("table", null, "table table-sm text-center table-bordered");
table.style.cssText = "table-layout:fixed;font-size:20px";
host.appendChild(table);
makeTable(table, result, quota);
}
function assertResult(result, quota) {
var validRow = function (row) {
return row && Array.isArray(row.cells) && row.cells.every(function (cell) {
return cell && Number.isSafeInteger(cell.columnIndex) && cell.columnIndex >= 0 && typeof cell.kind === "string" &&
(cell.rowSpan == null || Number.isSafeInteger(cell.rowSpan) && cell.rowSpan > 0) &&
(cell.colSpan == null || Number.isSafeInteger(cell.colSpan) && cell.colSpan > 0);
});
};
if (!result || !Array.isArray(result.headerRows) || !result.headerRows.every(validRow) ||
!Array.isArray(result.rows) || !result.rows.every(validRow) ||
(!quota && (!["TABLE", "TEXT_ANALYSIS"].includes(result.type) || !Array.isArray(result.columns) || !Array.isArray(result.words)))) {
throw new Error("집계 결과 형식을 확인해 주세요.");
}
return result;
}
async function readReportStream(response, indexes, onEvent, signal) {
if (!response.body || !(response.headers.get("content-type") || "").includes("application/x-ndjson")) {
if (response.body) await response.body.cancel();
throw new Error("집계 스트림 응답을 확인해 주세요.");
}
var reader = response.body.getReader();
var decoder = new TextDecoder("utf-8", { fatal: true });
var pending = "", position = 0, succeeded = 0, failed = 0, complete = false;
function accept(line) {
if (!line.trim()) return;
if (complete) throw new Error("완료 이후에 스트림 이벤트가 수신되었습니다.");
var event = JSON.parse(line);
if (event.type === "complete") {
if (event.total !== indexes.length || event.succeeded !== succeeded || event.failed !== failed || position !== indexes.length) {
throw new Error("집계 스트림의 완료 건수가 일치하지 않습니다.");
}
complete = true;
return;
}
if (event.position !== position || event.index !== indexes[position] || position >= indexes.length) {
throw new Error("집계 스트림의 문항 순서가 올바르지 않습니다.");
}
if (event.type === "result") { assertResult(event.result, false); succeeded++; }
else if (event.type === "error" && typeof event.message === "string" && Number.isInteger(event.status) && event.status >= 400 && event.status <= 599) failed++;
else throw new Error("집계 스트림 이벤트 형식을 확인해 주세요.");
onEvent(event);
position++;
}
try {
while (true) {
var chunk = await reader.read();
signal.throwIfAborted();
pending += decoder.decode(chunk.value, { stream: !chunk.done });
var newline;
while ((newline = pending.indexOf("\n")) >= 0) {
accept(pending.slice(0, newline));
pending = pending.slice(newline + 1);
}
if (chunk.done) break;
}
if (pending.trim()) accept(pending);
if (!complete) throw new Error("집계 스트림이 완료 전에 종료되었습니다. 수신한 결과는 유지합니다.");
return { succeeded: succeeded, failed: failed };
} finally {
await reader.cancel().catch(function () {});
reader.releaseLock();
}
}
async function loadReports(signal) {
var section = document.getElementById("progress-reports");
section.textContent = "";
var indexes = progressConfig.indexes;
if (!Array.isArray(indexes) || !indexes.length) {
section.appendChild(progressNode("p", "조회할 문항이 없습니다. indexes를 설정해 주세요.", "text-muted"));
return { succeeded: 0, failed: 0 };
}
var hosts = indexes.map(function (index) {
var host = progressNode("section", "조회 중: " + index, "mb-3");
host.dataset.pending = "true";
section.appendChild(host);
return host;
});
try {
var response = await progressFetch("/project/" + progressProject() + "/statistics/result", Object.assign({}, progressOptions(), {
indexes: indexes, mode: "STANDARD", banners: progressConfig.banners, filter: progressConfig.filter
}), signal);
return await readReportStream(response, indexes, function (event) {
var host = hosts[event.position];
delete host.dataset.pending;
if (event.type === "error") {
host.textContent = event.index + ": " + event.message;
host.className = "text-danger mb-3";
} else {
renderResult(host, event.result, progressConfig.titles[event.position] || event.result.title || event.index, false);
}
}, signal);
} finally {
hosts.forEach(function (host) {
if (host.dataset.pending) { host.textContent = "결과를 수신하지 못했습니다."; delete host.dataset.pending; }
});
}
}
async function loadQuotaList(signal) {
var select = document.getElementById("progress-quota");
if(!select) return;
select.textContent = "";
select.appendChild(progressNode("option", "쿼터 없음"));
select.options[0].value = "";
document.getElementById("progress-quota-result").textContent = "";
if (!progressConfig.loadQuotas) return;
var response = await progressFetch("/quota/" + progressProject() + "/list", undefined, signal);
var sets = await response.json();
signal.throwIfAborted();
if (!Array.isArray(sets) || !sets.every(function (set) { return set && Number.isInteger(set.qsOrder); })) {
throw new Error("쿼터 목록 형식을 확인해 주세요.");
}
if (sets.length) select.options[0].textContent = "쿼터 선택";
sets.forEach(function (set) {
var option = progressNode("option", set.qsTitle || "쿼터 " + set.qsOrder);
option.value = String(set.qsOrder);
select.appendChild(option);
});
}
async function view_type() {
return progressRun(async function (signal) {
// Bluebird in the legacy Header does not provide Promise.allSettled.
var outcomes = await Promise.all([loadReports(signal), loadQuotaList(signal)].map(function (request) {
return Promise.resolve(request).then(
function (value) { return { status: "fulfilled", value: value }; },
function (reason) { return { status: "rejected", reason: reason }; }
);
}));
signal.throwIfAborted();
var errors = outcomes.filter(function (outcome) { return outcome.status === "rejected"; });
if (errors.length) throw new Error(errors.map(function (outcome) { return outcome.reason.message; }).join(" / "));
var reports = outcomes[0].value;
progressStatus("조회 완료: Report 성공 " + reports.succeeded + "건, 실패 " + reports.failed + "건", reports.failed > 0);
});
}
async function viewQuota() {
return progressRun(async function (signal) {
var select = document.getElementById("progress-quota");
if(!select) return;
if (!select.value) throw new Error("쿼터를 선택해 주세요.");
var options = progressOptions();
var response = await progressFetch("/quota/" + progressProject() + "/" + encodeURIComponent(select.value) + "/result", {
dataScope: options.dataScope, startDate: options.startDate, endDate: options.endDate
}, signal);
var result = assertResult(await response.json(), true);
signal.throwIfAborted();
renderResult(document.getElementById("progress-quota-result"), result, result.title || select.options[select.selectedIndex].text, true);
progressStatus("쿼터 조회를 완료했습니다.", false);
});
}
$(document).ready(function () {
var toolbar = document.getElementById("progress-toolbar");
var query = progressNode("button", "조회", "btn btn-sm btn-secondary mr-2");
query.type = "button";
query.setAttribute("data-progress-action", "");
query.addEventListener("click", view_type);
toolbar.appendChild(query);
if(progressConfig.loadQuotas){
var select = progressNode("select", null, "form-control form-control-sm mr-2");
select.id = "progress-quota";
select.style.width = "auto";
select.setAttribute("aria-label", "쿼터 선택");
select.setAttribute("data-progress-action", "");
select.addEventListener("change", function () { $("#progress-quota-view").prop("disabled", !select.value); });
toolbar.appendChild(select);
var quota = progressNode("button", "쿼터 조회", "btn btn-sm btn-secondary mr-2");
quota.type = "button";
quota.id = "progress-quota-view";
quota.disabled = true;
quota.setAttribute("data-progress-action", "");
quota.addEventListener("click", viewQuota);
toolbar.appendChild(quota);
}
var cancel = progressNode("button", "취소", "btn btn-sm btn-outline-secondary");
cancel.id = "progress-cancel";
cancel.type = "button";
cancel.disabled = true;
cancel.addEventListener("click", function () { if (activeProgressRequest) activeProgressRequest.abort(); });
toolbar.appendChild(cancel);
window.addEventListener("pagehide", function () { if (activeProgressRequest) activeProgressRequest.abort(); });
if (!progressConfig.apiBase || !progressConfig.apiKey) {
progressStatus("API 주소와 API Key를 설정한 후 조회해 주세요.", false);
} else view_type();
});
</script>
<!-- #include Virtual="/include/Footer.asp"-->
<script>
var loc = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var pkey = loc.split("/")[2];
clklog("wi11u215oh",pkey,"","현황 페이지","","");
</script>