From c6bbdac0d79aa7633a7c96c9cfa8765a251bba70 Mon Sep 17 00:00:00 2001 From: Kevin Crider Date: Wed, 18 Sep 2013 15:53:35 -0400 Subject: [PATCH 1/5] Added ability to delete multiple events at once --- web/app/Controller/EventsController.php | 9 ++++++++- web/app/View/Events/index.ctp | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/web/app/Controller/EventsController.php b/web/app/Controller/EventsController.php index 80185face..81733b9da 100644 --- a/web/app/Controller/EventsController.php +++ b/web/app/Controller/EventsController.php @@ -69,7 +69,14 @@ public function index() { return $this->redirect(array('action' => 'index')); } } - + + public function deleteSelected() { + $this->log(print_r($this->data['Events'], true)); + foreach($this->data['Events'] as $key => $value) { + $this->Event->delete($value); + } + $this->redirect($this->referer()); + } } ?> diff --git a/web/app/View/Events/index.ctp b/web/app/View/Events/index.ctp index 146e3502c..de855b9df 100644 --- a/web/app/View/Events/index.ctp +++ b/web/app/View/Events/index.ctp @@ -61,13 +61,21 @@ echo $this->Form->inputs(array( Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> +Form->create('Events', array('action' => 'deleteSelected')); +?> + Html->tableHeaders(array( 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score', '' )); + echo $this->Html->tableHeaders(array('', 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score')); foreach ($events as $key => $value) { echo $this->Html->tableCells(array( - $this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( + $this->Form->checkbox('delete.', array( + 'value' => $value['Event']['Id'], + 'hiddenField' => false + )), + $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'] @@ -82,16 +90,16 @@ foreach ($events as $key => $value) { $value['Event']['AlarmFrames'], $value['Event']['TotScore'], $value['Event']['AvgScore'], - $value['Event']['MaxScore'], - $this->Form->postLink( - 'Delete', - array('action' => 'delete', $value['Event']['Id']), - array('confirm' => 'Are you sure?')) + $value['Event']['MaxScore'] )); } ?>
+Form->end('Delete Selected'); +?> + + \ No newline at end of file From 0cf11adb9984dad29a823efa03a6738b5e0ed418 Mon Sep 17 00:00:00 2001 From: Kevin Crider Date: Wed, 18 Sep 2013 15:55:50 -0400 Subject: [PATCH 2/5] Removed logging line from deleteSelected function --- web/app/Controller/EventsController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/web/app/Controller/EventsController.php b/web/app/Controller/EventsController.php index 81733b9da..50fb864ea 100644 --- a/web/app/Controller/EventsController.php +++ b/web/app/Controller/EventsController.php @@ -71,7 +71,6 @@ public function index() { } public function deleteSelected() { - $this->log(print_r($this->data['Events'], true)); foreach($this->data['Events'] as $key => $value) { $this->Event->delete($value); } From bf8f799c4cbdaa20f1cf03740c0e3cc4ac4ca261 Mon Sep 17 00:00:00 2001 From: Kevin Crider Date: Wed, 18 Sep 2013 16:46:44 -0400 Subject: [PATCH 3/5] Moved delete button to the sidebar --- web/app/View/Events/index.ctp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/app/View/Events/index.ctp b/web/app/View/Events/index.ctp index de855b9df..370748739 100644 --- a/web/app/View/Events/index.ctp +++ b/web/app/View/Events/index.ctp @@ -52,7 +52,8 @@ echo $this->Form->inputs(array( ?> -Form->end(array('label' => 'Search', 'id' => 'EventsButtonSearch')); ?> +Form->end(array('label' => 'Search', 'id' => 'EventsButtonSearch', 'class' => 'btn btn-default')); ?> +Html->link('Delete Selected','#',array('class' => 'btn btn-default', 'onClick' => '$("#EventsDeleteSelectedForm").submit();')); ?> end(); ?> @@ -97,7 +98,7 @@ foreach ($events as $key => $value) { Form->end('Delete Selected'); + echo $this->Form->end(); ?>
    From d7fd5566a7f26e5863a84c21169aa40fc543a8bc Mon Sep 17 00:00:00 2001 From: Kevin Crider Date: Wed, 18 Sep 2013 17:10:17 -0400 Subject: [PATCH 4/5] Fixes issue 129 - Bandwidth is now updated in the UI after changing it --- web/app/Controller/AppController.php | 15 +++++++++------ web/app/Controller/BandwidthController.php | 9 +++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/web/app/Controller/AppController.php b/web/app/Controller/AppController.php index 60066e2ee..584c206d2 100644 --- a/web/app/Controller/AppController.php +++ b/web/app/Controller/AppController.php @@ -45,12 +45,7 @@ class AppController extends Controller { parent::beforeFilter(); $this->loadModel('Config'); $this->loadModel('AppModel'); - $this->Cookie->name = 'ZoneMinder'; - if (!$this->Cookie->read('zmBandwidth')) { - $this->Cookie->write('zmBandwidth', 'low', false); - } - $this->set('zmBandwidth', $this->Cookie->read('zmBandwidth')); - + $this->Cookie->name = 'ZoneMinder'; $configFile = "/usr/local/etc/zm.conf"; $lines = file($configFile); @@ -84,6 +79,14 @@ class AppController extends Controller { $this->set('zmVersion', $zmVersion); } + public function beforeRender() { + parent::beforeRender(); + if (!$this->Cookie->read('zmBandwidth')) { + $this->Cookie->write('zmBandwidth', 'low', false); + } + $this->set('zmBandwidth', $this->Cookie->read('zmBandwidth')); + } + function extractNamedParams($mandatory, $optional = array()) { $params = $this->params['named']; diff --git a/web/app/Controller/BandwidthController.php b/web/app/Controller/BandwidthController.php index 8d580cf85..5dc6fa694 100644 --- a/web/app/Controller/BandwidthController.php +++ b/web/app/Controller/BandwidthController.php @@ -2,17 +2,18 @@ class BandwidthController extends AppController { public function index() { - $this->set('bandwidth', $this->Cookie->read('zmBandwidth')); - if (!empty($this->request->data)) { $bandwidth = $this->request->data['Bandwidth']['Bandwidth']; $this->Cookie->write('zmBandwidth', $bandwidth, false); - if ($this->Cookie->read('zmBandwidth') == $bandwidth) { + $this->set('bandwidth', $bandwidth); + if ($this->Cookie->read('zmBandwidth') == $bandwidth) { $this->Session->setFlash('Successfully updated bandwidth'); } else { $this->Session->setFlash('Failed to update bandwidth'); } - } + } else { + $this->set('bandwidth', $this->Cookie->read('zmBandwidth')); + } } } From 5178d4fa3787df13085873f8c42206974b8ea529 Mon Sep 17 00:00:00 2001 From: Kevin Crider Date: Wed, 18 Sep 2013 17:24:52 -0400 Subject: [PATCH 5/5] Added "Function" column to the $monitors array to fix issue 140 --- web/app/Controller/MonitorsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/Controller/MonitorsController.php b/web/app/Controller/MonitorsController.php index 9e7fa9221..06c659d0d 100644 --- a/web/app/Controller/MonitorsController.php +++ b/web/app/Controller/MonitorsController.php @@ -5,7 +5,7 @@ public function index() { $zmBandwidth = $this->Cookie->read('zmBandwidth'); $this->set('width', Configure::read('ZM_WEB_LIST_THUMB_WIDTH')); - $monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence'), 'order' => 'Sequence ASC', 'recursive' => -1); + $monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence', 'Function'), 'order' => 'Sequence ASC', 'recursive' => -1); $this->set('monitors', $this->Monitor->find('all', $monitoroptions)); $monitors = $this->Monitor->find('all', array('recursive' => -1, 'fields' => array('Id', 'StreamReplayBuffer'))); foreach ($monitors as $monitor => $mon) {