Bug 434 - Added delete functionality back into DVR events view plus enhanced events scrolloing etc to support.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2391 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
44943e21e9
commit
c617a8436c
|
@ -650,7 +650,7 @@ bool EventStream::loadEventData( int event_id )
|
|||
|
||||
mysql_free_result( result );
|
||||
|
||||
if ( mode == MODE_ALL_GAPLESS )
|
||||
if ( forceEventChange || mode == MODE_ALL_GAPLESS )
|
||||
{
|
||||
if ( replay_rate > 0 )
|
||||
curr_stream_time = event_data->frames[0].timestamp;
|
||||
|
@ -849,6 +849,8 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
curr_frame_id = 0;
|
||||
else
|
||||
curr_frame_id = event_data->frame_count-1;
|
||||
paused = false;
|
||||
forceEventChange = true;
|
||||
break;
|
||||
}
|
||||
case CMD_NEXT :
|
||||
|
@ -858,6 +860,8 @@ void EventStream::processCommand( const CmdMsg *msg )
|
|||
curr_frame_id = event_data->frame_count-1;
|
||||
else
|
||||
curr_frame_id = 0;
|
||||
paused = false;
|
||||
forceEventChange = true;
|
||||
break;
|
||||
}
|
||||
case CMD_SEEK :
|
||||
|
@ -971,7 +975,7 @@ mysql_free_result( $result );
|
|||
|
||||
if ( reload_event )
|
||||
{
|
||||
if ( mode != MODE_SINGLE )
|
||||
if ( forceEventChange || mode != MODE_SINGLE )
|
||||
{
|
||||
//Info(( "SQL:%s", sql ));
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
|
@ -1017,6 +1021,7 @@ mysql_free_result( $result );
|
|||
paused = true;
|
||||
}
|
||||
mysql_free_result( result );
|
||||
forceEventChange = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -206,6 +206,7 @@ protected:
|
|||
|
||||
protected:
|
||||
StreamMode mode;
|
||||
bool forceEventChange;
|
||||
|
||||
protected:
|
||||
int curr_frame_id;
|
||||
|
@ -227,6 +228,8 @@ public:
|
|||
{
|
||||
mode = DEFAULT_MODE;
|
||||
|
||||
forceEventChange = false;
|
||||
|
||||
curr_frame_id = 0;
|
||||
curr_stream_time = 0.0;
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
<script type="text/javascript" src="mootools.ext.js"></script>
|
||||
<script type="text/javascript" src="zm_html.js"></script>
|
||||
<script type="text/javascript">
|
||||
var url = "<?= ZM_BASE_URL.$PHP_SELF ?>";
|
||||
|
||||
function eventWindow( eventId, eventFilter )
|
||||
{
|
||||
var windowUrl = '<?= $PHP_SELF ?>?view=event&eid='+eventId;
|
||||
|
|
|
@ -65,8 +65,6 @@ $connkey = generateConnKey();
|
|||
<?php require_once( 'zm_html_js.php' ) ?>
|
||||
<script type="text/javascript">
|
||||
|
||||
var url = "<?= ZM_BASE_URL.$PHP_SELF ?>";
|
||||
|
||||
function setButtonState( element, butclass )
|
||||
{
|
||||
element.className = butclass;
|
||||
|
@ -392,11 +390,15 @@ function getActResponse( resp_text, resp_xml )
|
|||
{
|
||||
window.opener.location.reload();
|
||||
}
|
||||
evtQuery();
|
||||
if ( resp_obj.refreshEvent )
|
||||
{
|
||||
evtQuery();
|
||||
}
|
||||
}
|
||||
|
||||
function actQuery( action, parms )
|
||||
{
|
||||
console.log( event );
|
||||
var actParms = "view=request&request=event&id="+event.Id+"&action="+action;
|
||||
//console.log( parms );
|
||||
if ( parms != null )
|
||||
|
@ -416,8 +418,8 @@ function startRequests()
|
|||
function deleteEvent()
|
||||
{
|
||||
actQuery( 'delete' );
|
||||
streamNext();
|
||||
opener.location.reload(true);
|
||||
streamNext( true );
|
||||
//opener.location.reload(true);
|
||||
}
|
||||
|
||||
function renameEvent()
|
||||
|
|
|
@ -93,7 +93,8 @@ body {
|
|||
}
|
||||
|
||||
#events {
|
||||
width: 100%;
|
||||
width: 96%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
#eventList {
|
||||
|
@ -123,10 +124,14 @@ span.alert {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
#eventList tr.highlight {
|
||||
#eventList tr.recent {
|
||||
background-color: #B0E0E6;
|
||||
}
|
||||
|
||||
#eventList tr.highlight {
|
||||
background-color: #DCDCDC;
|
||||
}
|
||||
|
||||
#ptzControls {
|
||||
vertical-align: top;
|
||||
margin-top: 10px;
|
||||
|
|
|
@ -473,11 +473,37 @@ function cmdCancelForcedAlarm()
|
|||
alarmCmdReq.request( alarmCmdParms+"&command=cancelForcedAlarm" );
|
||||
}
|
||||
|
||||
var eventCmdParms = "view=request&request=status&entity=events&id=<?= $mid ?>&count=<?= MAX_EVENTS ?>&sort=Id%20desc";
|
||||
function getActResponse( respText )
|
||||
{
|
||||
if ( respText == 'Ok' )
|
||||
return;
|
||||
var response = Json.evaluate( respText );
|
||||
|
||||
if ( response.refreshParent )
|
||||
{
|
||||
window.opener.location.reload();
|
||||
}
|
||||
eventCmdQuery();
|
||||
}
|
||||
|
||||
function deleteEvent( event, eventId )
|
||||
{
|
||||
var actParms = "view=request&request=event&action=delete&id="+eventId;
|
||||
var actReq = new Ajax( url, { method: 'post', timeout: 3000, data: actParms, onComplete: getActResponse } );
|
||||
actReq.request();
|
||||
event.stop();
|
||||
}
|
||||
|
||||
var eventCmdParms = "view=request&request=status&entity=events&id=<?= $mid ?>&count=<?= 2*MAX_EVENTS ?>&sort=Id%20desc";
|
||||
var eventCmdReq = new Ajax( thisUrl, { method: 'post', timeout: <?= ZM_WEB_AJAX_TIMEOUT ?>, data: eventCmdParms, onComplete: getEventCmdResponse } );
|
||||
var eventCmdTimer = null;
|
||||
var eventCmdFirst = true;
|
||||
|
||||
function highlightRow( row )
|
||||
{
|
||||
$(row).toggleClass( 'highlight' );
|
||||
}
|
||||
|
||||
function getEventCmdResponse( respText )
|
||||
{
|
||||
if ( eventCmdTimer )
|
||||
|
@ -491,70 +517,94 @@ function getEventCmdResponse( respText )
|
|||
var eventList = $('eventList');
|
||||
var eventListBody = $(eventList).getElement( 'tbody' );
|
||||
var eventListRows = $(eventListBody).getElements( 'tr' );
|
||||
|
||||
eventListRows.each( function( row ) { row.removeClass( 'updated' ); } );
|
||||
|
||||
for ( var i = 0; i < db_events.length; i++ )
|
||||
{
|
||||
var row = $('event'+db_events[i].Id);
|
||||
if ( !$(row) )
|
||||
var newEvent = (row == null ? true : false);
|
||||
if ( newEvent )
|
||||
{
|
||||
row = new Element( 'tr', { 'id': 'event'+db_events[i].Id } );
|
||||
if ( !eventCmdFirst )
|
||||
$(row).addClass( 'highlight' );
|
||||
var cell = new Element( 'td' );
|
||||
$(cell).injectInside( $(row) );
|
||||
$(cell).clone().injectInside( $(row) );
|
||||
$(cell).clone().injectInside( $(row) );
|
||||
$(cell).clone().injectInside( $(row) );
|
||||
$(cell).clone().injectInside( $(row) );
|
||||
$(cell).clone().injectInside( $(row) );
|
||||
$(row).injectTop( $(eventListBody) );
|
||||
cell.injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
cell.clone().injectInside( row );
|
||||
|
||||
var cells = row.getElements( 'td' );
|
||||
|
||||
var link = new Element( 'a', { 'href': '#', 'events': { 'click': eventWindow.pass( db_events[i].Id, '&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?>&page=1' ) } });
|
||||
link.setHTML( db_events[i].Id );
|
||||
link.injectInside( cells[0] );
|
||||
|
||||
link = new Element( 'a', { 'href': '#', 'events': { 'click': eventWindow.pass( db_events[i].Id, '&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?>&page=1' ) } });
|
||||
link.setHTML( db_events[i].Name );
|
||||
link.injectInside( cells[1] );
|
||||
|
||||
cells[2].setHTML( db_events[i].StartTime );
|
||||
cells[3].setHTML( db_events[i].Length );
|
||||
|
||||
link = new Element( 'a', { 'href': '#', 'events': { 'click': framesWindow.pass( db_events[i].Id ) } });
|
||||
link.setHTML( db_events[i].Frames+'/'+db_events[i].AlarmFrames );
|
||||
link.injectInside( cells[4] );
|
||||
|
||||
link = new Element( 'a', { 'href': '#', 'events': { 'click': frameWindow.pass( [ db_events[i].Id, '0' ] ) } });
|
||||
link.setHTML( db_events[i].AvgScore+'/'+db_events[i].MaxScore );
|
||||
link.injectInside( cells[5] );
|
||||
|
||||
link = new Element( 'a', { 'href': '#', 'title': '<?= $zmSlangDelete ?>', 'events': { 'click': deleteEvent.bindWithEvent( link, db_events[i].Id ), 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } });
|
||||
//link.setHTML( '✘' );
|
||||
link.setHTML( 'X' );
|
||||
link.injectInside( cells[6] );
|
||||
|
||||
console.log( "Injecting "+db_events[i].Id );
|
||||
if ( i == 0 )
|
||||
{
|
||||
row.injectInside( $(eventListBody) );
|
||||
}
|
||||
else
|
||||
{
|
||||
row.injectTop( $(eventListBody) );
|
||||
if ( !eventCmdFirst )
|
||||
row.addClass( 'recent' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$(row).removeClass( 'highlight' );
|
||||
var cells = row.getElements( 'td' );
|
||||
|
||||
cells[1].getElement( 'a' ).setHTML( db_events[i].Name );
|
||||
cells[3].setHTML( db_events[i].Length );
|
||||
cells[4].getElement( 'a' ).setHTML( db_events[i].Frames+'/'+db_events[i].AlarmFrames );
|
||||
cells[5].getElement( 'a' ).setHTML( db_events[i].AvgScore+'/'+db_events[i].MaxScore );
|
||||
|
||||
row.removeClass( 'recent' );
|
||||
}
|
||||
var cells = $(row).getElements( 'td' );
|
||||
var id = cells[0];
|
||||
var idLink = $(id).getElement( 'a' );
|
||||
if ( !$(idLink) )
|
||||
{
|
||||
idLink = new Element( 'a', { 'href': '#', 'events': { 'click': eventWindow.pass( db_events[i].Id, '&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?>&page=1' ) } });
|
||||
$(idLink).injectInside( $(id) );
|
||||
}
|
||||
$(idLink).setHTML( db_events[i].Id );
|
||||
var name = cells[1];
|
||||
var nameLink = $(name).getElement( 'a' );
|
||||
if ( !$(nameLink) )
|
||||
{
|
||||
nameLink = new Element( 'a', { 'href': '#', 'events': { 'click': eventWindow.pass( db_events[i].Id, '&trms=1&attr1=MonitorId&op1=%3d&val1=<?= $mid ?>&page=1' ) } });
|
||||
$(nameLink).injectInside( $(name) );
|
||||
}
|
||||
$(nameLink).setHTML( db_events[i].Name );
|
||||
var time = cells[2];
|
||||
$(time).setHTML( db_events[i].StartTime );
|
||||
var secs = cells[3];
|
||||
$(secs).setHTML( db_events[i].Length );
|
||||
var frames = cells[4];
|
||||
var framesLink = $(frames).getElement( 'a' );
|
||||
if ( !$(framesLink) )
|
||||
{
|
||||
framesLink = new Element( 'a', { 'href': '#', 'events': { 'click': framesWindow.pass( db_events[i].Id ) } });
|
||||
$(framesLink).injectInside( $(frames) );
|
||||
}
|
||||
$(framesLink).setHTML( db_events[i].Frames+'/'+db_events[i].AlarmFrames );
|
||||
var score = cells[5];
|
||||
var scoreLink = $(score).getElement( 'a' );
|
||||
if ( !$(scoreLink) )
|
||||
{
|
||||
scoreLink = new Element( 'a', { 'href': '#', 'events': { 'click': frameWindow.pass( [ db_events[i].Id, '0' ] ) } });
|
||||
$(scoreLink).injectInside( $(score) );
|
||||
}
|
||||
$(scoreLink).setHTML( db_events[i].AvgScore+'/'+db_events[i].MaxScore );
|
||||
row.addClass( 'updated' );
|
||||
}
|
||||
|
||||
var rows = $(eventListBody).getElements( 'tr' );
|
||||
while ( $$(rows).length > <?= MAX_EVENTS ?> )
|
||||
for ( var i = 0; i < rows.length; i++ )
|
||||
{
|
||||
$$(rows)[$$(rows).length-1].remove();
|
||||
rows = $(eventListBody).getElements( 'tr' );
|
||||
if ( !rows[i].hasClass( 'updated' ) )
|
||||
{
|
||||
console.log( "Removing row "+i );
|
||||
rows[i].remove();
|
||||
rows.splice( i, 1 );
|
||||
//rows.length--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
while ( rows.length > <?= 2*MAX_EVENTS ?> )
|
||||
{
|
||||
console.log( "Trimming" );
|
||||
rows[rows.length-1].remove();
|
||||
rows.length--;
|
||||
}
|
||||
var eventCmdTimeout = <?= 1000*ZM_WEB_REFRESH_STATUS ?>;
|
||||
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
|
||||
|
@ -814,6 +864,7 @@ if ( canView( 'Events' ) )
|
|||
<td><?= $zmSlangSecs ?></td>
|
||||
<td><?= $zmSlangFrames ?></td>
|
||||
<td><?= $zmSlangScore ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
|
@ -14,6 +14,7 @@ if ( !$_REQUEST['id'] )
|
|||
return;
|
||||
}
|
||||
|
||||
$refresh_event = false;
|
||||
$refresh_parent = false;
|
||||
|
||||
// Event scope actions, edit permissions required
|
||||
|
@ -26,6 +27,7 @@ else if ( $_REQUEST['action'] == "eventdetail" )
|
|||
if ( $_REQUEST['id'] )
|
||||
{
|
||||
dbQuery( "update Events set Cause = '".dbEscape($_REQUEST['new_event']['Cause'])."', Notes = '".dbEscape($_REQUEST['new_event']['Notes'])."' where Id = '".dbEscape($_REQUEST['id'])."'" );
|
||||
$refresh_event = true;
|
||||
$refresh_parent = true;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +38,7 @@ elseif ( $_REQUEST['action'] == "archive" || $_REQUEST['action'] == "unarchive"
|
|||
if ( $_REQUEST['id'] )
|
||||
{
|
||||
dbQuery( "update Events set Archived = ".$archive_val." where Id = '".dbEscape($_REQUEST['id'])."'" );
|
||||
$refresh_event = true;
|
||||
}
|
||||
elseif ( $mark_eids || $mark_eid )
|
||||
{
|
||||
|
@ -55,22 +58,15 @@ elseif ( $_REQUEST['action'] == "archive" || $_REQUEST['action'] == "unarchive"
|
|||
}
|
||||
elseif ( $_REQUEST['action'] == "delete" )
|
||||
{
|
||||
if ( !$mark_eids && $mark_eid )
|
||||
if ( !empty($_REQUEST['id']) )
|
||||
{
|
||||
$mark_eids[] = $mark_eid;
|
||||
}
|
||||
if ( $mark_eids )
|
||||
{
|
||||
foreach( $mark_eids as $mark_eid )
|
||||
{
|
||||
deleteEvent( $mark_eid );
|
||||
}
|
||||
$refresh_parent = true;
|
||||
deleteEvent( dbEscape($_REQUEST['id']) );
|
||||
}
|
||||
}
|
||||
|
||||
$response['result'] = 'Ok';
|
||||
$response['refreshParent'] = $refresh_parent;
|
||||
$response['refreshEvent'] = $refresh_event;
|
||||
|
||||
header("Content-type: text/plain" );
|
||||
echo jsValue( $response );
|
||||
|
|
Loading…
Reference in New Issue