mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 04:15:12 +00:00
some more work on forum notifications
This commit is contained in:
parent
53efd4e470
commit
db0a3a7534
5 changed files with 53 additions and 10 deletions
|
@ -673,14 +673,27 @@ class Ping extends \Zotlabs\Web\Controller {
|
||||||
dbesc($r1[$x]['xchan_hash'])
|
dbesc($r1[$x]['xchan_hash'])
|
||||||
);
|
);
|
||||||
if($r[0]['unseen']) {
|
if($r[0]['unseen']) {
|
||||||
|
$r1[$x]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id'];
|
||||||
|
$r1[$x]['name'] = $r1[$x]['xchan_name'];
|
||||||
|
$r1[$x]['url'] = $r1[$x]['xchan_url'];
|
||||||
|
$r1[$x]['photo'] = $r1[$x]['xchan_photo_s'];
|
||||||
$r1[$x]['unseen'] = $r[0]['unseen'];
|
$r1[$x]['unseen'] = $r[0]['unseen'];
|
||||||
$r1['total'] = $r1['total'] + $r[0]['unseen'];
|
$r1['total'] = $r1['total'] + $r[0]['unseen'];
|
||||||
|
|
||||||
|
unset($r1[$x]['abook_id']);
|
||||||
|
unset($r1[$x]['xchan_hash']);
|
||||||
|
unset($r1[$x]['xchan_name']);
|
||||||
|
unset($r1[$x]['xchan_url']);
|
||||||
|
unset($r1[$x]['xchan_photo_s']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unset($r1[$x]);
|
unset($r1[$x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result['forums'] = $r1['total'];
|
$result['forums'] = $r1['total'];
|
||||||
|
unset($r1['total']);
|
||||||
|
|
||||||
|
$result['forums_sub'] = $r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = json_encode($result);
|
$x = json_encode($result);
|
||||||
|
|
|
@ -118,12 +118,8 @@ class Notifications {
|
||||||
'severity' => 'secondary',
|
'severity' => 'secondary',
|
||||||
'label' => t('Forums'),
|
'label' => t('Forums'),
|
||||||
'title' => t('Forums'),
|
'title' => t('Forums'),
|
||||||
'viewall' => [
|
'filter' => [
|
||||||
//'url' => 'notifications/system',
|
'name_label' => t('Filter by name')
|
||||||
//'label' => t('View all notices')
|
|
||||||
],
|
|
||||||
'markall' => [
|
|
||||||
//'label' => t('Mark all notices seen')
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,6 +420,14 @@ function notificationsUpdate(cached_data) {
|
||||||
// Put the object into storage
|
// Put the object into storage
|
||||||
sessionStorage.setItem('notifications_cache', JSON.stringify(data));
|
sessionStorage.setItem('notifications_cache', JSON.stringify(data));
|
||||||
|
|
||||||
|
var fnotifs = [];
|
||||||
|
if(data.forums) {
|
||||||
|
$.each(data.forums_sub, function() {
|
||||||
|
fnotifs.push(this);
|
||||||
|
});
|
||||||
|
handleNotificationsItems('forums', fnotifs);
|
||||||
|
}
|
||||||
|
|
||||||
if(data.invalid == 1) {
|
if(data.invalid == 1) {
|
||||||
window.location.href=window.location.href;
|
window.location.href=window.location.href;
|
||||||
}
|
}
|
||||||
|
@ -495,13 +503,13 @@ function handleNotifications(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNotificationsItems(notifyType, data) {
|
function handleNotificationsItems(notifyType, data) {
|
||||||
var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html());
|
var notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html()));
|
||||||
var notify_menu = $("#nav-" + notifyType + "-menu");
|
var notify_menu = $("#nav-" + notifyType + "-menu");
|
||||||
|
|
||||||
notify_menu.html('');
|
notify_menu.html('');
|
||||||
|
|
||||||
$(data).each(function() {
|
$(data).each(function() {
|
||||||
html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top);
|
html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen);
|
||||||
notify_menu.append(html);
|
notify_menu.append(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -812,6 +820,14 @@ function updateInit() {
|
||||||
if (initialLoad && (sessionStorage.getItem('notifications_cache') !== null)) {
|
if (initialLoad && (sessionStorage.getItem('notifications_cache') !== null)) {
|
||||||
var cached_data = JSON.parse(sessionStorage.getItem('notifications_cache'));
|
var cached_data = JSON.parse(sessionStorage.getItem('notifications_cache'));
|
||||||
notificationsUpdate(cached_data);
|
notificationsUpdate(cached_data);
|
||||||
|
|
||||||
|
var fnotifs = [];
|
||||||
|
if(cached_data.forums) {
|
||||||
|
$.each(cached_data.forums_sub, function() {
|
||||||
|
fnotifs.push(this);
|
||||||
|
});
|
||||||
|
handleNotificationsItems('forums', fnotifs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! src) {
|
if(! src) {
|
||||||
|
@ -1022,6 +1038,7 @@ function loadNotificationItems(notifyType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('updating ' + notifyType + ' notifications...');
|
console.log('updating ' + notifyType + ' notifications...');
|
||||||
|
|
||||||
$.get(pingExCmd, function(data) {
|
$.get(pingExCmd, function(data) {
|
||||||
if(data.invalid == 1) {
|
if(data.invalid == 1) {
|
||||||
window.location.href=window.location.href;
|
window.location.href=window.location.href;
|
||||||
|
|
|
@ -593,7 +593,8 @@ footer {
|
||||||
background-color: $comment_item_colour;
|
background-color: $comment_item_colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav-notifications-template {
|
#nav-notifications-template,
|
||||||
|
#nav-notifications-forums-template {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,6 +838,11 @@ div.jGrowl div.jGrowl-notification {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification.notification-forum {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: $font_colour;
|
||||||
|
}
|
||||||
|
|
||||||
#acl-search::-webkit-input-placeholder {
|
#acl-search::-webkit-input-placeholder {
|
||||||
/* non-fontawesome fonts set a fallback for text parts of the placeholder*/
|
/* non-fontawesome fonts set a fallback for text parts of the placeholder*/
|
||||||
font-family: ForkAwesome, sans-serif, arial, freesans;
|
font-family: ForkAwesome, sans-serif, arial, freesans;
|
||||||
|
|
|
@ -127,12 +127,19 @@
|
||||||
{{$no_notifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
|
{{$no_notifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="nav-notifications-template" rel="template">
|
<div id="nav-notifications-template" rel="template">
|
||||||
<a class="list-group-item clearfix notification {5}" href="{0}" title="{2} {3}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}">
|
<a class="list-group-item clearfix notification {5}" href="{0}" title="{2}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}">
|
||||||
<img class="menu-img-3" data-src="{1}">
|
<img class="menu-img-3" data-src="{1}">
|
||||||
<span class="contactname">{2}</span>
|
<span class="contactname">{2}</span>
|
||||||
<span class="dropdown-sub-text">{3}<br>{4}</span>
|
<span class="dropdown-sub-text">{3}<br>{4}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="nav-notifications-forums-template" rel="template">
|
||||||
|
<a class="list-group-item clearfix notification notification-forum" href="{0}" title="{2} {3}" data-b64mid="{6}" data-notify_id="{7}" data-thread_top="{8}" data-contact_name="{2}">
|
||||||
|
<span class="float-right badge badge-{{$notification.severity}}">{9}</span>
|
||||||
|
<img class="menu-img-1" src="{1}">
|
||||||
|
<span class="">{2}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div id="notifications" class="navbar-nav">
|
<div id="notifications" class="navbar-nav">
|
||||||
{{foreach $notifications as $notification}}
|
{{foreach $notifications as $notification}}
|
||||||
<div class="collapse {{$notification.type}}-button">
|
<div class="collapse {{$notification.type}}-button">
|
||||||
|
@ -152,15 +159,19 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $notification.filter}}
|
{{if $notification.filter}}
|
||||||
|
{{if $notification.filter.posts_label}}
|
||||||
<div class="list-group-item cursor-pointer" id="tt-{{$notification.type}}-only">
|
<div class="list-group-item cursor-pointer" id="tt-{{$notification.type}}-only">
|
||||||
<i class="fa fa-fw fa-filter"></i> {{$notification.filter.posts_label}}
|
<i class="fa fa-fw fa-filter"></i> {{$notification.filter.posts_label}}
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
{{if $notification.filter.name_label}}
|
||||||
<div class="list-group-item clearfix notifications-textinput" id="cn-{{$notification.type}}-only">
|
<div class="list-group-item clearfix notifications-textinput" id="cn-{{$notification.type}}-only">
|
||||||
<div class="text-muted notifications-textinput-filter"><i class="fa fa-fw fa-filter"></i></div>
|
<div class="text-muted notifications-textinput-filter"><i class="fa fa-fw fa-filter"></i></div>
|
||||||
<input id="cn-{{$notification.type}}-input" type="text" class="form-control form-control-sm" placeholder="{{$notification.filter.name_label}}">
|
<input id="cn-{{$notification.type}}-input" type="text" class="form-control form-control-sm" placeholder="{{$notification.filter.name_label}}">
|
||||||
<div id="cn-{{$notification.type}}-input-clear" class="text-muted notifications-textinput-clear d-none"><i class="fa fa-times"></i></div>
|
<div id="cn-{{$notification.type}}-input-clear" class="text-muted notifications-textinput-clear d-none"><i class="fa fa-times"></i></div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
<div id="nav-{{$notification.type}}-menu" class="">
|
<div id="nav-{{$notification.type}}-menu" class="">
|
||||||
{{$loading}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
|
{{$loading}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue