From 50085d48b534953c3c27e8ffbc870b6bdbc23348 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Thu, 30 May 2013 22:54:51 -0400 Subject: [PATCH] Reworked the Events index view to display thumbnails by default. The EventsController calls createListThumbnail() to build a list of thumbnail data which is then passed to the view to be looped though. Also had to change how I loop through $events so that I can match up the indexes in $events with the indexes in $thumbData --- web/app/Controller/EventsController.php | 8 +++++++- web/app/View/Events/index.ctp | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web/app/Controller/EventsController.php b/web/app/Controller/EventsController.php index f0665ac05..311144cc0 100644 --- a/web/app/Controller/EventsController.php +++ b/web/app/Controller/EventsController.php @@ -6,6 +6,7 @@ class EventsController extends AppController { public function index() { $this->loadModel('Monitor'); + $this->loadModel('Frame'); $conditions = array(); $named = $this->extractNamedParams( @@ -22,7 +23,7 @@ public function index() { $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'), + 'fields' => array('Event.Name', 'Event.Length', 'Event.MonitorId', 'Event.Id', 'Monitor.Name', 'Event.MaxScore', 'Event.Width', 'Event.Height', 'Event.StartTime'), 'limit' => $events_per_page, 'order' => array( 'Event.Id' => 'asc'), 'conditions' => $conditions @@ -37,6 +38,11 @@ public function index() { $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); + } } public function view($id = null) { diff --git a/web/app/View/Events/index.ctp b/web/app/View/Events/index.ctp index f4c7af964..11d81d3a0 100644 --- a/web/app/View/Events/index.ctp +++ b/web/app/View/Events/index.ctp @@ -24,16 +24,24 @@ Length - + $value): ?> - Html->link($event['Event']['Name'], -array('controller' => 'events', 'action' => 'view', $event['Event']['Id'])); ?> +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)); +?> + + - +
Paginator->numbers(); ?>