From 186f763a4cfbac028e283b7078ead2c39a3c9d63 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Tue, 24 Sep 2013 20:34:36 -0400 Subject: [PATCH] Moved vars for Monitors edit and add views to appropriate elements. This saves a bunch of redundant code, while putting the code in the 'right place'. --- web/app/Controller/MonitorsController.php | 103 +--------------------- web/app/View/Elements/tabs-general.ctp | 20 +++++ web/app/View/Elements/tabs-source.ctp | 85 ++++++++++++++++++ web/app/View/Monitors/add.ctp | 62 ++++--------- 4 files changed, 125 insertions(+), 145 deletions(-) diff --git a/web/app/Controller/MonitorsController.php b/web/app/Controller/MonitorsController.php index d6364536b..027915463 100755 --- a/web/app/Controller/MonitorsController.php +++ b/web/app/Controller/MonitorsController.php @@ -41,108 +41,6 @@ throw new NotFoundException(__('Invalid monitor')); } $this->set('monitor', $monitor['Monitor']); - - $typeoptions = array( - 'Local' => 'Local', - 'Remote' => 'Remote', - 'File' => 'File', - 'Ffmpeg' => 'Ffmpeg' - ); - $this->set('typeoptions', $typeoptions); - - $functionoptions = array( - 'Modect' => 'Modect', - 'Monitor' => 'Monitor', - 'Record' => 'Record', - 'None' => 'None', - 'Nodect' => 'Nodect', - 'Mocord' => 'Mocord' - ); - $this->set('functionoptions', $functionoptions); - - $protocoloptions = array( - 'rtsp' => 'RTSP', - 'http' => 'HTTP' - ); - $this->set('protocoloptions', $protocoloptions); - - $methodoptions = array( - 'simple' => 'Simple', - 'regexp' => 'Regexp' - ); - $this->set('methodoptions', $methodoptions); - - $optionsColours = array( - 1 => '8 bit grayscale', - 3 => '24 bit color', - 4 => '32 bit color' - ); - $this->set('optionsColours', $optionsColours); - - $channeloptions = array(); - for ($i=1; $i<32; $i++) { - array_push($channeloptions, $i); - } - $this->set('channeloptions', $channeloptions); - - $formatoptions = array( - 255 => "PAL", - 45056 => "NTSC", - 1 => "PAL B", - 2 => "PAL B1", - 4 => "PAL G", - 8 => "PAL H", - 16 => "PAL I", - 32 => "PAL D", - 64 => "PAL D1", - 128 => "PAL K", - 256 => "PAL M", - 512 => "PAL N", - 1024 => "PAL Nc", - 2048 => "PAL 60", - 4096 => "NTSC M", - 8192 => "NTSC M JP", - 16384 => "NTSC 443", - 32768 => "NTSC M KR", - 65536 => "SECAM B", - 131072 => "SECAM D", - 262144 => "SECAM G", - 524288 => "SECAM H", - 1048576 => "SECAM K", - 2097152 => "SECAM K1", - 4194304 => "SECAM L", - 8388608 => "SECAM LC", - 16777216 => "ATSC 8 VSB", - 33554432 => "ATSC 16 VSB" - ); - $this->set('formatoptions', $formatoptions); - - $optionsPalette = array( - 0 => 'Auto', - 1497715271 => 'Gray', - 877807426 => 'BGR32', - 876758866 => 'RGB32', - 861030210 => 'BGR24', - 859981650 => 'RGB24', - 1448695129 => '*YUYV', - 1195724874 => '*JPEG', - 1196444237 => '*MJPEG', - 875836498 => '*RGB444', - 1329743698 => '*RGB555', - 1346520914 => '*RGB565', - 1345466932 => '*YUV422P', - 1345401140 => '*YUV411P', - 875836505 => '*YUV444', - 961959257 => '*YUV410', - 842093913 => '*YUV420' - ); - $this->set('optionsPalette', $optionsPalette); - - $optionsMethod = array( - 'v4l2' => 'Video For Linux 2' - ); - $this->set('optionsMethod', $optionsMethod); - $this->set('linkedMonitors', $this->Monitor->find('list', array('fields' => array('Id', 'Name')))); if ($this->request->is('put') || $this->request->is('post')) { @@ -161,6 +59,7 @@ } public function add() { + $this->set('linkedMonitors', $this->Monitor->find('list', array('fields' => array('Id', 'Name')))); if ($this->request->is('post')) { $this->Monitor->create(); if ($this->Monitor->save($this->request->data)) { diff --git a/web/app/View/Elements/tabs-general.ctp b/web/app/View/Elements/tabs-general.ctp index 6b701338c..5404727ba 100644 --- a/web/app/View/Elements/tabs-general.ctp +++ b/web/app/View/Elements/tabs-general.ctp @@ -1,3 +1,23 @@ + 'Local', + 'Remote' => 'Remote', + 'File' => 'File', + 'Ffmpeg' => 'Ffmpeg' + ); + $this->set('typeoptions', $typeoptions); + + $functionoptions = array( + 'Modect' => 'Modect', + 'Monitor' => 'Monitor', + 'Record' => 'Record', + 'None' => 'None', + 'Nodect' => 'Nodect', + 'Mocord' => 'Mocord' + ); + $this->set('functionoptions', $functionoptions); +?> +
Form->input('Name'); diff --git a/web/app/View/Elements/tabs-source.ctp b/web/app/View/Elements/tabs-source.ctp index 2567518ef..5d62a75e4 100644 --- a/web/app/View/Elements/tabs-source.ctp +++ b/web/app/View/Elements/tabs-source.ctp @@ -1,3 +1,88 @@ + '8 bit grayscale', + 3 => '24 bit color', + 4 => '32 bit color' + ); + $this->set('optionsColours', $optionsColours); + + $protocoloptions = array( + 'rtsp' => 'RTSP', + 'http' => 'HTTP' + ); + $this->set('protocoloptions', $protocoloptions); + + $methodoptions = array( + 'simple' => 'Simple', + 'regexp' => 'Regexp' + ); + $this->set('methodoptions', $methodoptions); + + $channeloptions = array(); + for ($i=1; $i<32; $i++) { + array_push($channeloptions, $i); + } + $this->set('channeloptions', $channeloptions); + + $formatoptions = array( + 255 => "PAL", + 45056 => "NTSC", + 1 => "PAL B", + 2 => "PAL B1", + 4 => "PAL G", + 8 => "PAL H", + 16 => "PAL I", + 32 => "PAL D", + 64 => "PAL D1", + 128 => "PAL K", + 256 => "PAL M", + 512 => "PAL N", + 1024 => "PAL Nc", + 2048 => "PAL 60", + 4096 => "NTSC M", + 8192 => "NTSC M JP", + 16384 => "NTSC 443", + 32768 => "NTSC M KR", + 65536 => "SECAM B", + 131072 => "SECAM D", + 262144 => "SECAM G", + 524288 => "SECAM H", + 1048576 => "SECAM K", + 2097152 => "SECAM K1", + 4194304 => "SECAM L", + 8388608 => "SECAM LC", + 16777216 => "ATSC 8 VSB", + 33554432 => "ATSC 16 VSB" + ); + $this->set('formatoptions', $formatoptions); + + $optionsPalette = array( + 0 => 'Auto', + 1497715271 => 'Gray', + 877807426 => 'BGR32', + 876758866 => 'RGB32', + 861030210 => 'BGR24', + 859981650 => 'RGB24', + 1448695129 => '*YUYV', + 1195724874 => '*JPEG', + 1196444237 => '*MJPEG', + 875836498 => '*RGB444', + 1329743698 => '*RGB555', + 1346520914 => '*RGB565', + 1345466932 => '*YUV422P', + 1345401140 => '*YUV411P', + 875836505 => '*YUV444', + 961959257 => '*YUV410', + 842093913 => '*YUV420' + ); + $this->set('optionsPalette', $optionsPalette); + + $optionsMethod = array( + 'v4l2' => 'Video For Linux 2' + ); + $this->set('optionsMethod', $optionsMethod); +?> +
Add Monitor + - "Local", "Remote" => "Remote", "File" => "File", "Ffmpeg" => "Ffmpeg"); -$functionoptions = array('Modect' => 'Modect', 'Monitor' => 'Monitor', 'Record' => 'Record', 'None' => 'None', 'Nodect' => 'Nodect', 'Mocord' => 'Mocord'); -$defaultviewoptions = array('Events' => 'Events', 'Control' => 'Control'); -$defaultrateoptions = array(10000 => '100x', 5000 => '50x', 2500 => '25x', 1000 => '10x', 400 => '4x', 200 => '2x', 100 => 'Real', 50 => '1/2x', 25 => '1/4x'); -$defaultscaleoptions = array(400 => '4x', 300 => '4x', 200 => '2x', 100 => 'Actual', 75 => '3/4x', 50 => '1/2x', 33 => '1/3x', 25 => '1/4x'); +Form->create('Monitor', array( 'inputDefaults' => array( 'legend' => false, 'fieldset' => false))); ?> +Form->input('Id', array('type' => 'hidden')); ?> -echo $this->Form->create('Monitor'); -echo $this->Form->inputs(array( - 'legend' => 'General', - 'Name', - 'Type' => array('type' => 'select', 'options' => $typeoptions), - 'Function' => array('type' => 'select', 'options' => $functionoptions), - 'Enabled' => array('type' => 'checkbox') -)); -echo $this->Form->inputs(array( - 'legend' => 'Buffers', - 'Image Buffer Size (frames)', - 'Warmup Frames', - 'Pre Event Image Count', - 'Post Event Image Count', - 'Stream Reply Image Buffer', - 'Alarm Frame Count' -)); -echo $this->Form->inputs(array( - 'Timestamp Label Format' => array('default' => '%N - %d/%m/%y %H:%M:%S'), - 'Timestamp Label X' => array('default' => 0), - 'Timestamp Label Y' => array('default' => 0) -)); -echo $this->Form->inputs(array( - 'legend' => 'Misc', - 'Event Prefix' => array('default' => 'Event-'), - 'Section Length' => array('default' => 600), - 'Frame Skip' => array('default' => 0), - 'FPS Report Interval' => array('default' => 1000), - 'Web Colour' => array('default' => 'red'), - 'Signal Check Colour' => array('default' => '#0000c0'), - 'Default View' => array('type' => 'select', 'options' => $defaultviewoptions, 'selected' => 'Events'), - 'Default Rate' => array('type' => 'select', 'options' => $defaultrateoptions, 'selected' => 100), - 'Default Scale' => array('type' => 'select', 'options' => $defaultscaleoptions, 'selected' => 100) -)); -echo $this->Form->end('Save'); +
+element('tabs-general'); ?> +element('tabs-source'); ?> +element('tabs-timestamp'); ?> +element('tabs-buffers'); ?> +element('tabs-control'); ?> +element('tabs-misc'); ?> +
-?> +Form->end('Save Monitor'); ?>