Add web notifications

This commit is contained in:
Frederic Guillot
2015-10-03 12:09:27 -04:00
parent b5a2b8f9f7
commit d67d7c54e6
41 changed files with 1670 additions and 567 deletions

View File

@@ -0,0 +1,61 @@
<div class="page-header">
<h2><?= t('My notifications') ?></h2>
<?php if (empty($notifications)): ?>
<p class="alert"><?= t('No new notifications.') ?></p>
</div>
<?php else: ?>
<ul>
<li>
<i class="fa fa-check-square-o fa-fw"></i>
<?= $this->url->link(t('Mark all as read'), 'webnotification', 'flush', array('user_id' => $user['id'])) ?>
</li>
</ul>
</div>
<table class="table-fixed table-small">
<tr>
<th><?= t('Notification') ?></th>
<th class="column-20"><?= t('Date') ?></th>
<th class="column-15"><?= t('Action') ?></th>
</tr>
<?php foreach ($notifications as $notification): ?>
<tr>
<td>
<?php if ($this->text->contains($notification['event_name'], 'subtask')): ?>
<i class="fa fa-tasks fa-fw"></i>
<?php elseif ($this->text->contains($notification['event_name'], 'task.move')): ?>
<i class="fa fa-arrows-alt fa-fw"></i>
<?php elseif ($this->text->contains($notification['event_name'], 'task.overdue')): ?>
<i class="fa fa-calendar-times-o fa-fw"></i>
<?php elseif ($this->text->contains($notification['event_name'], 'task')): ?>
<i class="fa fa-newspaper-o fa-fw"></i>
<?php elseif ($this->text->contains($notification['event_name'], 'comment')): ?>
<i class="fa fa-comments-o fa-fw"></i>
<?php elseif ($this->text->contains($notification['event_name'], 'file')): ?>
<i class="fa fa-file-o fa-fw"></i>
<?php endif ?>
<?php if ($this->text->contains($notification['event_name'], 'comment')): ?>
<?= $this->url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id']), false, '', '', false, 'comment-'.$notification['event_data']['comment']['id']) ?>
<?php elseif ($this->text->contains($notification['event_name'], 'task.overdue')): ?>
<?php if (count($notification['event_data']['tasks']) > 1): ?>
<?= $notification['title'] ?>
<?php else: ?>
<?= $this->url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['tasks'][0]['id'], 'project_id' => $notification['event_data']['tasks'][0]['project_id'])) ?>
<?php endif ?>
<?php else: ?>
<?= $this->url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id'])) ?>
<?php endif ?>
</td>
<td>
<?= dt('%B %e, %Y at %k:%M %p', $notification['date_creation']) ?>
</td>
<td>
<i class="fa fa-check fa-fw"></i>
<?= $this->url->link(t('Mark as read'), 'webnotification', 'remove', array('user_id' => $user['id'], 'notification_id' => $notification['id'])) ?>
</td>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>

View File

@@ -19,6 +19,9 @@
<li <?= $this->app->getRouterAction() === 'activity' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('My activity stream'), 'app', 'activity', array('user_id' => $user['id'])) ?>
</li>
<li <?= $this->app->getRouterAction() === 'notifications' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('My notifications'), 'app', 'notifications', array('user_id' => $user['id'])) ?>
</li>
<?= $this->hook->render('template:dashboard:sidebar') ?>
</ul>
<div class="sidebar-collapse"><a href="#" title="<?= t('Hide sidebar') ?>"><i class="fa fa-chevron-left"></i></a></div>

View File

@@ -25,6 +25,10 @@
</li>
<?php endif ?>
<li>
<?php if ($this->user->hasNotifications()): ?>
<?= $this->url->link('<i class="fa fa-bell web-notification-icon"></i>', 'app', 'notifications', array('user_id' => $this->user->getId()), false, '', t('Unread notifications')) ?>
<?php endif ?>
<?= $this->url->link(t('Logout'), 'auth', 'logout') ?>
<span class="username hide-tablet">(<?= $this->user->getProfileLink() ?>)</span>
</li>

View File

@@ -37,7 +37,7 @@
<?= $this->form->label(t('Language'), 'language') ?>
<?= $this->form->select('language', $languages, $values, $errors) ?><br/>
<?= $this->form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?>
<?= $this->form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?>
<?= $this->form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?>
<?= $this->form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?>
</div>

View File

@@ -40,7 +40,7 @@
<?= $this->form->label(t('Language'), 'language') ?>
<?= $this->form->select('language', $languages, $values, $errors) ?><br/>
<?= $this->form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?>
<?= $this->form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?>
<?= $this->form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?>
<?= $this->form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?>
<?= $this->form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?>

View File

@@ -1,33 +1,24 @@
<div class="page-header">
<h2><?= t('Email notifications') ?></h2>
<h2><?= t('Notifications') ?></h2>
</div>
<form method="post" action="<?= $this->url->href('user', 'notifications', array('user_id' => $user['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->checkbox('notifications_enabled', t('Enable email notifications'), '1', $notifications['notifications_enabled'] == 1) ?><br>
<?= $this->form->checkbox('notifications_enabled', t('Enable notifications'), '1', $notifications['notifications_enabled'] == 1) ?><br>
<hr>
<?= t('I want to receive notifications for:') ?>
<?= $this->form->radios('notifications_filter', array(
\Model\Notification::FILTER_NONE => t('All tasks'),
\Model\Notification::FILTER_ASSIGNEE => t('Only for tasks assigned to me'),
\Model\Notification::FILTER_CREATOR => t('Only for tasks created by me'),
\Model\Notification::FILTER_BOTH => t('Only for tasks created by me and assigned to me'),
), $notifications) ?><br>
<h4><?= t('Notification methods:') ?></h4>
<?= $this->form->checkboxes('notification_types', $types, $notifications) ?>
<hr>
<h4><?= t('I want to receive notifications for:') ?></h4>
<?= $this->form->radios('notifications_filter', $filters, $notifications) ?>
<hr>
<?php if (! empty($projects)): ?>
<p><?= t('I want to receive notifications only for those projects:') ?><br/><br/></p>
<div class="form-checkbox-group">
<?php foreach ($projects as $project_id => $project_name): ?>
<?= $this->form->checkbox('projects['.$project_id.']', $project_name, '1', isset($notifications['project_'.$project_id])) ?><br>
<?php endforeach ?>
</div>
<h4><?= t('I want to receive notifications only for those projects:') ?></h4>
<?= $this->form->checkboxes('notification_projects', $projects, $notifications) ?>
<?php endif ?>
<div class="form-actions">

View File

@@ -51,7 +51,7 @@
<?= $this->url->link(t('Public access'), 'user', 'share', array('user_id' => $user['id'])) ?>
</li>
<li <?= $this->app->getRouterController() === 'user' && $this->app->getRouterAction() === 'notifications' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('Email notifications'), 'user', 'notifications', array('user_id' => $user['id'])) ?>
<?= $this->url->link(t('Notifications'), 'user', 'notifications', array('user_id' => $user['id'])) ?>
</li>
<li <?= $this->app->getRouterController() === 'user' && $this->app->getRouterAction() === 'external' ? 'class="active"' : '' ?>>
<?= $this->url->link(t('External accounts'), 'user', 'external', array('user_id' => $user['id'])) ?>