-
Notifications
You must be signed in to change notification settings - Fork 40
Notification framework #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
dc5e6f8
3d9a85d
c79c1bd
5cd7500
d507c44
1dd3d6b
47feb76
0e9465f
6982837
ec85ee2
f630f8a
4c24e6c
db07aa5
e98ff6f
99c3aff
80124a4
7d5a2c9
24ea0e2
3706261
9c672dd
3542ff8
8cd3d09
d9f31bb
d4f786a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .notification_read { | ||
| background-color: #bdbdbd; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| $(document).ready(function () { | ||
| /** | ||
| * Mark notification as read through the UI. | ||
| */ | ||
|
|
||
|
|
||
| // Method to mark as read individual notifications | ||
| $(".read_notification").click(function(e){ | ||
| // get the user id of the logged in user | ||
| var uid = $(this).attr('uid'); | ||
| // get a list of notification ids, in this case it will be a | ||
| // list of length 1 as it a single notification | ||
| var notification_ids = [$(this).attr('notification_id')]; | ||
| // Call function read_notification which sends a POST request to mark | ||
| // notification as read | ||
| read_notifications(uid, notification_ids, function(error, data){ | ||
| if (error) { | ||
| return alert(error); | ||
| } else { | ||
| // If no error is caught that manipulate the DOM for notification | ||
| manipulate_dom(notification_ids); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| // Method to mark all notification of a group as read for the user | ||
| $(".read_all_group_notifications").click(function(e){ | ||
| // get the user id of the logged in user | ||
| var uid = $(this).attr('uid'); | ||
| // get the group id of the notifications that need to be marked as read | ||
| var group_id = $(this).attr('group_id'); | ||
| // create a list of notification ids which are present in the group | ||
| var notification_ids = []; | ||
| $.each($('.notifications.' + group_id), function( index, notification ) { | ||
| notification_ids.push($(notification).attr('id')); | ||
| }); | ||
| // Call function read_notifications which sends a POST request to mark | ||
| // notifications as read | ||
| read_notifications(uid, notification_ids, function(error, data){ | ||
| if (error) { | ||
| return alert(error); | ||
| } else { | ||
| // If no error is caught that manipulate the DOM for notification | ||
| manipulate_dom(notification_ids); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| // Method to mark all notifications as read for the user | ||
| $(".read_all_notifications").click(function(e){ | ||
| // get the user id of the logged in user | ||
| var uid = $(this).attr('uid'); | ||
| // create a list of notification ids which are present in the group | ||
| var notification_ids = []; | ||
| $.each($('.notifications'), function( index, notification ) { | ||
| notification_ids.push($(notification).attr('id')); | ||
| }); | ||
| // Call function read_notification which sends a POST request to mark | ||
| // notifications as read | ||
| read_notifications(uid, notification_ids, function(error, data){ | ||
| if (error) { | ||
| return alert(error); | ||
| } else { | ||
| // If no error is caught that manipulate the DOM for notification | ||
| manipulate_dom(notification_ids); | ||
| $ | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| // send a POST request to the view method mark_notificartions_as_read_api | ||
| // with a list of notification_ids | ||
| var read_notifications = function(uid, notification_ids, callback) { | ||
| console.log(notification_ids); | ||
| $.post('/javascript/' + uid + '/mark_notifications_as_read_api/', { | ||
| 'notification_ids[]': [notification_ids] | ||
| }, function (data) { | ||
| if (data.Error) { | ||
| callback(data.Error, null); | ||
| } else { | ||
| callback(null, data); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| // grey out notification row and remove the tick mark for notification row | ||
| var manipulate_dom = function(notification_ids){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename method name to "grey_out_notifications" |
||
| $.each($(notification_ids), function(index, element){ | ||
| $('.remove_read'+element).remove(); | ||
| $('.notification_event'+element).addClass('notification_read'); | ||
| }); | ||
| }; | ||
|
|
||
| // helper function for tooltip, used to display text when cursors hovers on | ||
| // the read tick marks. | ||
| $('[data-toggle="tooltip"]').tooltip(); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,10 @@ <h4 class="modal-title" id="myModalLabel">Forgot Information</h4> | |
| {% endif %} | ||
| <li><a href="{% url 'features' %}">Features</a></li> | ||
| <li><a href="{% url 'help_tutorial' %}">Help</a></li> | ||
| <li><a href="{% url 'help_about' %}" style="text-align:center">About Us</a></li> | ||
| <li><a href="{% url 'help_about' %}" style="text-align:center">About Us</a></li> | ||
| {% if uid != None %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this check sufficient? Should we not check that the user is indeed logged in and is a "valid" user? I am asking without knowledge of how this check is performed in other parts of GraphSpace.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this will be enough as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <li><a href="{% url 'notifications' uid %}">Notifications</a></li> | ||
| {% endif %} | ||
| </ul> | ||
|
|
||
| <!-- display login form if not logged in --> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| {% extends 'base.html' %} | ||
| {% block content %} | ||
| {% load staticfiles %} | ||
| <link href={% static "graphs/css/notifications.css" %} rel="stylesheet"> | ||
| <script type="text/javascript" src="{% static 'graphs/js/notifications.js' %}"></script> | ||
|
|
||
| {% if uid != None %} | ||
|
|
||
| <br> | ||
| <div class="row"><button style="position: relative; | ||
| right: 100px; float: right;" class="btn btn-default read_all_notifications" uid="{{ uid }}" allid="True">Mark all notifications as read</button></div> | ||
| <br> | ||
|
|
||
| <div class="row"> | ||
| <div class="col-sm-3"> | ||
| <div class="list-group"> | ||
| <a href="{% url 'notifications' uid %}" class="list-group-item">Unread<span class="badge">{{ num_active_notifications }}</span> </a> | ||
| <a href="{% url 'notifications' uid %}?all=1" class="list-group-item">All Notifications <span class="badge">{{ num_notifications }}</span> </a> | ||
| </div> | ||
| <div class="list-group"> | ||
| <a href="#" class="list-group-item active">Groups</a> | ||
| {% for group_id, notifications in groups_of_user.items %} | ||
| <a href="{% url 'notifications' uid %}?group_id={{ group_id }}" class="list-group-item">{{ group_id }} <span class="badge">{{ notifications }}</span></a> | ||
| {% endfor %} | ||
| </div> | ||
| </div> | ||
|
|
||
| {% if grouped_notifications|length != 0 %} | ||
| <div class="col-sm-8"> | ||
| <div class="panel panel-primary"> | ||
| {% for group, events in grouped_notifications.items %} | ||
| {% if events|length > 0 %} | ||
|
|
||
| <table class="table" id="notification_table{{ group }}"> | ||
| <tr bgcolor="#428BCA"> | ||
| <th><font color="white">{{ group }}</font></th> | ||
| <th></th> | ||
| <th><a href="#" data-toggle="tooltip" title="Mark all {{ group }} notifications as read" data-placement="left"><button class="btn btn-default read_all_group_notifications" uid="{{ uid }}" group_id="{{ group }}"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button></a> </th> | ||
| </tr> | ||
| {% for event in events %} | ||
| {% if event.owner_id != uid %} | ||
|
|
||
| <tr id="{{ event.id }}" class="notification_event{{ event.id }} {{ group }} notifications"> | ||
| <td> <a href="{% url 'graphs' %}/{{ event.owner_id }}/{{ event.graph_id}}">{{ event.owner_id }} shared {{ event.graph_id }} with {{ event.group_id }}.</a></td> | ||
| <td> Shared on {{ event.share_time }}</td> | ||
| <td class="remove_read{{ event.id }}"><a href="#" data-toggle="tooltip" title="Mark as read" data-placement="left"><button class="btn btn-default read_notification" notification_id="{{ event.id }}" uid="{{ event.member_id }}"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button></a></td> | ||
| </tr> | ||
|
|
||
| {% endif %} | ||
| {% endfor %} | ||
| </table> | ||
| {% endif %} | ||
| {% endfor %} | ||
| </div> | ||
| </div> | ||
|
|
||
|
|
||
| {% else %} | ||
| <div class="col-sm-8"> | ||
| <div class="panel panel-primary"> | ||
| <div class="panel-heading"> | ||
| <h4 class="panel-title" style="text-align: center">No new notifications.</h4> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {% endif %} | ||
|
|
||
|
|
||
| </div> | ||
|
|
||
| {% endif %} | ||
| {% endblock %} |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some docs on the schema. What does the table store? Why do you need each attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class names should have camel case.