Merge pull request #154 from WDKevin/modern

Add support to change order of monitors
This commit is contained in:
Kyle Johnson 2013-09-18 09:43:08 -07:00
commit 08e224f2af
2 changed files with 132 additions and 118 deletions

View File

@ -1,11 +1,11 @@
<?php
class MonitorsController extends AppController {
public $helpers = array('LiveStream');
public $helpers = array('LiveStream', 'Js'=>array('Jquery'));
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'), 'recursive' => -1);
$monitoroptions = array('fields' => array('Name', 'Id', 'Function', 'Enabled', 'Sequence'), '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) {
@ -173,6 +173,14 @@
}
}
public function reorder() {
foreach ($this->data['Monitor'] as $key => $value) {
$this->log($value);
$this->Monitor->id = $value;
$this->Monitor->saveField('Sequence', $key + 1);
}
exit();
}
}
?>

View File

@ -3,9 +3,10 @@
echo $this->Html->link( 'Add Monitor', array('controller' => 'monitors', 'action' => 'add'));
$this->end();
?>
<div class="row">
<div class="row" id="monitors">
<?php foreach ($monitors as $monitor => $mon): ?>
<div class="col-sm-6 col-md-3">
<div class="col-sm-6 col-md-3" id="Monitor_<?= $mon['Monitor']['Sequence']; ?>">
<div class="thumbnail">
<?php
if($daemonStatus && $mon['Monitor']['Function'] != "None" && $mon['Monitor']['Enabled'])
@ -22,3 +23,8 @@
<?php endforeach; ?>
<?php unset($monitor); ?>
</div>
<?php
$this->Js->get('#monitors');
$this->Js->sortable(array('complete' => '$.post("/monitors/reorder", $("#monitors").sortable("serialize"))',));
?>