+
- ${collection.apis.map((api, apiIndex) => this.collectionApiTemplate(api, apiIndex, collection.id)).join('')}
+ ${collection.apis.map((api, apiIndex) =>
+ this.collectionApiTemplate(api, apiIndex, collection.id)
+ ).join('')}
-
- `;
+ `;
}
collectionApiTemplate(api, apiIndex, collectionId) {
return `
-
- ${api.name}
-
-
-
-
-
- `;
+
+ ${api.name}
+
+
+
+
+ `;
}
init(servers) {
@@ -133,6 +145,7 @@ class APITester {
this.serverManager = new ServerManager(this.servers);
this.bindEvents();
this.loadCollections();
+
}
bindEvents() {
@@ -163,11 +176,59 @@ class APITester {
$(document).on('change', '.request_headers input', this.handleUIUpdate.bind(this));
$(document).on('change', '.api_request_info select, .api_request_info input', this.handleUIUpdate.bind(this));
$(document).on('change', '.api_request_info select', this.handleUpdateServer.bind(this));
+ $('#api_search').on('input', this.handleSearch.bind(this));
window.addEventListener('resize', this.resizeEditor.bind(this));
}
+ handleSearch(event) {
+
+ const searchTerm = (event !== undefined)? event.target.value.toLowerCase() : '';
+ console.log("검색어:", searchTerm);
+
+ this.collections.forEach(collection => {
+ const collectionMatches = collection.name.toLowerCase().includes(searchTerm);
+ console.log(`컬렉션 "${collection.name}" 검색어 매칭 여부: ${collectionMatches}`);
+
+ if (searchTerm === '') {
+ // 검색어가 없으면 모든 컬렉션과 API를 표시
+ collection.show = true;
+ collection.apis.forEach(api => {
+ api.show = true;
+ });
+ console.log(`검색어가 없으므로 컬렉션 "${collection.name}"과 모든 API를 표시합니다.`);
+ } else if (collectionMatches) {
+ // 컬렉션명이 검색어와 매칭되면 모두 표시
+ collection.show = true;
+ collection.apis.forEach(api => {
+ api.show = true;
+ });
+ console.log(`컬렉션 "${collection.name}"이(가) 검색어와 매칭되어 모든 API를 표시합니다.`);
+ } else {
+ // 컬렉션명이 매칭되지 않을 경우, 하위 API만 체크
+ let anyApiMatches = false;
+ collection.apis.forEach(api => {
+ if (api.name.toLowerCase().includes(searchTerm)) {
+ api.show = true;
+ anyApiMatches = true;
+ console.log(`컬렉션 "${collection.name}"의 API "${api.name}"가 검색어와 매칭됩니다.`);
+ } else {
+ api.show = false;
+ console.log(`컬렉션 "${collection.name}"의 API "${api.name}"는 검색어와 매칭되지 않습니다.`);
+ }
+ });
+ // 하위 API 중 하나라도 매칭되면 컬렉션도 보여야 함
+ collection.show = anyApiMatches;
+ console.log(`컬렉션 "${collection.name}" 자체는 매칭되지 않지만, 하위 API 매칭 여부: ${anyApiMatches}`);
+ }
+ });
+
+ // 무한 루프 방지를 위해 AJAX 호출 없이 바로 렌더링
+ this.renderCollections();
+ }
+
+
resizeEditor() {
//FIXME: 창 크기 변경시 자동으로 editor 크기가 조정되지 않아서, 0으로 강제 변경후 다시 layout() 호출
@@ -531,11 +592,13 @@ class APITester {
}
renderCollections() {
- let select = $('#modal_collection');
- let sidemenu = $(this.collectionTarget);
- select.empty();
- sidemenu.empty();
+ const sidemenu = $(this.collectionTarget);
+ const select = $('#modal_collection');
+ sidemenu.empty();
+ select.empty();
+
+ // 컬렉션과 API 렌더링 (이미 handleSearch에서 show 플래그가 설정되어 있다고 가정)
for (let i = 0; i < this.collections.length; i++) {
sidemenu.append(this.renderCollection(this.collections[i], i));
let option = $('
");let _=null;return g&&u&&o.isBasicASCII&&s.useMonospaceOptimizations&&0===v.containsForeignElements&&(_=new f(this._renderedViewLine?this._renderedViewLine.domNode:null,p,v.characterMapping)),_||(_=b(this._renderedViewLine?this._renderedViewLine.domNode:null,p,v.characterMapping,v.containsRTL,v.containsForeignElements)),this._renderedViewLine=_,!0}layoutLine(e,t){this._renderedViewLine&&this._renderedViewLine.domNode&&(this._renderedViewLine.domNode.setTop(t),this._renderedViewLine.domNode.setHeight(this._options.lineHeight))}getWidth(e){return this._renderedViewLine?this._renderedViewLine.getWidth(e):0}getWidthIsFast(){return!this._renderedViewLine||this._renderedViewLine.getWidthIsFast()}needsMonospaceFontCheck(){return!!this._renderedViewLine&&this._renderedViewLine instanceof f}monospaceAssumptionsAreValid(){return this._renderedViewLine&&this._renderedViewLine instanceof f?this._renderedViewLine.monospaceAssumptionsAreValid():g}onMonospaceAssumptionsInvalidated(){this._renderedViewLine&&this._renderedViewLine instanceof f&&(this._renderedViewLine=this._renderedViewLine.toSlowRenderedLine())}getVisibleRangesForRange(e,t,i,n){if(!this._renderedViewLine)return null;t=Math.min(this._renderedViewLine.input.lineContent.length+1,Math.max(1,t)),i=Math.min(this._renderedViewLine.input.lineContent.length+1,Math.max(1,i));const o=this._renderedViewLine.input.stopRenderingLineAfter;if(-1!==o&&t>o+1&&i>o+1)return new r.CH(!0,[new r.CR(this.getWidth(n),0)]);-1!==o&&t>o+1&&(t=o+1),-1!==o&&i>o+1&&(i=o+1);const s=this._renderedViewLine.getVisibleRangesForRange(e,t,i,n);return s&&s.length>0?new r.CH(!1,s):null}getColumnOfNodeOffset(e,t){return this._renderedViewLine?this._renderedViewLine.getColumnOfNodeOffset(e,t):1}}m.CLASS_NAME="view-line";class f{constructor(e,t,i){this._cachedWidth=-1,this.domNode=e,this.input=t;const n=Math.floor(t.lineContent.length/300);if(n>0){this._keyColumnPixelOffsetCache=new Float32Array(n);for(let e=0;e