Skip to content

Commit

Permalink
can now add templates to dashboard + fixed resize bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmusbergpalm committed Aug 22, 2011
1 parent 270949a commit 5633ee3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/controllers/dbviews_controller.php
Expand Up @@ -21,14 +21,14 @@ function add($dashboard_id, $template = null) {
$this->Dbview->create();

$this->data['Dbview']['name'] = $template;
$this->data['Dbview']['code'] = file_get_contents(APP.'templates'.DS.'views'.DS.$template.DS.$template.'.js');
$this->data['Dbview']['code'] = file_get_contents(APP.'templates'.DS.$template);
$this->data['Dbview']['dashboard_id'] = $dashboard_id;
$this->data['Dbview']['left'] = 100;
$this->data['Dbview']['top'] = 100;
$this->data['Dbview']['width'] = 300;
$this->data['Dbview']['width'] = 400;
$this->data['Dbview']['height'] = 300;
if ($this->Dbview->save($this->data)) {
$this->Session->setFlash(__('The dbview has been saved', true));
$this->Session->setFlash(__('The widget has been added', true));
$this->redirect(array('controller' => 'dashboards','action' => 'view', $dashboard_id));
} else {
$this->Session->setFlash(__('The dbview could not be saved. Please, try again.', true));
Expand Down
6 changes: 3 additions & 3 deletions app/views/dashboards/view.ctp
Expand Up @@ -5,15 +5,15 @@
$id = $dbview['id'];

echo "<div class='dragbox' id='dragbox_$id'
style='position: relative; left: ".$dbview['left']."px; top: ".$dbview['top']."px; width: ".($dbview['width']+20)."px; height: ".($dbview['height']+40)."px;'>
style='position: absolute; z-index: $id; left: ".$dbview['left']."px; top: ".$dbview['top']."px; width: ".($dbview['width'])."px; height: ".($dbview['height'])."px;'>
<div class='header'>
<span>".$dbview['name']."</span>";
<span>&nbsp;</span>";
echo $this->Html->link('X', "/dbviews/delete/$id", array('style' =>'float: right; margin-left: 10px;'));
echo $this->Html->link('edit', "/dbviews/edit/$id", array('style' =>'float: right;', 'class' => 'editlink'));


echo "</div>
<div class='dragbox-content' id='view$id' style='clear: both; width: ".$dbview['width']."px; height: ".$dbview['height']."px;'>Loading...</div>
<div class='dragbox-content' id='view$id' style='clear: both; width: ".($dbview['width']-10)."px; height: ".($dbview['height']-40)."px;'>Loading...</div>
</div>";
}
?>
Expand Down
1 change: 1 addition & 0 deletions app/views/dbviews/add.ctp
Expand Up @@ -7,6 +7,7 @@
style='float: left; width: 420px; height: 320px;'>
<div class='header' style='cursor: default;'>
<span>$name</span>";
echo $this->Html->link('Add', "/dbviews/add/$dashboard_id/$name", array('style' =>'float: right; margin-left: 10px;'));
echo "</div>
<div class='dragbox-content' id='view$id' style='clear: both; width: 400px; height: 300px;'>Loading...</div>
</div>";
Expand Down

0 comments on commit 5633ee3

Please sign in to comment.