Merge commit '54d3a69d8f0644d08c6000a22cb4f64540a4e739'

This commit is contained in:
bgme 2025-07-03 18:52:35 +00:00
commit 7727f17ed5
4 changed files with 380 additions and 291 deletions
luci-app-smartdns
Makefile
htdocs/luci-static/resources/view/smartdns
po/zh_Hans

View file

@ -4,21 +4,30 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-smartdns
PKG_VERSION:=1.2025.47.2
PKG_RELEASE:=2
PKG_LICENSE:=GPL-3.0-or-later
PKG_MAINTAINER:=Nick Peng <pymumu@gmail.com>
PKG_VERSION:=1.2025.47.2
PKG_RELEASE:=1
LUCI_TITLE:=LuCI for smartdns
LUCI_DESCRIPTION:=Provides Luci for smartdns
LUCI_DEPENDS:=+smartdns
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+luci-base +smartdns \
+PACKAGE_$(PKG_NAME)_INCLUDE_smartdns_ui:smartdns-ui
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)/config
# shown in make menuconfig <Help>
help
$(LUCI_TITLE)
Version: $(PKG_VERSION)-$(PKG_RELEASE)
config PACKAGE_$(PKG_NAME)_INCLUDE_smartdns_ui
bool "Include smartdns-ui"
default n
endef
include $(TOPDIR)/feeds/luci/luci.mk

View file

@ -90,7 +90,7 @@ return view.extend({
var button = ev.target;
button.disabled = true;
button.textContent = _('Clear Logs...');
fs.exec_direct('/usr/libexec/smartdns-call', ['clear_log'])
fs.exec('/usr/libexec/smartdns-call', ['clear_log'])
.then(function () {
button.textContent = _('Logs cleared successfully!');
setTimeout(function () {
@ -114,9 +114,9 @@ return view.extend({
poll.add(L.bind(function () {
return fs.exec_direct('/usr/libexec/smartdns-call', ['tail'])
return fs.exec('/usr/libexec/smartdns-call', ['tail'])
.then(function (res) {
var log = E('pre', { 'wrap': 'pre' }, [res.trim() || _('Log is clean.')]);
var log = E('pre', { 'wrap': 'pre' }, [res.stdout.trim() || _('Log is clean.')]);
dom.content(log_textarea, log);
log.scrollTop = log.scrollHeight;

View file

@ -61,8 +61,16 @@ function smartdnsRenderStatus(res) {
var smartdnsEnable = uci.get_first('smartdns', 'smartdns', 'enabled');
var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server');
var uiEnable = uci.get_first('smartdns', 'smartdns', 'ui') || "0";
var uiPort = uci.get_first('smartdns', 'smartdns', 'ui_port') || "6080";
if (isRunning) {
renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>";
if (uiEnable === '1') {
var uiLink = "http://" + window.location.hostname + ":" + uiPort + "/";
renderHTML += "<a class=\"cbi-button cbi-button-action\" style=\"margin-left: 10px;\" href=\"" + uiLink + "\" target=\"_blank\">" + _("Open the WebUI") + "</a>";
}
} else {
renderHTML += "<span style=\"color:red;font-weight:bold\">SmartDNS - " + _("NOT RUNNING") + "</span>";
if (smartdnsEnable === '1') {
@ -84,17 +92,28 @@ function smartdnsRenderStatus(res) {
return renderHTML;
}
function isSmartdnsUiAvailable() {
return fs.stat('/usr/lib/libsmartdns_ui.so').then(function (res) {
return res && res.type === 'file';
}).catch(function () {
return false;
});
}
return view.extend({
load: function () {
return Promise.all([
uci.load('dhcp'),
uci.load('smartdns'),
isSmartdnsUiAvailable()
]);
},
render: function (stats) {
var m, s, o;
var ss, so;
var servers, download_files;
var hasUi = stats[2];
m = new form.Map('smartdns', _('SmartDNS'));
m.title = _("SmartDNS Server");
@ -166,6 +185,31 @@ return view.extend({
o.rmempty = false;
o.default = o.enabled;
//WebUI
if (hasUi) {
o = s.taboption("settings", form.Flag, "ui", _("Enable WebUI"), _("Enable or disable smartdns webui plugin."));
o.rmempty = false;
o.default = o.disabled;
o = s.taboption("settings", form.Value, "ui_port", _("WebUI Port"), _("WebUI server port."));
o.placeholder = 6080;
o.datatype = "port";
o.rempty = false;
o.depends('ui', '1');
o = s.taboption("settings", form.Value, "ui_data_dir", _("WebUI Data Dir"), _("Directory for storing the webui database."));
o.placeholder = "/var/lib/smartdns";
o.datatype = "string";
o.rempty = false;
o.depends('ui', '1');
o = s.taboption("settings", form.Value, "ui_log_max_age", _("WebUI Log Retention"), _("Number of days to retain webui logs."));
o.placeholder = 30;
o.datatype = "uinteger";
o.rempty = false;
o.depends('ui', '1');
}
///////////////////////////////////////
// advanced settings;
///////////////////////////////////////

File diff suppressed because it is too large Load diff