From ff8cd695b054f6a44809004ebfb1b83b698eed39 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Thu, 24 Jan 2019 16:02:59 +0800 Subject: [PATCH] update --- plugins/mysql/js/mysql.js | 8 +- plugins/qbittorrent/index.py | 31 +++++++- plugins/qbittorrent/js/qbittorrent.js | 108 ++++++++++++++++++++------ route/static/app/public.js | 45 ++++------- 4 files changed, 131 insertions(+), 61 deletions(-) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index c83ce1be0..41fa45cc0 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -459,11 +459,11 @@ function showHidePass(obj){ function copyPass(password){ var clipboard = new ClipboardJS('#bt_copys'); clipboard.on('success', function (e) { - layer.msg({msg:'复制成功',icon:1}); + layer.msg('复制成功',{icon:1,time:2000}); }); clipboard.on('error', function (e) { - layer.msg({msg:'复制失败,浏览器不兼容!',icon:2}); + layer.msg('复制失败,浏览器不兼容!',{icon:2,time:2000}); }); $("#bt_copys").attr('data-clipboard-text',password); $("#bt_copys").click(); @@ -912,9 +912,9 @@ function myLogs(){ var rdata = $.parseJSON(data.data); var limitCon = '

\ - '+ lan.soft.mysql_log_bin + ' ' + toSize(rdata.msg) + '\ + 二进制日志 ' + toSize(rdata.msg) + '\ \ -

'+ lan.soft.mysql_log_err + '

\ +

错误日志

\ \

' $(".soft-man-con").html(limitCon); diff --git a/plugins/qbittorrent/index.py b/plugins/qbittorrent/index.py index 44d57e69f..831e471c4 100755 --- a/plugins/qbittorrent/index.py +++ b/plugins/qbittorrent/index.py @@ -236,14 +236,39 @@ def pQbClient(): def qbList(): + args = getArgs() + # data = checkArgs(args, ['type']) + # if not data[0]: + # return data[1] + args_type = '' + if 'type' in args: + args_type = args['type'] + + f = ['downloading', 'completed'] + tfilter = '' + if args_type in f: + tfilter = args['type'] try: qb = pQbClient() - torrents = qb.torrents() - return public.returnJson(True, 'ok', torrents) + torrents = qb.torrents(filter=tfilter) + data = {} + data['type'] = tfilter + data['torrents'] = torrents + return public.returnJson(True, 'ok', data) except Exception as e: return public.returnJson(False, str(e)) +def qbDel(): + args = getArgs() + data = checkArgs(args, ['hash']) + if not data[0]: + return data[1] + qb = pQbClient() + data = qb.delete(args['hash']) + return public.returnJson(True, '操作成功!', data) + + def test(): qb = pQbClient() # magnet_link = "magnet:?xt=urn:btih:57a0ec92a61c60585f1b7a206a75798aa69285a5" @@ -278,6 +303,8 @@ if __name__ == "__main__": print getRunLog() elif func == 'qb_list': print qbList() + elif func == 'qb_del': + print qbDel() elif func == 'test': print test() else: diff --git a/plugins/qbittorrent/js/qbittorrent.js b/plugins/qbittorrent/js/qbittorrent.js index b9e9d9670..74ea6d5e0 100755 --- a/plugins/qbittorrent/js/qbittorrent.js +++ b/plugins/qbittorrent/js/qbittorrent.js @@ -30,55 +30,115 @@ function qbPost(method, args, callback){ }); } -function qbList(page,search){ - var _data = {}; - if (typeof(page) =='undefined'){ - var page = 1; - } +function showHideHash(obj){ + var a = "glyphicon-eye-open"; + var b = "glyphicon-eye-close"; - _data['page'] = page; - _data['page_size'] = 10; + if($(obj).hasClass(a)){ + $(obj).removeClass(a).addClass(b); + $(obj).prev().text($(obj).prev().attr('data-pw')) + } else{ + $(obj).removeClass(b).addClass(a); + $(obj).prev().text($(obj).attr('data-pw')); + } +} + + +function copyText(password){ + var clipboard = new ClipboardJS('#bt_copys'); + clipboard.on('success', function (e) { + layer.msg('复制成功',{icon:1,time:2000}); + }); + + clipboard.on('error', function (e) { + layer.msg('复制失败,浏览器不兼容!',{icon:2,time:2000}); + }); + $("#bt_copys").attr('data-clipboard-text',password); + $("#bt_copys").click(); +} + +function getLocalTime(nS) { + return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '); +} + + +function qbAdd(type){ + +} + + +function qbDel(hash){ + qbPost('qb_del', {hash:hash}, function(data){ + var rdata = $.parseJSON(data.data); + if (rdata['status']){ + layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']}); + } else { + layer.msg(rdata.msg,{icon:2,time:2000,shade: [0.3, '#000']}); + } + }); +} + +function qbListFind(){ + var qbs = $('#qb_selected').val(); + if ( qbs == '0' ){ + qbList(); + } else { + qbList(qbs); + } +} + +function qbList(search){ + var _data = {}; + _data['test'] ='yes'; if(typeof(search) != 'undefined'){ - _data['search'] = search; + _data['type'] = search; } qbPost('qb_list', _data, function(data){ - var rdata = $.parseJSON(data.data); if (!rdata['status']){ layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); return; } - console.log(rdata); - content = ''; - // content += ''; + + content = ''; + content += ''; content += '
'; content += ''; content += ''; - content += ''; - content += ''; + content += ''; + content += ''; content += ''; content += ''; - ulist = rdata.data; + ulist = rdata.data.torrents; for (i in ulist){ - content += ''+ - ''+ - ''; + content += ''+ + ''+ + ''; } content += ''; content += '
种子(hash)状态操作(添加 | 管理)添加时间操作(添加 | 管理)
'+ulist[i]['hash']+''+'下载中'+'删除
'+ + ''+ulist[i]['hash'].substr(0,3)+'' + + ''+ + ''+ + ''+getLocalTime(ulist[i]['added_on'])+'删除
'; - // page = ''; - - // content += page; - $(".soft-man-con").html(content); + + var type = rdata.data.type; + if (type == ''){ + $("#qb_selected option[value='0']").attr("selected", true); + } else { + $("#qb_selected option[value='"+type+"']").attr("selected", true); + } }); } diff --git a/route/static/app/public.js b/route/static/app/public.js index 512f08b34..9af45c1aa 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -22,6 +22,9 @@ function toSizeM(byteLen) { return a || 0; } + + + function randomStrPwd(b) { b = b || 32; var c = "AaBbCcDdEeFfGHhiJjKkLMmNnPpRSrTsWtXwYxZyz2345678"; @@ -345,36 +348,8 @@ function aotuHeight() { var a = $("body").height() - 40; $(".main-content").css("min-height", a) } -$(function() { - aotuHeight() -}); -$(window).resize(function() { - aotuHeight() -}); -function showHidePwd() { - var a = "glyphicon-eye-open", - b = "glyphicon-eye-close"; - $(".pw-ico").click(function() { - var g = $(this).attr("class"), - e = $(this).prev(); - if(g.indexOf(a) > 0) { - var h = e.attr("data-pw"); - $(this).removeClass(a).addClass(b); - e.text(h) - } else { - $(this).removeClass(b).addClass(a); - e.text("**********") - } - var d = $(this).next().position().left; - var f = $(this).next().position().top; - var c = $(this).next().width(); - $(this).next().next().css({ - left: d + c + "px", - top: f + "px" - }) - }) -} + function showMsg(msg, callback ,icon, time){ @@ -700,7 +675,7 @@ function ActionTask() { }) } -function RemoveTask(b) { +function removeTask(b) { var a = layer.msg(lan.public.the_del, { icon: 16, time: 0, @@ -1590,4 +1565,12 @@ function pluginLogs(_name, version, func, line){ },'json'); },'json'); } -/*** 其中功能,针对插件通过库使用 end ***/ \ No newline at end of file +/*** 其中功能,针对插件通过库使用 end ***/ + + +$(function() { + aotuHeight(); +}); +$(window).resize(function() { + aotuHeight(); +}); \ No newline at end of file