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

1 line
5.5 KiB
JavaScript
Raw Normal View History

(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<n&&(i=d(t,u,c))?(c++,s=i,u-=1):c=0,r.get(scriptname+"notifications/"+l.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],f++,o.id="node"+f,u<m.length-1&&(o.nodes=[],o.level=u+1,o.query=s,o.over=c),a.push(o);return l.waiting=!1},function(t){return l.waiting=!1})},l.displayNotification=function(t){var e,n;return l.waiting=!0,l.currentScope=t,n=(e=t.$modelValue).notification,"actives"===l.type&&(n=e.uid+"_"+e.reference),r.get(scriptname+"notifications/"+l.type+"/"+n).then(function(t){return l.currentNotification={uid:e.uid,reference:e.reference,condition:e.condition},"actives"===l.type?l.currentNotification.notifications=t.data.notifications:l.currentNotification.done=t.data.done,l.waiting=!1},function(t){return l.waiting=!1}),l.showT=!1},l.showModal=function(t,e){var n,i;return i=a.open({templateUrl:t,controller:"ModalInstanceCtrl",size:"lg",resolve:{elem:function(){return function(t){return l[t]}},set:function(){return function(t,e){return l[t]=e}},init:function(){return e}}}),n=o.defer(),i.result.then(function(t){return l.message={title:"",message:""},n.resolve(t)},function(t){return l.messa