diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm index c680ebcad..f07f0f0ba 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm @@ -15,10 +15,9 @@ use feature 'state'; extends 'Lemonldap::NG::Common::Conf::AccessLib'; -our $VERSION = '2.0.6'; +our $VERSION = '2.0.7'; has notifAccess => ( is => 'rw' ); - has notifFormat => ( is => 'rw' ); ############################# @@ -75,7 +74,6 @@ sub addRoutes { { done => { ':notificationId' => 'deleteDoneNotification' } }, ['DELETE'] ); - } sub setNotifAccess { @@ -158,6 +156,7 @@ sub notifications { my ( $notifs, $res ); $notifs = $self->notifAccess->$sub(); + my $total = ( keys %$notifs ); # Restrict to wanted values if ( @@ -201,6 +200,7 @@ sub notifications { result => 1, count => $count, values => $res, + total => $total } ); } @@ -221,7 +221,7 @@ sub notifications { } } return $self->sendJSONresponse( $req, - { result => 1, count => scalar(@r), values => \@r } ); + { result => 1, count => scalar(@r), values => \@r, total => $total } ); } } @@ -289,6 +289,7 @@ sub newNotification { $self->logger->debug("Notification Date = $json->{date}"); unless ( $json->{date} =~ /^\d{4}-\d{2}-\d{2}$/ ) { + $self->logger->error("Malformed date"); return $self->sendError( $req, "Malformed date", 200 ); } @@ -312,8 +313,8 @@ sub newNotification { delete $json->{xml}; }; if ($@) { - $self->logger->error("Notification malformed $@"); - return $self->sendError( $req, "Notification malformed: $@", 200 ); + $self->logger->error("Malformed notification $@"); + return $self->sendError( $req, "Malformed notification: $@", 200 ); } $newNotif = to_json($json); } diff --git a/lemonldap-ng-manager/site/coffee/notifications.coffee b/lemonldap-ng-manager/site/coffee/notifications.coffee index 150bc32ff..a0d94b672 100644 --- a/lemonldap-ng-manager/site/coffee/notifications.coffee +++ b/lemonldap-ng-manager/site/coffee/notifications.coffee @@ -125,11 +125,12 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat $scope.waiting = false $scope.init() + # Open node $scope.stoggle = (scope) -> node = scope.$modelValue if node.nodes.length == 0 $scope.updateTree node.value, node.nodes, node.level, node.over, node.query, node.count - scope.toggle() + scope.toggle() $scope.notifDate = (s) -> if s? @@ -182,8 +183,8 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat n.level = level + 1 n.query = query n.over = over - node.push n + $scope.total = data.total if value == '' $scope.waiting = false , (resp) -> $scope.waiting = false diff --git a/lemonldap-ng-manager/site/htdocs/static/js/notifications.js b/lemonldap-ng-manager/site/htdocs/static/js/notifications.js index 5bdc1437f..60ec428dc 100644 --- a/lemonldap-ng-manager/site/htdocs/static/js/notifications.js +++ b/lemonldap-ng-manager/site/htdocs/static/js/notifications.js @@ -20,7 +20,7 @@ ]; overScheme = function(v, level, over) { - console.log('overSchema => level', level, 'over', over); + console.log('overScheme => level', level, 'over', over); if (level === 1 && v.length > over) { return "uid=" + v + "*&groupBy=substr(uid," + (level + over + 1) + ")"; } else { @@ -143,8 +143,8 @@ node = scope.$modelValue; if (node.nodes.length === 0) { $scope.updateTree(node.value, node.nodes, node.level, node.over, node.query, node.count); - return scope.toggle(); } + return scope.toggle(); }; $scope.notifDate = function(s) { var d; @@ -207,6 +207,9 @@ } node.push(n); } + if (value === '') { + $scope.total = data.total; + } } return $scope.waiting = false; }, function(resp) { diff --git a/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js b/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js index 384a849ed..d3e79296d 100644 --- a/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js +++ b/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js @@ -1 +1 @@ -(function(){var u,d,m;m=[function(t){return"groupBy=substr(uid,1)"},function(t){return"uid="+t+"*&groupBy=uid"},function(t){return"uid="+t}],d=function(t,e,n){return console.log("overSchema => level",e,"over",n),1===e&&t.length>n?"uid="+t+"*&groupBy=substr(uid,"+(e+n+1)+")":null},u={actives:[{title:"markAsDone",icon:"check"}],done:[{title:"deleteNotification",icon:"trash"}],new:[{title:"save",icon:"save"}],home:[]},angular.module("llngNotificationsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("NotificationsExplorerCtrl",["$scope","$translator","$location","$q","$http","$uibModal",function(l,e,t,o,r,a){var f,n,i;return l.links=links,l.menulinks=menulinks,l.staticPrefix=staticPrefix,l.scriptname=scriptname,l.formPrefix=formPrefix,l.availableLanguages=availableLanguages,l.waiting=!0,l.showM=!1,l.showT=!0,l.showForm=!1,l.data=[],l.form={},l.formPost={},l.currentScope=null,l.currentNotification=null,l.menu=u,l.translateP=e.translateP,l.translate=e.translate,l.translateTitle=function(t){return e.translateField(t,"title")},l.menuClick=function(t){if(t.popup)window.open(t.popup);else switch(t.action||(t.action=t.title),typeof t.action){case"function":t.action(l.currentNode,l);break;case"string":l[t.action]();break;default:console.log(typeof t.action)}return l.showM=!1},l.markAsDone=function(){return l.waiting=!0,r.put(scriptname+"notifications/"+l.type+"/"+l.currentNotification.uid+"_"+l.currentNotification.reference,{done:1}).then(function(t){return l.currentNotification=null,l.currentScope.remove(),l.message={title:"notificationDeleted"},l.showModal("alert.html"),l.waiting=!1,l.init()},function(t){return l.message={title:"notificationNotDeleted",message:t.statusText},l.showModal("alert.html"),l.waiting=!1,l.init()})},l.deleteNotification=function(){return l.waiting=!0,r.delete(scriptname+"notifications/"+l.type+"/"+l.currentNotification.uid+"_"+l.currentNotification.reference+"_"+l.currentNotification.done).then(function(t){return l.currentNotification=null,l.currentScope.remove(),l.message={title:"notificationPurged"},l.showModal("alert.html"),l.waiting=!1,l.init()},function(t){return l.message={title:"notificationNotPurged",message:t.statusText},l.showModal("alert.html"),l.waiting=!1,l.init()})},l.stoggle=function(t){var e;if(0===(e=t.$modelValue).nodes.length)return l.updateTree(e.value,e.nodes,e.level,e.over,e.query,e.count),t.toggle()},l.notifDate=function(t){return null!=t?(t.match(/(\d{4})-(\d{2})-(\d{2})/)&&(t=t.substr(0,4)+t.substr(5,2)+t.substr(8,2)),new Date(t.substr(0,4),t.substr(4,2)-1,t.substr(6,2)).toLocaleDateString()):""},l.getLanguage=function(t){return l.lang=t,l.form="white",l.init(),l.showM=!1},l.$on("$locationChangeSuccess",function(t,e,n){var i;return i=e.match(/#!?\/(\w+)/),l.type=null!=i?i[1]:"actives","new"===l.type?l.displayCreateForm():(l.showForm=!1,l.init())}),f=0,l.updateTree=function(t,a,u,c,e,n){var s,i;return l.waiting=!0,s=m[u](t,e),25 level",e,"over",n),1===e&&t.length>n?"uid="+t+"*&groupBy=substr(uid,"+(e+n+1)+")":null},u={actives:[{title:"markAsDone",icon:"check"}],done:[{title:"deleteNotification",icon:"trash"}],new:[{title:"save",icon:"save"}],home:[]},angular.module("llngNotificationsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("NotificationsExplorerCtrl",["$scope","$translator","$location","$q","$http","$uibModal",function(f,e,t,o,i,r){var d,n,a;return f.links=links,f.menulinks=menulinks,f.staticPrefix=staticPrefix,f.scriptname=scriptname,f.formPrefix=formPrefix,f.availableLanguages=availableLanguages,f.waiting=!0,f.showM=!1,f.showT=!0,f.showForm=!1,f.data=[],f.form={},f.formPost={},f.currentScope=null,f.currentNotification=null,f.menu=u,f.translateP=e.translateP,f.translate=e.translate,f.translateTitle=function(t){return e.translateField(t,"title")},f.menuClick=function(t){if(t.popup)window.open(t.popup);else switch(t.action||(t.action=t.title),typeof t.action){case"function":t.action(f.currentNode,f);break;case"string":f[t.action]();break;default:console.log(typeof t.action)}return f.showM=!1},f.markAsDone=function(){return f.waiting=!0,i.put(scriptname+"notifications/"+f.type+"/"+f.currentNotification.uid+"_"+f.currentNotification.reference,{done:1}).then(function(t){return f.currentNotification=null,f.currentScope.remove(),f.message={title:"notificationDeleted"},f.showModal("alert.html"),f.waiting=!1,f.init()},function(t){return f.message={title:"notificationNotDeleted",message:t.statusText},f.showModal("alert.html"),f.waiting=!1,f.init()})},f.deleteNotification=function(){return f.waiting=!0,i.delete(scriptname+"notifications/"+f.type+"/"+f.currentNotification.uid+"_"+f.currentNotification.reference+"_"+f.currentNotification.done).then(function(t){return f.currentNotification=null,f.currentScope.remove(),f.message={title:"notificationPurged"},f.showModal("alert.html"),f.waiting=!1,f.init()},function(t){return f.message={title:"notificationNotPurged",message:t.statusText},f.showModal("alert.html"),f.waiting=!1,f.init()})},f.stoggle=function(t){var e;return 0===(e=t.$modelValue).nodes.length&&f.updateTree(e.value,e.nodes,e.level,e.over,e.query,e.count),t.toggle()},f.notifDate=function(t){return null!=t?(t.match(/(\d{4})-(\d{2})-(\d{2})/)&&(t=t.substr(0,4)+t.substr(5,2)+t.substr(8,2)),new Date(t.substr(0,4),t.substr(4,2)-1,t.substr(6,2)).toLocaleDateString()):""},f.getLanguage=function(t){return f.lang=t,f.form="white",f.init(),f.showM=!1},f.$on("$locationChangeSuccess",function(t,e,n){var i;return i=e.match(/#!?\/(\w+)/),f.type=null!=i?i[1]:"actives","new"===f.type?f.displayCreateForm():(f.showForm=!1,f.init())}),d=0,f.updateTree=function(a,u,c,s,t,e){var l,n;return f.waiting=!0,l=g[c](a,t),25 +

{{total}}