lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/viewDiff.min.js
Christophe Maudoux 28c34b7eea Typo (#1964)
2019-10-01 22:06:16 +02:00

1 line
3.6 KiB
JavaScript

(function(){angular.module("llngConfDiff",["ui.tree","ui.bootstrap","llApp","ngCookies"],["$rootScopeProvider",function(t){return t.digestTtl(15)}]).controller("DiffCtrl",["$scope","$http","$q","$translator","$location",function(p,o,l,a,i){var n,u,c,t,s,h,f;return p.links=links,p.menulinks=menulinks,p.staticPrefix=staticPrefix,p.scriptname=scriptname,p.availableLanguages=availableLanguages,p.waiting=!0,p.showM=!1,p.cfg=[],p.data={},p.currentNode=null,p.translateTitle=function(t){return a.translateField(t,"title")},p.translateP=a.translateP,p.translate=a.translate,p.toggle=function(t){return t.toggle()},p.stoggle=function(t,e){return p.currentNode=e,t.toggle()},p.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(p.currentNode,p);break;case"string":p[t.action]();break;default:console.log(typeof t.action)}return p.showM=!1},p.getLanguage=function(t){return p.lang=t,c(),p.showM=!1},u=function(n,r){var a;return a=l.defer(),null==p.cfg[n]||p.cfg[n]!==r?o.get(""+confPrefix+r).then(function(t){var e;return t&&t.data?(p.cfg[n]=t.data,e=new Date(1e3*t.data.cfgDate),p.cfg[n].date=e.toLocaleString(),console.log("Metadatas of cfg "+r+" loaded"),a.resolve("OK")):a.reject(t)},function(t){return console.log(t),a.reject("NOK")}):a.resolve(),a.promise},c=function(){return p.message=null,p.currentNode=null,l.all([a.init(p.lang),o.get(staticPrefix+"reverseTree.json").then(function(t){return t.data,console.log("Structure loaded")})]).then(function(){return l.defer(),o.get(scriptname+"view/diff/"+p.cfg[0].cfgNum+"/"+p.cfg[1].cfgNum).then(function(t){var e;return[],e=s(t.data[0],t.data[1]),p.data=n(e),p.message="",p.waiting=!1},function(t){return p.message=p.translate("error")+" : "+t.statusLine})}),p.activeModule="viewer",p.myStyle={color:"#ffb84d"}},s=function(t,e,n){var r,a,o,l;for(r in null==n&&(n=!0),a=[],t)l=t[r],o=n?{title:p.translate(r),id:r}:{title:r},r.match(/^cfg(?:Num|Log|Author(?:IP)?|Date)$/)||(null!=l&&"object"==typeof l?"array"===l.constructor?(o.oldvalue=l,o.newvalue=e[r]):"object"==typeof e[r]?o.nodes=s(t[r],e[r],!1):o.oldnodes=f(l,"old"):(o.oldvalue=l,o.newvalue=e[r]),a.push(o));for(r in e)l=e[r],r.match(/^cfg(?:Num|Log|Author(?:IP)?|Date)$/)||null!=t[r]||(o=n?{title:p.translate(r),id:r}:{title:r},null!=l&&"object"==typeof l?"array"===l.constructor?o.newvalue=l:(console.log("Iteration"),o.newnodes=f(l,"new")):o.newvalue=l,a.push(o));return a},f=function(t,e){var n,r,a,o;for(n in r=[],t)a={title:n},"object"==typeof(o=t[n])?"array"===o.constructor?a[e+"value"]=o:a[e+"nodes"]=f(t[n],e):a[e+"value"]=o,r.push(a);return r},h=[],n=function(t){var e,n,r,a,o,l,i,u,c,s,f,g,d;if(null==h)return t;for(d=[],a=0,l=t.length;a<l;a++){for(e=t[a],f=d,o=0,i=(g=null!=h[e.id]?h[e.id].split("/"):"").length;o<i;o++)if(0<(s=g[o]).length)if(f.length){for(n=-1,r=c=0,u=f.length;c<u;r=++c)f[r].id===s&&(n=r);f=-1!==n?f[n].nodes:(f.push({id:s,title:p.translate(s),nodes:[]}),f[f.length-1].nodes)}else f.push({id:s,title:p.translate(s),nodes:[]}),f=f[0].nodes;f.push(e)}return d},p.newDiff=function(){return i.path("/"+p.cfg[0].cfgNum+"/"+p.cfg[1].cfgNum)},t=function(t,e,n){var r;return null===(r=e.match(new RegExp("#!?/(latest|[0-9]+)(?:/(latest|[0-9]+))?$")))?i.path("/latest"):(p.waiting=!0,l.all([a.init(p.lang),o.get(staticPrefix+"reverseTree.json").then(function(t){return h=t.data,console.log("Structure loaded")}),u(0,r[1]),null!=r[2]?u(1,r[2]):void 0]).then(function(){return null!=r[2]?c():p.cfg[0].prev?(p.cfg[1]=p.cfg[0],u(0,p.cfg[1].prev).then(function(){return c()})):(p.data=[],p.waiting=!1)},function(){return p.message=p.translate("error"),p.waiting=!1})),!0},p.$on("$locationChangeSuccess",t)}])}).call(this);