diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-09 17:59:02 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-09 17:59:02 -0500 |
commit | e89ba5e9e692f33427fedb05a095255f27480a6b (patch) | |
tree | 59cbca6ac75a8eff45be14f6ae4ab487e0a427b1 /app/Controller | |
parent | 3df63e051fac84cec98c912668722f87d6e8183e (diff) |
Analytics: add the first graph (task repartition)
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/Analytic.php | 56 | ||||
-rw-r--r-- | app/Controller/Base.php | 1 |
2 files changed, 57 insertions, 0 deletions
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php new file mode 100644 index 00000000..68177c83 --- /dev/null +++ b/app/Controller/Analytic.php @@ -0,0 +1,56 @@ +<?php + +namespace Controller; + +/** + * Project Anaytic controller + * + * @package controller + * @author Frederic Guillot + */ +class Analytic extends Base +{ + /** + * Common layout for analytic views + * + * @access private + * @param string $template Template name + * @param array $params Template parameters + * @return string + */ + private function layout($template, array $params) + { + $params['board_selector'] = $this->projectPermission->getAllowedProjects($this->acl->getUserId()); + $params['analytic_content_for_layout'] = $this->template->load($template, $params); + + return $this->template->layout('analytic/layout', $params); + } + + /** + * Show task distribution graph + * + * @access public + */ + public function repartition() + { + $project = $this->getProject(); + $metrics = $this->projectAnalytic->getTaskRepartition($project['id']); + + if ($this->request->isAjax()) { + $this->response->json(array( + 'metrics' => $metrics, + 'labels' => array( + 'column_title' => t('Column'), + 'nb_tasks' => t('Number of tasks'), + ) + )); + } + else { + $this->response->html($this->layout('analytic/repartition', array( + 'project' => $project, + 'metrics' => $metrics, + 'title' => t('Task repartition for "%s"', $project['name']), + ))); + } + } +} diff --git a/app/Controller/Base.php b/app/Controller/Base.php index c0483aa1..7eb75b07 100644 --- a/app/Controller/Base.php +++ b/app/Controller/Base.php @@ -26,6 +26,7 @@ use Model\LastLogin; * @property \Model\Notification $notification * @property \Model\Project $project * @property \Model\ProjectPermission $projectPermission + * @property \Model\ProjectAnalytic $projectAnalytic * @property \Model\SubTask $subTask * @property \Model\Task $task * @property \Model\TaskHistory $taskHistory |