Add a dashboard (first version)
This commit is contained in:
@@ -13,17 +13,21 @@ use Model\Project as ProjectModel;
|
||||
class App extends Base
|
||||
{
|
||||
/**
|
||||
* Redirect to the project creation page or the board controller
|
||||
* Dashboard for the current user
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->project->countByStatus(ProjectModel::ACTIVE)) {
|
||||
$this->response->redirect('?controller=board');
|
||||
}
|
||||
else {
|
||||
$this->redirectNoProject();
|
||||
}
|
||||
$user_id = $this->acl->getUserId();
|
||||
$projects = $this->projectPermission->getAllowedProjects($user_id);
|
||||
|
||||
$this->response->html($this->template->layout('app_index', array(
|
||||
'board_selector' => $projects,
|
||||
'events' => $this->projectActivity->getProjects(array_keys($projects), 10),
|
||||
'tasks' => $this->taskFinder->getAllTasksByUser($user_id),
|
||||
'menu' => 'dashboard',
|
||||
'title' => t('Dashboard'),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ class Project extends Base
|
||||
$project = $this->getProject();
|
||||
|
||||
$this->response->html($this->template->layout('project_activity', array(
|
||||
'events' => $this->projectActivity->getAll($project['id']),
|
||||
'events' => $this->projectActivity->getProject($project['id']),
|
||||
'menu' => 'projects',
|
||||
'project' => $project,
|
||||
'title' => t('%s\'s activity', $project['name'])
|
||||
@@ -427,6 +427,7 @@ class Project extends Base
|
||||
'project_id' => $project['id'],
|
||||
),
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'columns' => $this->board->getColumnsList($project['id']),
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'title' => $project['name'].($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
|
||||
@@ -461,6 +462,7 @@ class Project extends Base
|
||||
'limit' => $limit,
|
||||
),
|
||||
'project' => $project,
|
||||
'menu' => 'projects',
|
||||
'columns' => $this->board->getColumnsList($project['id']),
|
||||
'categories' => $this->category->getList($project['id'], false),
|
||||
'tasks' => $tasks,
|
||||
|
||||
@@ -59,7 +59,7 @@ class User extends Base
|
||||
$this->response->redirect('?'.$redirect_query);
|
||||
}
|
||||
else {
|
||||
$this->response->redirect('?controller=board');
|
||||
$this->response->redirect('?controller=app');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
'Started on %B %e, %Y' => 'Commençé le %d/%m/%Y',
|
||||
'Start date' => 'Date de début',
|
||||
'Time estimated' => 'Temps estimé',
|
||||
'There is nothing assigned to you.' => 'Aucune tâche assignée pour vous.',
|
||||
'My tasks' => 'Mes tâches',
|
||||
'Activity stream' => 'Flux d\'activité',
|
||||
'Dashboard' => 'Tableau de bord',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -543,4 +543,8 @@ return array(
|
||||
// 'Started on %B %e, %Y' => '',
|
||||
// 'Start date' => '',
|
||||
// 'Time estimated' => '',
|
||||
// 'There is nothing assigned to you.' => '',
|
||||
// 'My tasks' => '',
|
||||
// 'Activity stream' => '',
|
||||
// 'Dashboard' => '',
|
||||
);
|
||||
|
||||
@@ -61,15 +61,32 @@ class ProjectActivity extends Base
|
||||
* @param integer $limit Maximum events number
|
||||
* @return array
|
||||
*/
|
||||
public function getAll($project_id, $limit = 50)
|
||||
public function getProject($project_id, $limit = 50)
|
||||
{
|
||||
return $this->getProjects(array($project_id), $limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all events for the given projects list
|
||||
*
|
||||
* @access public
|
||||
* @param integer $project_id Project id
|
||||
* @param integer $limit Maximum events number
|
||||
* @return array
|
||||
*/
|
||||
public function getProjects(array $projects, $limit = 50)
|
||||
{
|
||||
if (empty($projects)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$events = $this->db->table(self::TABLE)
|
||||
->columns(
|
||||
self::TABLE.'.*',
|
||||
User::TABLE.'.username AS author_username',
|
||||
User::TABLE.'.name AS author_name'
|
||||
)
|
||||
->eq('project_id', $project_id)
|
||||
->in('project_id', $projects)
|
||||
->join(User::TABLE, 'id', 'creator_id')
|
||||
->desc('id')
|
||||
->limit($limit)
|
||||
|
||||
@@ -111,6 +111,33 @@ class TaskFinder extends Base
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all open tasks for a given user
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id User id
|
||||
* @return array
|
||||
*/
|
||||
public function getAllTasksByUser($user_id)
|
||||
{
|
||||
return $this->db
|
||||
->table(Task::TABLE)
|
||||
->columns(
|
||||
'tasks.id',
|
||||
'tasks.title',
|
||||
'tasks.date_due',
|
||||
'tasks.date_creation',
|
||||
'tasks.project_id',
|
||||
'tasks.color_id',
|
||||
'projects.name AS project_name'
|
||||
)
|
||||
->join(Project::TABLE, 'id', 'project_id')
|
||||
->eq('tasks.owner_id', $user_id)
|
||||
->eq('tasks.is_active', Task::STATUS_OPEN)
|
||||
->asc('tasks.id')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all tasks for a given project and status
|
||||
*
|
||||
|
||||
45
app/Templates/app_index.php
Normal file
45
app/Templates/app_index.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<section id="main">
|
||||
<div class="page-header">
|
||||
<h2><?= t('Dashboard') ?></h2>
|
||||
</div>
|
||||
<section id="dashboard">
|
||||
<div class="dashboard-left-column">
|
||||
<h2><?= t('My tasks') ?></h2>
|
||||
<?php if (empty($tasks)): ?>
|
||||
<p class="alert"><?= t('There is nothing assigned to you.') ?></p>
|
||||
<?php else: ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th width="15%"><?= t('Project') ?></th>
|
||||
<th width="40%"><?= t('Title') ?></th>
|
||||
<th><?= t('Due date') ?></th>
|
||||
<th><?= t('Date created') ?></th>
|
||||
</tr>
|
||||
<?php foreach ($tasks as $task): ?>
|
||||
<tr>
|
||||
<td class="task-table task-<?= $task['color_id'] ?>">
|
||||
<?= Helper\a('#'.$task['id'], 'task', 'show', array('task_id' => $task['id'])) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= Helper\a(Helper\escape($task['project_name']), 'board', 'show', array('project_id' => $task['project_id'])) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= Helper\a(Helper\escape($task['title']), 'task', 'show', array('task_id' => $task['id'])) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= dt('%B %e, %Y', $task['date_due']) ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= dt('%B %e, %Y', $task['date_creation']) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="dashboard-right-column">
|
||||
<h2><?= t('Activity stream') ?></h2>
|
||||
<?= Helper\template('project_events', array('events' => $events)) ?>
|
||||
</section>
|
||||
</section>
|
||||
@@ -50,6 +50,9 @@
|
||||
</select>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<li <?= isset($menu) && $menu === 'dashboard' ? 'class="active"' : '' ?>>
|
||||
<a href="?controller=app"><?= t('Dashboard') ?></a>
|
||||
</li>
|
||||
<li <?= isset($menu) && $menu === 'boards' ? 'class="active"' : '' ?>>
|
||||
<a href="?controller=board"><?= t('Boards') ?></a>
|
||||
</li>
|
||||
|
||||
@@ -9,29 +9,10 @@
|
||||
</ul>
|
||||
</div>
|
||||
<section>
|
||||
<?php if (empty($events)): ?>
|
||||
<p class="alert"><?= t('No activity.') ?></p>
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ($project['is_public']): ?>
|
||||
<p class="pull-right"><i class="fa fa-rss-square"></i> <?= Helper\a(t('RSS feed'), 'project', 'feed', array('token' => $project['token'])) ?></p>
|
||||
<?php endif ?>
|
||||
|
||||
<?php foreach ($events as $event): ?>
|
||||
<div class="activity-event">
|
||||
<p class="activity-datetime">
|
||||
<?php if (Helper\contains($event['event_name'], 'task')): ?>
|
||||
<i class="fa fa-newspaper-o"></i>
|
||||
<?php elseif (Helper\contains($event['event_name'], 'subtask')): ?>
|
||||
<i class="fa fa-tasks"></i>
|
||||
<?php elseif (Helper\contains($event['event_name'], 'comment')): ?>
|
||||
<i class="fa fa-comments-o"></i>
|
||||
<?php endif ?>
|
||||
<?= dt('%B %e, %Y at %k:%M %p', $event['date_creation']) ?>
|
||||
</p>
|
||||
<div class="activity-content"><?= $event['event_content'] ?></div>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
<?= Helper\template('project_events', array('events' => $events)) ?>
|
||||
</section>
|
||||
</section>
|
||||
21
app/Templates/project_events.php
Normal file
21
app/Templates/project_events.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php if (empty($events)): ?>
|
||||
<p class="alert"><?= t('No activity.') ?></p>
|
||||
<?php else: ?>
|
||||
|
||||
<?php foreach ($events as $event): ?>
|
||||
<div class="activity-event">
|
||||
<p class="activity-datetime">
|
||||
<?php if (Helper\contains($event['event_name'], 'subtask')): ?>
|
||||
<i class="fa fa-tasks"></i>
|
||||
<?php elseif (Helper\contains($event['event_name'], 'task')): ?>
|
||||
<i class="fa fa-newspaper-o"></i>
|
||||
<?php elseif (Helper\contains($event['event_name'], 'comment')): ?>
|
||||
<i class="fa fa-comments-o"></i>
|
||||
<?php endif ?>
|
||||
<?= dt('%B %e, %Y at %k:%M %p', $event['date_creation']) ?>
|
||||
</p>
|
||||
<div class="activity-content"><?= $event['event_content'] ?></div>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php endif ?>
|
||||
@@ -13,7 +13,7 @@
|
||||
<?php foreach ($tasks as $task): ?>
|
||||
<tr>
|
||||
<td class="task-table task-<?= $task['color_id'] ?>">
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>" title="<?= t('View this task') ?>"><?= Helper\escape($task['id']) ?></a>
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>" title="<?= t('View this task') ?>">#<?= Helper\escape($task['id']) ?></a>
|
||||
</td>
|
||||
<td>
|
||||
<?= Helper\in_list($task['column_id'], $columns) ?>
|
||||
|
||||
Reference in New Issue
Block a user