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

1 line
4.7 KiB
JavaScript

!function(){var a={_whatToTrace:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*"}]},d={_whatToTrace:function(e,t,n,r){return console.log("overSchema => level",n,"over",r),1===n&&t.length>r?e+"="+t+"*&groupBy=substr("+e+","+(n+r+1)+")":null}},_={dateTitle:["_utime","_startTime","_updateTime"],sfaTitle:["_2fDevices"]},i={home:[]};angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(v,t,e,n,p){var f,r,h;return v.links=links,v.menulinks=menulinks,v.staticPrefix=staticPrefix,v.scriptname=scriptname,v.formPrefix=formPrefix,v.availableLanguages=availableLanguages,v.waiting=!0,v.showM=!1,v.showT=!0,v.data=[],v.currentScope=null,v.currentSession=null,v.menu=i,v.searchString="",v.sfatypes={},v.translateP=t.translateP,v.translate=t.translate,v.translateTitle=function(e){return t.translateField(e,"title")},h="persistent",v.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(v.currentNode,v),v[e.action]();break;case"string":v[e.action]();break;default:console.log(typeof e.action)}return v.showM=!1},v.search2FA=function(e){return e&&(v.searchString=""),v.currentSession=null,v.data=[],v.updateTree2("",v.data,0,0)},v.delete2FA=function(e,t){for(var n=document.querySelectorAll(".data-"+t),r=0,a=n.length;r<a;r++)n[r].remove();return v.waiting=!0,p.delete(scriptname+"sfa/"+h+"/"+v.currentSession.id+"?type="+e+"&epoch="+t).then(function(e){return v.waiting=!1},function(e){return v.waiting=!1}),v.showT=!1},v.stoggle=function(e){var t=e.$modelValue;return 0===t.nodes.length&&v.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},v.displaySession=function(e){var t,n=function(e){var t,n,r,a,i,o,u,s,l,c,p,f,h,d,g,m,w,y=e._utime;for(s in e)(w=e[s])?("string"==typeof e&&w.match(/; /)&&(e[s]=w.split("; ")),"object"!=typeof e[s]&&("_password".match(new RegExp("\b"+s+"\b"))?e[s]="********":s.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?e[s]=v.localeDate(w):s.match(/^(_startTime|_updateTime)$/)&&(f=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/,f=w.match(f),e[s]=f[3]+"/"+f[2]+"/"+f[1]+" à "+f[4]+":"+f[5]+":"+f[6]))):delete e[s];for(a in h=[],_){for(g=[],o=0,l=(r=_[a]).length;o<l;o++)if(n=r[o],e[n])if("_2fDevices"===n&&e[n]){if(0<(t=JSON.parse(e[n])).length)for(g.push({title:"type",value:"name",epoch:"date"}),u=0,c=t.length;u<c;u++){for(s in d=t[u])w=d[s],"type"===s&&(m=w),"name"===s&&(p=w),"epoch"===s&&(i=w);g.push({title:m,value:p,epoch:i,sfrow:!0})}delete e[n]}else e[n].toString().match(/\w+/)&&g.push({title:n,value:e[n]}),delete e[n];else delete e[n];0<g.length&&h.push({title:"__"+a+"__",nodes:g})}return{_utime:y,nodes:h}};return v.currentScope=e,t=e.$modelValue.session,p.get(scriptname+"sfa/"+h+"/"+t).then(function(e){return v.currentSession=n(e.data),v.currentSession.id=t}),v.showT=!1},v.localeDate=function(e){return new Date(1e3*e).toLocaleString()},v.getLanguage=function(e){return v.lang=e,v.form="white",v.init(),v.showM=!1},r=function(e,t,n){t=t.match(/#!?\/(\w+)/);return null!==t&&!t[1].match(/^(persistent)$/)||(v.type="_session_uid"),v.init()},v.$on("$locationChangeSuccess",r),f=0,v.updateTree=function(i,o,u,s,e,t){var l,c,n;return v.waiting=!0,c=a[v.type]||a._whatToTrace,l=c[u](v.type,i,e),25<t&&d[v.type]&&(n=d[v.type](v.type,i,u,s,e))?(s++,l=n,u-=1):s=0,p.get(scriptname+"sfa/"+h+"?"+l+Object.entries(v.sfatypes).map(function(e){return e[1]?"&type="+e[0]:""}).join("")).then(function(e){var t,n,r,a,e=e.data;if(e.result){for(t=0,n=(a=e.values).length;t<n;t++)r=a[t],f++,r.id="node"+f,u<c.length-1&&(r.nodes=[],r.level=u+1,r.query=l,r.over=s),o.push(r);""===i&&(v.total=e.total)}return v.waiting=!1},function(e){return v.waiting=!1})},v.updateTree2=function(i,o,u,s,e,t){var l,c,n;return v.waiting=!0,c=a[v.type]||("_updateTime"===v.type?a._startTime:a._whatToTrace),l=c[u](v.type,i,e),25<t&&d[v.type]&&(n=d[v.type](v.type,i,u,s,e))?(s++,l=n,u-=1):s=0,p.get(scriptname+"sfa/"+h+"?_session_uid="+v.searchString+"*&groupBy=substr(_session_uid,"+v.searchString.length+")"+Object.entries(v.sfatypes).map(function(e){return e[1]?"&type="+e[0]:""}).join("")).then(function(e){var t,n,r,a,e=e.data;if(e.result){for(t=0,n=(a=e.values).length;t<n;t++)r=a[t],f++,r.id="node"+f,u<c.length-1&&(r.nodes=[],r.level=u+1,r.query=l,r.over=s),o.push(r);""===i&&(v.total=e.total)}return v.waiting=!1},function(e){return v.waiting=!1})},v.init=function(){return v.waiting=!0,v.data=[],n.all([t.init(v.lang),v.updateTree("",v.data,0,0)]).then(function(){return v.waiting=!1},function(e){return v.waiting=!1}),v.activeModule="2ndFA",v.myStyle={color:"#ffb84d"}},e=e.path().match(/^\/(\w+)/),v.type=e?e[1]:"_whatToTrace"}])}.call(this);