diff --git a/plugins/supervisor/index.py b/plugins/supervisor/index.py
index 596fde2f7..65935c0d2 100755
--- a/plugins/supervisor/index.py
+++ b/plugins/supervisor/index.py
@@ -434,6 +434,26 @@ def getJobInfo():
return mw.getJson(info)
+def configTpl():
+ path = getServerDir() + '/conf.d'
+ pathFile = os.listdir(path)
+ tmp = []
+ for one in pathFile:
+ file = path + '/' + one
+ tmp.append(file)
+ return mw.getJson(tmp)
+
+
+def readConfigTpl():
+ args = getArgs()
+ data = checkArgs(args, ['file'])
+ if not data[0]:
+ return data[1]
+
+ content = mw.readFile(args['file'])
+ return mw.returnJson(True, 'ok', content)
+
+
def runLog():
return getServerDir() + '/log/supervisor.log'
@@ -455,6 +475,10 @@ if __name__ == "__main__":
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
+ elif func == 'config_tpl':
+ print(configTpl())
+ elif func == 'read_config_tpl':
+ print(readConfigTpl())
elif func == 'conf':
print(getConf())
elif func == 'run_log':
diff --git a/plugins/supervisor/js/supervisor.js b/plugins/supervisor/js/supervisor.js
index 2a32525f9..54fba2c68 100755
--- a/plugins/supervisor/js/supervisor.js
+++ b/plugins/supervisor/js/supervisor.js
@@ -318,3 +318,141 @@ function supAdd() {
});
}
+
+
+//supervisor
+function supConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_func){
+ if ( typeof(version) == 'undefined' ){
+ version = '';
+ }
+
+ var func_name = 'conf';
+ if ( typeof(func) != 'undefined' ){
+ func_name = func;
+ }
+
+ var _config_tpl_func = 'config_tpl';
+ if ( typeof(config_tpl_func) != 'undefined' ){
+ _config_tpl_func = config_tpl_func;
+ }
+
+ var _read_config_tpl_func = 'read_config_tpl';
+ if ( typeof(read_config_tpl_func) != 'undefined' ){
+ _read_config_tpl_func = read_config_tpl_func;
+ }
+
+
+ var con = '
提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!
\
+
\
+
\
+
\
+
\
+ - 此处为'+ _name + version +'配置文件,若您不了解配置规则,请勿随意修改。
\
+
';
+ $(".soft-man-con").html(con);
+
+ function getFileName(file){
+ var list = file.split('/');
+ var f = list[list.length-1];
+ return f
+ }
+
+ var fileName = '';
+ $.post('/plugins/run',{name:_name, func:_config_tpl_func,version:version}, function(data){
+ var rdata = $.parseJSON(data.data);
+ for (var i = 0; i < rdata.length; i++) {
+ $('#config_tpl').append('
');
+ }
+
+ $('#config_tpl').change(function(){
+ var selected = $(this).val();
+ if (selected != '0'){
+ fileName = selected;
+ var loadT = layer.msg('配置获取中...',{icon:16,time:0,shade: [0.3, '#000']});
+
+ var _args = JSON.stringify({file:selected});
+ $.post('/plugins/run', {name:_name, func:_read_config_tpl_func,version:version,args:_args}, function(data){
+ layer.close(loadT);
+ var rdata = $.parseJSON(data.data);
+ if (!rdata.status){
+ layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
+ return;
+ }
+
+ $("#textBody").empty().text(rdata.data);
+ $(".CodeMirror").remove();
+ var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
+ extraKeys: {
+ "Ctrl-Space": "autocomplete",
+ "Ctrl-F": "findPersistent",
+ "Ctrl-H": "replaceAll",
+ "Ctrl-S": function() {
+ $("#textBody").text(editor.getValue());
+ pluginConfigSave(fileName);
+ }
+ },
+ lineNumbers: true,
+ matchBrackets:true,
+ });
+ editor.focus();
+ $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
+ $("#onlineEditFileBtn").unbind('click');
+ $("#onlineEditFileBtn").click(function(){
+ $("#textBody").text(editor.getValue());
+ pluginConfigSave(fileName);
+ });
+ },'json');
+ }
+ });
+
+ },'json');
+
+ var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']});
+ $.post('/plugins/run', {name:_name, func:func_name,version:version}, function (data) {
+ layer.close(loadT);
+
+ var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']});
+ fileName = data.data;
+ $.post('/files/get_body', 'path=' + fileName, function(rdata) {
+ layer.close(loadT2);
+ if (!rdata.status){
+ layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
+ return;
+ }
+ $("#textBody").empty().text(rdata.data.data);
+ $(".CodeMirror").remove();
+ var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
+ extraKeys: {
+ "Ctrl-Space": "autocomplete",
+ "Ctrl-F": "findPersistent",
+ "Ctrl-H": "replaceAll",
+ "Ctrl-S": function() {
+ $("#textBody").text(editor.getValue());
+ supConfigSave(fileName);
+ }
+ },
+ lineNumbers: true,
+ matchBrackets:true,
+ });
+ editor.focus();
+ $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
+ $("#onlineEditFileBtn").click(function(){
+ $("#textBody").text(editor.getValue());
+ supConfigSave(fileName);
+ });
+ },'json');
+ },'json');
+}
+
+
+//保存
+function supConfigSave(fileName) {
+ var data = encodeURIComponent($("#textBody").val());
+ var encoding = 'utf-8';
+ var loadT = layer.msg('保存中...', {icon: 16,time: 0});
+ $.post('/files/save_body', 'data=' + data + '&path=' + fileName + '&encoding=' + encoding, function(rdata) {
+ layer.close(loadT);
+ layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
+ },'json');
+}
+