let selectId; // 제품 아이디 let selectName; // 제품 이름 let versionList; // 선택한 제품 리스트 $(function () { setSideMenu("sidebar_menu_product", "sidebar_menu_version_manage"); }); // --- 데이터 테이블 설정 --- // $(function () { jstreeDataTableReload(); $(".dataTables_length").find("select:eq(0)").addClass("darkBack"); $(".dataTables_length").find("select:eq(0)").css("min-height", "30px"); //min-height: 30px; $("body").find("[aria-controls='pdserviceTable']").css("width", "100px"); $("select[name=pdserviceTable_length]").css("width", "50px"); }); function jstreeDataTableReload() { console.log("href: " + $(location).attr("href")); console.log("protocol: " + $(location).attr("protocol")); console.log("host: " + $(location).attr("host")); console.log("pathname: " + $(location).attr("pathname")); console.log("search: " + $(location).attr("search")); console.log("hostname: " + $(location).attr("hostname")); console.log("port: " + $(location).attr("port")); var isDevelopingToRoute = "/auth-user"; var tempDataTable = $("#pdserviceTable").DataTable({ ajax: { url: isDevelopingToRoute + "/api/arms/pdservice/getMonitor.do", dataSrc: "", }, destroy: true, processing: true, responsive: false, columns: [{ data: "c_id" }, { data: "c_title" }], columnDefs: [ { targets: -1, className: "dt-body-left", }, ], }); $("#pdserviceTable tbody").on("click", "tr", function () { $("#versionContents").html(""); if ($(this).hasClass("selected")) { $(this).removeClass("selected"); } else { tempDataTable.$("tr.selected").removeClass("selected"); $(this).addClass("selected"); } var data = tempDataTable.row(this).data(); selectId = data.c_id; selectName = data.c_title; console.log(data.c_id); dataLoad(data.c_id, data.c_title); }); } $("#regist-version").click(function () { console.log("save btn"); $.ajax({ url: "/auth-user/api/arms/pdversion/addNode.do", type: "POST", data: { ref: 2, c_title: $("#tooltip-enabled-service-version").val(), c_type: "default", c_pdservice_link: $('#pdserviceTable').DataTable().rows('.selected').data()[0].c_id, c_contents: CKEDITOR.instances["modal-editor"].getData(), c_start_date: $("#btn-enabled-date").val(), c_end_date: $("#btn-end-date").val(), }, statusCode: { 200: function () { console.log("성공!"); //모달 팝업 끝내고 $('#close-version').trigger('click'); //버전 데이터 재 로드 dataLoad(selectId, selectName); }, }, }); }); // --- 에디터 설정 --- // CKEDITOR.replace("input_pdservice_editor"); CKEDITOR.replace("modal-editor"); // --- 팝업 띄울때 사이즈 조정 -- // $("#modalPopupId").click(function () { var height = $(document).height() - 400; $(".modal-body") .find(".cke_contents:eq(0)") .css("height", height + "px"); }); function jsTreeClick(selectedNode) { console.log("-->" + selectedNode.attr("id").replace("node_", "")); console.log( "->" + selectedNode.find("a.jstree-clicked").siblings(".jstree-icon").text() + "<-" ); var tempNode = selectedNode.find("a.jstree-clicked").siblings(".jstree-icon"); tempNode.trigger("click"); console.log("여기:" + tempNode); var getSelectedText = selectedNode.find("a.jstree-clicked").text().trimStart(); console.log(getSelectedText); $("#product-input").val(getSelectedText); checkEqualSelectedNode(selectedNode); dataLoad(selectedNode.attr("id").replace("node_", ""), getSelectedText); } function checkEqualSelectedNode(selectedNode) { var getSelectedText = selectedNode.find("a.jstree-clicked").text().trimStart(); var inputText = $("#product-input").val(); if (getSelectedText == inputText) { console.log("동일하다 선택된 값이다."); $(".updatemode").click(); } else { console.log("값이 틀리다."); $(".newmode").click(); } } function dataLoad(getSelectedText, selectedText) { //데이터 로드를 사용자에게 알리기 Messenger().post({ message: 'Launching thermonuclear war...', actions: { cancel: { label: 'cancel launch', action: function() { return msg.update({ message: 'Thermonuclear war averted', type: 'success', actions: false }); } } } }); // ajax 처리 후 에디터 바인딩. console.log(getSelectedText); $.ajax("/auth-user/api/arms/pdversion/getVersion.do?c_id=" + getSelectedText) .done(function (json) { console.log("success", json); $("#versionAccordion").jsonMenu("set", json, { speed: 5000 }); versionList = json; //version text setting $(".list-group-item").text(selectedText); $("#tooltip-enabled-service-name").val(selectedText); Messenger().post({ message: 'Version Data 조회를 완료하였습니다.', type: 'success', showCloseButton: true }); }) .fail(function (jqXHR) { console.log("error"); }) .always(function (jqXHR) { console.log("finished"); }); } // 초기 개발 및 확인 용도 // versionlist 노출 (function ($) { let menu; $.fn.jsonMenu = function (action, items, options) { $(this).addClass("json-menu"); if (action == "add") { menu.body.push(items); draw($(this), menu); } else if (action == "set") { menu = items; draw($(this), menu); } return this; }; })(jQuery); //version list html 삽입 function draw(main, menu) { main.html(""); let data = `