From 4ee1ead2a809b537ee9b9bde12ee4432efcda880 Mon Sep 17 00:00:00 2001
From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com>
Date: Sun, 30 Nov 2025 22:27:23 -0800
Subject: [PATCH] New Features and Improvements
1) Added "Rotate All" and "Rotate Log" on the WebUI page.
2) Added "Clear All" and "Clear Log" on the WebUI page.
3) Added file size information for each log file.
---
Main_LogStatus_Content.asp | 29 +-
Main_LogStatus_Content.js | 550 +++++++++++++++++++++++++++++--------
README.md | 2 +-
uiScribe.sh | 468 ++++++++++++++++++++++++++++---
4 files changed, 881 insertions(+), 168 deletions(-)
diff --git a/Main_LogStatus_Content.asp b/Main_LogStatus_Content.asp
index 656855a..74b45b5 100644
--- a/Main_LogStatus_Content.asp
+++ b/Main_LogStatus_Content.asp
@@ -25,15 +25,16 @@ p{font-weight:bolder}thead.collapsible-jquery{color:#fff;padding:0;width:100%;bo
@@ -185,14 +186,18 @@ var clockinterval,bootinterval,timeoutsenabled=!0;function showclock(){JS_timeOb
@@ -200,13 +205,17 @@ var clockinterval,bootinterval,timeoutsenabled=!0;function showclock(){JS_timeOb
diff --git a/Main_LogStatus_Content.js b/Main_LogStatus_Content.js
index fe477fd..dd98480 100644
--- a/Main_LogStatus_Content.js
+++ b/Main_LogStatus_Content.js
@@ -1,7 +1,15 @@
+/**----------------------------**/
+/** Last Modified: 2025-Nov-30 **/
+/**----------------------------**/
+
var timeoutsenabled = true;
var clockinterval;
var bootinterval;
+let logFileInfoListInterval = null;
+let isInitialLoading = false;
+
+var logRotate_InfoListArray = [];
function showclock()
{
@@ -21,7 +29,8 @@ function showclock()
document.getElementById('log_messages').style.width = '99%';
}
-function showbootTime(){
+function showbootTime()
+{
Days = Math.floor(boottime / (60*60*24));
Hours = Math.floor((boottime / 3600) % 24);
Minutes = Math.floor(boottime % 3600 / 60);
@@ -33,25 +42,30 @@ function showbootTime(){
boottime += 1;
}
-function capitalise(string){
+function capitalise(string)
+{
return string.charAt(0).toUpperCase()+string.slice(1);
}
-function GetCookie(cookiename,returntype){
- if(cookie.get('uiscribe_'+cookiename) != null){
+function GetCookie(cookiename,returntype)
+{
+ if (cookie.get('uiscribe_'+cookiename) != null)
+ {
return cookie.get('uiscribe_'+cookiename);
}
- else{
- if(returntype == 'string'){
+ else
+ {
+ if (returntype == 'string'){
return '';
}
- else if(returntype == 'number'){
+ else if (returntype == 'number'){
return 0;
}
}
}
-function SetCookie(cookiename,cookievalue){
+function SetCookie(cookiename,cookievalue)
+{
cookie.set('uiscribe_'+cookiename,cookievalue,10*365);
}
@@ -67,30 +81,41 @@ $.fn.serializeObject = function(){
return o;
};
-function SetCurrentPage(){
+function SetCurrentPage()
+{
document.config_form.next_page.value = window.location.pathname.substring(1);
document.config_form.current_page.value = window.location.pathname.substring(1);
}
-function initial(){
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-28] **/
+/**----------------------------------------**/
+function initial()
+{
+ isInitialLoading = true;
SetCurrentPage();
LoadCustomSettings();
ScriptUpdateLayout();
+ GetLogRotateInfoList();
+ setTimeout(GetLogFileInfoList, 7000);
show_menu();
showclock();
showbootTime();
clockinterval = setInterval(showclock,1000);
bootinterval = setInterval(showbootTime,1000);
showDST();
- get_conf_file();
+ GetLogsUserTable();
+ logFileInfoListInterval = setInterval(GetLogFileInfoList,180000);
}
-function ScriptUpdateLayout(){
+function ScriptUpdateLayout()
+{
var localver = GetVersionNumber('local');
var serverver = GetVersionNumber('server');
$('#uiscribe_version_local').text(localver);
- if(localver != serverver && serverver != 'N/A'){
+ if (localver != serverver && serverver != 'N/A')
+ {
$('#uiscribe_version_server').text('Updated version available: '+serverver);
showhide('btnChkUpdate',false);
showhide('uiscribe_version_server',true);
@@ -98,133 +123,175 @@ function ScriptUpdateLayout(){
}
}
-function reload(){
+function reload()
+{
location.reload(true);
}
-function get_logfile(filename){
- var filenamesafe = filename.replace('.log','');
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-30] **/
+/**----------------------------------------**/
+function get_logfile(fileName)
+{
+ let fileNameShort = fileName.replace('.log','');
+
$.ajax({
- url: '/ext/uiScribe/'+filename+'.htm',
+ url: '/ext/uiScribe/'+fileName+'.htm',
dataType: 'text',
timeout: 3000,
- error: function(xhr){
- if(timeoutsenabled == true && window['timeoutenabled_'+filenamesafe] == true){
- window['timeout_'+filenamesafe] = setTimeout(get_logfile,2000,filename);
+ error: function(xhr)
+ {
+ if (timeoutsenabled == true && window['timeoutenabled_'+fileNameShort] == true)
+ {
+ window['timeout_'+fileNameShort] = setTimeout(get_logfile,2000,fileName);
}
},
- success: function(data){
- if(timeoutsenabled == true && window['timeoutenabled_'+filenamesafe] == true){
- if(filename != 'messages'){
- if(data.length > 0){
- document.getElementById('log_'+filename.substring(0,filename.indexOf('.'))).innerHTML = data;
- if(document.getElementById('auto_scroll').checked){
- $('#log_'+filename.substring(0,filename.indexOf('.'))).scrollTop(9999999);
+ success: function(data)
+ {
+ let logFileDataElem = document.getElementById('log_'+fileNameShort);
+
+ if (timeoutsenabled == true && window['timeoutenabled_'+fileNameShort] == true)
+ {
+ if (data.length === 0)
+ {
+ logFileDataElem.innerHTML = '*** The log file is either empty or does not yet exist ***';
+ }
+ if (fileName != 'messages')
+ {
+ if (data.length > 0)
+ {
+ logFileDataElem.innerHTML = data;
+ if (document.getElementById('auto_scroll').checked)
+ {
+ $('#log_'+fileNameShort).scrollTop(9999999);
}
}
}
- else{
- if(data.length > 0){
- document.getElementById('log_'+filename).innerHTML = data;
- if(document.getElementById('auto_scroll').checked){
- $('#log_'+filename).scrollTop(9999999);
+ else
+ {
+ if (data.length > 0)
+ {
+ logFileDataElem.innerHTML = data;
+ if (document.getElementById('auto_scroll').checked)
+ {
+ $('#log_'+fileName).scrollTop(9999999);
}
}
}
- window['timeout_'+filenamesafe] = setTimeout(get_logfile,3000,filename);
+ window['timeout_'+fileNameShort] = setTimeout(get_logfile,3000,fileName);
}
}
});
}
-function get_conf_file(){
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-28] **/
+/**----------------------------------------**/
+function GetLogsUserTable()
+{
$.ajax({
- url: '/ext/uiScribe/logs.htm',
+ url: '/ext/uiScribe/logs_user.htm',
timeout: 2000,
dataType: 'text',
- error: function(xhr){
- setTimeout(get_conf_file,1000);
+ error: function(xhr)
+ {
+ setTimeout(GetLogsUserTable,2000);
},
- success: function(data){
- var logs=data.split('\n');
- logs.sort();
- logs=logs.filter(Boolean);
-
+ success: function(data)
+ {
+ var logFiles = data.split('\n');
+ logFiles.sort();
+ logFiles = logFiles.filter(Boolean);
+
var logconfigtablehtml='| Logs to display in WebUI | ';
-
- for(var i = 0; i < logs.length; i++){
- var filename=logs[i].substring(logs[i].lastIndexOf('/')+1);
- if(filename.indexOf('#') != -1){
- filename = filename.substring(0,filename.indexOf('#')).replace('.log','').replace('.htm','').trim();
- logconfigtablehtml += '';
- logconfigtablehtml += '';
+
+ for (var i = 0; i < logFiles.length; i++)
+ {
+ var fileName = logFiles[i].substring(logFiles[i].lastIndexOf('/')+1);
+ if (fileName.indexOf('#') != -1)
+ {
+ fileName = fileName.substring(0,fileName.indexOf('#')).replace('.log','').replace('.htm','').trim();
+ logconfigtablehtml += '';
+ logconfigtablehtml += '';
}
- else{
- filename = filename.replace(".log","").replace(".htm","").trim();
- logconfigtablehtml += '';
- logconfigtablehtml += '';
+ else
+ {
+ fileName = fileName.replace(".log","").replace(".htm","").trim();
+ logconfigtablehtml += '';
+ logconfigtablehtml += '';
}
- if((i+1) % 4 == 0){
+ if ((i+1) % 4 == 0)
+ {
logconfigtablehtml += ' ';
}
}
-
+
logconfigtablehtml += ' |
';
logconfigtablehtml += '';
logconfigtablehtml += '| ';
logconfigtablehtml += '';
logconfigtablehtml += ' |
';
$('#table_config').append(logconfigtablehtml);
- logs.reverse();
-
- for(var i = 0; i < logs.length; i++){
- var commentstart=logs[i].indexOf('#');
- if(commentstart != -1){
- continue
- }
- filename=logs[i].substring(logs[i].lastIndexOf('/')+1);
- $('#table_messages').after(BuildLogTable(filename));
+ logFiles.reverse();
+
+ for (var i = 0; i < logFiles.length; i++)
+ {
+ var commentstart = logFiles[i].indexOf('#');
+ if (commentstart != -1) { continue; }
+ fileName = logFiles[i].substring(logFiles[i].lastIndexOf('/')+1);
+ $('#table_messages').after(BuildLogTable(fileName));
}
-
+
+ let logFileInfoStr = GetLogFileSizeInfo('messages');
+ document.getElementById('fileTitle_messages').innerHTML = logFileInfoStr + '  (click to show/hide)'
AddEventHandlers();
+ isInitialLoading = false;
}
});
}
-function DownloadAllLogFile(){
+function DownloadAllLogFiles()
+{
$('.btndownload').each(function(index){$(this).trigger('click');});
}
-function DownloadLogFile(btnlog){
- $(btnlog).prop('disabled',true);
- $(btnlog).addClass('btndisabled');
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-28] **/
+/**----------------------------------------**/
+function DownloadLogFile(btnLog)
+{
+ $(btnLog).prop('disabled',true);
+ $(btnLog).addClass('btndisabled');
var filepath = '';
- if(btnlog.name == 'btnmessages'){
+ if (btnLog.name === 'btnDownload_messages')
+ {
filepath='/ext/uiScribe/messages.htm';
}
- else{
- filepath='/ext/uiScribe/'+btnlog.name.replace('btn','')+'.log.htm';
+ else
+ {
+ filepath='/ext/uiScribe/'+btnLog.name.replace('btnDownload_','')+'.log.htm';
}
fetch(filepath).then(resp => resp.blob()).then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
- a.download = btnlog.name.replace('btn','')+'.log';
+ a.download = btnLog.name.replace('btnDownload_','')+'.log';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
- $(btnlog).prop('disabled',false);
- $(btnlog).removeClass('btndisabled');
+ $(btnLog).prop('disabled',false);
+ $(btnLog).removeClass('btndisabled');
})
.catch(() => {
console.log('File download failed!');
- $(btnlog).prop('disabled',false);
- $(btnlog).removeClass('btndisabled');
+ $(btnLog).prop('disabled',false);
+ $(btnLog).removeClass('btndisabled');
});
}
-function update_status(){
+function update_status()
+{
$.ajax({
url: '/ext/uiScribe/detect_update.js',
dataType: 'script',
@@ -232,19 +299,24 @@ function update_status(){
error: function(xhr){
setTimeout(update_status,1000);
},
- success: function(){
- if(updatestatus == 'InProgress'){
+ success: function()
+ {
+ if (updatestatus == 'InProgress')
+ {
setTimeout(update_status,1000);
}
- else{
+ else
+ {
document.getElementById('imgChkUpdate').style.display = 'none';
showhide('uiscribe_version_server',true);
- if(updatestatus != 'None'){
+ if (updatestatus != 'None')
+ {
$('#uiscribe_version_server').text('Updated version available: '+updatestatus);
showhide('btnChkUpdate',false);
showhide('btnDoUpdate',true);
}
- else{
+ else
+ {
$('#uiscribe_version_server').text('No update available');
showhide('btnChkUpdate',true);
showhide('btnDoUpdate',false);
@@ -254,7 +326,103 @@ function update_status(){
});
}
-function CheckUpdate(){
+var logRotateStatus = '';
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function Update_LogRotate_Status(logObj)
+{
+ $.ajax({
+ url: '/ext/uiScribe/logRotateStatus.js',
+ dataType: 'script',
+ timeout: 3000,
+ error: function(xhr){
+ setTimeout(Update_LogRotate_Status,1000,logObj);
+ },
+ success: function()
+ {
+ let theStatus = '';
+ if (logRotateStatus === 'InProgress')
+ {
+ setTimeout(Update_LogRotate_Status,2000,logObj);
+ }
+ else if (logRotateStatus === 'ERROR')
+ {
+ theStatus = logRotateStatus;
+ }
+ else if (logRotateStatus === 'DONE')
+ {
+ theStatus = logRotateStatus;
+ }
+ $(logObj).prop('disabled',false);
+ $(logObj).removeClass('btndisabled');
+ document.getElementById(logObj.id).style.display = '';
+ document.getElementById('imgChkUpdate').style.display = 'none';
+ }
+ });
+}
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function RotateLogFile(logObj, logFileName)
+{
+ if (typeof logFileInfoListInterval !== 'undefined' && logFileInfoListInterval !== null)
+ {
+ clearInterval(logFileInfoListInterval);
+ logFileInfoListInterval = null;
+ }
+
+ $(logObj).prop('disabled',true);
+ $(logObj).addClass('btndisabled');
+
+ let waitValue = 30;
+ if (logFileName === 'ALL')
+ {
+ if (logRotate_InfoListArray.length > 5)
+ { waitValue = 60; }
+ else
+ { waitValue = 45; }
+ }
+ let actionScriptVal = 'start_uiScribeRotateLog_' + logFileName;
+ document.config_form.action_script.value = actionScriptVal;
+ document.config_form.action_wait.value = waitValue;
+ showLoading();
+ document.config_form.submit();
+}
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function ClearLogFile(logObj, logFileName)
+{
+ if (typeof logFileInfoListInterval !== 'undefined' && logFileInfoListInterval !== null)
+ {
+ clearInterval(logFileInfoListInterval);
+ logFileInfoListInterval = null;
+ }
+
+ $(logObj).prop('disabled',true);
+ $(logObj).addClass('btndisabled');
+
+ let waitValue = 30;
+ if (logFileName === 'ALL')
+ {
+ if (logRotate_InfoListArray.length > 5)
+ { waitValue = 60; }
+ else
+ { waitValue = 45; }
+ }
+ let actionScriptVal = 'start_uiScribeClearLog_' + logFileName;
+ document.config_form.action_script.value = actionScriptVal;
+ document.config_form.action_wait.value = waitValue;
+ showLoading();
+ document.config_form.submit();
+}
+
+function CheckUpdate()
+{
showhide('btnChkUpdate',false);
document.formScriptActions.action_script.value='start_uiScribecheckupdate';
document.formScriptActions.submit();
@@ -262,14 +430,25 @@ function CheckUpdate(){
setTimeout(update_status,2000);
}
-function DoUpdate(){
+function DoUpdate()
+{
document.config_form.action_script.value = 'start_uiScribedoupdate';
document.config_form.action_wait.value = 10;
showLoading();
document.config_form.submit();
}
-function SaveConfig(){
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-28] **/
+/**----------------------------------------**/
+function SaveConfig()
+{
+ if (typeof logFileInfoListInterval !== 'undefined' && logFileInfoListInterval !== null)
+ {
+ clearInterval(logFileInfoListInterval);
+ logFileInfoListInterval = null;
+ }
+
document.getElementById('amng_custom').value = JSON.stringify($('config_form').serializeObject());
document.config_form.action_script.value = 'start_uiScribeconfig';
document.config_form.action_wait.value = 5;
@@ -277,16 +456,17 @@ function SaveConfig(){
document.config_form.submit();
}
-function GetVersionNumber(versiontype){
+function GetVersionNumber(versiontype)
+{
var versionprop;
- if(versiontype == 'local'){
+ if (versiontype == 'local'){
versionprop = custom_settings.uiscribe_version_local;
}
- else if(versiontype == 'server'){
+ else if (versiontype == 'server'){
versionprop = custom_settings.uiscribe_version_server;
}
- if(typeof versionprop == 'undefined' || versionprop == null){
+ if (typeof versionprop == 'undefined' || versionprop == null){
return 'N/A';
}
else{
@@ -294,34 +474,155 @@ function GetVersionNumber(versiontype){
}
}
-function BuildLogTable(name){
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function GetLogRotateInfoList()
+{
+ $.ajax({
+ url: '/ext/uiScribe/logRotateInfoList.js',
+ dataType: 'script',
+ timeout: 1000,
+ error: function(xhr){
+ setTimeout(GetLogRotateInfoList, 1000);
+ },
+ success: function()
+ {
+ if (logRotate_InfoListArray.length === 0)
+ { return false; }
+ if (isInitialLoading) { return true; }
+ SetLogFileSizeInfo();
+ }
+ });
+}
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function GetLogFileInfoList()
+{
+ document.formScriptActions.action_script.value='start_uiScribeLogFileInfoList';
+ document.formScriptActions.submit();
+ setTimeout(GetLogRotateInfoList,3000);
+}
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function SetLogFileSizeInfo()
+{
+ $.ajax({
+ url: '/ext/uiScribe/logs_user.htm',
+ timeout: 2000,
+ dataType: 'text',
+ error: function(xhr)
+ {
+ setTimeout(SetLogFileSizeInfo,2000);
+ },
+ success: function(data)
+ {
+ let logFileName, fileNameShort, logFileTitleElem, logFileInfoStr;
+ let logFiles = data.split('\n');
+ logFiles.sort();
+ logFiles = logFiles.filter(Boolean);
+
+ for (var indx = 0; indx < logFiles.length; indx++)
+ {
+ var commentstart = logFiles[indx].indexOf('#');
+ if (commentstart != -1) { continue; }
+ logFileName = logFiles[indx].substring(logFiles[indx].lastIndexOf('/')+1);
+ fileNameShort = logFileName.replace('.log','');
+
+ logFileTitleElem = document.getElementById('fileTitle_' + fileNameShort);
+ if (typeof logFileTitleElem !== 'undefined' && logFileTitleElem !== null)
+ {
+ logFileInfoStr = GetLogFileSizeInfo(logFileName);
+ logFileTitleElem.innerHTML = logFileInfoStr + '  (click to show/hide)'
+ }
+ }
+
+ logFileTitleElem = document.getElementById('fileTitle_messages');
+ if (typeof logFileTitleElem !== 'undefined' && logFileTitleElem !== null)
+ {
+ logFileInfoStr = GetLogFileSizeInfo('messages');
+ logFileTitleElem.innerHTML = logFileInfoStr + '  (click to show/hide)'
+ }
+ }
+ });
+}
+
+/**-------------------------------------**/
+/** Added by Martinski W. [2025-Nov-28] **/
+/**-------------------------------------**/
+function GetLogFileSizeInfo(theFileName)
+{
+ let logFilePath, logFileSize, logFileName, logFileInfoStr;
+ let fileSizeOK = false;
+
+ for (var indx = 0; indx < logRotate_InfoListArray.length; indx++)
+ {
+ logFilePath = logRotate_InfoListArray[indx].LOG_PATH0;
+ logFileSize = logRotate_InfoListArray[indx].LOG_SIZE0;
+ logFileName = logFilePath.replace('/opt/var/log/','');
+ if (logFileName === theFileName)
+ { fileSizeOK = true; break; }
+ }
+
+ if (logFileSize === '' || !fileSizeOK)
+ { logFileInfoStr = theFileName; }
+ else
+ { logFileInfoStr = theFileName + ' [' + logFileSize + ']'; }
+
+ return logFileInfoStr;
+}
+
+/**----------------------------------------**/
+/** Modified by Martinski W. [2025-Nov-28] **/
+/**----------------------------------------**/
+function BuildLogTable(logFileName)
+{
+ let logFileInfoStr = GetLogFileSizeInfo(logFileName);
+ let fileNameShort = logFileName.substring(0,logFileName.indexOf('.'));
+
var loghtml = '
';
- loghtml += '