diff --git a/web/app/Controller/EventsController.php b/web/app/Controller/EventsController.php index 311144cc0e..5cbd2efc54 100644 --- a/web/app/Controller/EventsController.php +++ b/web/app/Controller/EventsController.php @@ -5,26 +5,35 @@ class EventsController extends AppController { public $components = array('Paginator'); public function index() { + $this->loadModel('Monitor'); $this->loadModel('Frame'); - $conditions = array(); + $conditions = array(); + + $this->set('thumb_width', Configure::read('ZM_WEB_LIST_THUMB_WIDTH')); $named = $this->extractNamedParams( - array('MonitorId') + array('MonitorId', 'StartTime' ) ); if ($named) { - foreach ($named as $key => $value) { - $$key = array($key => $value); - array_push($conditions, $$key); - } + foreach ($named as $key => $value) { + switch ($key) { + case "StartTime": + $StartTime = array("$key BETWEEN FROM_UNIXTIME($value[0]) and FROM_UNIXTIME($value[1])"); + array_push($conditions, $StartTime); + break; + case "MonitorId": + $$key = array($key => $value); + array_push($conditions, $$key); + break; + } + } }; - $events_per_page = Configure::read('ZM_WEB_EVENTS_PER_PAGE'); - $this->paginate = array( - 'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name', 'Event.MaxScore', 'Event.Width', 'Event.Height', 'Event.StartTime'), - 'limit' => $events_per_page, + 'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name', 'Event.MaxScore', 'Event.Width', 'Event.Height', 'Event.StartTime', 'Event.TotScore', 'Event.AvgScore', 'Event.Cause', 'Event.AlarmFrames', 'TIMESTAMPDIFF (SECOND, Event.StartTime, Event.EndTime) AS Duration' ), + 'limit' => Configure::read('ZM_WEB_EVENTS_PER_PAGE'), 'order' => array( 'Event.Id' => 'asc'), 'conditions' => $conditions ); @@ -33,12 +42,6 @@ public function index() { $this->set('monitors', $this->Monitor->find('all', array('fields' => array('Monitor.Name') ))); - $this->set('eventsLastHour', $this->Monitor->query('SELECT COUNT(Event.Id) AS count FROM Monitors AS Monitor LEFT JOIN Events as Event ON Monitor.Id = Event.MonitorId AND Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 HOUR) GROUP BY Monitor.Id')); - $this->set('eventsLastDay', $this->Monitor->query('SELECT COUNT(Event.Id) AS count FROM Monitors AS Monitor LEFT JOIN Events as Event ON Monitor.Id = Event.MonitorId AND Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY Monitor.Id')); - $this->set('eventsLastWeek', $this->Monitor->query('SELECT COUNT(Event.Id) AS count FROM Monitors AS Monitor LEFT JOIN Events as Event ON Monitor.Id = Event.MonitorId AND Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 WEEK) GROUP BY Monitor.Id')); - $this->set('eventsLastMonth', $this->Monitor->query('SELECT COUNT(Event.Id) AS count FROM Monitors AS Monitor LEFT JOIN Events as Event ON Monitor.Id = Event.MonitorId AND Event.StartTime > DATE_SUB(NOW(), INTERVAL 1 MONTH) GROUP BY Monitor.Id')); - $this->set('eventsArchived', $this->Monitor->query('SELECT COUNT(Event.Id) AS count FROM Monitors AS Monitor LEFT JOIN Events as Event ON Monitor.Id = Event.MonitorId AND Event.Archived = 1 GROUP BY Monitor.Id')); - foreach ($data as $key => $value) { $thumbData[$key] = $this->Frame->createListThumbnail($value['Event']); $this->set('thumbData', $thumbData); diff --git a/web/app/View/Events/index.ctp b/web/app/View/Events/index.ctp index 5a96017c6d..0c3ba4fd71 100644 --- a/web/app/View/Events/index.ctp +++ b/web/app/View/Events/index.ctp @@ -1,46 +1,98 @@ -

Events

- + +
Paginator->numbers(); ?>
- - - - - + + + + + + + + + + + + + - $value): ?> - - - - - - -
Event NameMonitor NameLength
ThumbnailIdNameMonitorCauseTimeDurationAlarm FramesTotal ScoreAvg. ScoreMax Score
-Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( - 'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'], - 'width' => $thumbData[$key]['Width'], - 'height' => $thumbData[$key]['Height'] -)), array('controller' => 'events', 'action' => 'view', $value['Event']['Id']), -array('escape' => false)); + $value) { + echo $this->Html->tableCells(array( + $this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( + 'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'], + 'width' => $thumbData[$key]['Width'], + 'height' => $thumbData[$key]['Height'] + )), + array('controller' => 'events', 'action' => 'view', $value['Event']['Id']), array('escape' => false)), + $value['Event']['Id'], + $value['Event']['Name'], + $value['Monitor']['Name'], + $value['Event']['Cause'], + $value['Event']['StartTime'], + $value[0]['Duration'], + $value['Event']['AlarmFrames'], + $value['Event']['TotScore'], + $value['Event']['AvgScore'], + $value['Event']['MaxScore'] + )); +} ?> -
-
Paginator->numbers(); ?>
+
Paginator->numbers(); ?>
diff --git a/web/app/webroot/css/cake.generic.css b/web/app/webroot/css/cake.generic.css index 6b82482983..d309acf9aa 100644 --- a/web/app/webroot/css/cake.generic.css +++ b/web/app/webroot/css/cake.generic.css @@ -755,10 +755,34 @@ div#footer a{ color: #fff; } - #selectable .ui-selecting { background: #FECA40; } - #selectable .ui-selected { background: #F39814; color: white; } - #selectable { list-style-type: none; margin: 0; padding: 0; width: 450px; } - #selectable li { margin: 3px; padding: 1px; float: left; width: 100px; height: 80px; font-size: 1em; text-align: center; } + +#selectable .ui-selecting { background: #FECA40; } +#selectable .ui-selected { background: #F39814; color: white; } +#selectable { list-style-type: none; margin: 0; padding: 0; } +#selectable li { margin: 3px; padding: 0.4em; height: 18px; border:1px solid #AAAAAA;} +#selectable input { display:none; } + +#sidebar { + float:left; + width:350px; + margin-right:5px; + font-size:80%; +} + +#sidebar input { + margin:0; + padding:0; +} + +#events_date_time fieldset fieldset input { + float:left; + width:175px; + margin-right:5px; +} + +#events_date_time fieldset fieldset { + border:none; +} /* Config Page */ diff --git a/web/app/webroot/js/main.js b/web/app/webroot/js/main.js index d9cc523760..99ce758fd4 100644 --- a/web/app/webroot/js/main.js +++ b/web/app/webroot/js/main.js @@ -36,7 +36,8 @@ $(document).ready(function() { }); }); - $("#EventsButtonSearch").button().click(function() { + $("#EventsButtonSearch").button(); + $("#EventsIndexForm").submit(function() { $base_url = '/events/index/'; $( "li.ui-selected" ).each(function() {