updae
This commit is contained in:
@@ -21,3 +21,4 @@ discord-webhook
|
||||
pyyaml
|
||||
pycryptodome
|
||||
telepot-mod
|
||||
Flask-Dropzone
|
||||
@@ -90,6 +90,15 @@ class Framework:
|
||||
|
||||
self.celery = self.__init_celery()
|
||||
|
||||
from flask_dropzone import Dropzone
|
||||
self.app.config.update(
|
||||
DROPZONE_MAX_FILE_SIZE = 102400,
|
||||
DROPZONE_TIMEOUT = 5*60*1000,
|
||||
#DROPZONE_ALLOWED_FILE_CUSTOM = True,
|
||||
#DROPZONE_ALLOWED_FILE_TYPE = 'default, image, audio, video, text, app, *.*',
|
||||
)
|
||||
self.dropzone = Dropzone(self.app)
|
||||
|
||||
|
||||
def __init_celery(self):
|
||||
try:
|
||||
@@ -190,7 +199,7 @@ class Framework:
|
||||
|
||||
self.__make_default_logger()
|
||||
self.logger.info('### LAST')
|
||||
self.logger.info(f"### PORT: {self.config['port']}")
|
||||
self.logger.info(f"### PORT: {self.config.get('port')}")
|
||||
self.logger.info('### Now you can access App by webbrowser!!')
|
||||
|
||||
|
||||
|
||||
@@ -35,9 +35,11 @@ def global_ajax(sub):
|
||||
# globalEditBtn
|
||||
try:
|
||||
import flaskcode
|
||||
return jsonify(True)
|
||||
from flaskcode.setup import P as PP
|
||||
ret = {'ret':True, 'target':PP.ModelSetting.get('setting_open_target')}
|
||||
return jsonify(ret)
|
||||
except:
|
||||
return jsonify(False)
|
||||
return jsonify({'ret':False})
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +94,7 @@ def file2(path):
|
||||
|
||||
|
||||
|
||||
@F.app.route("/up", methods=['GET', 'POST'])
|
||||
@F.app.route("/upload", methods=['GET', 'POST'])
|
||||
def upload():
|
||||
# curl -F file=@downloader_video.tar https://dev.soju6jan.com/up
|
||||
#
|
||||
@@ -100,9 +102,9 @@ def upload():
|
||||
if request.method == 'POST':
|
||||
f = request.files['file']
|
||||
from werkzeug import secure_filename
|
||||
tmp = secure_filename(f.filename)
|
||||
F.logger.debug('upload : %s', tmp)
|
||||
f.save(os.path.join(F.path_data, 'upload', tmp))
|
||||
upload_path = F.SystemModelSetting.get('path_upload')
|
||||
os.makedirs(upload_path, exist_ok=True)
|
||||
f.save(os.path.join(upload_path, secure_filename(f.filename)))
|
||||
return jsonify('success')
|
||||
except Exception as exception:
|
||||
F.logger.error('Exception:%s', exception)
|
||||
|
||||
@@ -49,6 +49,7 @@ def jinja_initialize(app):
|
||||
app.jinja_env.globals.update(get_theme=get_theme)
|
||||
app.jinja_env.globals.update(get_menu_map=MenuManager.get_menu_map)
|
||||
app.jinja_env.globals.update(get_web_title=get_web_title)
|
||||
app.jinja_env.globals.update(dropzone=F.dropzone)
|
||||
|
||||
app.jinja_env.filters['get_menu'] = get_menu
|
||||
app.jinja_env.filters['get_theme'] = get_theme
|
||||
|
||||
@@ -112,8 +112,8 @@ $("body").on('click', '#globalEditBtn', function(e) {
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function (ret) {
|
||||
if (ret) {
|
||||
window.location.href = '/flaskcode?open=' + file;
|
||||
if (ret.ret) {
|
||||
window.open('/flaskcode?open=' + file, ret.target);
|
||||
} else {
|
||||
notify('편집기 플러그인을 설치해야 합니다.', 'warning');
|
||||
}
|
||||
@@ -160,11 +160,11 @@ function shutdown_confirm() {
|
||||
|
||||
var select_local_file_modal_callback = null;
|
||||
|
||||
function selectLocalFile(title, init_path, func) {
|
||||
function globalSelectLocalFile(title, init_path, func) {
|
||||
_selectLocalFileModal(title, init_path, false, func);
|
||||
}
|
||||
|
||||
function selectLocalFolder(title, init_path, func) {
|
||||
function globalSelectLocalFolder(title, init_path, func) {
|
||||
_selectLocalFileModal(title, init_path, true, func);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,11 @@
|
||||
{% if category_child['uri'] == menu[0] %}
|
||||
<a class="dropdown-item active" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold">{{ category_child['name'] }}</a>
|
||||
{% else %}
|
||||
{% if category_child['target'] == '__blank' %}
|
||||
<a class="dropdown-item" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold">{{ category_child['name'] }}</a>
|
||||
{% else %}
|
||||
<a class="dropdown-item" href="/{{ category_child['uri'] }}" style="font-size: .850rem; font-weight:bold" target="__blank">{{ category_child['name'] }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -85,11 +89,19 @@
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if current_menu[1] == module['uri'] or (current_menu[2] is not none and current_menu[1] + "/" + current_menu[2] == module['uri']) %}
|
||||
{% if 'target' in module and module['target'] == '_blank' %}
|
||||
<li class="nav-item"><a class="nav-link active" href="/{{current_menu[0]}}/{{module['uri']}}" target="_blank">{{module['name']}}</a></li>
|
||||
{% else %}
|
||||
<li class="nav-item"><a class="nav-link active" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if 'target' in module and module['target'] == '_blank' %}
|
||||
<li class="nav-item"><a class="nav-link" href="/{{current_menu[0]}}/{{module['uri']}}" target="_blank">{{module['name']}}</a></li>
|
||||
{% else %}
|
||||
<li class="nav-item"><a class="nav-link" href="/{{current_menu[0]}}/{{module['uri']}}">{{module['name']}}</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% break %}
|
||||
|
||||
43
lib/system/mod_tool.py
Normal file
43
lib/system/mod_tool.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from support import SupportFile
|
||||
|
||||
from .setup import *
|
||||
|
||||
name = 'tool'
|
||||
|
||||
class ModuleTool(PluginModuleBase):
|
||||
db_default = {
|
||||
'path_upload': os.path.join(F.config['path_data'], 'upload'),
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, P):
|
||||
super(ModuleTool, self).__init__(P, name=name, first_menu='celery')
|
||||
|
||||
|
||||
def process_menu(self, page, req):
|
||||
arg = P.ModelSetting.to_dict()
|
||||
try:
|
||||
return render_template(f'{__package__}_{name}_{page}.html', arg=arg)
|
||||
except Exception as e:
|
||||
P.logger.error(f'Exception:{str(e)}')
|
||||
P.logger.error(traceback.format_exc())
|
||||
return render_template('sample.html', title=f"{__package__}/{name}/{page}")
|
||||
|
||||
|
||||
def process_command(self, command, arg1, arg2, arg3, req):
|
||||
ret = {'ret':'success'}
|
||||
if command == 'plugin_install':
|
||||
ret = F.PluginManager.plugin_install(arg1)
|
||||
|
||||
return jsonify(ret)
|
||||
|
||||
|
||||
def plugin_load(self):
|
||||
try:
|
||||
pass
|
||||
except Exception as e:
|
||||
P.logger.error(f'Exception:{str(e)}')
|
||||
P.logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
@@ -73,11 +73,11 @@ try:
|
||||
|
||||
SystemModelSetting = P.ModelSetting
|
||||
from .mod_home import ModuleHome
|
||||
from .mod_plugin import ModulePlugin
|
||||
from .mod_route import ModuleRoute
|
||||
from .mod_setting import ModuleSetting
|
||||
|
||||
P.set_module_list([ModuleSetting, ModuleHome, ModuleRoute, ModulePlugin])
|
||||
from .mod_plugin import ModulePlugin
|
||||
from .mod_tool import ModuleTool
|
||||
P.set_module_list([ModuleHome, ModuleRoute, ModuleSetting, ModulePlugin, ModuleTool])
|
||||
|
||||
except Exception as e:
|
||||
P.logger.error(f'Exception:{str(e)}')
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<script type="text/javascript">
|
||||
$("body").on('click', '#select_btn', function(e){
|
||||
e.preventDefault();
|
||||
selectLocalFolder("폴더 선택", $('#plugin_dev_path').val(), function(ret) {
|
||||
globalSelectLocalFolder("폴더 선택", $('#plugin_dev_path').val(), function(ret) {
|
||||
$('#plugin_dev_path').val(ret);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장']])}}
|
||||
{{ macros.m_row_start('5') }}
|
||||
{{ macros.m_row_end() }}
|
||||
{{ macros.m_hr() }}
|
||||
|
||||
<nav>
|
||||
{{ macros.m_tab_head_start() }}
|
||||
{{ macros.m_tab_head2('basic', 'Basic', true) }}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
{{ macros.m_button_group([['yaml_edit_btn', '편집'], ['terminal_open_btn', 'Terminal 실행'], ['all_append_files_show_btn', '모두 확장'], ['all_append_files_hide_btn', '모두 축소']])}}
|
||||
{{ macros.m_row_start('5') }}
|
||||
{{ macros.m_row_end() }}
|
||||
{{ macros.m_hr_head_bottom() }}
|
||||
<div id="list_div"></div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var package_name = "{{arg['package_name']}}";
|
||||
var sub = "{{arg['sub']}}";
|
||||
var yaml_path = "{{arg['yaml_path']}}";
|
||||
var current_data = null;
|
||||
|
||||
$(document).ready(function(){
|
||||
reqeust_info();
|
||||
});
|
||||
|
||||
function reqeust_info() {
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/'+sub+'/get_info',
|
||||
type: "POST",
|
||||
cache: false,
|
||||
data:{},
|
||||
dataType: "json",
|
||||
success: function (ret) {
|
||||
make_list(ret);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function make_list(data) {
|
||||
current_data = data;
|
||||
data = data.commands;
|
||||
str = '';
|
||||
str = '<table id="result_table" class="table table-sm tableRowHover " ><thead class="thead-dark"><tr> \
|
||||
<th style="width:10%; text-align:center;">INDEX</th> \
|
||||
<th style="width:80%; text-align:left;">제목</th> \
|
||||
<th style="width:10%; text-align:center;">실행</th> \
|
||||
</tr></thead><tbody id="list">';
|
||||
|
||||
if (data.length == 0) str += '<tr><td colspan="3"><h4>명령이 없습니다.</h4></td></tr>';
|
||||
|
||||
for(i in data) {
|
||||
console.log(data[i]);
|
||||
str += '<tr class="chover" style="cursor: pointer;" data-toggle="collapse" data-target="#collapse_' + i + '" aria-expanded="true" >';
|
||||
str += '<td scope="col" style="width:10%; text-align:center;">'+ (parseInt(i)+1) + '</td>';
|
||||
str += '<td scope="col" style="width:80%; text-align:left;">'+ data[i].title + '</td>';
|
||||
tmp = m_button('terminal_open_btn', '실행', [{'key':'index', 'value':i}]);
|
||||
str += '<td scope="col" style="width:10%; text-align:center;">'+ tmp + '</td>';
|
||||
|
||||
str += '</tr>';
|
||||
|
||||
str += '<tr class="collapse tableRowHoverOff" style="cursor: pointer;" id="collapse_' + i + '">';
|
||||
str += '<td></td><td colspan="2">';
|
||||
str += "<pre>"+data[i].command+"</pre>";
|
||||
|
||||
str += '</td>';
|
||||
str += '</tr>'
|
||||
|
||||
}
|
||||
str += '</table>';
|
||||
document.getElementById("list_div").innerHTML = str;
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
$("body").on('click', '#yaml_edit_btn', function(e){
|
||||
url = '/flaskcode' + yaml_path;
|
||||
window.open(url, '_blank')
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("body").on('click', '#terminal_open_btn', function(e){
|
||||
e.preventDefault();
|
||||
index = $(this).data('index');
|
||||
console.log(index);
|
||||
if (index == null) {
|
||||
window.open("/terminal", "_blank");
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/' + package_name + '/ajax/' + sub + '/run',
|
||||
type: "POST",
|
||||
cache: false,
|
||||
data: {index:index},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.ret == 'success') {
|
||||
window.open("/terminal", "_blank");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("body").on('click', '#all_append_files_show_btn', function(e){
|
||||
e.preventDefault();
|
||||
$('.collapse').collapse('show');
|
||||
|
||||
});
|
||||
|
||||
$("body").on('click', '#all_append_files_hide_btn', function(e){
|
||||
e.preventDefault();
|
||||
$('.collapse').collapse('hide');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
36
lib/system/templates/system_tool_upload.html
Normal file
36
lib/system/templates/system_tool_upload.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<head>
|
||||
{{ dropzone.load_css() }}
|
||||
{{ dropzone.style('border: 2px dashed #0087F7; margin: 10%; min-height: 400px;') }}
|
||||
</head>
|
||||
|
||||
<div>
|
||||
{{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장']])}}
|
||||
{{ macros.m_row_start('5') }}
|
||||
{{ macros.m_row_end() }}
|
||||
{{ macros.m_hr() }}
|
||||
<form id='setting' name='setting'>
|
||||
{{ macros.setting_input_text_and_buttons('path_upload', '업로드 경로', [['select_btn', '폴더 선택']], value=arg['path_upload'], desc=['설정 저장 후부터 적용']) }}
|
||||
</form>
|
||||
{{ macros.m_hr_black() }}
|
||||
{{ dropzone.create(action='upload') }}
|
||||
{{ dropzone.load_js() }}
|
||||
{{ dropzone.config() }}
|
||||
|
||||
<script type="text/javascript">
|
||||
$("body").on('click', '#select_btn', function(e){
|
||||
e.preventDefault();
|
||||
globalSelectLocalFolder("업로드 폴더 선택", $('#path_upload').val(), function(ret) {
|
||||
$('#path_upload').val(ret);
|
||||
});
|
||||
});
|
||||
|
||||
$("body").on('click', '#plugin_install_btn', function(e){
|
||||
e.preventDefault();
|
||||
globalSendCommand('plugin_install', $('#_plugin_git').val());
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user