Initial ability to edit limited options of existing monitors

This commit is contained in:
Kyle Johnson 2013-05-01 21:03:25 -04:00
parent 6bc6610542
commit e2751c0597
3 changed files with 41 additions and 3 deletions

View File

@ -18,6 +18,32 @@
}
$this->set('monitor', $monitor);
}
public function edit($id = null) {
if (!$id) {
throw new NotFoundException(__('Invalid monitor'));
}
$monitor = $this->Monitor->findById($id);
if (!$monitor) {
throw new NotFoundException(__('Invalid monitor'));
}
if ($this->request->is('put') || $this->request->is('post')) {
$this->Monitor->id = $id;
if ($this->Monitor->save($this->request->data)) {
$this->Session->setFlash('Your monitor has been updated.');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('Unable to update your monitor.');
}
}
if (!$this->request->data) {
$this->request->data = $monitor;
}
}
}
?>

View File

@ -0,0 +1,10 @@
<h2>Edit Monitor</h2>
<?php
echo $this->Form->create('Monitor');
echo $this->Form->input('Name');
$functionoptions = array('Modect' => 'Modect', 'Monitor' => 'Monitor', 'Record' => 'Record', 'None' => 'None', 'Nodect' => 'Nodect', 'Mocord' => 'Mocord');
echo $this->Form->input('Function', array('type' => 'select', 'options' => $functionoptions));
echo $this->Form->input('Enabled', array('type' => 'checkbox'));
echo $this->Form->input('Id', array('type' => 'hidden'));
echo $this->Form->end('Save Monitor');
?>

View File

@ -9,9 +9,11 @@
<?php foreach ($monitors as $monitor): ?>
<tr>
<td>
<?php echo $this->Html->link($monitor['Monitor']['Name'],
array('controller' => 'monitors', 'action' => 'view', $monitor['Monitor']['Id'])); ?>
<td><?php echo $monitor['Monitor']['Function']; ?></td>
<?php echo $this->Html->link($monitor['Monitor']['Name'],array('controller' => 'monitors', 'action' => 'view', $monitor['Monitor']['Id'])); ?>
</td>
<td>
<?php echo $this->Html->link($monitor['Monitor']['Function'], array('action' => 'edit', $monitor['Monitor']['Id'])); ?>
</td>
<td><?php echo $monitor['Monitor']['Host']; ?></td>
</tr>
<?php endforeach; ?>