rough in the ability to filter on RunState
This commit is contained in:
parent
132249e96d
commit
242e5a56d8
|
@ -203,6 +203,7 @@ CREATE TABLE `Events` (
|
|||
`Messaged` tinyint(3) unsigned NOT NULL default '0',
|
||||
`Executed` tinyint(3) unsigned NOT NULL default '0',
|
||||
`Notes` text,
|
||||
`StateId` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`Id`,`MonitorId`),
|
||||
KEY `MonitorId` (`MonitorId`),
|
||||
KEY `StartTime` (`StartTime`),
|
||||
|
|
|
@ -77,10 +77,14 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
|||
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 );
|
||||
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 ) )
|
||||
{
|
||||
Error( "Can't insert event: %s", mysql_error( &dbconn ) );
|
||||
|
|
|
@ -1243,6 +1243,7 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) {
|
|||
case 'MaxScore':
|
||||
case 'Cause':
|
||||
case 'Notes':
|
||||
case 'StateId':
|
||||
case 'Archived':
|
||||
$filter['sql'] .= 'E.'.$filter['terms'][$i]['attr'];
|
||||
break;
|
||||
|
|
|
@ -127,6 +127,7 @@ $SLANG = array(
|
|||
'AttrMonitorName' => 'Monitor Name',
|
||||
'AttrServerId' => 'Server Id',
|
||||
'AttrServerName' => 'Server Name',
|
||||
'AttrStateId' => 'Run State',
|
||||
'AttrName' => 'Name',
|
||||
'AttrNotes' => 'Notes',
|
||||
'AttrSystemLoad' => 'System Load',
|
||||
|
|
|
@ -97,6 +97,7 @@ $attrTypes = array(
|
|||
'DiskPercent' => translate('AttrDiskPercent'),
|
||||
'DiskBlocks' => translate('AttrDiskBlocks'),
|
||||
'SystemLoad' => translate('AttrSystemLoad'),
|
||||
'StateId' => translate('AttrStateId'),
|
||||
'ServerId' => translate('AttrServerId'),
|
||||
'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><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
|
||||
}
|
||||
elseif ( $_REQUEST['filter']['terms'][$i]['attr'] == "Weekday" )
|
||||
|
|
Loading…
Reference in New Issue