mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<p onclick="pluginConfig('qbittorrent', '','get_sql');" title="手动导入SQL">导入SQL</p>
|
||||
<p onclick="pluginConfig('qbittorrent');">配置</p>
|
||||
<p onclick="pluginLogs('qbittorrent','','get_run_Log', 25);">日志</p>
|
||||
<p onclick="qbList();">列表</p>
|
||||
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
|
||||
@@ -10,6 +10,11 @@ import sys
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding("utf8")
|
||||
|
||||
sys.path.append('/usr/local/lib/python2.7/site-packages')
|
||||
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
@@ -199,6 +204,17 @@ def getDbConfInfo():
|
||||
return data
|
||||
|
||||
|
||||
def getQbConf():
|
||||
cfg = getConf()
|
||||
content = public.readFile(cfg)
|
||||
data = {}
|
||||
data['QB_HOST'] = matchData("QB_HOST\s*=\s(.*)", content)
|
||||
data['QB_PORT'] = matchData("QB_PORT\s*=\s(.*)", content)
|
||||
data['QB_USER'] = matchData("QB_USER\s*=\s(.*)", content)
|
||||
data['QB_PWD'] = matchData("QB_PWD\s*=\s(.*)", content)
|
||||
return data
|
||||
|
||||
|
||||
def pMysqlDb():
|
||||
data = getDbConfInfo()
|
||||
conn = mysql.mysql()
|
||||
@@ -212,13 +228,20 @@ def pMysqlDb():
|
||||
|
||||
def pQbClient():
|
||||
from qbittorrent import Client
|
||||
qb = Client('http://154.48.251.71:8080/')
|
||||
qb.login('admin', 'adminadmin')
|
||||
info = getQbConf()
|
||||
url = 'http://' + info['QB_HOST'] + ':' + info['QB_PORT'] + '/'
|
||||
qb = Client(url)
|
||||
qb.login(info['QB_USER'], info['QB_PWD'])
|
||||
return qb
|
||||
|
||||
|
||||
def qbList():
|
||||
return ''
|
||||
try:
|
||||
qb = pQbClient()
|
||||
torrents = qb.torrents()
|
||||
return public.returnJson(True, 'ok', torrents)
|
||||
except Exception as e:
|
||||
return public.returnJson(False, str(e))
|
||||
|
||||
|
||||
def test():
|
||||
@@ -253,8 +276,8 @@ if __name__ == "__main__":
|
||||
print getConf()
|
||||
elif func == 'get_run_Log':
|
||||
print getRunLog()
|
||||
elif func == 'get_trend_data':
|
||||
print getTrendData()
|
||||
elif func == 'qb_list':
|
||||
print qbList()
|
||||
elif func == 'test':
|
||||
print test()
|
||||
else:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
function dhtPostMin(method, args, callback){
|
||||
function qbPostMin(method, args, callback){
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'simdht';
|
||||
req_data['name'] = 'qbittorrent';
|
||||
req_data['func'] = method;
|
||||
|
||||
if (typeof(args) != 'undefined' && args!=''){
|
||||
@@ -20,9 +20,9 @@ function dhtPostMin(method, args, callback){
|
||||
},'json');
|
||||
}
|
||||
|
||||
function dhtPost(method, args, callback){
|
||||
function qbPost(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
dhtPostMin(method,args,function(data){
|
||||
qbPostMin(method,args,function(data){
|
||||
layer.close(loadT);
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
@@ -30,243 +30,55 @@ function dhtPost(method, args, callback){
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function dhtTrend(){
|
||||
var obj = $('#dht_trend');
|
||||
if (obj.length>0){
|
||||
console.log('已经加载图表...');
|
||||
return;
|
||||
function qbList(page,search){
|
||||
var _data = {};
|
||||
if (typeof(page) =='undefined'){
|
||||
var page = 1;
|
||||
}
|
||||
|
||||
var trend = '<div id="dht_trend" style="width:100%;height:330px;"></div>';
|
||||
$('.soft-man-con').html(trend);
|
||||
dhtTrendRender();
|
||||
}
|
||||
|
||||
function dhtTrendData(callback){
|
||||
dhtPostMin('get_trend_data',{interval:1},function(data){
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function dhtTrendRender() {
|
||||
var myChartNetwork = echarts.init(document.getElementById('dht_trend'));
|
||||
var xData = [];
|
||||
var oneData = [];
|
||||
var twoData = [];
|
||||
var threeData = [];
|
||||
|
||||
function getTime() {
|
||||
var now = new Date();
|
||||
var hour = now.getHours();
|
||||
var minute = now.getMinutes();
|
||||
var second = now.getSeconds();
|
||||
if (minute < 10) {
|
||||
minute = "0" + minute;
|
||||
}
|
||||
if (second < 10) {
|
||||
second = "0" + second;
|
||||
}
|
||||
var nowdate = hour + ":" + minute + ":" + second;
|
||||
return nowdate;
|
||||
}
|
||||
|
||||
function ts(m) { return m < 10 ? '0' + m : m }
|
||||
|
||||
function format(sjc) {
|
||||
var time = new Date(sjc);
|
||||
var h = time.getHours();
|
||||
var mm = time.getMinutes();
|
||||
var s = time.getSeconds();
|
||||
return ts(h) + ':' + ts(mm) + ':' + ts(s);
|
||||
}
|
||||
|
||||
function addData(data) {
|
||||
// console.log(data);
|
||||
var rdata = $.parseJSON(data.data);
|
||||
xData.push(getTime());
|
||||
oneData.push(rdata[0]);
|
||||
twoData.push(rdata[1]);
|
||||
threeData.push(rdata[2]);
|
||||
|
||||
xData.shift();
|
||||
oneData.shift();
|
||||
twoData.shift();
|
||||
threeData.shift();
|
||||
}
|
||||
for (var i = 8; i >= 0; i--) {
|
||||
var time = (new Date()).getTime();
|
||||
xData.push(format(time - (i * 5 * 1000)));
|
||||
oneData.push(0);
|
||||
twoData.push(0);
|
||||
threeData.push(0);
|
||||
}
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
title: {
|
||||
text: '种子收录趋势',
|
||||
left: 'center',
|
||||
textStyle: {
|
||||
color: '#888888',fontStyle: 'normal',
|
||||
fontFamily: '宋体',fontSize: 16,
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['1s', '5s', '10s'],
|
||||
bottom: '2%'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: xData,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: "#666"
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: '单位个数',
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "#eee"
|
||||
}
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: "#666"
|
||||
}
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '1s',
|
||||
type: 'line',
|
||||
data: oneData,
|
||||
smooth: true,
|
||||
showSymbol: false,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1,
|
||||
[{offset: 0,color: 'rgba(205, 51, 51,0.5)'},
|
||||
{offset: 1,color: 'rgba(205, 51, 51,0.8)'}], false)
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {color: '#cd3333'}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {width: 1}
|
||||
}
|
||||
}, {
|
||||
name: '5s',
|
||||
type: 'line',
|
||||
data: twoData,
|
||||
smooth: true,
|
||||
showSymbol: false,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: 'rgba(30, 144, 255,0.5)'
|
||||
}, {
|
||||
offset: 1,
|
||||
color: 'rgba(30, 144, 255,0.8)'
|
||||
}], false)
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {color: '#52a9ff'}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 1
|
||||
}
|
||||
}
|
||||
},{
|
||||
name: '10s',
|
||||
type: 'line',
|
||||
data: threeData,
|
||||
smooth: true,
|
||||
showSymbol: false,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: 'rgba(30, 144, 255,0.5)'
|
||||
}, {
|
||||
offset: 1,
|
||||
color: 'rgba(30, 144, 255,0.8)'
|
||||
}], false)
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {color: '#C6E2FF'}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 1
|
||||
}
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChartNetwork.setOption(option);
|
||||
window.addEventListener("resize", function() {
|
||||
myChartNetwork.resize();
|
||||
});
|
||||
|
||||
function render(){
|
||||
dhtTrendData(function(data){
|
||||
addData(data);
|
||||
});
|
||||
myChartNetwork.setOption({
|
||||
xAxis: {data: xData},
|
||||
series: [
|
||||
{name: '1s',data: oneData},
|
||||
{name: '5s',data: twoData},
|
||||
{name: '10s',data: threeData}
|
||||
]
|
||||
});
|
||||
_data['page'] = page;
|
||||
_data['page_size'] = 10;
|
||||
if(typeof(search) != 'undefined'){
|
||||
_data['search'] = search;
|
||||
}
|
||||
render();
|
||||
|
||||
renderTick = setInterval(function() {
|
||||
render();
|
||||
}, 3000);
|
||||
qbPost('qb_list', _data, function(data){
|
||||
|
||||
checkTick = setInterval(function() {
|
||||
var obj = $('#dht_trend');
|
||||
if (obj.length>0){
|
||||
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata['status']){
|
||||
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
} else {
|
||||
console.log('取消定时请求...');
|
||||
clearInterval(renderTick);
|
||||
clearInterval(checkTick);
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
console.log(rdata);
|
||||
content = '';
|
||||
// content += '<button class="btn btn-success btn-sm" onclick="csvnUserFind();">查找</button></div>';
|
||||
|
||||
function dhtRead(){
|
||||
dhtPost('dht_cmd','', function(data){
|
||||
console.log(data);
|
||||
var readme = '<p>* 在手动导入SQL-先把数据表创建</p>';
|
||||
readme += '<p>* 修改成对应的配置文件</p>';
|
||||
readme += '<p>* 加入到计划[自行调节]:'+data.data+'</p>';
|
||||
$('.soft-man-con').html(readme);
|
||||
content += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
|
||||
content += '<thead><tr>';
|
||||
content += '<th>种子(hash)</th>';
|
||||
content += '<th>状态</th>';
|
||||
content += '<th>操作(<a class="btlink" onclick="csvnAddUser();">添加</a> | <a class="btlink" onclick="">管理</a>)</th>';
|
||||
content += '</tr></thead>';
|
||||
|
||||
content += '<tbody>';
|
||||
|
||||
ulist = rdata.data;
|
||||
for (i in ulist){
|
||||
content += '<tr><td>'+ulist[i]['hash']+'</td>'+
|
||||
'<td>'+'下载中'+'</td>'+
|
||||
'<td><a class="btlink" onclick="csvnDelUser(\''+ulist[i]+'\')">删除</a></td></tr>';
|
||||
}
|
||||
|
||||
content += '</tbody>';
|
||||
content += '</table></div>';
|
||||
|
||||
// page = '<div class="dataTables_paginate paging_bootstrap pagination" style="margin-top:0px;"><ul id="softPage" class="page"><div>';
|
||||
// page += rdata.list;
|
||||
// page += '</div></ul></div>';
|
||||
|
||||
// content += page;
|
||||
|
||||
$(".soft-man-con").html(content);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ DB_NAME = qbittorrent
|
||||
|
||||
[qb]
|
||||
QB_HOST = 127.0.0.1
|
||||
QB_PORT = 8081
|
||||
QB_PORT = 8080
|
||||
QB_USER = admin
|
||||
QB_PWD = adminadmin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user