lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js

1 line
6.3 KiB
JavaScript
Raw Normal View History

(function(){var c,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},c={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=c,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,c,u,l,t,e){var s,n;if(f.waiting=!0,s=g[u](a,t),25<e&&(n=m(a,u,l))?(l++,s=n,u-=1):l=0,"done"!==f.type&&"actives"!==f.type||i.get(scriptname+"notifications/"+f.type+"?"+s).then(function(t){var e,n,i,o,r;if((e=t.data).result){for(n=0,i=(r=e.values).length;n<i;n++)o=r[n],d++,o.id="node"+d,u<g.length-1&&(o.nodes=[],o.level=u+1,o.query=s,o.over=l),c.push(o);""===a&&(f.total=e.total)}return f.waiting=!1},function(t){return f.waiting=!1}),console.log("Selection",f.type),f.activesStyle={color:"#777"},f.doneStyle={color:"#777"},f.newStyle={color:"#777"},"actives"===f.type&&(f.activesStyle={color:"#333"}),"done"===f.type)return f.doneStyle={color:"#333"}},f.displayNotification=function(t){var n,e;return f.waiting=!0,f.currentScope=t,e=(n=t.$modelValue).notification.replace(/#/g,"_"),"actives"===f.type&&(e=n.uid+"_"+n.reference),i.get(scriptname+"notifications/"+f.type+"/"+e).then(function(e){var t;f.currentNotification={uid:n.uid,reference:n.reference,condition:n.condition},"done"===f.type&&(f.currentNotification.done=e.data.done);try{console.log("Try to parse a JSON formated notification..."),t=JSON.parse(e.data.notifications),f.currentNotification.date=f.notifDate(t.date),f.curren