update
This commit is contained in:
parent
76e756c1e5
commit
7e4c4e9419
|
|
@ -3,7 +3,7 @@
|
|||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('sphinx');">服务</p>
|
||||
<p onclick="pluginInitD('sphinx');">自启动</p>
|
||||
<p onclick="pluginConfig('sphinx');">配置修改</p>
|
||||
<p onclick="pluginConfigTpl('sphinx');">配置修改</p>
|
||||
<p onclick="pluginLogs('sphinx','','run_log',30);">运行日志</p>
|
||||
<p onclick="pluginLogs('sphinx','','query_log', 30);">查询日志</p>
|
||||
<p onclick="runStatus();">运行状态</p>
|
||||
|
|
|
|||
|
|
@ -62,10 +62,37 @@ def getArgs():
|
|||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
|
||||
return tmp
|
||||
|
||||
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def configTpl():
|
||||
path = getPluginDir() + '/tpl'
|
||||
pathFile = os.listdir(path)
|
||||
tmp = []
|
||||
for one in pathFile:
|
||||
file = path + '/' + one
|
||||
tmp.append(file)
|
||||
return public.getJson(tmp)
|
||||
|
||||
|
||||
def readConfigTpl():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
content = public.readFile(args['file'])
|
||||
content = contentReplace(content)
|
||||
return public.returnJson(True, 'ok', content)
|
||||
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = public.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', public.getRootDir())
|
||||
|
|
@ -247,14 +274,13 @@ def sphinxCmd():
|
|||
cmd_delta = []
|
||||
for x in range(indexlen):
|
||||
if string.find(sindex[x], ':') != -1:
|
||||
t = sindex[x].split(':')
|
||||
cmd_delta.append(t[0].strip())
|
||||
cmd_delta.append(sindex[x])
|
||||
else:
|
||||
cmd_index.append(sindex[x])
|
||||
|
||||
cmd['index'] = cmd_index
|
||||
cmd['delta'] = cmd_delta
|
||||
cmd['cmd'] = bin_dir + '/bin/bin/searchd -c ' + bin_dir + '/sphinx.conf'
|
||||
cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf'
|
||||
|
||||
return public.returnJson(True, 'ok', cmd)
|
||||
else:
|
||||
|
|
@ -283,6 +309,10 @@ if __name__ == "__main__":
|
|||
print initdUinstall()
|
||||
elif func == 'conf':
|
||||
print getConf()
|
||||
elif func == 'config_tpl':
|
||||
print configTpl()
|
||||
elif func == 'read_config_tpl':
|
||||
print readConfigTpl()
|
||||
elif func == 'run_log':
|
||||
print runLog()
|
||||
elif func == 'query_log':
|
||||
|
|
|
|||
|
|
@ -91,11 +91,22 @@ function readme(){
|
|||
|
||||
var con = '';
|
||||
|
||||
console.log(rdata);
|
||||
//主索引
|
||||
for (var i = 0; i < rdata['data']['index'].length; i++) {
|
||||
var index_t = rdata['data']['index'][i];
|
||||
con += '<p>主索引:' + rdata['data']['cmd'] + ' '+ index_t +' --rotate </p>';
|
||||
}
|
||||
|
||||
for (var i = 0; i < rdata['data']['delta'].length; i++) {
|
||||
var delta_t = rdata['data']['delta'][i];
|
||||
var list = delta_t.split(':');
|
||||
console.log(list);
|
||||
con += '<p>增量索引:' + rdata['data']['cmd'] + ' '+ list[0] +' --rotate </p>';
|
||||
con += '<p>合并索引:' + rdata['data']['cmd'] + ' --merge '+ list[1] + ' ' + list[0] +' --rotate </p>';
|
||||
}
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1336,6 +1336,125 @@ function pluginConfig(_name, version, func){
|
|||
"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").click(function(){
|
||||
$("#textBody").text(editor.getValue());
|
||||
pluginConfigSave(fileName);
|
||||
});
|
||||
},'json');
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
//配置修改模版 --- start
|
||||
function pluginConfigTpl(_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 = '<p style="color: #666; margin-bottom: 7px">提示:Ctrl+F 搜索关键字,Ctrl+G 查找下一个,Ctrl+S 保存,Ctrl+Shift+R 查找替换!</p>\
|
||||
<select id="config_tpl" class="bt-input-text mr20" style="width:30%;margin-bottom: 3px;"><option value="0">无选择</option></select>\
|
||||
<textarea class="bt-input-text" style="height: 320px; line-height:18px;" id="textBody"></textarea>\
|
||||
<button id="onlineEditFileBtn" class="btn btn-success btn-sm" style="margin-top:10px;">保存</button>\
|
||||
<ul class="help-info-text c7 ptb15">\
|
||||
<li>此处为'+ _name + version +'主配置文件,若您不了解配置规则,请勿随意修改。</li>\
|
||||
</ul>';
|
||||
$(".soft-man-con").html(con);
|
||||
|
||||
function getFileName(file){
|
||||
var list = file.split('/');
|
||||
var f = list[list.length-1];
|
||||
return f
|
||||
}
|
||||
|
||||
$.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('<option value="'+rdata[i]+'"">'+getFileName(rdata[i])+'</option>');
|
||||
}
|
||||
|
||||
$('#config_tpl').change(function(){
|
||||
var selected = $(this).val();
|
||||
if (selected != '0'){
|
||||
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});
|
||||
},'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']});
|
||||
var 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());
|
||||
pluginConfigSave(fileName);
|
||||
}
|
||||
},
|
||||
|
|
@ -1357,15 +1476,10 @@ function pluginConfig(_name, version, func){
|
|||
function pluginConfigSave(fileName) {
|
||||
var data = encodeURIComponent($("#textBody").val());
|
||||
var encoding = 'utf-8';
|
||||
var loadT = layer.msg('保存中...', {
|
||||
icon: 16,
|
||||
time: 0
|
||||
});
|
||||
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
|
||||
});
|
||||
layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue