diff --git a/lemonldap-ng-manager/site/coffee/notifications.coffee b/lemonldap-ng-manager/site/coffee/notifications.coffee index a0d94b672..4d6741aa5 100644 --- a/lemonldap-ng-manager/site/coffee/notifications.coffee +++ b/lemonldap-ng-manager/site/coffee/notifications.coffee @@ -142,7 +142,10 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat $scope.getLanguage = (lang) -> $scope.lang = lang - $scope.form = 'white' + if $scope.form.date + $scope.form.date = new Date() + else + $scope.form = 'white' $scope.init() $scope.showM = false @@ -172,22 +175,23 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat over = 0 # Launch HTTP query - $http.get("#{scriptname}notifications/#{$scope.type}?#{query}").then (response) -> - data = response.data - if data.result - for n in data.values - autoId++ - n.id = "node#{autoId}" - if level < scheme.length - 1 - n.nodes = [] - 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 + if $scope.type == 'done' || $scope.type == 'actives' + $http.get("#{scriptname}notifications/#{$scope.type}?#{query}").then (response) -> + data = response.data + if data.result + for n in data.values + autoId++ + n.id = "node#{autoId}" + if level < scheme.length - 1 + n.nodes = [] + 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 $scope.displayNotification = (scope) -> $scope.waiting = true @@ -202,7 +206,11 @@ llapp.controller 'NotificationsExplorerCtrl', [ '$scope', '$translator', '$locat reference: node.reference condition: node.condition if $scope.type == 'actives' - $scope.currentNotification.notifications = response.data.notifications + notif = JSON.parse response.data.notifications + $scope.currentNotification.text = notif.text + $scope.currentNotification.title = notif.title + $scope.currentNotification.subtitle = notif.subtitle + $scope.currentNotification.notifications = response.data.notifications else $scope.currentNotification.done = response.data.done $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 60ec428dc..9447cfcb2 100644 --- a/lemonldap-ng-manager/site/htdocs/static/js/notifications.js +++ b/lemonldap-ng-manager/site/htdocs/static/js/notifications.js @@ -159,7 +159,11 @@ }; $scope.getLanguage = function(lang) { $scope.lang = lang; - $scope.form = 'white'; + if ($scope.form.date) { + $scope.form.date = new Date(); + } else { + $scope.form = 'white'; + } $scope.init(); return $scope.showM = false; }; @@ -190,31 +194,33 @@ } else { over = 0; } - return $http.get(scriptname + "notifications/" + $scope.type + "?" + query).then(function(response) { - var data, i, len, n, ref; - data = response.data; - if (data.result) { - ref = data.values; - for (i = 0, len = ref.length; i < len; i++) { - n = ref[i]; - autoId++; - n.id = "node" + autoId; - if (level < scheme.length - 1) { - n.nodes = []; - n.level = level + 1; - n.query = query; - n.over = over; + if ($scope.type === 'done' || $scope.type === 'actives') { + return $http.get(scriptname + "notifications/" + $scope.type + "?" + query).then(function(response) { + var data, i, len, n, ref; + data = response.data; + if (data.result) { + ref = data.values; + for (i = 0, len = ref.length; i < len; i++) { + n = ref[i]; + autoId++; + n.id = "node" + autoId; + if (level < scheme.length - 1) { + n.nodes = []; + n.level = level + 1; + n.query = query; + n.over = over; + } + node.push(n); + } + if (value === '') { + $scope.total = data.total; } - node.push(n); } - if (value === '') { - $scope.total = data.total; - } - } - return $scope.waiting = false; - }, function(resp) { - return $scope.waiting = false; - }); + return $scope.waiting = false; + }, function(resp) { + return $scope.waiting = false; + }); + } }; $scope.displayNotification = function(scope) { var node, notificationId; @@ -226,12 +232,17 @@ notificationId = node.uid + "_" + node.reference; } $http.get(scriptname + "notifications/" + $scope.type + "/" + notificationId).then(function(response) { + var notif; $scope.currentNotification = { uid: node.uid, reference: node.reference, condition: node.condition }; if ($scope.type === 'actives') { + notif = JSON.parse(response.data.notifications); + $scope.currentNotification.text = notif.text; + $scope.currentNotification.title = notif.title; + $scope.currentNotification.subtitle = notif.subtitle; $scope.currentNotification.notifications = response.data.notifications; } else { $scope.currentNotification.done = response.data.done; 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 d3e79296d..be4d9e5e4 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,m,g;g=[function(t){return"groupBy=substr(uid,1)"},function(t){return"uid="+t+"*&groupBy=uid"},function(t){return"uid="+t}],m=function(t,e,n){return console.log("overScheme => 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 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.date?f.form.date=new Date: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;if(f.waiting=!0,l=g[c](a,t),25