2022-10-02 20:18:05 +09:00
|
|
|
// global socketio
|
|
|
|
|
$(document).ready(function(){
|
2022-10-19 16:40:29 +09:00
|
|
|
ResizeTextArea();
|
2022-10-02 20:18:05 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
$('.loading').hide();
|
|
|
|
|
})
|
|
|
|
|
.ajaxStart(function(){
|
|
|
|
|
$('.loading').show();
|
|
|
|
|
})
|
|
|
|
|
.ajaxStop(function(){
|
|
|
|
|
$('.loading').hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var protocol = window.location.protocol;
|
|
|
|
|
var frameSocket = io.connect(protocol + "//" + document.domain + ":" + location.port + "/framework");
|
2022-10-14 15:38:44 +09:00
|
|
|
console.log(frameSocket);
|
2022-10-02 20:18:05 +09:00
|
|
|
|
|
|
|
|
frameSocket.on('notify', function(data){
|
|
|
|
|
$.notify({
|
|
|
|
|
message : data['msg'],
|
|
|
|
|
url: data['url'],
|
|
|
|
|
target: '_self'
|
|
|
|
|
},{
|
|
|
|
|
type: data['type'],
|
2022-10-19 16:40:29 +09:00
|
|
|
z_index: 2000,
|
2022-10-02 20:18:05 +09:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('modal', function(data){
|
|
|
|
|
m_modal(data.data, data.title, false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('loading_hide', function(data){
|
|
|
|
|
$('#loading').hide();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('refresh', function(data){
|
|
|
|
|
console.log('data')
|
|
|
|
|
window.location.reload();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 01:32:51 +09:00
|
|
|
$('#command_modal').on('hide.bs.modal', function (event) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `/global/ajax/command_modal_hide`,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {},
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-02 20:18:05 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// Global - 버튼
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#globalOpenBtn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
url = $(this).data('url')
|
|
|
|
|
window.open(url, "_blank");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#globalLinkBtn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
url = $(this).data('url')
|
|
|
|
|
window.location.href = url;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// global_link_btn 모두 찾아 변경
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#globalSettingSaveBtn', function(e){
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
globalSettingSave();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function globalSettingSave() {
|
2022-10-15 03:42:52 +09:00
|
|
|
var formData = getFormdata('#setting');
|
2022-10-02 20:18:05 +09:00
|
|
|
$.ajax({
|
|
|
|
|
url: '/' + PACKAGE_NAME + '/ajax/setting_save',
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: formData,
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret) {
|
|
|
|
|
$.notify('<strong>설정을 저장하였습니다.</strong>', {
|
|
|
|
|
type: 'success'
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
$.notify('<strong>설정 저장에 실패하였습니다.</strong>', {
|
|
|
|
|
type: 'warning'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#globalEditBtn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
file = $(this).data('file');
|
|
|
|
|
console.log(file);
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/global/ajax/is_available_edit',
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
2022-10-07 15:11:05 +09:00
|
|
|
if (ret.ret) {
|
|
|
|
|
window.open('/flaskcode?open=' + file, ret.target);
|
2022-10-02 20:18:05 +09:00
|
|
|
} else {
|
|
|
|
|
notify('편집기 플러그인을 설치해야 합니다.', 'warning');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-15 03:42:52 +09:00
|
|
|
$("body").on('click', '#globalCliboardBtn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
window.navigator.clipboard.writeText($(this).data('text'));
|
|
|
|
|
notify("클립보드에 복사하였습니다.", "success");
|
|
|
|
|
});
|
2022-10-02 20:18:05 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// Global - 함수
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
function globalSendCommand(command, arg1, arg2, arg3, modal_title, callback) {
|
2022-10-07 01:48:42 +09:00
|
|
|
console.log("globalSendCommand [" + command + '] [' + arg1 + '] [' + arg2 + '] [' + arg3 + '] [' + modal_title + '] [' + callback + ']');
|
2022-10-02 20:18:05 +09:00
|
|
|
console.log('/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/command');
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/command',
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data:{command:command, arg1:arg1, arg2:arg2, arg3},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.msg != null) notify(ret.msg, ret.ret);
|
|
|
|
|
if (ret.modal != null) m_modal(ret.modal, modal_title, false);
|
|
|
|
|
if (ret.json != null) m_modal(ret.json, modal_title, true);
|
2022-10-15 03:42:52 +09:00
|
|
|
if (callback != null) callback(ret);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function globalSendCommandPage(command, arg1, arg2, arg3, modal_title, callback) {
|
|
|
|
|
console.log("globalSendCommandPage [" + command + '] [' + arg1 + '] [' + arg2 + '] [' + arg3 + '] [' + modal_title + '] [' + callback + ']');
|
|
|
|
|
console.log('/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/command');
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/' + PACKAGE_NAME + '/ajax/' + MODULE_NAME + '/' + PAGE_NAME + '/command',
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data:{command:command, arg1:arg1, arg2:arg2, arg3},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
if (ret.msg != null) notify(ret.msg, ret.ret);
|
|
|
|
|
if (ret.modal != null) m_modal(ret.modal, modal_title, false);
|
|
|
|
|
if (ret.json != null) m_modal(ret.json, modal_title, true);
|
2022-10-02 20:18:05 +09:00
|
|
|
if (callback != null) callback(ret);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-06 14:39:43 +09:00
|
|
|
function shutdown_confirm() {
|
|
|
|
|
$("#confirm_title").html("종료 확인");
|
|
|
|
|
$("#confirm_body").html("종료 하시겠습니까?");
|
|
|
|
|
$('#confirm_button').attr('onclick', 'window.location.href = "/system/shutdown";');
|
|
|
|
|
$("#confirm_modal").modal();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-02 20:18:05 +09:00
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// 파일 선택 모달
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
var select_local_file_modal_callback = null;
|
|
|
|
|
|
2022-10-07 15:11:05 +09:00
|
|
|
function globalSelectLocalFile(title, init_path, func) {
|
2022-10-02 20:18:05 +09:00
|
|
|
_selectLocalFileModal(title, init_path, false, func);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-07 15:11:05 +09:00
|
|
|
function globalSelectLocalFolder(title, init_path, func) {
|
2022-10-02 20:18:05 +09:00
|
|
|
_selectLocalFileModal(title, init_path, true, func);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _selectLocalFileModal(title, init_path, only_dir, func) {
|
|
|
|
|
if (init_path == '' || init_path == null)
|
|
|
|
|
init_path = '/';
|
|
|
|
|
document.getElementById("select_local_file_modal_title").innerHTML = title;
|
|
|
|
|
document.getElementById("select_local_file_modal_path").value = init_path;
|
|
|
|
|
document.getElementById("select_local_file_modal_only_dir").value = only_dir;
|
|
|
|
|
select_local_file_modal_callback = func;
|
|
|
|
|
$("#select_local_file_modal").modal();
|
|
|
|
|
listdir(init_path, only_dir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#global_select_local_file_load_btn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
let current_path = $('#select_local_file_modal_path').val().trim();
|
|
|
|
|
only_dir = $('#select_local_file_modal_only_dir').val().trim();
|
|
|
|
|
listdir(current_path, only_dir);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#select_local_file_modal_confirm_btn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (select_local_file_modal_callback != null)
|
|
|
|
|
select_local_file_modal_callback($('#select_local_file_modal_path').val().trim());
|
|
|
|
|
$("#select_local_file_modal").modal('toggle');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let listdir = (path = '/', only_dir = true) => {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: `/global/ajax/listdir`,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {
|
|
|
|
|
path: path,
|
|
|
|
|
only_dir : only_dir
|
|
|
|
|
},
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
}).done((datas) => {
|
|
|
|
|
console.log(datas)
|
|
|
|
|
if (datas.length == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let new_obj = ``;
|
|
|
|
|
const path_spliter = (path.indexOf('/')>=0)?'/':'\\';
|
|
|
|
|
$('#select_local_file_modal_list_group').empty();
|
|
|
|
|
for (let dt of datas) {
|
|
|
|
|
tmp = dt.split('|');
|
|
|
|
|
new_obj += `<a href='#' class="list-group-item list-group-item-action item_path" data-value="${tmp[1]}">${tmp[0]}</a>`;
|
|
|
|
|
}
|
|
|
|
|
$('#select_local_file_modal_list_group').append(new_obj);
|
|
|
|
|
$('.item_path').off('click').click((evt) => {
|
|
|
|
|
|
|
|
|
|
let new_path = '';
|
|
|
|
|
/*
|
|
|
|
|
if ($(evt.currentTarget).text() === '..'){
|
|
|
|
|
let split_path = '';
|
|
|
|
|
split_path = path.split(path_spliter);
|
|
|
|
|
split_path.pop();
|
|
|
|
|
new_path = split_path.join(path_spliter);
|
|
|
|
|
if (new_path.length === 0){
|
|
|
|
|
new_path = path_spliter
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//new_path = (path !== path_spliter) ? path + path_spliter + $(evt.currentTarget).text() : path + $(evt.currentTarget).text();
|
|
|
|
|
new_path = $(evt.currentTarget).data('value');
|
|
|
|
|
console.log(new_path)
|
|
|
|
|
console.log(evt)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
new_path = $(evt.currentTarget).data('value');
|
|
|
|
|
$('#select_local_file_modal_path').val(new_path);
|
|
|
|
|
listdir(new_path, only_dir);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}).fail((datas) => {
|
|
|
|
|
$.notify('<strong>경로 읽기 실패</strong><br/>${add_path}', {type: 'danger'});
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 파일 선택 모달 End
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
2022-10-12 01:32:51 +09:00
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
// Command MODAL
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
frameSocket.on('command_modal_add_text', function(data){
|
|
|
|
|
document.getElementById("command_modal_textarea").innerHTML += data ;
|
|
|
|
|
document.getElementById("command_modal_textarea").scrollTop = document.getElementById("command_modal_textarea").scrollHeight;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('command_modal_input_disable', function(data){
|
|
|
|
|
$('#command_modal_input').attr('disabled', true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('command_modal_show', function(data){
|
|
|
|
|
command_modal_show(data)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameSocket.on('command_modal_clear', function(data){
|
|
|
|
|
document.getElementById("command_modal_textarea").innerHTML = ""
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function command_modal_show(title) {
|
|
|
|
|
ClientHeight = window.innerHeight
|
|
|
|
|
document.getElementById("command_modal_title").innerHTML = title
|
|
|
|
|
$("#command_modal").height(ClientHeight+50);
|
|
|
|
|
$("#command_modal_textarea").height(ClientHeight-380);
|
|
|
|
|
$("#command_modal").modal({backdrop: 'static', keyboard: false}, 'show');
|
|
|
|
|
$('#command_modal_input').attr('disabled', false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("body").on('click', '#command_modal_input_btn', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/global/ajax/command_modal_input',
|
|
|
|
|
type: "POST",
|
|
|
|
|
cache: false,
|
|
|
|
|
data: {cmd:$('#command_modal_input').val()},
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function (ret) {
|
|
|
|
|
$('#command_modal_input').val('');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-10-19 16:40:29 +09:00
|
|
|
|
|
|
|
|
$(window).resize(function() {
|
|
|
|
|
ResizeTextArea();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ResizeTextArea() {
|
|
|
|
|
ClientHeight = window.innerHeight
|
|
|
|
|
$("#command_modal").height(ClientHeight-100);
|
|
|
|
|
$("#command_modal_textarea").height(ClientHeight-380);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 01:32:51 +09:00
|
|
|
///////////////////////////////////////
|
|
|
|
|
|