mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-13 14:10:59 +00:00
luci-app: updated log.
This commit is contained in:
@@ -11,7 +11,7 @@ LUCI_APP=1
|
||||
OWRT_VERSION="current"
|
||||
RUAB_VERSION="1.4-1"
|
||||
RUAB_MOD_LUA_VERSION="1.4-0"
|
||||
RUAB_LUCI_APP_VERSION="1.4-1"
|
||||
RUAB_LUCI_APP_VERSION="1.4-2"
|
||||
BASE_URL="https://raw.githubusercontent.com/gSpotx2f/packages-openwrt/master"
|
||||
PKG_DIR="/tmp"
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#
|
||||
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=1.4-1
|
||||
PKG_VERSION:=1.4-2
|
||||
LUCI_TITLE:=LuCI support for ruantiblock
|
||||
LUCI_DEPENDS:=+ruantiblock
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
@@ -34,6 +34,11 @@ document.head.append(E('style', {'type': 'text/css'},
|
||||
--app-log-debug: #5986b1;
|
||||
--app-log-entries-count-border: #555;
|
||||
}
|
||||
#logWrapper {
|
||||
overflow: auto !important;
|
||||
width: 100%;
|
||||
min-height: 20em';
|
||||
}
|
||||
.log-empty {
|
||||
}
|
||||
.log-emerg {
|
||||
@@ -137,6 +142,8 @@ log-emerg td {
|
||||
position: fixed;
|
||||
z-index: 1 !important;
|
||||
opacity: 0.7;
|
||||
right: 1px;
|
||||
top: 40vh;
|
||||
}
|
||||
.log-side-btn {
|
||||
position: relative;
|
||||
@@ -881,8 +888,7 @@ return baseclass.extend({
|
||||
this.pollFuncWrapper = L.bind(this.pollFunc, this);
|
||||
|
||||
this.logWrapper = E('div', {
|
||||
'id' : 'logWrapper',
|
||||
'style': 'width:100%; min-height:20em'
|
||||
'id': 'logWrapper',
|
||||
}, this.makeLogArea(this.parseLogData(logdata, this.tailValue)));
|
||||
|
||||
this.fastTailValue = this.tailValue
|
||||
@@ -1045,7 +1051,6 @@ return baseclass.extend({
|
||||
E('div', {
|
||||
'align': 'right',
|
||||
'class': 'log-side-block',
|
||||
'style': `right:1px; top:${window.innerHeight / 2 - 60}px`,
|
||||
}, [
|
||||
this.refreshBtn,
|
||||
this.moreEntriesBtn,
|
||||
|
||||
@@ -5,34 +5,24 @@
|
||||
|
||||
document.head.append(E('style', {'type': 'text/css'},
|
||||
`
|
||||
.log-entry-empty {
|
||||
#logTable {
|
||||
width: calc(100% - 4px);
|
||||
}
|
||||
.log-entry-number {
|
||||
min-width: 4em !important;
|
||||
}
|
||||
.log-entry-time {
|
||||
min-width: 15em !important;
|
||||
}
|
||||
.log-entry-host {
|
||||
min-width: 10em !important;
|
||||
.log-entry-time-cell {
|
||||
min-width: 14em !important;
|
||||
}
|
||||
.log-entry-host-cell {
|
||||
word-break: break-all !important;
|
||||
word-wrap: break-word !important;
|
||||
}
|
||||
.log-entry-log-level {
|
||||
max-width: 5em !important;
|
||||
}
|
||||
.log-entry-facility{
|
||||
max-width: 7em !important;
|
||||
}
|
||||
.log-entry-message {
|
||||
min-width: 25em !important;
|
||||
min-width: 10em !important;
|
||||
overflow-wrap: anywhere !important;
|
||||
}
|
||||
.log-entry-message-cell {
|
||||
overflow-x: hidden !important;
|
||||
text-overflow: ellipsis !important;
|
||||
min-width: 20em !important;
|
||||
white-space: pre-wrap !important;
|
||||
overflow-wrap: anywhere !important;
|
||||
}
|
||||
.log-entry-text-nowrap {
|
||||
white-space: nowrap !important;
|
||||
};
|
||||
`));
|
||||
|
||||
return baseclass.extend({
|
||||
@@ -43,7 +33,7 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
makeLogArea(logdataArray) {
|
||||
let lines = `<tr class="tr"><td class="td center log-entry-empty">${_('No entries available...')}</td></tr>`;
|
||||
let lines = `<tr class="tr"><td class="td center">${_('No entries available...')}</td></tr>`;
|
||||
let logTable = E('table', { 'id': 'logTable', 'class': 'table' });
|
||||
|
||||
for(let level of Object.keys(this.logLevels)) {
|
||||
@@ -56,27 +46,30 @@ return baseclass.extend({
|
||||
if(e[4] in this.logLevels) {
|
||||
this.logLevelsStat[e[4]] = this.logLevelsStat[e[4]] + 1;
|
||||
};
|
||||
|
||||
lines.push(
|
||||
`<tr class="tr log-${e[4] || 'empty'}"><td class="td left" data-title="#">${e[0]}</td>` +
|
||||
((e[1]) ? `<td class="td left" data-title="${_('Timestamp')}">${e[1]}</td>` : '') +
|
||||
`<tr class="tr log-${e[4] || 'empty'}"><td class="td left log-entry-text-nowrap" data-title="#">${e[0]}</td>` +
|
||||
((e[1]) ? `<td class="td left log-entry-time-cell" data-title="${_('Timestamp')}">${e[1]}</td>` : '') +
|
||||
((e[2]) ? `<td class="td left log-entry-host-cell" data-title="${_('Host')}">${e[2]}</td>` : '') +
|
||||
((e[3]) ? `<td class="td left" data-title="${_('Facility')}">${e[3]}</td>` : '') +
|
||||
((e[4]) ? `<td class="td left" data-title="${_('Level')}">${e[4]}</td>` : '') +
|
||||
((e[3]) ? `<td class="td left log-entry-text-nowrap" data-title="${_('Facility')}">${e[3]}</td>` : '') +
|
||||
((e[4]) ? `<td class="td left log-entry-text-nowrap" data-title="${_('Level')}">${e[4]}</td>` : '') +
|
||||
((e[5]) ? `<td class="td left log-entry-message-cell" data-title="${_('Message')}">${e[5]}</td>` : '') +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
lines = lines.join('');
|
||||
|
||||
logTable.append(
|
||||
E('tr', { 'class': 'tr table-titles' }, [
|
||||
E('th', { 'class': 'th left log-entry-number' }, '#'),
|
||||
(logdataArray[0][1]) ? E('th', { 'class': 'th left log-entry-time' }, _('Timestamp')) : '',
|
||||
(logdataArray[0][2]) ? E('th', { 'class': 'th left log-entry-host' }, _('Host')) : '',
|
||||
(logdataArray[0][3]) ? E('th', { 'class': 'th left log-entry-facility' }, _('Facility')) : '',
|
||||
(logdataArray[0][4]) ? E('th', { 'class': 'th left log-entry-log-level' }, _('Level')) : '',
|
||||
(logdataArray[0][5]) ? E('th', { 'class': 'th left log-entry-message' }, _('Message')) : '',
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, '#'),
|
||||
(logdataArray[0][1]) ?
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Timestamp')) : '',
|
||||
(logdataArray[0][2]) ?
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Host')) : '',
|
||||
(logdataArray[0][3]) ?
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Facility')) : '',
|
||||
(logdataArray[0][4]) ?
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Level')) : '',
|
||||
(logdataArray[0][5]) ?
|
||||
E('th', { 'class': 'th left log-entry-text-nowrap' }, _('Message')) : '',
|
||||
])
|
||||
);
|
||||
};
|
||||
|
||||
@@ -9,40 +9,44 @@ return abc.view.extend({
|
||||
|
||||
title : _('Ruantiblock') + ' - ' + _('Log'),
|
||||
|
||||
testRegexp : new RegExp(/([0-9]{2}:){2}[0-9]{2}/),
|
||||
logdRegexp : new RegExp(/^([^\s]{3}\s+[^\s]{3}\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2}\s+\d{4})\s+([a-z]+)\.([a-z]+)\s+(.*)$/),
|
||||
|
||||
syslog_ngRegexp: new RegExp(/^([^\s]{3}\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2})\s+([^\s]+)\s+(.*)$/),
|
||||
|
||||
entryRegexp : null,
|
||||
|
||||
isLoggerChecked: false,
|
||||
|
||||
entriesHandler : null,
|
||||
|
||||
logger : null,
|
||||
|
||||
getLogHash : null,
|
||||
|
||||
// logd
|
||||
logdHandler(strArray, lineNum) {
|
||||
let logLevel = strArray[5].split('.');
|
||||
return [
|
||||
lineNum, // # (Number)
|
||||
strArray.slice(0, 5).join(' '), // Timestamp (String)
|
||||
null, // Host (String)
|
||||
logLevel[0], // Facility (String)
|
||||
logLevel[1], // Level (String)
|
||||
this.htmlEntities(strArray.slice(6).join(' ')), // Message (String)
|
||||
lineNum, // # (Number)
|
||||
strArray[1], // Timestamp (String)
|
||||
null, // Host (String)
|
||||
strArray[2], // Facility (String)
|
||||
strArray[3], // Level (String)
|
||||
this.htmlEntities(strArray[4]) || ' ', // Message (String)
|
||||
];
|
||||
},
|
||||
|
||||
// syslog-ng
|
||||
syslog_ngHandler(strArray, lineNum) {
|
||||
if(!(strArray[3] in this.logHosts)) {
|
||||
this.logHosts[strArray[3]] = this.makeLogHostsDropdownItem(strArray[3]);
|
||||
if(!(strArray[2] in this.logHosts)) {
|
||||
this.logHosts[strArray[2]] = this.makeLogHostsDropdownItem(strArray[2]);
|
||||
};
|
||||
|
||||
return [
|
||||
lineNum, // # (Number)
|
||||
strArray.slice(0, 3).join(' '), // Timestamp (String)
|
||||
strArray[3], // Host (String)
|
||||
null, // Facility (String)
|
||||
null, // Level (String)
|
||||
this.htmlEntities(strArray.slice(4).join(' ')), // Message (String)
|
||||
lineNum, // # (Number)
|
||||
strArray[1], // Timestamp (String)
|
||||
strArray[2], // Host (String)
|
||||
null, // Facility (String)
|
||||
null, // Level (String)
|
||||
this.htmlEntities(strArray[3]) || ' ', // Message (String)
|
||||
];
|
||||
},
|
||||
|
||||
@@ -89,24 +93,16 @@ return abc.view.extend({
|
||||
this.totalLogLines = strings.length;
|
||||
|
||||
let entriesArray = strings.map((e, i) => {
|
||||
let strArray = e.split(/\s+/);
|
||||
|
||||
if(!this.isLoggerChecked) {
|
||||
/**
|
||||
* Checking the fourth field of a line.
|
||||
* If it contains time then logd.
|
||||
*/
|
||||
if(this.testRegexp.test(strArray[3])) {
|
||||
if(this.logdRegexp.test(e)) {
|
||||
this.entryRegexp = this.logdRegexp;
|
||||
this.isFacilities = true;
|
||||
this.isLevels = true;
|
||||
this.logHosts = {};
|
||||
this.entriesHandler = this.logdHandler;
|
||||
}
|
||||
/**
|
||||
* Checking the third field of a line.
|
||||
* If it contains time then syslog-ng.
|
||||
*/
|
||||
else if(this.testRegexp.test(strArray[2])) {
|
||||
else if(this.syslog_ngRegexp.test(e)) {
|
||||
this.entryRegexp = this.syslog_ngRegexp;
|
||||
this.isHosts = true;
|
||||
this.logFacilities = {};
|
||||
this.logLevels = {};
|
||||
@@ -118,7 +114,13 @@ return abc.view.extend({
|
||||
this.isLoggerChecked = true;
|
||||
};
|
||||
|
||||
return this.entriesHandler(strArray, i + 1);
|
||||
let strArray = e.match(this.entryRegexp);
|
||||
if(strArray) {
|
||||
return this.entriesHandler(strArray, i + 1);
|
||||
} else {
|
||||
unsupportedLog = true;
|
||||
return;
|
||||
};
|
||||
});
|
||||
|
||||
if(unsupportedLog) {
|
||||
@@ -127,7 +129,6 @@ return abc.view.extend({
|
||||
if(this.logSortingValue === 'desc') {
|
||||
entriesArray.reverse();
|
||||
};
|
||||
|
||||
return entriesArray;
|
||||
};
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# (с) 2023 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
# (с) 2024 gSpot (https://github.com/gSpotx2f/ruantiblock_openwrt)
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
Reference in New Issue
Block a user