mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
- Added some javascript code for the search form
- Added background logik to read and display the filters in the search field in the index page
This commit is contained in:
parent
e87146c2d7
commit
2ef8e6811c
@ -49,6 +49,7 @@ $content['BUILDNUMBER'] = "0.1.101";
|
||||
$content['TITLE'] = "PhpLogCon - Release " . $content['BUILDNUMBER']; // Title of the Page
|
||||
$content['BASEPATH'] = $gl_root_path;
|
||||
$content['EXTRA_METATAGS'] = "";
|
||||
$content['EXTRA_JAVASCRIPT'] = "";
|
||||
// ---
|
||||
|
||||
function InitBasicPhpLogCon()
|
||||
|
85
index.php
85
index.php
@ -48,11 +48,96 @@ $content['uid_last'] = UID_UNKNOWN;
|
||||
|
||||
// Init Sorting variables
|
||||
$content['sorting'] = "";
|
||||
$content['searchstr'] = "";
|
||||
|
||||
//if ( isset($content['myserver']) )
|
||||
// $content['TITLE'] = "PhpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page
|
||||
//else
|
||||
$content['TITLE'] = "PhpLogCon :: Home";
|
||||
|
||||
// Read and process filters from search dialog!
|
||||
if ( isset($_POST['search']) && $_POST['search'] == $content['LN_SEARCH_PERFORMADVANCED'])
|
||||
{
|
||||
if ( isset($_POST['filter_datemode']) )
|
||||
{
|
||||
$filters['filter_datemode'] = intval($_POST['filter_datemode']);
|
||||
if ( $filters['filter_datemode'] == DATEMODE_RANGE )
|
||||
{
|
||||
// Read range values
|
||||
if ( isset($_POST['filter_daterange_from_year']) )
|
||||
$filters['filter_daterange_from_year'] = intval($_POST['filter_daterange_from_year']);
|
||||
if ( isset($_POST['filter_daterange_from_month']) )
|
||||
$filters['filter_daterange_from_month'] = intval($_POST['filter_daterange_from_month']);
|
||||
if ( isset($_POST['filter_daterange_from_day']) )
|
||||
$filters['filter_daterange_from_day'] = intval($_POST['filter_daterange_from_day']);
|
||||
if ( isset($_POST['filter_daterange_to_year']) )
|
||||
$filters['filter_daterange_to_year'] = intval($_POST['filter_daterange_to_year']);
|
||||
if ( isset($_POST['filter_daterange_to_month']) )
|
||||
$filters['filter_daterange_to_month'] = intval($_POST['filter_daterange_to_month']);
|
||||
if ( isset($_POST['filter_daterange_to_day']) )
|
||||
$filters['filter_daterange_to_day'] = intval($_POST['filter_daterange_to_day']);
|
||||
|
||||
// Append to searchstring
|
||||
$content['searchstr'] .= "datefrom:" . $filters['filter_daterange_from_year'] . "-" .
|
||||
$filters['filter_daterange_from_month'] . "-" .
|
||||
$filters['filter_daterange_from_day'] . "T00:00:00 ";
|
||||
$content['searchstr'] .= "dateto:" . $filters['filter_daterange_to_year'] . "-" .
|
||||
$filters['filter_daterange_to_month'] . "-" .
|
||||
$filters['filter_daterange_to_day'] . "T00:00:00 ";
|
||||
|
||||
}
|
||||
else if ( $filters['filter_datemode'] == DATEMODE_LASTX )
|
||||
{
|
||||
if ( isset($_POST['filter_daterange_last_x']) )
|
||||
{
|
||||
$filters['filter_daterange_last_x'] = intval($_POST['filter_daterange_last_x']);
|
||||
$content['searchstr'] .= "datefrom:" . $filters['filter_daterange_last_x'] . " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset($_POST['filter_facility']) && count($_POST['filter_facility']) < 18 ) // If we have more than 18 elements, this means all facilities are enabled
|
||||
{
|
||||
$tmpStr = "";
|
||||
foreach ($_POST['filter_facility'] as $tmpfacility)
|
||||
{
|
||||
if ( strlen($tmpStr) > 0 )
|
||||
$tmpStr .= ",";
|
||||
$tmpStr .= $tmpfacility;
|
||||
}
|
||||
$content['searchstr'] .= "facility:" . $tmpStr . " ";
|
||||
}
|
||||
|
||||
if ( isset($_POST['filter_severity']) && count($_POST['filter_facility']) < 7 ) // If we have more than 7 elements, this means all facilities are enabled)
|
||||
{
|
||||
$tmpStr = "";
|
||||
foreach ($_POST['filter_severity'] as $tmpfacility)
|
||||
{
|
||||
if ( strlen($tmpStr) > 0 )
|
||||
$tmpStr .= ",";
|
||||
$tmpStr .= $tmpfacility;
|
||||
}
|
||||
$content['searchstr'] .= "severity:" . $tmpStr . " ";
|
||||
}
|
||||
|
||||
// Spaces need to be converted!
|
||||
if ( isset($_POST['filter_syslogtag']) && strlen($_POST['filter_syslogtag']) > 0 )
|
||||
{
|
||||
$content['searchstr'] .= "syslogtag:" . $_POST['filter_syslogtag'] . " ";
|
||||
}
|
||||
|
||||
// Spaces need to be converted!
|
||||
if ( isset($_POST['filter_source']) && strlen($_POST['filter_source']) > 0 )
|
||||
{
|
||||
$content['searchstr'] .= "source:" . $_POST['filter_source'] . " ";
|
||||
}
|
||||
|
||||
// Message is just appended
|
||||
if ( isset($_POST['filter_message']) && strlen($_POST['filter_message']) > 0 )
|
||||
$content['searchstr'] .= $_POST['filter_message'];
|
||||
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
// --- BEGIN Custom Code
|
||||
|
48
js/common.js
48
js/common.js
@ -1,8 +1,6 @@
|
||||
/*
|
||||
Helper Javascript Constants
|
||||
*/
|
||||
const DATEMODE_ALL = 1, DATEMODE_RANGE = 2, DATEMODE_LASTX = 3;
|
||||
const DATE_LASTX_HOUR = 1, DATE_LASTX_12HOURS = 2, DATE_LASTX_24HOURS = 3, DATE_LASTX_7DAYS = 4,DATE_LASTX_31DAYS = 5;
|
||||
|
||||
/*
|
||||
Helper Javascript functions
|
||||
@ -92,49 +90,3 @@ function hidevisibility(ElementNameToggle, ElementNameButton)
|
||||
toggle.style.visibility = "hidden";
|
||||
toggle.style.display = "none";
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to show and hide areas of the filterview
|
||||
*/
|
||||
function toggleDatefiltervisibility(FormName)
|
||||
{
|
||||
var myform = document.getElementById(FormName);
|
||||
if (myform.elements['filter_datemode'].value == DATEMODE_ALL)
|
||||
{
|
||||
hidevisibility('HiddenDateFromOptions');
|
||||
hidevisibility('HiddenDateLastXOptions');
|
||||
}
|
||||
else if (myform.elements['filter_datemode'].value == DATEMODE_RANGE)
|
||||
{
|
||||
togglevisibility('HiddenDateFromOptions');
|
||||
hidevisibility('HiddenDateLastXOptions');
|
||||
}
|
||||
else if (myform.elements['filter_datemode'].value == DATEMODE_LASTX)
|
||||
{
|
||||
togglevisibility('HiddenDateLastXOptions');
|
||||
hidevisibility('HiddenDateFromOptions');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to add a date filter into the search field
|
||||
*/
|
||||
function addDatefilterToSearch(DateName, SearchFormName)
|
||||
{
|
||||
var myDateform = document.getElementById(DateName);
|
||||
var mySearchform = document.getElementById(SearchFormName);
|
||||
if (myDateform.elements['filter_datemode'].value == DATEMODE_RANGE)
|
||||
{
|
||||
mySearchform.elements['filter'].value += "date:from:" + myDateform.elements['filter_daterange_from_year'].value + "-"
|
||||
+ myDateform.elements['filter_daterange_from_month'].value + "-"
|
||||
+ myDateform.elements['filter_daterange_from_day'].value + ":to:"
|
||||
+ myDateform.elements['filter_daterange_to_year'].value + "-"
|
||||
+ myDateform.elements['filter_daterange_to_month'].value + "-"
|
||||
+ myDateform.elements['filter_daterange_to_day'].value + " ";
|
||||
}
|
||||
else if (myDateform.elements['filter_datemode'].value == DATEMODE_LASTX)
|
||||
{
|
||||
mySearchform.elements['filter'].value += "date:lastx:" + myDateform.elements['filter_daterange_last_x'].value + " ";
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ $content['LN_MAINTITLE'] = "Main PhpLogCon";
|
||||
$content['LN_MAIN_SELECTSTYLE'] = "Select a Style";
|
||||
$content['LN_GEN_LANGUAGE'] = "Select language";
|
||||
$content['LN_GEN_SELECTSOURCE'] = "Select Source";
|
||||
$content['LN_GEN_MOREPAGES'] = "More then one Page available";
|
||||
$content['LN_GEN_MOREPAGES'] = "More than one Page available";
|
||||
$content['LN_GEN_FIRSTPAGE'] = "First Page";
|
||||
$content['LN_GEN_LASTPAGE'] = "Last Page";
|
||||
$content['LN_GEN_NEXTPAGE'] = "Next Page";
|
||||
@ -24,11 +24,14 @@ $content['LN_GRID_INFOUNIT'] = "InfoUnit";
|
||||
$content['LN_GRID_HOST'] = "Source";
|
||||
$content['LN_GRID_MSG'] = "Message";
|
||||
|
||||
$content['LN_SEARCH_USETHISBLA'] = "Use the form below and your advanced search will appear here";
|
||||
$content['LN_SEARCH_FILTER'] = "Search (filter):";
|
||||
$content['LN_SEARCH_ADVANCED'] = "Advanced Search";
|
||||
$content['LN_SEARCH_FEELSAD'] = "I'm feeling sad ...";
|
||||
$content['LN_SEARCH'] = "Search";
|
||||
$content['LN_SEARCH_RESET'] = "Reset search";
|
||||
$content['LN_SEARCH_PERFORMADVANCED'] = "Perform Advanced Search";
|
||||
|
||||
|
||||
// Filter Options
|
||||
$content['LN_FILTER_DATE'] = "Datetime Range";
|
||||
|
@ -32,6 +32,10 @@ IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' );
|
||||
InitFilterHelpers();
|
||||
// *** *** //
|
||||
|
||||
// --- Extra Javascript?
|
||||
$content['EXTRA_JAVASCRIPT'] = "<script type='text/javascript' src='" . $content['BASEPATH'] . "js/searchhelpers.js'></script>";
|
||||
// ---
|
||||
|
||||
// --- CONTENT Vars
|
||||
// ---
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
<link rel="stylesheet" href="css/defaults.css" type="text/css">
|
||||
<link rel="stylesheet" href="themes/{user_theme}/main.css" type="text/css">
|
||||
<script type='text/javascript' src='{BASEPATH}js/common.js'></script>
|
||||
{EXTRA_JAVASCRIPT}
|
||||
</head>
|
||||
<body TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
<!-- INCLUDE include_header.html -->
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="2" align="center">
|
||||
<form action="" method="post" name="search">
|
||||
<form action="" method="post" id="search">
|
||||
<tr>
|
||||
<!-- <td class="topmenu2 ExpansionPlus" nowrap align="center" width="105" id="advancedsearch"><a class="topmenu1_link" href="#" OnClick="togglevisibility('HiddenOptions', 'advancedsearch');">Advanced Search</a></td>-->
|
||||
<td nowrap align="center" nowrap valign="middle">
|
||||
<B> {LN_SEARCH_FILTER}</B>
|
||||
|
||||
<!-- <img src="{BASEPATH}images/icons/navigate_down.png" class="SelectSavedFilter" align="middle" width="16" height="16">-->
|
||||
<input maxlength="2048" name="filter" size="55" title="Search" value="" class="SearchFormControl">
|
||||
<input maxlength="2048" name="filter" size="80" title="Search" value="{searchstr}" class="SearchFormTextbox">
|
||||
<br>
|
||||
<input name="search" type="submit" value="{LN_SEARCH}" class="SearchFormControl">
|
||||
<input name="search" type="submit" value="{LN_SEARCH_FEELSAD}" class="SearchFormControl">
|
||||
|
@ -1,17 +1,16 @@
|
||||
<!-- INCLUDE include_header.html -->
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="2" align="center" class="table_with_border">
|
||||
<br>
|
||||
<table width="100%" border="0" cellspacing="5" cellpadding="2" align="center" class="with_border">
|
||||
<tr>
|
||||
<!-- <td class="topmenu2 ExpansionPlus" nowrap align="center" width="105" id="advancedsearch"><a class="topmenu1_link" href="#" OnClick="togglevisibility('HiddenOptions', 'advancedsearch');">Advanced Search</a></td>-->
|
||||
<td nowrap align="center" nowrap valign="middle">
|
||||
<B> {LN_SEARCH_FILTER}</B>
|
||||
<input maxlength="2048" name="filter" size="100" title="Search" value="" class="SearchFormControl" readonly>
|
||||
<br>
|
||||
<td nowrap align="center" nowrap valign="middle" class="line1">
|
||||
<div id="SearchCode">{LN_SEARCH_USETHISBLA}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
<form action="" method="post" name="filterdateform">
|
||||
<form action="index.php" method="post" id="filterdateform" OnChange="CalculateSearchPreview('filterdateform', 'SearchCode');" onkeyup="CalculateSearchPreview('filterdateform', 'SearchCode');" >
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
|
||||
<tr>
|
||||
<td width="50%" valign="top" class="table_with_border">
|
||||
@ -118,7 +117,7 @@
|
||||
<tr>
|
||||
<td align="left" class="cellmenu2" width="50%" nowrap><b>{LN_FILTER_FACILITY}</b></td>
|
||||
<td align="right" class="line1" nowrap>
|
||||
<select name="filter_facility" size="8" multiple>
|
||||
<select name="filter_facility[]" size="8" multiple>
|
||||
<!-- BEGIN filter_facility_list -->
|
||||
<option {selected} value="{ID}">{DisplayName}</option>
|
||||
<!-- END filter_facility_list -->
|
||||
@ -126,7 +125,7 @@
|
||||
</td>
|
||||
<td align="left" class="cellmenu2" width="50%" nowrap><b>{LN_FILTER_SEVERITY}</b></td>
|
||||
<td align="right" class="line1" nowrap>
|
||||
<select name="filter_severity" size="8" multiple>
|
||||
<select name="filter_severity[]" size="8" multiple>
|
||||
<!-- BEGIN filter_severity_list -->
|
||||
<option {selected} value="{ID}">{DisplayName}</option>
|
||||
<!-- END filter_severity_list -->
|
||||
@ -146,7 +145,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" class="line0" width="100%">
|
||||
<input maxlength="2048" name="filter" size="70" title="Search" value="">
|
||||
<input maxlength="2048" name="filter_message" size="70" title="Search" value="">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -158,13 +157,13 @@
|
||||
<tr>
|
||||
<td align="left" class="cellmenu2" width="150" nowrap><b>{LN_FILTER_SYSLOGTAG}</b></td>
|
||||
<td align="right" class="line1" nowrap>
|
||||
<input maxlength="2048" name="filter" size="50" title="Search" value="">
|
||||
<input maxlength="2048" name="filter_syslogtag" size="50" title="Search" value="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" class="cellmenu2" width="150" nowrap><b>{LN_FILTER_SOURCE}</b></td>
|
||||
<td align="right" class="line1" nowrap>
|
||||
<input maxlength="2048" name="filter" size="50" title="Search" value="">
|
||||
<input maxlength="2048" name="filter_source" size="50" title="Search" value="">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -173,7 +172,7 @@
|
||||
<tr>
|
||||
<td colspan="3" valign="top" align="center">
|
||||
<br>
|
||||
<input name="search" type="submit" value="Perform Advanced Search" class="SearchFormControl">
|
||||
<input name="search" type="submit" value="{LN_SEARCH_PERFORMADVANCED}" class="SearchFormControl">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -392,3 +392,14 @@ select, input, button, textarea
|
||||
border: 1px solid;
|
||||
border-color: #233B51 #124A7C #124A7C #233B51;
|
||||
}
|
||||
|
||||
.SearchFormTextbox
|
||||
{
|
||||
height: 20px;
|
||||
margin: 2px;
|
||||
background-color: #0B253C;
|
||||
color:#FFFFFF;
|
||||
font:10px Verdana,Arial,Helvetica,sans-serif;
|
||||
border: 1px solid;
|
||||
border-color: #233B51 #124A7C #124A7C #233B51;
|
||||
}
|
@ -394,3 +394,14 @@ select, input, button, textarea, .SelectSavedFilter
|
||||
border: 1px solid;
|
||||
border-color: #233B51 #124A7C #124A7C #233B51;
|
||||
}
|
||||
|
||||
.SearchFormTextbox
|
||||
{
|
||||
height: 20px;
|
||||
margin: 2px;
|
||||
background-color: #E8E7E2;
|
||||
color:#000000;
|
||||
font:10px Verdana,Arial,Helvetica,sans-serif;
|
||||
border: 1px solid;
|
||||
border-color: #233B51 #124A7C #124A7C #233B51;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user