+
+
+
+
+
+
+
+
+
+ 검색 결과 상세 입니다.
+
+
+
+
+
+
+
+
+
Index: arms/js/searchEngine.js
===================================================================
diff -u -r3ba68007972bf8c0257dfe92715cc29df70977d1 -r46d2768ad80fa7b7b3d918faa222e2327cef4001
--- arms/js/searchEngine.js (.../searchEngine.js) (revision 3ba68007972bf8c0257dfe92715cc29df70977d1)
+++ arms/js/searchEngine.js (.../searchEngine.js) (revision 46d2768ad80fa7b7b3d918faa222e2327cef4001)
@@ -46,8 +46,9 @@
"../reference/jquery-plugins/dataTables-1.10.16/extensions/Buttons/js/jszip.min.js",
"../reference/jquery-plugins/dataTables-1.10.16/extensions/Buttons/js/pdfmake.min.js"
],
- [ "css/searchEngine.css"
-
+ [
+ "css/searchEngine.css",
+ "js/searchEngine/searchApiModule.js"
]
// 추가적인 플러그인 그룹들을 이곳에 추가하면 됩니다.
];
@@ -74,6 +75,7 @@
// 모달의 에디터를 각 모달 종류마다 해야하는지 검토.
CKEDITOR.replace("modal_detail_log",{ skin: "office2013" });
CKEDITOR.replace("modal_detail_log_jiraissue",{ skin: "office2013" });
+ CKEDITOR.replace("modal_detail_log_log",{ skin: "office2013" });
// 추가로 에디터 설정이 필요한 경우 여기에 추가
clearInterval(waitCKEDITOR);
}
@@ -200,8 +202,6 @@
});
}
-
-
/////////////////////////
//이벤트 리스너 활성화
/////////////////////////
@@ -222,290 +222,72 @@
});
//검색 결과 리스트 클릭 이벤트
- $("#search_main_wrapper").on("click", function (event) {
+ $("#search_main_wrapper .search_result_group .search_result_items").on("click", function (event) {
console.log($(event.target).closest(".search-result")[0]);
var clicked_content_id = $(event.target).closest(".search-result").find(".search_head").attr("id");
- var order_of_data = 0;
- if (clicked_content_id && clicked_content_id.includes("jiraissue")) {
- order_of_data = getDataOrder(clicked_content_id);
- mapDataToModal(order_of_data);
- } else {
- console.log("[searchEngine :: eventListenersActivator] :: 클릭한 clicked_content_id 가 유효하지 않거나, id에 jiraissue가 있지 않습니다.");
- }
+ let section_and_order = getDataSectionAndOrder(clicked_content_id);
+
+ SearchApiModule.mapDataToModal(section_and_order["search_section"], section_and_order["order"]);
});
}
function search_start(search_string) {
console.log("[searchEngine :: search_start] :: search_string => " + search_string);
$.ajax({
- url: "/engine-search-api/engine/jira/dashboard/search", //지라이슈로 바꾸자
+ url: "/engine-search-api/engine/jira/dashboard/search",
type: "GET",
- data: { "search_string": search_string },
+ data: { "search_string": search_string, "page" : 0, "size": 1000 },
dataType: "json",
success: function(result) {
console.log("[searchEngine :: search_start] :: jiraissue_search_results => ");
console.log(result);
- SearchApi.setSearchResult(result);
- SearchApi.appendSearchResultSections(result);
+ const current_page = 1; //현재 페이지 초기화
+ const items_per_Page = 10; //페이지당 아이템 수
+ SearchApiModule.setSearchResult("jiraissue",result, current_page, items_per_Page);
+
}
});
$.ajax({
url: "/engine-search-api/engine/jira/dashboard/search/fluentd",
type: "GET",
- data: { "search_string": search_string, "page" : 0, "size": 100 },
+ data: { "search_string": search_string, "page" : 0, "size": 1000 },
dataType: "json",
success: function(result) {
console.log("[searchEngine :: search_start] :: fluentd_search_results => ");
console.log(result);
-
- SearchApi.setSearchResult_fluentd(result);
- SearchApi.appendSearchResultSections_fluentd(result);
+ const current_page = 1; //현재 페이지 초기화
+ const items_per_Page = 10; //페이지당 아이템 수
+ SearchApiModule.setSearchResult("log", result, current_page, items_per_Page);
}
});
}
-function mapDataToModal(order) {
- const targetData = SearchApi.getSearchResult(order);
- console.log("[searchEngine :: mapDataToModal] :: targetData =>");
- console.log(targetData);
- $("#search_detail_modal_jiraissue #detail_id_jiraissue").text(targetData["id"]);
- $("#search_detail_modal_jiraissue #detail_index_jiraissue").text(targetData["index"]);
- $("#search_detail_modal_jiraissue #detail_score_jiraissue").text(targetData["score"] === null ? "-" : targetData["score"]);
- $("#search_detail_modal_jiraissue #detail_type_jiraissue").text(targetData["type"] === undefined ? " - " : targetData["type"]);
- $("#search_detail_modal_jiraissue #detail_modal_summary_jiraissue").text(targetData["content"]["summary"]);
- $("#search_detail_modal_jiraissue #detail_modal_key_jiraissue").text(targetData["content"]["key"]);
- $("#search_detail_modal_jiraissue #detail_modal_key_jiraissue").text(targetData["content"]["created"]);
- if(targetData["content"]["assignee"]) {
- $("#search_detail_modal_jiraissue #detail_modal_assignee_name_jiraissue")
- .text(targetData["content"]["assignee"]["assignee_displayName"]);
- } else {
- $("#search_detail_modal_jiraissue #detail_modal_assignee_name_jiraissue").text("담당자 정보 없음");
- }
-
-
+/////////////////////////////////////
+// 클릭한 아이디에서 section과 결과순서 가져오기
+/////////////////////////////////////
+function getDataSectionAndOrder(id) {
+ const targetId = id;
+ const matches = targetId.match(/hits_order_(jiraissue|log)_(\d+)/);
+ let returnVal = {"search_section": null, "order": null};
- CKEDITOR.instances.modal_detail_log_jiraissue.setData(JSON.stringify(targetData));
-}
-
-
-function getDataOrder(id) {
- var order_of_data; //es 인덱스와 혼란 방지를 위해, order로 사용
- if (id) {
- console.log("[searchEngine :: getDataOrder] :: 파싱할 id =>" + id);
- order_of_data = parseInt(id.match(/\d+/)[0]); // 숫자만 뽑기
- console.log("[searchEngine :: getDataOrder] :: 파싱(숫자만 뽑은) 결과 =>" + order_of_data);
+ if (matches) {
+ returnVal["search_section"] = matches[1];
+ returnVal["order"] = matches[2];
+ console.log("[searchEngine :: getDataSectionAndOrder] :: section -> " + matches[1] + ", order -> " + matches[2]);
+ return returnVal;
} else {
- console.log("[searchEngine :: getDataOrder] :: 선택한 항목의 데이터 인덱스(순서)가 없습니다. id =>" + id);
- return null;
+ console.log("[searchEngine :: getDataSectionAndOrder] No Match Found :: id -> " + targetId);
+ return returnVal;
}
- return order_of_data;
}
-
-
-function getMockJsonData() {
- $.ajax({
- url: "./js/searchEngine/sample_issue_index.json",
- type: "GET",
- dataType: "json",
- success: function(result) {
- console.log("[searchEngine :: getMockJsonData] :: issue_index.json");
-
- SearchApi.setSearchResult(result);
- SearchApi.appendSearchResultSections(result);
- }
-
- });
-}
-
-var SearchApi = (function() {
- var searchResult;
-
- var searchResultObject ={"jiraissue" : null, "fluentd" : null};
- var setSearchResult = function (result) {
- console.log("[SearchApi :: setSearchResult] :: result =>");
- console.log(result);
- searchResult = result;
- //searchResultObject["jiraissue"] = result; // 변경 대상.
- };
-
- var setSearchResult_fluentd = function(result) {
- searchResultObject["fluentd"] = result;
- }
- var getSearchResult = function (order) {
- return searchResult[order]; // 자료구조 검토
- }
-
- var getSearchResult_fluentd = function(order) {
- return searchResultObject["fluentd"][order];
- }
- //////////////////////////////////////////
- // 1. 검색 결과를 바탕으로 content 보여주기
- //////////////////////////////////////////
- var appendSearchResultSections = function (results) {
- const search_result_arr = results;
- var today = new Date();
-
- $("#jiraissue_section .search_result_group").html("");
- console.log("[searchEngine :: appendSearchResultSections] :: search_result_arr길이 =>" +search_result_arr.length);
- if(search_result_arr && search_result_arr.length !== 0) {
- //해당 search_result_group 내용 초기화
- search_result_arr.forEach(function (content, index) {
- $("#jiraissue_section .search_result_group").append(
- `
-
-
-
-
-
-
-
-
-
-
- ${content["content"]["summary"]}
-
-
-
-
-
- ${content["index"]}
-
-
- ${content["content"]["created"]}
-
-
-
-
-
- 이슈키: ${content["content"]["key"]} 지라프로젝트: ${content["content"]["project"]["project_name"]}
- 생성일: ${content["content"]["created"]}
- 타임스탬프: ${content["content"]["timestamp"]}
-
-
- `
- );
- });
- } else {
- $("#jiraissue_section .search_result_group").append(
- `
-
-
-
-
-
-
-
-
- 검색 결과가 없습니다.
-
-
-
-
-
- -
-
-
- ${today}
-
-
-
-
-
- 검색 결과가 없습니다. 현재시각 :: ${today}
-
-
- `
- );
- }
- }
-
- var appendSearchResultSections_fluentd = function (results) {
- const search_result_arr = results;
- var today = new Date();
-
- $("#log_section .search_result_group").html("");
- console.log("[searchEngine :: appendSearchResultSections_fluentd] :: search_result_arr길이 =>" +search_result_arr.length);
- if(search_result_arr && search_result_arr.length !== 0) {
- //해당 search_result_group 내용 초기화
- search_result_arr.forEach(function (content, index) {
- $("#log_section .search_result_group").append(
- `
-
-
-
-
-
-
-
-
-
-
- ${content["content"]["logName"]}
-
-
-
-
-
- ${content["index"]}
-
-
- ${content["content"]["timestamp"]}
-
-
-
-
-
- ${content["content"]["log"]}
-
-
- `
- );
- });
- } else {
- $("#log_section .search_result_group").append(
- `
-
-
-
-
-
-
-
-
- 검색 결과가 없습니다.
-
-
-
-
-
- -
-
-
- ${today}
-
-
-
-
-
- 검색 결과가 없습니다. 현재시각 :: ${today}
-
-
- `
- );
- }
- }
- return {
- setSearchResult, setSearchResult_fluentd,
- getSearchResult, getSearchResult_fluentd,
- appendSearchResultSections, appendSearchResultSections_fluentd
- }
-})(); //즉시실행 함수
-
+////////////////////////////////////////
+// 페이지 로드 시, 상단 검색어 기입 확인
+////////////////////////////////////////
function checkQueryStringOnUrl() {
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
@@ -516,29 +298,11 @@
search_start(searchTerm);
} else {
console.log("[searchEngine :: checkQueryStringOnUrl] :: 상단_검색 검색어가 없습니다.");
- // 검색페이지 중앙으로 커서 이동 이벤트 넣기 검토
}
}
-function renderPagination(totalItems, itemsPerPage) {
- var totalPages = Math.ceil(totalItems / itemsPerPage);
- var paginationElement = document.getElementById('pagination');
- for (var i = 1; i <= totalPages; i++) {
- var li = document.createElement('li');
- var a = document.createElement('a');
- a.href = '#';
- a.textContent = i;
- a.addEventListener('click', function(event) {
- event.preventDefault();
- // 해당 페이지의 데이터를 가져오는 함수 호출
- fetchData(i);
- });
- li.appendChild(a);
- paginationElement.appendChild(li);
- }
-}
-
-function fetchData(pageNumber) {
- // 해당 페이지의 데이터를 가져오는 로직을 여기에 구현
+function changePage(search_section,page) {
+ console.log("[searchEngine :: chagne] :: search_section -> " +search_section + ", page -> " +page);
+ SearchApiModule.changePage(search_section,page);
}
\ No newline at end of file
Index: arms/js/searchEngine/searchApiModule.js
===================================================================
diff -u
--- arms/js/searchEngine/searchApiModule.js (revision 0)
+++ arms/js/searchEngine/searchApiModule.js (revision 46d2768ad80fa7b7b3d918faa222e2327cef4001)
@@ -0,0 +1,317 @@
+var SearchApiModule = (function () {
+ "use strict";
+ var searchResult = {
+ "jiraissue" : null,
+ "fluentd" : null
+ };
+
+ let items_per_page=10; //페이지별 아이템 갯수. 기본값 10으로 설정
+
+ // 검색한 자료 세팅
+ var setItemsPerPage = function (items_per_page) {
+ items_per_page = +items_per_page;
+ return items_per_page;
+ };
+
+ var setSearchResult = function(search_section, search_results, current_page, items_per_Page) {
+ if(search_section) {
+ searchResult[search_section] = search_results;
+ paginateAndDisplayData(search_section, current_page,items_per_Page);
+ } else {
+ console.log("[searchApiModule :: setSearchResult] ::: search_section 없습니다.");
+ }
+ };
+
+ var getSearchResult = function(search_section) {
+ return searchResult[search_section];
+ };
+
+ // 클릭 했을 때, 모달 띄우기 위한 자료.
+ var getSearchResultDetail = function (search_section, order) {
+ console.log("[searchApiModule :: getSearchResultDetail] :: search_section -> " + search_section + ", order ->" + order);
+ return searchResult[search_section][order];
+ };
+ var paginateAndDisplayData = function (search_section, currentPage, itemsPerPage) {
+ const data = getSearchResult(search_section);
+ let items_per_page = setItemsPerPage(itemsPerPage);
+ // 현재 페이지에서 보여줄 데이터 추출
+ const startIndex = (currentPage - 1) * items_per_page;
+ const endIndex = startIndex + items_per_page;
+ const currentPageData = data.slice(startIndex, endIndex);
+ console.log("startIndex : " + startIndex); console.log("endIndex : " + endIndex);
+ console.log(currentPageData);
+ // 페이징된 데이터를 화면에 표시
+ displayData(search_section, currentPageData, currentPage, items_per_page);
+
+ const totalPage = Math.ceil(data.length / items_per_page);
+ const countPageBlock = 10; // 페이지블록 수 (한번에 보여줄 페이지 수)
+
+ let startPage = ((currentPage-1) / 10) * 10 + 1;
+ let endPage = startPage + countPageBlock -1;
+
+ if (totalPage < currentPage) {
+ currentPage = totalPage;
+ }
+ if (endPage > totalPage) {
+ endPage = totalPage;
+ }
+
+ let pagination = '';
+ pagination += '';
+
+ let pagination_spot = '#'+search_section+'_section'+' .pagination-div';
+ $(pagination_spot).html(pagination);
+ };
+
+ var displayData = function (search_section, currentPageData, startIndex, endIndex) {
+ console.log("[searchApiModule :: displayData] :: search_section -> " + search_section +", startIndex-> " + startIndex);
+ // 데이터를 화면에 표시하는 코드 작성
+ let search_result_arr = currentPageData;
+ let today = new Date();
+ let no_search_result =
+ `
+
+
+
+
+
+
+
+ 검색 결과가 없습니다.
+
+
+
+
+
+ -
+
+
+ ${today}
+
+
+
+
+
+ 검색 결과가 없습니다. 현재시각 :: ${today}
+
+
+ `;
+
+ if(search_section === 'jiraissue') {
+ $("#jiraissue_section .search_result_group .search_result_items").html("");
+ console.log("[searchApiModule :: appendSearchResultSections] :: search_result_arr길이 =>" +search_result_arr.length);
+ if(search_result_arr && search_result_arr.length !== 0) {
+ search_result_arr.forEach(function (content, index) {
+ let 순서 = startIndex+index;
+ $("#jiraissue_section .search_result_group .search_result_items").append(
+ `
+
+
+
+
+
+
+
+ ${content["content"]["summary"]}
+
+
+
+
+
+ ${content["index"]}
+
+
+ ${content["content"]["created"]}
+
+
+
+
+
+ 이슈키: ${content["content"]["key"]} 지라프로젝트: ${content["content"]["project"]["project_name"]}
+ 생성일: ${content["content"]["created"]}
+ 타임스탬프: ${content["content"]["timestamp"]}
+
+
+ `
+ );
+ });
+ } else {
+ $("#jiraissue_section .search_result_group .search_result_items").append(no_search_result);
+ }
+ }
+ else if (search_section === 'log') {
+ $("#log_section .search_result_group .search_result_items").html("");
+ console.log("[searchApiModule :: appendSearchResultSections_fluentd] :: search_result_arr길이 =>" +search_result_arr.length);
+ console.log(search_result_arr);
+ if(search_result_arr && search_result_arr.length !== 0) {
+ search_result_arr.forEach(function (content, index) {
+ let 순서 = startIndex+index;
+ $("#log_section .search_result_group .search_result_items").append(
+ `
+
+
+
+
+
+
+
+ ${content["content"]["logName"]}
+
+
+
+
+ ${content["index"]}
+
+
+ ${content["content"]["timestamp"]}
+
+
+
+
+
+ ${content["content"]["log"]}
+
+
+ `
+ );
+ });
+ } else {
+ $("#log_section .search_result_group .search_result_items").append(no_search_result);
+ }
+ }
+
+ };
+
+ var changePage = function (search_section, page) { // 11페이지가 나오면.
+ const current_page = page;
+
+ const startIndex = (current_page - 1) * items_per_page;
+ const endIndex = startIndex + items_per_page;
+
+ console.log("[searchApiModule :: changePage] :: startIndex -> " + startIndex+ ", endIndex -> " +endIndex);
+ const currentPageData = getSearchResult(search_section).slice(startIndex, endIndex);
+ console.log("[searchApiModule :: changePage] :: currentPageData => ");
+ console.log(currentPageData);
+ displayData(search_section, currentPageData, startIndex, endIndex);
+ updateButtons(search_section, current_page);
+ };
+
+ var updateButtons = function(search_section, current_page) {
+ console.log("updateButtons :: current_page => " + current_page);
+ const total_page = Math.ceil(getSearchResult(search_section).length / items_per_page);
+ const $pagination = $('#'+search_section+'_section .pagination-div .pagination');
+ const $prevButton = $('#'+search_section+'_section .pagination-div .pagination .prev');
+ const $nextButton = $('#'+search_section+'_section .pagination-div .pagination .next');
+ const countPageBlock = 10;
+
+ let startPage = ((current_page-1) / 10) * 10 + 1;
+ let endPage = startPage + countPageBlock -1;
+
+ if (total_page < current_page) {
+ current_page = total_page;
+ }
+ if (endPage > total_page) {
+ endPage = total_page;
+ }
+
+ // 만약 current_page가 11, 21, 31, 41, 51 이면 해당 페이지를 누를 당시, prev ~ next가 갱신(next를 누른 것) - 첫번째 블록이 아니면서 첫째페이지
+ if( ((current_page % 10) === 1 && (current_page / 10) !== 0)) {
+ let pagination = '';
+ pagination += '';
+ let pagination_spot = '#'+search_section+'_section'+' .pagination-div';
+ console.log(pagination);
+ $(pagination_spot).html("");
+ $(pagination_spot).html(pagination);
+ }
+
+ // 만약 current_page가 10, 20, 30, 40, 50 이면 해당 페이지를 누를 당시, prev ~ next가 갱신(prev를 누르거나 해당 블록의 endpage를 누른것) - 첫번재 블록이 아니면서 마지막페이지 or next 버튼
+ if ((current_page % 10) === 0) {
+ let 시작지점 = (current_page < 10 ? 1 : current_page - 9);
+ let pagination = '';
+ pagination += '';
+ let pagination_spot = '#'+search_section+'_section'+' .pagination-div';
+ $(pagination_spot).html("");
+ $(pagination_spot).html(pagination);
+ }
+
+ if (startPage === 0) {
+ $prevButton.addClass('disabled');
+ } else {
+ $prevButton.removeClass('disabled');
+ }
+
+ if (current_page === total_page) {
+ $nextButton.addClass('disabled');
+ } else {
+ $nextButton.removeClass('disabled');
+ }
+
+ // 이전에 선택된 페이지 요소에서 'active' 클래스 제거
+ $pagination.find('.active').removeClass('active');
+ // 선택된 페이지 번호에 해당하는 요소에 'active' 클래스 추가
+ $pagination.find('.page-num-' + current_page).addClass('active');
+ }
+ var mapDataToModal = function (search_section, order) {
+ const targetData = SearchApiModule.getSearchResultDetail(search_section,order);
+ console.log("[searchApiModule :: mapDataToModal] :: targetData => "); console.log(targetData);
+
+ if(search_section === "jiraissue") {
+ $("#search_detail_modal_jiraissue #detail_id_jiraissue").text(targetData["id"]);
+ $("#search_detail_modal_jiraissue #detail_index_jiraissue").text(targetData["index"]);
+ $("#search_detail_modal_jiraissue #detail_score_jiraissue").text(targetData["score"] === null ? "-" : targetData["score"]);
+ $("#search_detail_modal_jiraissue #detail_type_jiraissue").text(targetData["type"] === undefined ? " - " : targetData["type"]);
+ $("#search_detail_modal_jiraissue #detail_modal_summary_jiraissue").text(targetData["content"]["summary"]);
+ $("#search_detail_modal_jiraissue #detail_modal_key_jiraissue").text(targetData["content"]["key"]);
+ $("#search_detail_modal_jiraissue #detail_modal_key_jiraissue").text(targetData["content"]["created"]);
+ if(targetData["content"]["assignee"]) {
+ $("#search_detail_modal_jiraissue #detail_modal_assignee_name_jiraissue")
+ .text(targetData["content"]["assignee"]["assignee_displayName"]);
+ } else {
+ $("#search_detail_modal_jiraissue #detail_modal_assignee_name_jiraissue").text("담당자 정보 없음");
+ }
+ CKEDITOR.instances.modal_detail_log_jiraissue.setData(JSON.stringify(targetData));
+ }
+ else if (search_section === "log") {
+ $("#search_detail_modal_log #detail_id_log").text(targetData["id"]);
+ $("#search_detail_modal_log #detail_index_log").text(targetData["index"]);
+ $("#search_detail_modal_log #detail_score_log").text(targetData["score"] === null ? "-" : targetData["score"]);
+ $("#search_detail_modal_log #detail_type_log").text(targetData["type"] === undefined ? " - " : targetData["type"]);
+
+ $("#search_detail_modal_log #detail_modal_logname_log").text(targetData["content"]["logName"]);
+ $("#search_detail_modal_log #detail_modal_timestamp_log").text(targetData["content"]["timestamp"]);
+ $("#search_detail_modal_log #detail_modal_source_log").text(targetData["content"]["source"]);
+ $("#search_detail_modal_log #detail_modal_container_id_log").text(targetData["content"]["container_id"] === null? "-" : targetData["content"]["container_id"].substring(0,12));
+ $("#search_detail_modal_log #detail_modal_container_name_log").text(targetData["content"]["container_name"]);
+
+ CKEDITOR.instances.modal_detail_log_log.setData(JSON.stringify(targetData["content"]["log"]));
+ }
+ };
+
+ return {
+ setSearchResult,
+ getSearchResult,
+ getSearchResultDetail,
+ paginateAndDisplayData,
+ displayData,
+ changePage,
+ mapDataToModal
+ }
+})(); //즉시실행 함수
\ No newline at end of file