mirror of
https://github.com/openwrt/luci.git
synced 2026-04-15 10:51:51 +00:00
luci-app-adblock: update 4.5.3-3
* sync with base package Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
@@ -7,7 +7,7 @@ LUCI_TITLE:=LuCI support for Adblock
|
||||
LUCI_DEPENDS:=+luci-base +luci-lib-uqr +adblock
|
||||
|
||||
PKG_VERSION:=4.5.3
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||
|
||||
|
||||
@@ -88,9 +88,9 @@ function handleAction(ev) {
|
||||
document.getElementById('allowlist').focus();
|
||||
}
|
||||
|
||||
if (ev === 'query') {
|
||||
ui.showModal(_('Blocklist Query'), [
|
||||
E('p', _('Query active blocklists and backups for a specific domain.')),
|
||||
if (ev === 'search') {
|
||||
ui.showModal(_('Blocklist Search'), [
|
||||
E('p', _('Search active blocklists and backups for a specific domain.')),
|
||||
E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
|
||||
E('label', { 'style': 'padding-top:.5em', 'id': 'run' }, [
|
||||
E('input', {
|
||||
@@ -126,21 +126,37 @@ function handleAction(ev) {
|
||||
if (domain) {
|
||||
document.getElementById('run').classList.add("spinning");
|
||||
document.getElementById('search').value = domain;
|
||||
document.getElementById('result').textContent = 'The query is running, please wait...';
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['query', domain])).then(function (res) {
|
||||
const result = document.getElementById('result');
|
||||
if (res) {
|
||||
result.textContent = res.trim();
|
||||
} else {
|
||||
result.textContent = _('No Query results!');
|
||||
}
|
||||
document.getElementById('run').classList.remove("spinning");
|
||||
document.getElementById('search').value = '';
|
||||
document.getElementById('result').textContent = _('The search is running, please wait...');
|
||||
|
||||
if (window._adbSearchPoller) {
|
||||
clearInterval(window._adbSearchPoller);
|
||||
window._adbSearchPoller = null;
|
||||
}
|
||||
L.resolveDefault(fs.write('/var/run/adblock.search', ''), '').then(function () {
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['search', domain]), '');
|
||||
let attempts = 0;
|
||||
window._adbSearchPoller = setInterval(function () {
|
||||
attempts++;
|
||||
L.resolveDefault(fs.read('/var/run/adblock.search'), '').then(function (res) {
|
||||
if (res && res.trim()) {
|
||||
clearInterval(window._adbSearchPoller);
|
||||
window._adbSearchPoller = null;
|
||||
document.getElementById('result').textContent = res.trim();
|
||||
document.getElementById('run').classList.remove("spinning");
|
||||
document.getElementById('search').value = '';
|
||||
} else if (attempts >= 40) {
|
||||
clearInterval(window._adbSearchPoller);
|
||||
window._adbSearchPoller = null;
|
||||
document.getElementById('result').textContent = _('No Search results!');
|
||||
document.getElementById('run').classList.remove("spinning");
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
document.getElementById('search').focus();
|
||||
})
|
||||
}, _('Query'))
|
||||
}, _('Search'))
|
||||
])
|
||||
]);
|
||||
document.getElementById('search').focus();
|
||||
@@ -197,10 +213,27 @@ function handleAction(ev) {
|
||||
const top_count = document.getElementById('top_count').value;
|
||||
const res_count = document.getElementById('res_count').value;
|
||||
const search = document.getElementById('search').value.trim().replace(/[^\w.\-:]/g, '') || '+';
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['report', 'gen', top_count, res_count, search]), '')
|
||||
.then(function () {
|
||||
location.reload();
|
||||
});
|
||||
L.resolveDefault(fs.write('/var/run/adblock.report', ''), '').then(function () {
|
||||
L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['report', 'gen', top_count, res_count, search]), '');
|
||||
let attempts = 0;
|
||||
let poller = setInterval(function () {
|
||||
attempts++;
|
||||
L.resolveDefault(fs.read('/var/run/adblock.report'), '').then(function (res) {
|
||||
if (res && res.trim()) {
|
||||
clearInterval(poller);
|
||||
ui.hideModal();
|
||||
location.reload();
|
||||
} else if (attempts >= 40) {
|
||||
clearInterval(poller);
|
||||
document.querySelectorAll('.cbi-page-actions button').forEach(function (btn) {
|
||||
btn.disabled = false;
|
||||
});
|
||||
document.getElementById('refresh').classList.remove('spinning');
|
||||
ui.addNotification(null, E('p', _('Failed to generate adblock report!')), 'error');
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
}, _('Refresh'))
|
||||
])
|
||||
@@ -420,11 +453,11 @@ return view.extend({
|
||||
E('button', {
|
||||
'class': 'btn cbi-button cbi-button-apply',
|
||||
'style': 'float:none;margin-right:.4em;',
|
||||
'title': 'Blocklist Query',
|
||||
'title': 'Blocklist Search',
|
||||
'click': ui.createHandlerFn(this, function () {
|
||||
return handleAction('query');
|
||||
return handleAction('search');
|
||||
})
|
||||
}, [_('Blocklist Query...')]),
|
||||
}, [_('Blocklist Search...')]),
|
||||
E('button', {
|
||||
'class': 'btn cbi-button cbi-button-positive important',
|
||||
'style': 'float:none;margin-right:.4em;',
|
||||
|
||||
@@ -17,25 +17,15 @@ function Logview(logtag, name) {
|
||||
return callLogRead(1000, false, true).then(res => {
|
||||
const logEl = document.getElementById('logfile');
|
||||
if (!logEl) return;
|
||||
|
||||
const filtered = (res?.log ?? [])
|
||||
.filter(entry => !logtag || entry.msg.includes(logtag))
|
||||
.map(entry => {
|
||||
const d = new Date(entry.time * 1000);
|
||||
const date = d.toLocaleDateString([], {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
});
|
||||
const time = d.toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
});
|
||||
const d = new Date(entry.time);
|
||||
const pad = n => String(n).padStart(2, '0');
|
||||
const date = `${pad(d.getDate())}/${pad(d.getMonth() + 1)}/${d.getFullYear()}`;
|
||||
const time = `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||
return `[${date}-${time}] ${entry.msg}`;
|
||||
});
|
||||
|
||||
logEl.value = filtered.length > 0
|
||||
? filtered.join('\n')
|
||||
: _('No %s related logs yet!').format(name);
|
||||
|
||||
@@ -2,29 +2,74 @@
|
||||
"luci-app-adblock": {
|
||||
"description": "Grant access to LuCI app adblock",
|
||||
"write": {
|
||||
"uci": [ "adblock" ],
|
||||
"uci": [
|
||||
"adblock"
|
||||
],
|
||||
"file": {
|
||||
"/etc/adblock/*": [ "read", "write" ],
|
||||
"/etc/adblock/adblock.allowlist": [ "write" ],
|
||||
"/etc/adblock/adblock.blocklist": [ "write" ],
|
||||
"/etc/adblock/adblock.custom.feeds": [ "read", "write" ]
|
||||
"/etc/adblock/*": [
|
||||
"read"
|
||||
],
|
||||
"/etc/adblock/adblock.allowlist": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/etc/adblock/adblock.blocklist": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/etc/adblock/adblock.custom.feeds": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/var/run/adblock.search": [
|
||||
"read",
|
||||
"write"
|
||||
],
|
||||
"/var/run/adblock.report": [
|
||||
"read",
|
||||
"write"
|
||||
]
|
||||
}
|
||||
},
|
||||
"read": {
|
||||
"cgi-io": [ "exec" ],
|
||||
"cgi-io": [
|
||||
"exec"
|
||||
],
|
||||
"file": {
|
||||
"/var/run/adblock.pid": [ "read" ],
|
||||
"/var/run/adb_runtime.json": [ "read" ],
|
||||
"/etc/init.d/adblock reload": [ "exec" ],
|
||||
"/etc/init.d/adblock restart": [ "exec" ],
|
||||
"/etc/init.d/adblock suspend": [ "exec" ],
|
||||
"/etc/init.d/adblock resume": [ "exec" ],
|
||||
"/etc/init.d/adblock stop": [ "exec" ],
|
||||
"/etc/init.d/adblock report [a-z]* [0-9]* [0-9]* *": [ "exec" ],
|
||||
"/etc/init.d/adblock query *": [ "exec" ]
|
||||
"/var/run/adblock.pid": [
|
||||
"read"
|
||||
],
|
||||
"/var/run/adb_runtime.json": [
|
||||
"read"
|
||||
],
|
||||
"/etc/init.d/adblock reload": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock restart": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock suspend": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock resume": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock stop": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock report *": [
|
||||
"exec"
|
||||
],
|
||||
"/etc/init.d/adblock search *": [
|
||||
"exec"
|
||||
]
|
||||
},
|
||||
"uci": [ "adblock" ],
|
||||
"log": [ "read" ]
|
||||
"uci": [
|
||||
"adblock"
|
||||
],
|
||||
"log": [
|
||||
"read"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user