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
This commit is contained in:
parent
3505f35a6d
commit
50085d48b5
|
@ -6,6 +6,7 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->loadModel('Monitor');
|
$this->loadModel('Monitor');
|
||||||
|
$this->loadModel('Frame');
|
||||||
$conditions = array();
|
$conditions = array();
|
||||||
|
|
||||||
$named = $this->extractNamedParams(
|
$named = $this->extractNamedParams(
|
||||||
|
@ -22,7 +23,7 @@ public function index() {
|
||||||
$events_per_page = Configure::read('ZM_WEB_EVENTS_PER_PAGE');
|
$events_per_page = Configure::read('ZM_WEB_EVENTS_PER_PAGE');
|
||||||
|
|
||||||
$this->paginate = array(
|
$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,
|
'limit' => $events_per_page,
|
||||||
'order' => array( 'Event.Id' => 'asc'),
|
'order' => array( 'Event.Id' => 'asc'),
|
||||||
'conditions' => $conditions
|
'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('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('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'));
|
$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) {
|
public function view($id = null) {
|
||||||
|
|
|
@ -24,16 +24,24 @@
|
||||||
<th>Length</th>
|
<th>Length</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php foreach ($events as $event): ?>
|
<?php foreach ($events as $key => $value): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<?php echo $this->Html->link($event['Event']['Name'],
|
|
||||||
array('controller' => 'events', 'action' => 'view', $event['Event']['Id'])); ?>
|
|
||||||
<td><?php echo $event['Monitor']['Name']; ?></td>
|
<td><?php echo $event['Monitor']['Name']; ?></td>
|
||||||
<td><?php echo $event['Event']['Length']; ?></td>
|
<td><?php echo $event['Event']['Length']; ?></td>
|
||||||
|
<?php
|
||||||
|
echo $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));
|
||||||
|
?>
|
||||||
|
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php unset($event); ?>
|
<?php unset($key); ?>
|
||||||
</table>
|
</table>
|
||||||
<div><?php echo $this->Paginator->numbers(); ?></div>
|
<div><?php echo $this->Paginator->numbers(); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue