luci-app-qbittorrent: update luci

This commit is contained in:
LEAN-ESX 2019-11-09 07:18:58 -08:00
parent c235f68028
commit 51eead14e8
8 changed files with 83 additions and 31 deletions

View File

@ -10,7 +10,7 @@ LUCI_DEPENDS:=+qBittorrent
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-qbittorrent
PKG_VERSION=1.0
PKG_RELEASE:=4
PKG_RELEASE:=8
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -1,4 +1,16 @@
module("luci.controller.qbittorrent",package.seeall)
function index()
entry({"admin","nas","qbittorrent"},cbi("qbittorrent"),_("qbittorrent"))
if not nixio.fs.access("/etc/config/qbittorrent")then
return
end
entry({"admin","nas","qBittorrent"},cbi("qbittorrent"),_("qbittorrent"))
entry({"admin","nas","qBittorrent","status"},call("act_status")).leaf=true
end
function act_status()
local e={}
e.running=luci.sys.call("pgrep qbittorrent-nox >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -1,44 +1,32 @@
require("luci.sys")
local e=require"luci.model.uci".cursor()
local o=e:get_first("qbittorrent","Preferences","port")or 8080
local o=e:get_first("qbittorrent","Preferences","port") or 8080
local a=(luci.sys.call("pidof qbittorrent-nox > /dev/null")==0)
local t=""
local e=""
if a then
t="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input class=\"cbi-button cbi-button-apply\" type=\"submit\" value=\" "..translate("Open Web Interface").." \" onclick=\"window.open('http://'+window.location.hostname+':"..o.."')\"/>"
end
if a then
e="<b><font color=\"green\">"..translate("Running").."</font></b>"
else
e="<b><font color=\"red\">"..translate("Not running").."</font></b>"
t="<br /><br /><input class=\"cbi-button cbi-button-apply\" type=\"submit\" value=\" "..translate("Open Web Interface").." \" onclick=\"window.open('http://'+window.location.hostname+':"..o.."')\"/>"
end
m = Map("qbittorrent", translate("qbittorrent"), translate("A BT/PT downloader base on Qt")..t
.."<br/><br/>"..translate("qbittorrent Run Status").." : "..e.."<br/>")
m = Map("qbittorrent", translate("qBittorrent"), translate("qBittorrent is a cross-platform free and open-source BitTorrent client")..t)
m:section(SimpleSection).template="qbittorrent/qbittorrent_status"
s_basic = m:section(TypedSection, "basic", translate("Basic Settings"))
s_basic.anonymous = true
enable = s_basic:option(Flag, "enable", translate("Enable"))
profile_dir = s_basic:option(Value,"profile_dir",translate("profile_dir"),translate("Store configuration files in the Path"))
profile_dir.default = "/tmp"
program_dir = s_basic:option(Value,"program_dir",translate("program_dir"),translate("Store Program files in the Path"))
program_dir.default = "/usr/bin"
library_dir = s_basic:option(Value,"library_dir",translate("library_dir"),translate("Store Library in the Path"))
library_dir.default = "/usr/lib"
profile_dir.default = "/root"
s_download = m:section(TypedSection, "Preferences", translate("Download Settings"))
s_download.anonymous = true
download_dir = s_download:option(Value,"download_dir",translate("download_dir"),translate("Store download files in the Path"))
download_dir.default = "/tmp/download"
download_dir.default = "/root/download"
s_webui = m:section(TypedSection, "Preferences", translate("WEBUI Settings"))
s_webui.anonymous = true
port = s_webui:option(Value,"port",translate("port"),translate("WEBUI listening port"))
port.default = "8080"
local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/qbittorrent restart")
end
return m
return m

View File

@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[nas]], [[qBittorrent]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('qBittorrent_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>qBittorrent <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>qBittorrent <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="qBittorrent_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -1,5 +1,5 @@
msgid "qbittorrent"
msgstr "BT下载器-qb"
msgstr "qbittorrent"
msgid "Running"
msgstr "运行中"
@ -16,8 +16,8 @@ msgstr "基本设置"
msgid "Enable"
msgstr "启用"
msgid "A BT/PT downloader base on Qt"
msgstr "一个基于QT的BT/PT下载器"
msgid "qBittorrent is a cross-platform free and open-source BitTorrent client"
msgstr "qBittorrent是一个基于 QT 的跨平台的开源 BitTorrent 客户端"
msgid "profile_dir"
msgstr "配置文件目录"

View File

@ -1,3 +1,11 @@
config basic
option program_dir '/usr/bin'
option library_dir '/usr/lib'
option profile_dir '/root'
option enable '0'
config Preferences
option download_dir '/root/download'
option port '8080'

View File

@ -1,6 +1,11 @@
#!/bin/sh /etc/rc.common
START=99
get_config()
{
config_get_bool enable $1 enable 0
}
config_qbittorrent()
{
local download_dir
@ -24,9 +29,11 @@ Accepted=true
Cookies=@Invalid()
[Preferences]
General\Locale=zh
Downloads\SavePath=$download_dir
General\Locale=zh
WebUI\Port=$port
WebUI\CSRFProtection=false
EOF
fi
}
@ -39,7 +46,7 @@ run_qbittorrent()
if [ $enable ]; then
local profile_dir
config_get profile_dir $1 profile_dir
config_foreach config_qbittorrent 'Preferences' $profile_dir
config_foreach config_qbittorrent 'Preferences' $profile_dir
if [ "$profile_dir" != "" ]; then
config_get library_dir $1 library_dir
config_get program_dir $1 program_dir
@ -55,13 +62,16 @@ run_qbittorrent()
start()
{
stop
local profile_path
config_load 'qbittorrent'
config_load 'qbittorrent'
config_foreach get_config basic
[ $enable -eq 0 ] && exit 0
config_foreach run_qbittorrent 'basic'
}
stop()
{
killall qbittorrent-nox
killall qbittorrent-nox >/dev/null 2>&1
return 0
}

View File

@ -0,0 +1,12 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@qbittorrent[-1]
add ucitrack qbittorrent
set ucitrack.@qbittorrent[-1].init=qbittorrent
commit ucitrack
EOF
/etc/init.d/qbittorrent stop
rm -f /tmp/luci-indexcache
exit 0