Display notification content (#2353)
This commit is contained in:
parent
90c8c2ba86
commit
b3ad81ec8c
|
@ -5,6 +5,7 @@ use utf8;
|
|||
use Mouse;
|
||||
use JSON qw(from_json to_json);
|
||||
use POSIX qw(strftime);
|
||||
use MIME::Base64 qw(decode_base64);
|
||||
|
||||
use Lemonldap::NG::Common::Conf::Constants;
|
||||
use Lemonldap::NG::Common::PSGI::Constants;
|
||||
|
@ -243,40 +244,56 @@ sub notifications {
|
|||
}
|
||||
|
||||
sub notification {
|
||||
my ( $self, $req, $id, $type, $uid, $ref ) = @_;
|
||||
my ( $self, $req, $id, $type ) = @_;
|
||||
my $backend = $self->{notificationStorage};
|
||||
$self->logger->debug("Notification storage: $backend");
|
||||
|
||||
if ( $type eq 'actives' ) {
|
||||
( $uid, $ref ) = ( $id =~ /([^_]+?)_(.+)/ );
|
||||
my ( $uid, $ref ) = ( $id =~ /([^_]+?)_(.+)/ );
|
||||
my $n = $self->notifAccess->get( $uid, $ref );
|
||||
unless ($n) {
|
||||
$self->userLogger->notice(
|
||||
"Notification $ref not found for user $uid");
|
||||
"Active notification $ref not found for user $uid");
|
||||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
{
|
||||
result => 0,
|
||||
error => "Notification $ref not found for user $uid"
|
||||
error => "Active otification $ref not found for user $uid"
|
||||
}
|
||||
);
|
||||
}
|
||||
$self->logger->debug("Active notification $ref found for user $uid");
|
||||
return $self->sendJSONresponse( $req,
|
||||
{ result => 1, count => 1, notifications => [ values %$n ] } );
|
||||
}
|
||||
else {
|
||||
my ( $date, $uid, $ref ) =
|
||||
$backend eq 'File'
|
||||
? ( $id =~ /([^_]+?)_(.+?)_(.+?)\.done/ )
|
||||
: ( $id =~ /([^_]+?)_(.+?)_(.+)/ );
|
||||
$ref = decode_base64($ref) if ( $backend eq 'File' );
|
||||
my $n = $self->notifAccess->getAccepted( $uid, $ref );
|
||||
unless ($n) {
|
||||
$self->userLogger->notice(
|
||||
"Notification $ref not found for user $uid");
|
||||
"Done notification $ref not found for user $uid");
|
||||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
{
|
||||
result => 0,
|
||||
error => "Notification $ref not found for user $uid"
|
||||
error => "Done notification $ref not found for user $uid"
|
||||
}
|
||||
);
|
||||
}
|
||||
return $self->sendJSONresponse( $req,
|
||||
{ result => 1, count => 1, done => $id, notifications => [ values %$n ] } );
|
||||
$self->logger->debug("Done notification $ref found for user $uid");
|
||||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
{
|
||||
result => 1,
|
||||
count => 1,
|
||||
done => $id,
|
||||
notifications => [ values %$n ]
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,12 +206,10 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat
|
|||
$scope.currentScope = scope
|
||||
node = scope.$modelValue
|
||||
notificationId = node.notification
|
||||
query = ''
|
||||
if $scope.type == 'actives'
|
||||
notificationId = "#{node.uid}_#{node.reference}"
|
||||
if $scope.type == 'done'
|
||||
query = "?uid=#{node.uid}&reference=#{node.reference}"
|
||||
$http.get("#{scriptname}notifications/#{$scope.type}/#{notificationId}#{query}").then (response) ->
|
||||
node.reference.replace(/#/, '_')
|
||||
notificationId = "#{node.uid}_" + node.reference.replace(/#/, '_')
|
||||
$http.get("#{scriptname}notifications/#{$scope.type}/#{notificationId}").then (response) ->
|
||||
$scope.currentNotification =
|
||||
uid: node.uid
|
||||
reference: node.reference
|
||||
|
|
|
@ -243,19 +243,16 @@
|
|||
}
|
||||
};
|
||||
$scope.displayNotification = function(scope) {
|
||||
var node, notificationId, query;
|
||||
var node, notificationId;
|
||||
$scope.waiting = true;
|
||||
$scope.currentScope = scope;
|
||||
node = scope.$modelValue;
|
||||
notificationId = node.notification;
|
||||
query = '';
|
||||
if ($scope.type === 'actives') {
|
||||
notificationId = node.uid + "_" + node.reference;
|
||||
node.reference.replace(/#/, '_');
|
||||
notificationId = (node.uid + "_") + node.reference.replace(/#/, '_');
|
||||
}
|
||||
if ($scope.type === 'done') {
|
||||
query = "?uid=" + node.uid + "&reference=" + node.reference;
|
||||
}
|
||||
$http.get(scriptname + "notifications/" + $scope.type + "/" + notificationId + query).then(function(response) {
|
||||
$http.get(scriptname + "notifications/" + $scope.type + "/" + notificationId).then(function(response) {
|
||||
var e, notif;
|
||||
$scope.currentNotification = {
|
||||
uid: node.uid,
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -549,7 +549,7 @@
|
|||
"notificationServerSentAttributes":"Notification parameters to send",
|
||||
"serverNotification":"Server",
|
||||
"notificationCreated":"Notification has been created",
|
||||
"notificationDeleted":"Notification deleted",
|
||||
"notificationDeleted":"Notification has been marked as done",
|
||||
"notificationDone":"Notification done",
|
||||
"notificationsDone":"Notifications done",
|
||||
"notificationsExplorer":"Explorer",
|
||||
|
|
Loading…
Reference in New Issue
Block a user