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

1 line
16 KiB
JavaScript
Raw Normal View History

!function(){angular.module("llngManager",["ui.tree","ui.bootstrap","llApp","ngCookies"]).controller("TreeCtrl",["$scope","$http","$location","$q","$uibModal","$translator","$cookies","$htmlParams",function(f,l,r,d,i,n,u,e){var t,a,s,p,o,c,m,g;return f.links=window.links,f.menu=e.menu,f.menulinks=window.menulinks,f.staticPrefix=window.staticPrefix,f.formPrefix=window.formPrefix,f.availableLanguages=window.availableLanguages,f.waiting=!0,f.showM=!1,f.showT=!1,f.form="home",f.currentCfg={},f.confPrefix=window.confPrefix,f.message={},f.result="",f.translateTitle=function(e){return n.translateField(e,"title")},f.translateP=n.translateP,f.translate=n.translate,f.helpUrl="start.html#configuration",f.setShowHelp=function(e){var t;return null==e&&(e=!f.showH),f.showH=e,(t=new Date(Date.now())).setFullYear(t.getFullYear()+1),u.put("showhelp",e?"true":"false",{expires:t})},f.showH="false"!==u.get("showhelp"),null==f.showH&&f.setShowHelp(!0),c=function(e){var t=e.status,e=e.statusLine;return f.waiting=!1,403===t?f.message={title:"forbidden",message:"",items:[]}:401===t?(console.log("Authentication needed"),f.message={title:"authenticationNeeded",message:"__waitOrF5__",items:[]}):f.message=400===t||0<t?{title:"badRequest",message:e,items:[]}:{title:"networkProblem",message:"",items:[]},f.showModal("message.html")},f.showModal=function(e,t){var e=i.open({templateUrl:e,controller:"ModalInstanceCtrl",size:"lg",resolve:{elem:function(){return function(e){return f[e]}},set:function(){return function(e,t){return f[e]=t}},init:function(){return t}}}),n=d.defer();return e.result.then(function(e){return f.message={title:"",message:"",items:[]},n.resolve(e)},function(e){return f.message={title:"",message:"",items:[]},n.reject(e)}),n.promise},f.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(f.currentNode,f);break;case"string":f[e.action]();break;default:console.log(typeof e.action)}return f.showM=!1},f.home=function(){return f.form="home",f.showM=!1},t=function(e){if(f.message={title:"",message:"",items:[],itemsE:[],itemsNC:[],itemsW:[]},e.needConfirm&&(f.confirmNeeded=!0),e.message&&(f.message.message=e.message),e.details){for(var t in e.details)"__changes__"!==t&&("__needConfirmation__"===t?(f.message.itemsNC.push({message:t,items:e.details[t]}),console.log("NeedConfirmation:",f.message.itemsNC)):"__warnings__"===t?(f.message.itemsW.push({message:t,items:e.details[t]}),console.log("Warnings:",f.message.itemsW)):(f.message.itemsE.push({message:t,items:e.details[t]}),console.log("Errors:",f.message.itemsE)));f.message.items=f.message.itemsE.concat(f.message.itemsNC.concat(f.message.itemsW))}return f.waiting=!1,1===e.result?(r.path("/confs/"),f.message.title="successfullySaved"):f.message.title="saveReport",f.showModal("message.html")},f.downloadConf=function(){return window.open(f.confPrefix+f.currentCfg.cfgNum+"?full=1")},f.save=function(){return f.showModal("save.html").then(function(){return f.waiting=!0,f.data.push({id:"cfgLog",title:"cfgLog",data:f.result||""}),l.post(window.confPrefix+"?cfgNum="+f.currentCfg.cfgNum+"&cfgDate="+f.currentCfg.cfgDate+(f.forceSave?"&force=1":""),f.data).then(function(e){return f.data.pop(),t(e.data)},function(e){return c(e),f.data.pop()})},function(){return console.log("Saving canceled")}),f.showM=!1},f.saveRawConf=function(e){return f.waiting=!0,l.post(window.confPrefix+"/raw",e).then(function(e){return t(e.data)},c)},f.restore=function(){return f.currentNode=null,f.form="restore"},f.cancel=function(){return f.currentNode.data=null,f.getKey(f.currentNode)},o=1,f._findContainer=function(){return f._findScopeContainer().$modelValue},f._findScopeContainer=function(){for(var e=f.currentScope;!e.$modelValue.type.match(/Container$/);)e=e.$parentNodeScope;return e},f._findScopeByKey=function(e){for(var t=f.currentScope;t.$modelValue.title!==e;)t=t.$parentNodeScope;return t},f.newGrantRule=function(){var e=f._findContainer();e.nodes.length;return e.nodes.push({id:e.id+"/n"+o++,title:"New rule",re:"Message",comment:"New rule",da