Improve active project in sidebar

This commit is contained in:
Eike Foken
2011-09-15 02:37:40 +02:00
parent 08e5048e20
commit b9ee743f9d
2 changed files with 47 additions and 23 deletions

View File

@@ -143,16 +143,13 @@ class Project extends CI_Model {
} }
/** /**
* Get all available configurations from a specific project. * Counts all experiments for the specified project.
* *
* @param array $project_id The project to get the configuration from. * @param string $projectId
* @return integer
*/ */
public function getConfigurations($project_id) { public function countExperiments($projectId) {
$query = $this->db->get_where('configurations', array('project_id' => $project_id)); return $this->db->get_where('experiments', array('project_id' => $projectId))->num_rows();
$configurations = $query->result_array();
return $configurations;
} }
/** /**

View File

@@ -34,7 +34,7 @@
<div id="header"> <div id="header">
<h1><?=anchor('', image_asset('logo.png'));?></h1> <h1><?=anchor('', image_asset('logo.png'));?></h1>
<div class="status"> <div class="status">
<?=_('Current project:');?>&nbsp; <?=_('Current project');?>:&nbsp;
<select name="activeProject"> <select name="activeProject">
<?php <?php
// get the active project, if there is one // get the active project, if there is one
@@ -65,26 +65,53 @@
<div id="notifications"></div> <div id="notifications"></div>
<div id="sidebar"> <div id="sidebar">
<div class="title">
<h2><?=_('Actions');?></h2>
</div>
<div class="navigation">
<ul>
<?php <?php
if ($active_project): if ($active_project):
?> ?>
<li> <div class="title">
<a href="javascript:void(0);" onclick="$(this).parent().toggleClass('active').find('ul').toggle();"><?=_('Project');?> <?=$active_project['shortname'];?></a> <h2><?=_('Current project');?></h2>
<ul> </div>
<li><a href="<?=site_url('projects/detail/' . $active_project['id']);?>" title="<?=_('Show overview');?>"><?=_('Overview');?></a></li>
<li><a href="<?=site_url('experiments/create/' . $active_project['id']);?>" title="<?=sprintf(_('Create a new experiment for the project &quot;%s&quot;'), $active_project['name']);?>"><?=_('New experiment');?></a></li> <div class="box">
<li><a href="<?=site_url('results/project/' . $active_project['id']);?>" title="<?=sprintf(_('Show results for the project &quot;%s&quot;'), $active_project['name']);?>"><?=_('Show results');?></a></li> <?php
</ul> if ($active_project['default_model'] != ''):
</li> ?>
<canvas id="model" width="190" height="160"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('model');
var viewer = new JSC3D.Viewer(canvas);
viewer.setParameter('SceneUrl', BASE_URL + 'uploads/<?=$active_project['id'];?>/<?=$active_project['default_model'];?>');
viewer.setParameter('InitRotationX', -20);
viewer.setParameter('InitRotationY', 20);
viewer.setParameter('InitRotationZ', 0);
viewer.setParameter('ModelColor', '#cccccc');
viewer.setParameter('BackgroundColor1', '#ffffff');
viewer.setParameter('BackgroundColor2', '#ffffff');
viewer.setParameter('RenderMode', 'flat');
viewer.init();
viewer.update();
</script>
<?php
endif;
?>
<p>
<strong><?=_('Name');?>:</strong> <?=anchor('projects/detail/' . $active_project['id'], $active_project['shortname']);?><br />
<strong><?=_('Experiments');?>:</strong> <?=$this->project->countExperiments($active_project['id']);?><br />
</p>
<p>
<a href="<?=site_url('experiments/create/' . $active_project['id']);?>" class="button add" title="<?=sprintf(_('Create a new experiment for the project &quot;%s&quot;'), $active_project['name']);?>"><?=_('New experiment');?></a>
</p>
</div>
<?php <?php
endif; endif;
?> ?>
<div class="title">
<h2><?=_('Navigation');?></h2>
</div>
<div class="navigation">
<ul>
<li class="togglable" id="nav_projects"> <li class="togglable" id="nav_projects">
<a href="javascript:void(0);"><?=_('Projects');?></a> <a href="javascript:void(0);"><?=_('Projects');?></a>
<ul> <ul>