rough in the ability to filter on RunState

This commit is contained in:
Isaac Connor 2017-01-14 16:55:28 -05:00
parent 132249e96d
commit 242e5a56d8
5 changed files with 21 additions and 2 deletions

View File

@ -203,6 +203,7 @@ CREATE TABLE `Events` (
`Messaged` tinyint(3) unsigned NOT NULL default '0', `Messaged` tinyint(3) unsigned NOT NULL default '0',
`Executed` tinyint(3) unsigned NOT NULL default '0', `Executed` tinyint(3) unsigned NOT NULL default '0',
`Notes` text, `Notes` text,
`StateId` int(10) unsigned NOT NULL,
PRIMARY KEY (`Id`,`MonitorId`), PRIMARY KEY (`Id`,`MonitorId`),
KEY `MonitorId` (`MonitorId`), KEY `MonitorId` (`MonitorId`),
KEY `StartTime` (`StartTime`), KEY `StartTime` (`StartTime`),

View File

@ -77,10 +77,14 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
gettimeofday( &start_time, 0 ); gettimeofday( &start_time, 0 );
} }
static char sql[ZM_SQL_MED_BUFSIZ]; unsigned int state_id = 0;
if ( MYSQL_ROW dbrow = zmDbFetchOne( "SELECT Id FROM States WHERE IsActive=1" ) ) {
state_id = atoi(dbrow[0]);
}
static char sql[ZM_SQL_MED_BUFSIZ];
struct tm *stime = localtime( &start_time.tv_sec ); struct tm *stime = localtime( &start_time.tv_sec );
snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes, StateId ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), state_id );
if ( mysql_query( &dbconn, sql ) ) if ( mysql_query( &dbconn, sql ) )
{ {
Error( "Can't insert event: %s", mysql_error( &dbconn ) ); Error( "Can't insert event: %s", mysql_error( &dbconn ) );

View File

@ -1243,6 +1243,7 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {
case 'MaxScore': case 'MaxScore':
case 'Cause': case 'Cause':
case 'Notes': case 'Notes':
case 'StateId':
case 'Archived': case 'Archived':
$filter['sql'] .= 'E.'.$filter['terms'][$i]['attr']; $filter['sql'] .= 'E.'.$filter['terms'][$i]['attr'];
break; break;

View File

@ -127,6 +127,7 @@ $SLANG = array(
'AttrMonitorName' => 'Monitor Name', 'AttrMonitorName' => 'Monitor Name',
'AttrServerId' => 'Server Id', 'AttrServerId' => 'Server Id',
'AttrServerName' => 'Server Name', 'AttrServerName' => 'Server Name',
'AttrStateId' => 'Run State',
'AttrName' => 'Name', 'AttrName' => 'Name',
'AttrNotes' => 'Notes', 'AttrNotes' => 'Notes',
'AttrSystemLoad' => 'System Load', 'AttrSystemLoad' => 'System Load',

View File

@ -97,6 +97,7 @@ $attrTypes = array(
'DiskPercent' => translate('AttrDiskPercent'), 'DiskPercent' => translate('AttrDiskPercent'),
'DiskBlocks' => translate('AttrDiskBlocks'), 'DiskBlocks' => translate('AttrDiskBlocks'),
'SystemLoad' => translate('AttrSystemLoad'), 'SystemLoad' => translate('AttrSystemLoad'),
'StateId' => translate('AttrStateId'),
'ServerId' => translate('AttrServerId'), 'ServerId' => translate('AttrServerId'),
'ServerName' => translate('AttrServerName'), 'ServerName' => translate('AttrServerName'),
); );
@ -217,6 +218,17 @@ for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['term
?> ?>
<td><?php echo buildSelect( "filter[terms][$i][op]", $opTypes ); ?></td> <td><?php echo buildSelect( "filter[terms][$i][op]", $opTypes ); ?></td>
<td><input name="filter[terms][<?php echo $i ?>][val]" id="filter[terms][<?php echo $i ?>][val]" value="<?php echo isset($_REQUEST['filter']['terms'][$i]['val'])?validHtmlStr($_REQUEST['filter']['terms'][$i]['val']):'' ?>"/><?php if ( $hasCal ) { ?><script type="text/javascript">Calendar.setup( { inputField: "filter[terms][<?php echo $i ?>][val]", ifFormat: "%Y-%m-%d", showOthers: true, weekNumbers: false });</script><?php } ?></td> <td><input name="filter[terms][<?php echo $i ?>][val]" id="filter[terms][<?php echo $i ?>][val]" value="<?php echo isset($_REQUEST['filter']['terms'][$i]['val'])?validHtmlStr($_REQUEST['filter']['terms'][$i]['val']):'' ?>"/><?php if ( $hasCal ) { ?><script type="text/javascript">Calendar.setup( { inputField: "filter[terms][<?php echo $i ?>][val]", ifFormat: "%Y-%m-%d", showOthers: true, weekNumbers: false });</script><?php } ?></td>
<?php
}
elseif ( $_REQUEST['filter']['terms'][$i]['attr'] == "ServerId" )
{
$states = array();
foreach ( dbFetchAll( 'SELECT Id,Name FROM States ORDER BY lower(Name) ASC' ) as $state_row ) {
$states[$state_row['Id']] = $state_row['Name'];
}
?>
<td><?php echo buildSelect( "filter[terms][$i][op]", $opTypes ); ?></td>
<td><?php echo buildSelect( "filter[terms][$i][val]", $states ); ?></td>
<?php <?php
} }
elseif ( $_REQUEST['filter']['terms'][$i]['attr'] == "Weekday" ) elseif ( $_REQUEST['filter']['terms'][$i]['attr'] == "Weekday" )