lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js
2019-10-30 16:35:44 +01:00

2 lines
5.4 KiB
JavaScript

(function(){var t,e,n;n=[function(t){return"groupBy=substr(uid,1)"},function(t){return"uid="+t+"*&groupBy=uid"},function(t){return"uid="+t}],e={actives:[{title:"markAsDone",icon:"check"}],done:[{title:"deleteNotification",icon:"trash"}],new:[{title:"save",icon:"save"}],home:[]},t=angular.module("llngNotificationsExplorer",["ui.tree","ui.bootstrap","llApp"]),t.controller("NotificationsExplorerCtrl",["$scope","$translator","$location","$q","$http","$uibModal",function(t,i,o,r,a,u){var c,s,l;return t.links=links,t.menulinks=menulinks,t.staticPrefix=staticPrefix,t.scriptname=scriptname,t.formPrefix=formPrefix,t.availableLanguages=availableLanguages,t.waiting=!0,t.showM=!1,t.showT=!0,t.showForm=!1,t.data=[],t.form={},t.formPost={},t.currentScope=null,t.currentNotification=null,t.menu=e,t.translateP=i.translateP,t.translate=i.translate,t.translateTitle=function(t){return i.translateField(t,"title")},t.menuClick=function(e){if(e.popup)window.open(e.popup);else switch(e.action||(e.action=e.title),typeof e.action){case"function":e.action(t.currentNode,t);break;case"string":t[e.action]();break;default:console.log(typeof e.action)}return t.showM=!1},t.markAsDone=function(){return t.waiting=!0,a.put(scriptname+"notifications/"+t.type+"/"+t.currentNotification.uid+"_"+t.currentNotification.reference,{done:1}).then(function(e){return t.currentNotification=null,t.currentScope.remove(),t.message={title:"notificationDeleted"},t.showModal("alert.html"),t.waiting=!1,t.init()},function(e){return t.message={title:"notificationNotDeleted",message:e.statusText},t.showModal("alert.html"),t.waiting=!1,t.init()})},t.deleteNotification=function(){return t.waiting=!0,a.delete(scriptname+"notifications/"+t.type+"/"+t.currentNotification.uid+"_"+t.currentNotification.reference+"_"+t.currentNotification.done).then(function(e){return t.currentNotification=null,t.currentScope.remove(),t.message={title:"notificationPurged"},t.showModal("alert.html"),t.waiting=!1,t.init()},function(e){return t.message={title:"notificationNotPurged",message:e.statusText},t.showModal("alert.html"),t.waiting=!1,t.init()})},t.stoggle=function(e){var n;if(n=e.$modelValue,0===n.nodes.length)return t.updateTree(n.value,n.nodes,n.level,n.query),e.toggle()},t.notifDate=function(t){var e;return null!=t?(t.match(/(\d{4})-(\d{2})-(\d{2})/)&&(t=t.substr(0,4)+t.substr(5,2)+t.substr(8,2)),e=new Date(t.substr(0,4),t.substr(4,2)-1,t.substr(6,2)),e.toLocaleDateString()):""},t.getLanguage=function(e){return t.lang=e,t.form="white",t.init(),t.showM=!1},t.$on("$locationChangeSuccess",function(e,n,i){var o;return o=n.match(/#!?\/(\w+)/),t.type=null!=o?o[1]:"actives","new"===t.type?t.displayCreateForm():(t.showForm=!1,t.init())}),c=0,t.updateTree=function(e,i,o,r){var u;return t.waiting=!0,u=n[o](e,r),a.get(scriptname+"notifications/"+t.type+"?"+u).then(function(e){var r,a,s,l,f;if(r=e.data,r.result)for(f=r.values,a=0,s=f.length;a<s;a++)l=f[a],c++,l.id="node"+c,o<n.length-1&&(l.nodes=[],l.level=o+1,l.query=u),i.push(l);return t.waiting=!1},function(e){return t.waiting=!1})},t.displayNotification=function(e){var n,i;return t.waiting=!0,t.currentScope=e,n=e.$modelValue,i=n.notification,"actives"===t.type&&(i=n.uid+"_"+n.reference),a.get(scriptname+"notifications/"+t.type+"/"+i).then(function(e){return t.currentNotification={uid:n.uid,reference:n.reference,condition:n.condition},"actives"===t.type?t.currentNotification.notifications=e.data.notifications:t.currentNotification.done=e.data.done,t.waiting=!1},function(e){return t.waiting=!1}),t.showT=!1},t.showModal=function(e,n){var i,o;return o=u.open({templateUrl:e,controller:"ModalInstanceCtrl",size:"lg",resolve:{elem:function(){return function(e){return t[e]}},set:function(){return function(e,n){return t[e]=n}},init:function(){return n}}}),i=r.defer(),o.result.then(function(e){return t.message={title:"",message:""},i.resolve(e)},function(e){return t.message={title:"",message:""},i.reject(e)})},t.save=function(){return t.form.uid&&t.form.reference&&t.form.xml?(t.waiting=!0,t.formPost.uid=t.form.uid,t.form.date&&(t.formPost.date=l(t.form.date)),t.formPost.reference=t.form.reference,t.formPost.condition=t.form.condition,t.formPost.xml=t.form.xml,a.post("notifications/actives",t.formPost).then(function(e){var n;return n=e.data,t.form={},1===n.result?t.message={title:"notificationCreated"}:t.message={title:"notificationNotCreated",message:n.error},t.showModal("alert.html"),t.waiting=!1},function(e){return t.message={title:"notificationNotCreated",message:e.statusText},t.showModal("alert.html"),t.waiting=!1})):(t.message={title:"incompleteForm"},t.showModal("alert.html"))},t.init=function(){return t.waiting=!0,t.showM=!1,t.showT=!1,t.data=[],t.currentScope=null,t.currentNotification=null,r.all([i.init(t.lang),t.updateTree("",t.data,0)]).then(function(){return t.waiting=!1},function(e){return t.waiting=!1}),t.activeModule="notifications",t.myStyle={color:"#ffb84d"}},t.displayCreateForm=function(){return t.waiting=!0,i.init(t.lang).then(function(){return t.currentNotification=null,t.showForm=!0,t.data=[],t.waiting=!1,t.form.date=new Date})},s=o.path().match(/^\/(\w+)/),t.type=s?s[1]:"actives",t.popupopen=function(){return t.popup.opened=!0},t.dateOptions={startingDay:1,minDate:new Date},t.popup={opened:!1},l=function(t){var e,n,i;return i=t.getFullYear(),n=t.getMonth()+1,n<10&&(n="0"+n),e=t.getDate(),e<10&&(e="0"+e),i+"-"+n+"-"+e}}])}).call(this);
//# sourceMappingURL=lemonldap-ng-manager/site/htdocs/static/js/notifications.min.js.map