1 {% extends "base.html" %}
8 <div class="container-fluid d-flex flex-grow-1 flex-column">
9 <div class="row mt-3 mb-2">
10 <div class="col-2 px-0">
11 <div class="btn-group w-100" id="filterGroup">
12 <button class="btn btn-secondary active" data-read="-1">All</button>
13 <button class="btn btn-secondary" data-read="0">Unread</button>
14 <button class="btn btn-secondary" data-read="1">Read</button>
18 <div class="row flex-grow-1" id="fixHeight">
19 <!-- Notification list && Controls -->
20 <div class="mb-2 mb-lg-0 col-lg-2 px-0 mh-100">
21 <span class="text-muted d-none" id="noMessages">No messages available</span>
22 <div class="list-group rounded-0 rounded-left overflow-auto mh-100 notifications" id="unreadNotifications" data-read="0">
23 {% for notification in unread_notifications %}
26 onclick="showmessage({{notification.id}}); setactive(this);"
27 class="list-group-item list-group-item-action notification">
32 <div class="list-group rounded-0 rounded-left overflow-auto mh-100 notifications" id="readNotifications" data-read="1">
33 {% for notification in read_notifications %}
36 onclick="showmessage({{notification.id}}); setactive(this);"
37 class="list-group-item list-group-item-action list-group-item-secondary notification">
44 <div class="col ml-lg-2 border mh-100 p-4">
45 <iframe name="messageView" class="w-100 h-100" id="inbox-iframe" frameBorder="0" scrolling="yes">Please select a notification</iframe>
50 <script type="text/javascript">
51 function showmessage(msg_id) {
52 window.frames["messageView"].location = "notification/" + msg_id;
55 function setactive(obj) {
56 $(".notification").removeClass("active");
57 $(obj).addClass("active");
60 // Shows messages in the given notification list.
61 // Shows/hides the 'no messages' span after checking children amount
62 // given the .notification classed element
63 function showMessages(notificationList) {
64 $(".notifications").addClass("d-none");
65 if (notificationList.children().length < 1) {
66 $("#noMessages").removeClass("d-none");
68 $("#noMessages").addClass("d-none");
69 notificationList.removeClass("d-none");
73 $(document).ready(function(){
74 // For all / unread / read
75 $("#filterGroup button").click(function(){
76 let read = $(this).attr("data-read");
77 $(this).siblings().removeClass("active");
78 $(this).addClass("active");
80 return showMessages($(".notifications"));
82 return showMessages($(`.notifications[data-read="${read}"]`));
84 showMessages($(".notifications"));