Commit 3cea903c authored by Yadd's avatar Yadd
Browse files

Merge branch 'v2.0'

parents 4fcf77e7 81c88216
......@@ -294,6 +294,8 @@ $(SRCPORTALDIR)/site/htdocs/static/common/js/%.js: $(SRCPORTALDIR)/site/coffee/%
@if which coffee >/dev/null; then \
echo "Compiling $(SRCPORTALDIR)/site/coffee/$*.coffee"; \
coffee -c -o $(SRCPORTALDIR)/site/htdocs/static/common/js/ $(SRCPORTALDIR)/site/coffee/$*.coffee; \
else \
echo "Can't find coffee"; \
fi
$(SRCMANAGERDIR)/site/htdocs/static/js/%.js: $(SRCMANAGERDIR)/site/coffee/%.coffee
......
......@@ -119,13 +119,8 @@
"namespace" : "lemonldap-ng-sessions"
},
"locationRules" : {
"auth.example.com" : {
"(?#checkUser)^/checkuser": "$uid eq \"dwho\"",
"(?#errors)^/lmerror/": "accept",
"default" : "accept"
},
"manager.__DNSDOMAIN__" : {
"(?#Configuration)^/(manager\\.html|$)" : "$uid eq \"dwho\"",
"(?#Configuration)^/(manager\\.html|conf/)" : "$uid eq \"dwho\"",
"(?#Notifications)/notifications" : "$uid eq \"dwho\" or $uid eq \"rtyler\"",
"(?#Sessions)/sessions" : "$uid eq \"dwho\" or $uid eq \"rtyler\"",
"default" : "$uid eq \"dwho\" or $uid eq \"rtyler\""
......
......@@ -28,7 +28,6 @@ totp2fActivation = 1
totp2fSelfRegistration = 1
captcha_mail_enabled = 0
portalDisplayResetPassword = 1
translations = __pwd__/lemonldap-ng-portal/site/templates/localeTranslations.txt
[handler]
......@@ -40,6 +39,10 @@ useRedirectOnError = 0
enabledModules = conf, sessions, notifications, 2ndFA, viewer
protection = manager
viewerHiddenPK = samlIDPMetaDataNodes samlSPMetaDataNodes portalDisplayLogout
viewerAllowBrowser = 1
staticPrefix = /static
languages = fr, en, vi, ar, de, it, zh
templateDir = __pwd__/lemonldap-ng-manager/site/templates
......
......@@ -204,7 +204,6 @@ languages = en, fr, vi, it, ar
;useOldMenuItems=1
; Override error codes
;error_0 = You are well authenticated!
;translations = __PORTALTEMPLATESDIR__/localeTranslations.txt
; Custom template parameters
; For example to use <TMPL_VAR NAME="myparam">
;tpl_myparam = test
......
......@@ -24,6 +24,7 @@ sub compactConf {
s/^(\w+).*$/lc($1)/e;
s/OpenIDConnect/oidc/i;
$keep{$_} = 1;
if ( $_ eq "ad" ) { $keep{'ldap'} = 1; }
}
}
if ( $keep{choice} ) {
......@@ -33,6 +34,7 @@ sub compactConf {
s/^(\w+).*$/lc($1)/e;
s/OpenIDConnect/oidc/i;
$keep{$_} = 1;
if ( $_ eq "ad" ) { $keep{'ldap'} = 1; }
}
}
}
......
......@@ -780,7 +780,11 @@ sub postInputFilter {
my %data =
$class->tsv->{inputPostData}->{$vhost}->{$uri}->( $req, $session );
foreach ( keys %data ) {
$data{$_} = uri_escape( $data{$_} );
my $post_key = uri_escape($_);
my $post_value = uri_escape( $data{$_} );
delete $data{$_};
$data{$post_key} = $post_value;
$class->logger->debug("Send key $post_key with value $post_value");
}
$class->setPostParams( $req, \%data );
}
......@@ -809,7 +813,8 @@ sub postJavascript {
: "form.submit();\n";
my $jqueryUrl = $formParams->{jqueryUrl} || "";
$jqueryUrl = &{ $class->tsv->{portal} } . "skins/common/js/jquery-1.10.2.js"
$jqueryUrl =
&{ $class->tsv->{portal} } . "static/bwr/jquery/dist/jquery.min.js"
if ( $jqueryUrl eq "default" );
$jqueryUrl = "<script type='text/javascript' src='$jqueryUrl'></script>\n"
if ($jqueryUrl);
......
......@@ -21,6 +21,7 @@ lib/Lemonldap/NG/Manager/Conf/Tests.pm
lib/Lemonldap/NG/Manager/Conf/Zero.pm
lib/Lemonldap/NG/Manager/Notifications.pm
lib/Lemonldap/NG/Manager/Sessions.pm
lib/Lemonldap/NG/Manager/Viewer.pm
Makefile.PL
MANIFEST This list of files
META.json
......@@ -36,6 +37,7 @@ site/coffee/llApp.coffee
site/coffee/manager.coffee
site/coffee/notifications.coffee
site/coffee/sessions.coffee
site/coffee/viewer.coffee
site/htdocs/manager.fcgi
site/htdocs/manager.psgi
site/htdocs/static/bwr/angular-animate/angular-animate.js
......@@ -156,6 +158,8 @@ site/htdocs/static/js/notifications.js
site/htdocs/static/js/notifications.min.js
site/htdocs/static/js/sessions.js
site/htdocs/static/js/sessions.min.js
site/htdocs/static/js/viewer.js
site/htdocs/static/js/viewer.min.js
site/htdocs/static/languages/ar.json
site/htdocs/static/languages/de.json
site/htdocs/static/languages/en.json
......@@ -187,6 +191,7 @@ site/templates/notifications.tpl
site/templates/scripts.tpl
site/templates/sessions.tpl
site/templates/tree.tpl
site/templates/viewer.tpl
t/02-HTML-template.t
t/03-HTML-forms.t
t/05-rest-api.t
......
......@@ -87,7 +87,7 @@ sub init {
$self->csp(
"default-src 'self' $portal;frame-ancestors 'none';form-action 'self';"
);
$self->brw( $conf->{viewerAllowBrowser} );
$self->brw( $self->{viewerAllowBrowser} || $conf->{viewerAllowBrowser} );
$self->defaultRoute( $working[0]->defaultRoute );
# Find out more glyphicones at https://www.w3schools.com/icons/bootstrap_icons_glyphicons.asp
......
......@@ -31,6 +31,8 @@ sub addRoutes {
my ( $self, $conf ) = @_;
$self->ua( Lemonldap::NG::Common::UserAgent->new($conf) );
my $hiddenPK = '';
$hiddenPK = $self->{viewerHiddenPK} || $conf->{viewerHiddenPK};
my @enabledPK = ();
my @keys = qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes
applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes
......@@ -42,7 +44,7 @@ sub addRoutes {
# Ignore hidden ConfTree Primary Keys
push @enabledPK, $_
unless ( $conf->{viewerHiddenPK} =~ /\b$_\b/ );
unless ( $hiddenPK =~ /\b$_\b/ );
}
# HTML template
......@@ -55,10 +57,17 @@ sub addRoutes {
':cfgNum' => \@enabledPK
},
['GET']
)
);
# Other keys
->addRoute( view => { ':cfgNum' => { '*' => 'getKey' } }, ['GET'] )
foreach ( split /\s+/, $hiddenPK ) {
$self->addRoute(
view => { ':cfgNum' => { $_ => 'rejectKey' } },
['GET']
);
}
# Other keys
$self->addRoute( view => { ':cfgNum' => { '*' => 'getKey' } }, ['GET'] )
# Difference between confs
->addRoute( diff => { ':conf1' => { ':conf2' => 'diff' } } )
......@@ -75,4 +84,9 @@ sub diff {
$self->SUPER::diff( $req, @path );
}
sub rejectKey {
my ( $self, $req ) = @_;
return $self->sendJSONresponse( $req, { 'value' => '_Hidden_' } );
}
1;
......@@ -179,8 +179,6 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
# Session preparation
transformSession = (session) ->
_stToStr = (s) ->
s
_insert = (re, title) ->
tmp = []
reg = new RegExp(re)
......@@ -210,10 +208,7 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
else if key.match /^(_utime|_lastAuthnUTime|_lastSeen|notification)$/
session[key] = $scope.localeDate value
else if key.match /^(_startTime|_updateTime)$/
value = _stToStr value
pattern = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
arrayDate = value.match(pattern)
session[key] = "#{arrayDate[3]}/#{arrayDate[2]}/#{arrayDate[1]} à #{arrayDate[4]}:#{arrayDate[5]}:#{arrayDate[6]}"
session[key] = $scope.strToLocaleDate value
res = []
......@@ -345,6 +340,12 @@ llapp.controller 'SessionsExplorerCtrl', ['$scope', '$translator', '$location',
d = new Date(s * 1000)
return d.toLocaleString()
$scope.strToLocaleDate = (s) ->
arrayDate = s.match /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
return s unless arrayDate.length
d = new Date "#{arrayDate[1]}-#{arrayDate[2]}-#{arrayDate[3]}T#{arrayDate[4]}:#{arrayDate[5]}:#{arrayDate[6]}"
return d.toLocaleString()
# Function to change interface language
$scope.getLanguage = (lang) ->
$scope.lang = lang
......
......@@ -136,35 +136,6 @@ llapp.controller 'TreeCtrl', [
$scope.form = 'home'
$scope.showM = false
# SAVE FUNCTIONS
# # Private method called by $scope.save()
# _checkSaveResponse = (data) ->
# $scope.message =
# title: ''
# message: ''
# items: []
# $scope.confirmNeeded = true if data.needConfirm
# $scope.message.message = data.message if data.message
# if data.details
# for m of data.details when m != '__changes__'
# if m == '__needConfirmation__'
# $scope.message.items.unshift
# message: m
# items: data.details[m]
# else
# $scope.message.items.push
# message: m
# items: data.details[m]
# $scope.waiting = false
# if data.result == 1
# # Force reloading page
# $location.path '/confs/'
# $scope.message.title = 'successfullySaved'
# else
# $scope.message.title = 'saveReport'
# $scope.showModal 'message.html'
# Download raw conf
$scope.downloadConf = () ->
window.open $scope.viewPrefix + $scope.currentCfg.cfgNum + '?full=1'
......@@ -379,6 +350,9 @@ llapp.controller 'TreeCtrl', [
node.data = node['default']
else
node.data = data.value
if node.data.toString().match /_Hidden_$/
node.type = 'text'
node.data = '######'
# Cast int as int (remember that booleans are int for Perl)
if node.type and node.type.match /^int$/
node.data = parseInt(node.data, 10)
......@@ -391,6 +365,9 @@ llapp.controller 'TreeCtrl', [
readError response
d.reject response.status
else
if node.data.toString().match /_Hidden_$/
node.type = 'text'
node.data = '######'
d.resolve node.data
return d.promise
......
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 1.12.8
/*
* 2ndFA Session explorer
......
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 1.12.8
/*
diff.html script
......
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 1.12.8
(function() {
var filterFunctions;
......
// Generated by CoffeeScript 1.12.7
// Generated by CoffeeScript 1.12.8
/*
* LemonLDAP::NG Notifications Explorer client
......
......@@ -199,10 +199,7 @@
$scope.displaySession = function(scope) {
var sessionId, transformSession;
transformSession = function(session) {
var _insert, _stToStr, array, arrayDate, attr, attrs, category, cv, epoch, i, id, j, k, key, l, len, len1, len2, len3, len4, m, name, o, oidcConsent, pattern, ref, ref1, res, sfDevice, subres, time, title, tmp, value;
_stToStr = function(s) {
return s;
};
var _insert, array, attr, attrs, category, cv, epoch, i, id, j, k, key, l, len, len1, len2, len3, len4, m, name, o, oidcConsent, ref, ref1, res, sfDevice, subres, time, title, tmp, value;
_insert = function(re, title) {
var key, reg, tmp, value;
tmp = [];
......@@ -240,10 +237,7 @@
} else if (key.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)) {
session[key] = $scope.localeDate(value);
} else if (key.match(/^(_startTime|_updateTime)$/)) {
value = _stToStr(value);
pattern = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/;
arrayDate = value.match(pattern);
session[key] = arrayDate[3] + "/" + arrayDate[2] + "/" + arrayDate[1] + " à " + arrayDate[4] + ":" + arrayDate[5] + ":" + arrayDate[6];
session[key] = $scope.strToLocaleDate(value);
}
}
}
......@@ -424,6 +418,15 @@
d = new Date(s * 1000);
return d.toLocaleString();
};
$scope.strToLocaleDate = function(s) {
var arrayDate, d;
arrayDate = s.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);
if (!arrayDate.length) {
return s;
}
d = new Date(arrayDate[1] + "-" + arrayDate[2] + "-" + arrayDate[3] + "T" + arrayDate[4] + ":" + arrayDate[5] + ":" + arrayDate[6]);
return d.toLocaleString();
};
$scope.getLanguage = function(lang) {
$scope.lang = lang;
$scope.form = 'white';
......
(function(){var categories,hiddenAttributes,llapp,max,menu,overScheme,schemes;max=25;schemes={_whatToTrace:[function(t,v){return"groupBy=substr("+t+",1)"},function(t,v){return t+"="+v+"*&groupBy="+t},function(t,v){return t+"="+v}],ipAddr:[function(t,v){return"groupBy=net("+t+",16,1)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",32,2)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",48,3)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",128,4)"},function(t,v){return t+"="+v+"&groupBy=_whatToTrace"},function(t,v,q){return q.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+v)}],_startTime:[function(t,v){return"groupBy=substr("+t+",8)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",10)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",11)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",12)"},function(t,v){return t+"="+v+"*&groupBy=_whatToTrace"},function(t,v,q){console.log(t);console.log(v);console.log(q);return q.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+v)}],doubleIp:[function(t,v){return t},function(t,v){return"_whatToTrace="+v+"&groupBy=ipAddr"},function(t,v,q){return q.replace(/\&groupBy.*$/,"")+("&ipAddr="+v)}]};overScheme={_whatToTrace:function(t,v,level,over){if(level===1&&v.length>over){return t+"="+v+"*&groupBy=substr("+t+","+(level+over+1)+")"}else{return null}},ipAddr:function(t,v,level,over){if(level>0&&level<4){return t+"="+v+"*&groupBy=net("+t+","+(16*level+4*(over+1))+",2)"}else{return null}}};hiddenAttributes="_password";categories={dateTitle:["_utime","_startTime","_updateTime","_lastAuthnUTime","_lastSeen"],connectionTitle:["ipAddr","_timezone","_url"],authenticationTitle:["_session_id","_user","_password","authenticationLevel"],modulesTitle:["_auth","_userDB","_passwordDB","_issuerDB","_authChoice","_authMulti","_userDBMulti"],saml:["_idp","_idpConfKey","_samlToken","_lassoSessionDump","_lassoIdentityDump"],groups:["groups","hGroups"],ldap:["dn"],BrowserID:["_browserIdAnswer","_browserIdAnswerRaw"],OpenIDConnect:["_oidc_id_token","_oidc_OP","_oidc_access_token"],sfaTitle:["_2fDevices"],oidcConsents:["_oidcConsents"]};menu={session:[{title:"deleteSession",icon:"trash"}],home:[]};llapp=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]);llapp.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function($scope,$translator,$location,$q,$http){var autoId,c,pathEvent,sessionType;$scope.links=links;$scope.menulinks=menulinks;$scope.staticPrefix=staticPrefix;$scope.scriptname=scriptname;$scope.formPrefix=formPrefix;$scope.availableLanguages=availableLanguages;$scope.waiting=true;$scope.showM=false;$scope.showT=true;$scope.data=[];$scope.currentScope=null;$scope.currentSession=null;$scope.menu=menu;$scope.translateP=$translator.translateP;$scope.translate=$translator.translate;$scope.translateTitle=function(node){return $translator.translateField(node,"title")};sessionType="global";$scope.menuClick=function(button){if(button.popup){window.open(button.popup)}else{if(!button.action){button.action=button.title}switch(typeof button.action){case"function":button.action($scope.currentNode,$scope);break;case"string":$scope[button.action]();break;default:console.log(typeof button.action)}}return $scope.showM=false};$scope.deleteOIDCConsent=function(rp,epoch){var item;item=angular.element(".data-"+epoch);item.remove();$scope.waiting=true;$http["delete"](scriptname+"sessions/OIDCConsent/"+sessionType+"/"+$scope.currentSession.id+"?rp="+rp+"&epoch="+epoch).then(function(response){return $scope.waiting=false},function(resp){return $scope.waiting=false});return $scope.showT=false};$scope.deleteSession=function(){$scope.waiting=true;return $http["delete"](scriptname+"sessions/"+sessionType+"/"+$scope.currentSession.id).then(function(response){$scope.currentSession=null;$scope.currentScope.remove();return $scope.waiting=false},function(resp){$scope.currentSession=null;$scope.currentScope.remove();return $scope.waiting=false})};$scope.stoggle=function(scope){var node;node=scope.$modelValue;if(node.nodes.length===0){$scope.updateTree(node.value,node.nodes,node.level,node.over,node.query,node.count)}return scope.toggle()};$scope.displaySession=function(scope){var sessionId,transformSession;transformSession=function(session){var _insert,_stToStr,array,arrayDate,attr,attrs,category,cv,epoch,i,id,j,k,key,l,len,len1,len2,len3,len4,m,name,o,oidcConsent,pattern,ref,ref1,res,sfDevice,subres,time,title,tmp,value;_stToStr=function(s){return s};_insert=function(re,title){var key,reg,tmp,value;tmp=[];reg=new RegExp(re);for(key in session){value=session[key];if(key.match(reg)&&value){tmp.push({title:key,value:value});delete session[key]}}if(tmp.length>0){return res.push({title:title,nodes:tmp})}};time=session._utime;id=session._session_id;for(key in session){value=session[key];if(!value){delete session[key]}else{if(typeof session==="string"&&value.match(/; /)){session[key]=value.split("; ")}if(typeof session[key]!=="object"){if(hiddenAttributes.match(new RegExp("\b"+key+"\b"))){session[key]="********"}else if(key.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)){session[key]=$scope.localeDate(value)}else if(key.match(/^(_startTime|_updateTime)$/)){value=_stToStr(value);pattern=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/;arrayDate=value.match(pattern);session[key]=arrayDate[3]+"/"+arrayDate[2]+"/"+arrayDate[1]+" à "+arrayDate[4]+":"+arrayDate[5]+":"+arrayDate[6]}}}}res=[];for(category in categories){attrs=categories[category];subres=[];for(i=0,len=attrs.length;i<len;i++){attr=attrs[i];if(session[attr]){if(session[attr].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){subres.push({title:"type",value:"name",epoch:"date",td:"0"});array=JSON.parse(session[attr]);for(j=0,len1=array.length;j<len1;j++){sfDevice=array[j];for(key in sfDevice){value=sfDevice[key];if(key==="type"){title=value}if(key==="name"){name=value}if(key==="epoch"){epoch=value}}subres.push({title:title,value:name,epoch:epoch,td:"1"})}delete session[attr]}else if(session[attr].toString().match(/"rp":\s*"[\w-]+"/)){subres.push({title:"rp",value:"scope",epoch:"date",td:"0"});array=JSON.parse(session[attr]);for(k=0,len2=array.length;k<len2;k++){oidcConsent=array[k];for(key in oidcConsent){value=oidcConsent[key];if(key==="rp"){title=value}if(key==="scope"){name=value}if(key==="epoch"){epoch=value}}subres.push({title:title,value:name,epoch:epoch,td:"2"})}delete session[attr]}else if(session[attr].toString().match(/\w+/)){subres.push({title:attr,value:session[attr],epoch:""});delete session[attr]}else{delete session[attr]}}else{delete session[attr]}}if(subres.length>0){res.push({title:"__"+category+"__",nodes:subres})}}_insert("^openid","OpenID");_insert("^notification_(.+)","__notificationsDone__");if(session._loginHistory){tmp=[];if(session._loginHistory.successLogin){ref=session._loginHistory.successLogin;for(m=0,len3=ref.length;m<len3;m++){l=ref[m];cv="";for(key in l){value=l[key];if(!key.match(/^(_utime|ipAddr|error)$/)){cv+=", "+key+" : "+value}}tmp.push({t:l._utime,title:$scope.localeDate(l._utime),value:"Success (IP "+l.ipAddr+")"+cv})}}if(session._loginHistory.failedLogin){ref1=session._loginHistory.failedLogin;for(o=0,len4=ref1.length;o<len4;o++){l=ref1[o];cv="";for(key in l){value=l[key];if(!key.match(/^(_utime|ipAddr|error)$/)){cv+=", "+key+" : "+value}}tmp.push({t:l._utime,title:$scope.localeDate(l._utime),value:"Error "+l.error+" (IP "+l.ipAddr+")"+cv})}}delete session._loginHistory;tmp.sort(function(a,b){return b.t-a.t});res.push({title:"__loginHistory__",nodes:tmp})}tmp=[];for(key in session){value=session[key];tmp.push({title:key,value:value})}tmp.sort(function(a,b){if(a.title>b.title){return 1}else if(a.title<b.title){return-1}else{return 0}});res.push({title:"__attributesAndMacros__",nodes:tmp});return{_utime:time,id:id,nodes:res}};$scope.currentScope=scope;sessionId=scope.$modelValue.session;$http.get(scriptname+"sessions/"+sessionType+"/"+sessionId).then(function(response){return $scope.currentSession=transformSession(response.data)});return $scope.showT=false};$scope.localeDate=function(s){var d;d=new Date(s*1e3);return d.toLocaleString()};$scope.getLanguage=function(lang){$scope.lang=lang;$scope.form="white";$scope.init();return $scope.showM=false};pathEvent=function(event,next,current){var n;n=next.match(/#!?\/(\w+)/);sessionType="global";if(n===null){$scope.type="_whatToTrace"}else if(n[1].match(/^(persistent)$/)){sessionType=RegExp.$1;$scope.type="_session_uid"}else{$scope.type=n[1]}return $scope.init()};$scope.$on("$locationChangeSuccess",pathEvent);autoId=0;$scope.updateTree=function(value,node,level,over,currentQuery,count){var query,scheme,tmp;$scope.waiting=true;scheme=schemes[$scope.type]?schemes[$scope.type]:$scope.type==="_updateTime"?schemes._startTime:schemes._whatToTrace;query=scheme[level]($scope.type,value,currentQuery);if(count>max&&overScheme[$scope.type]){if(tmp=overScheme[$scope.type]($scope.type,value,level,over,currentQuery)){over++;query=tmp;level=level-1}else{over=0}}else{over=0}return $http.get(scriptname+"sessions/"+sessionType+"?"+query).then(function(response){var data,i,len,n,ref;data=response.data;if(data.result){ref=data.values;for(i=0,len=ref.length;i<len;i++){n=ref[i];autoId++;n.id="node"+autoId;if(level<scheme.length-1){n.nodes=[];n.level=level+1;n.query=query;n.over=over;if($scope.type.match(/^(?:start|update)Time$/)){n.title=n.value.replace(/^(\d{8})(\d{2})(\d{2})$/,"$2:$3").replace(/^(\d{8})(\d{2})(\d)$/,"$2:$30").replace(/^(\d{8})(\d{2})$/,"$2h").replace(/^(\d{4})(\d{2})(\d{2})/,"$1-$2-$3")}}node.push(n)}if(value===""){$scope.total=data.total}}return $scope.waiting=false},function(resp){return $scope.waiting=false})};$scope.init=function(){$scope.waiting=true;$scope.data=[];$q.all([$translator.init($scope.lang),$scope.updateTree("",$scope.data,0,0)]).then(function(){return $scope.waiting=false},function(resp){return $scope.waiting=false});$scope.activeModule="sessions";return $scope.myStyle={color:"#ffb84d"}};c=$location.path().match(/^\/(\w+)/);return $scope.type=c?c[1]:"_whatToTrace"}])}).call(this);
(function(){var categories,hiddenAttributes,llapp,max,menu,overScheme,schemes;max=25;schemes={_whatToTrace:[function(t,v){return"groupBy=substr("+t+",1)"},function(t,v){return t+"="+v+"*&groupBy="+t},function(t,v){return t+"="+v}],ipAddr:[function(t,v){return"groupBy=net("+t+",16,1)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",32,2)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",48,3)"},function(t,v){if(!v.match(/:/)){v=v+"."}return t+"="+v+"*&groupBy=net("+t+",128,4)"},function(t,v){return t+"="+v+"&groupBy=_whatToTrace"},function(t,v,q){return q.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+v)}],_startTime:[function(t,v){return"groupBy=substr("+t+",8)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",10)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",11)"},function(t,v){return t+"="+v+"*&groupBy=substr("+t+",12)"},function(t,v){return t+"="+v+"*&groupBy=_whatToTrace"},function(t,v,q){console.log(t);console.log(v);console.log(q);return q.replace(/\&groupBy.*$/,"")+("&_whatToTrace="+v)}],doubleIp:[function(t,v){return t},function(t,v){return"_whatToTrace="+v+"&groupBy=ipAddr"},function(t,v,q){return q.replace(/\&groupBy.*$/,"")+("&ipAddr="+v)}]};overScheme={_whatToTrace:function(t,v,level,over){if(level===1&&v.length>over){return t+"="+v+"*&groupBy=substr("+t+","+(level+over+1)+")"}else{return null}},ipAddr:function(t,v,level,over){if(level>0&&level<4){return t+"="+v+"*&groupBy=net("+t+","+(16*level+4*(over+1))+",2)"}else{return null}}};hiddenAttributes="_password";categories={dateTitle:["_utime","_startTime","_updateTime","_lastAuthnUTime","_lastSeen"],connectionTitle:["ipAddr","_timezone","_url"],authenticationTitle:["_session_id","_user","_password","authenticationLevel"],modulesTitle:["_auth","_userDB","_passwordDB","_issuerDB","_authChoice","_authMulti","_userDBMulti"],saml:["_idp","_idpConfKey","_samlToken","_lassoSessionDump","_lassoIdentityDump"],groups:["groups","hGroups"],ldap:["dn"],BrowserID:["_browserIdAnswer","_browserIdAnswerRaw"],OpenIDConnect:["_oidc_id_token","_oidc_OP","_oidc_access_token"],sfaTitle:["_2fDevices"],oidcConsents:["_oidcConsents"]};menu={session:[{title:"deleteSession",icon:"trash"}],home:[]};llapp=angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]);llapp.controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function($scope,$translator,$location,$q,$http){var autoId,c,pathEvent,sessionType;$scope.links=links;$scope.menulinks=menulinks;$scope.staticPrefix=staticPrefix;$scope.scriptname=scriptname;$scope.formPrefix=formPrefix;$scope.availableLanguages=availableLanguages;$scope.waiting=true;$scope.showM=false;$scope.showT=true;$scope.data=[];$scope.currentScope=null;$scope.currentSession=null;$scope.menu=menu;$scope.translateP=$translator.translateP;$scope.translate=$translator.translate;$scope.translateTitle=function(node){return $translator.translateField(node,"title")};sessionType="global";$scope.menuClick=function(button){if(button.popup){window.open(button.popup)}else{if(!button.action){button.action=button.title}switch(typeof button.action){case"function":button.action($scope.currentNode,$scope);break;case"string":$scope[button.action]();break;default:console.log(typeof button.action)}}return $scope.showM=false};$scope.deleteOIDCConsent=function(rp,epoch){var item;item=angular.element(".data-"+epoch);item.remove();$scope.waiting=true;$http["delete"](scriptname+"sessions/OIDCConsent/"+sessionType+"/"+$scope.currentSession.id+"?rp="+rp+"&epoch="+epoch).then(function(response){return $scope.waiting=false},function(resp){return $scope.waiting=false});return $scope.showT=false};$scope.deleteSession=function(){$scope.waiting=true;return $http["delete"](scriptname+"sessions/"+sessionType+"/"+$scope.currentSession.id).then(function(response){$scope.currentSession=null;$scope.currentScope.remove();return $scope.waiting=false},function(resp){$scope.currentSession=null;$scope.currentScope.remove();return $scope.waiting=false})};$scope.stoggle=function(scope){var node;node=scope.$modelValue;if(node.nodes.length===0){$scope.updateTree(node.value,node.nodes,node.level,node.over,node.query,node.count)}return scope.toggle()};$scope.displaySession=function(scope){var sessionId,transformSession;transformSession=function(session){var _insert,array,attr,attrs,category,cv,epoch,i,id,j,k,key,l,len,len1,len2,len3,len4,m,name,o,oidcConsent,ref,ref1,res,sfDevice,subres,time,title,tmp,value;_insert=function(re,title){var key,reg,tmp,value;tmp=[];reg=new RegExp(re);for(key in session){value=session[key];if(key.match(reg)&&value){tmp.push({title:key,value:value});delete session[key]}}if(tmp.length>0){return res.push({title:title,nodes:tmp})}};time=session._utime;id=session._session_id;for(key in session){value=session[key];if(!value){delete session[key]}else{if(typeof session==="string"&&value.match(/; /)){session[key]=value.split("; ")}if(typeof session[key]!=="object"){if(hiddenAttributes.match(new RegExp("\b"+key+"\b"))){session[key]="********"}else if(key.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)){session[key]=$scope.localeDate(value)}else if(key.match(/^(_startTime|_updateTime)$/)){session[key]=$scope.strToLocaleDate(value)}}}}res=[];for(category in categories){attrs=categories[category];subres=[];for(i=0,len=attrs.length;i<len;i++){attr=attrs[i];if(session[attr]){if(session[attr].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){subres.push({title:"type",value:"name",epoch:"date",td:"0"});array=JSON.parse(session[attr]);for(j=0,len1=array.length;j<len1;j++){sfDevice=array[j];for(key in sfDevice){value=sfDevice[key];if(key==="type"){title=value}if(key==="name"){name=value}if(key==="epoch"){epoch=value}}subres.push({title:title,value:name,epoch:epoch,td:"1"})}delete session[attr]}else if(session[attr].toString().match(/"rp":\s*"[\w-]+"/)){subres.push({title:"rp",value:"scope",epoch:"date",td:"0"});array=JSON.parse(session[attr]);for(k=0,len2=array.length;k<len2;k++){oidcConsent=array[k];for(key in oidcConsent){value=oidcConsent[key];if(key==="rp"){title=value}if(key==="scope"){name=value}if(key==="epoch"){epoch=value}}subres.push({title:title,value:name,epoch:epoch,td:"2"})}delete session[attr]}else if(session[attr].toString().match(/\w+/)){subres.push({title:attr,value:session[attr],epoch:""});delete session[attr]}else{delete session[attr]}}else{delete session[attr]}}if(subres.length>0){res.push({title:"__"+category+"__",nodes:subres})}}_insert("^openid","OpenID");_insert("^notification_(.+)","__notificationsDone__");if(session._loginHistory){tmp=[];if(session._loginHistory.successLogin){ref=session._loginHistory.successLogin;for(m=0,len3=ref.length;m<len3;m++){l=ref[m];cv="";for(key in l){value=l[key];if(!key.match(/^(_utime|ipAddr|error)$/)){cv+=", "+key+" : "+value}}tmp.push({t:l._utime,title:$scope.localeDate(l._utime),value:"Success (IP "+l.ipAddr+")"+cv})}}if(session._loginHistory.failedLogin){ref1=session._loginHistory.failedLogin;for(o=0,len4=ref1.length;o<len4;o++){l=ref1[o];cv="";for(key in l){value=l[key];if(!key.match(/^(_utime|ipAddr|error)$/)){cv+=", "+key+" : "+value}}tmp.push({t:l._utime,title:$scope.localeDate(l._utime),value:"Error "+l.error+" (IP "+l.ipAddr+")"+cv})}}delete session._loginHistory;tmp.sort(function(a,b){return b.t-a.t});res.push({title:"__loginHistory__",nodes:tmp})}tmp=[];for(key in session){value=session[key];tmp.push({title:key,value:value})}tmp.sort(function(a,b){if(a.title>b.title){return 1}else if(a.title<b.title){return-1}else{return 0}});res.push({title:"__attributesAndMacros__",nodes:tmp});return{_utime:time,id:id,nodes:res}};$scope.currentScope=scope;sessionId=scope.$modelValue.session;$http.get(scriptname+"sessions/"+sessionType+"/"+sessionId).then(function(response){return $scope.currentSession=transformSession(response.data)});return $scope.showT=false};$scope.localeDate=function(s){var d;d=new Date(s*1e3);return d.toLocaleString()};$scope.strToLocaleDate=function(s){var arrayDate,d;arrayDate=s.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/);if(!arrayDate.length){return s}d=new Date(arrayDate[1]+"-"+arrayDate[2]+"-"+arrayDate[3]+"T"+arrayDate[4]+":"+arrayDate[5]+":"+arrayDate[6]);return d.toLocaleString()};$scope.getLanguage=function(lang){$scope.lang=lang;$scope.form="white";$scope.init();return $scope.showM=false};pathEvent=function(event,next,current){var n;n=next.match(/#!?\/(\w+)/);sessionType="global";if(n===null){$scope.type="_whatToTrace"}else if(n[1].match(/^(persistent)$/)){sessionType=RegExp.$1;$scope.type="_session_uid"}else{$scope.type=n[1]}return $scope.init()};$scope.$on("$locationChangeSuccess",pathEvent);autoId=0;$scope.updateTree=function(value,node,level,over,currentQuery,count){var query,scheme,tmp;$scope.waiting=true;scheme=schemes[$scope.type]?schemes[$scope.type]:$scope.type==="_updateTime"?schemes._startTime:schemes._whatToTrace;query=scheme[level]($scope.type,value,currentQuery);if(count>max&&overScheme[$scope.type]){if(tmp=overScheme[$scope.type]($scope.type,value,level,over,currentQuery)){over++;query=tmp;level=level-1}else{over=0}}else{over=0}return $http.get(scriptname+"sessions/"+sessionType+"?"+query).then(function(response){var data,i,len,n,ref;data=response.data;if(data.result){ref=data.values;for(i=0,len=ref.length;i<len;i++){n=ref[i];autoId++;n.id="node"+autoId;if(level<scheme.length-1){n.nodes=[];n.level=level+1;n.query=query;n.over=over;if($scope.type.match(/^(?:start|update)Time$/)){n.title=n.value.replace(/^(\d{8})(\d{2})(\d{2})$/,"$2:$3").replace(/^(\d{8})(\d{2})(\d)$/,"$2:$30").replace(/^(\d{8})(\d{2})$/,"$2h").replace(/^(\d{4})(\d{2})(\d{2})/,"$1-$2-$3")}}node.push(n)}if(value===""){$scope.total=data.total}}return $scope.waiting=false},function(resp){return $scope.waiting=false})};$scope.init=function(){$scope.waiting=true;$scope.data=[];$q.all([$translator.init($scope.lang),$scope.updateTree("",$scope.data,0,0)]).then(function(){return $scope.waiting=false},function(resp){return $scope.waiting=false});$scope.activeModule="sessions";return $scope.myStyle={color:"#ffb84d"}};c=$location.path().match(/^\/(\w+)/);return $scope.type=c?c[1]:"_whatToTrace"}])}).call(this);
......@@ -441,6 +441,10 @@ This file contains:
} else {
node.data = data.value;
}
if (node.data.toString().match(/_Hidden_$/)) {
node.type = 'text';
node.data = '######';
}
if (node.type && node.type.match(/^int$/)) {
node.data = parseInt(node.data, 10);
} else if (node.type && node.type.match(/^(saml(Service|Assertion)|blackWhiteList)$/) && !(typeof node.data === 'object')) {
......@@ -454,6 +458,10 @@ This file contains:
});
}
} else {
if (node.data.toString().match(/_Hidden_$/)) {
node.type = 'text';
node.data = '######';
}
d.resolve(node.data);
}
return d.promise;
......
(function(){var llapp;llapp=angular.module("llngManager",["ui.tree","ui.bootstrap","llApp","ngCookies"]);llapp.controller("TreeCtrl",["$scope","$http","$location","$q","$uibModal","$translator","$cookies","$htmlParams",function($scope,$http,$location,$q,$uibModal,$translator,$cookies,$htmlParams){var _download,_getAll,_stoggle,c,id,pathEvent,readError,setHelp;$scope.links=window.links;$scope.menu=$htmlParams.menu;$scope.menulinks=window.menulinks;$scope.staticPrefix=window.staticPrefix;$scope.formPrefix=window.formPrefix;$scope.availableLanguages=window.availableLanguages;$scope.waiting=true;$scope.showM=false;$scope.showT=false;$scope.form="home";$scope.currentCfg={};$scope.viewPrefix=window.viewPrefix;$scope.message={};$scope.result="";$scope.translateTitle=function(node){return $translator.translateField(node,"title")};$scope.translateP=$translator.translateP;$scope.translate=$translator.translate;$scope.helpUrl="start.html#configuration";$scope.setShowHelp=function(val){var d;if(val==null){val=!$scope.showH}$scope.showH=val;d=new Date(Date.now());d.setFullYear(d.getFullYear()+1);return $cookies.put("showhelp",val?"true":"false",{expires:d})};$scope.showH=$cookies.get("showhelp")==="false"?false:true;if($scope.showH==null){$scope.setShowHelp(true)}readError=function(response){var e,j;e=response.status;j=response.statusLine;$scope.waiting=false;if(e===403){$scope.message={title:"forbidden",message:"",items:[]}}else if(e===401){console.log("Authentication needed");$scope.message={title:"authenticationNeeded",message:"__waitOrF5__",items:[]}}else if(e===400){$scope.message={title:"badRequest",message:j,items:[]}}else if(e>0){$scope.message={title:"badRequest",message:j,items:[]}}else{$scope.message={title:"networkProblem",message:"",items:[]}}return $scope.showModal("message.html")};$scope.showModal=function(tpl,init){var d,modalInstance;modalInstance=$uibModal.open({templateUrl:tpl,controller:"ModalInstanceCtrl",size:"lg",resolve:{elem:function(){return function(s){return $scope[s]}},set:function(){return function(f,s){return $scope[f]=s}},init:function(){return init}}});d=$q.defer();modalInstance.result.then(function(msgok){$scope.message={title:"",message:"",items:[]};return d.resolve(msgok)},function(msgnok){$scope.message={title:"",message:"",items:[]};return d.reject(msgnok)});return d.promise};$scope.menuClick=function(button){if(button.popup){window.open(button.popup)}else{if(!button.action){button.action=button.title}switch(typeof button.action){case"function":button.action($scope.currentNode,$scope);break;case"string":$scope[button.action]();break;default:console.log(typeof button.action)}}return $scope.showM=false};$scope.home=function(){$scope.form="home";return $scope.showM=false};$scope.downloadConf=function(){return window.open($scope.viewPrefix+$scope.currentCfg.cfgNum+"?full=1")};id=1;$scope._findContainer=function(){return $scope._findScopeContainer().$modelValue};$scope._findScopeContainer=function(){var cs;cs=$scope.currentScope;while(!cs.$modelValue.type.match(/Container$/)){cs=cs.$parentNodeScope}return cs};$scope._findScopeByKey=function(k){var cs;cs=$scope.currentScope;while(!(cs.$modelValue.title===k)){cs=cs.$parentNodeScope}return cs};_getAll=function(node){var d,d2;d=$q.defer();d2=$q.defer();if(node._nodes){_stoggle(node);d.resolve()}else if(node.cnodes){_download(node).then(function(){return d.resolve()})}else if(node.nodes||node.data){d.resolve()}else{$scope.getKey(node).then(function(){return d.resolve()})}d.promise.then(function(){var l,len,n,ref,t;t=[];if(node.nodes){ref=node.nodes;for(l=0,len=ref.length;l<len;l++){n=ref[l];t.push(_getAll(n))}}return $q.all(t).then(function(){return d2.resolve()})});return d2.promise};$scope.down=function(){var i,ind,l,len,n,p,ref,tmp;id=$scope.currentNode.id;p=$scope.currentScope.$parentNodeScope.$modelValue;ind=p.nodes.length;ref=p.nodes;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];if(n.id===id){ind=i}}if(ind<p.nodes.length-1){tmp=p.nodes[ind];p.nodes[ind]=p.nodes[ind+1];p.nodes[ind+1]=tmp}return ind};$scope.up=function(){var i,ind,l,len,n,p,ref,tmp;id=$scope.currentNode.id;p=$scope.currentScope.$parentNodeScope.$modelValue;ind=-1;ref=p.nodes;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];if(n.id===id){ind=i}}if(ind>0){tmp=p.nodes[ind];p.nodes[ind]=p.nodes[ind-1];p.nodes[ind-1]=tmp}return ind};$scope.inSelect=function(value){var l,len,n,ref;ref=$scope.currentNode.select;for(l=0,len=ref.length;l<len;l++){n=ref[l];if(n.k===value){return true}}return false};$scope.changeRuleTitle=function(node){return node.title=node.comment.length>0?node.comment:node.re};$scope.filters={};$scope.execFilters=function(scope){var filter,func,ref;scope=scope?scope:$scope;ref=$scope.filters;for(filter in ref){func=ref[filter];if($scope.filters.hasOwnProperty(filter)){return window.filterFunctions[filter](scope,$q,func)}}return false};$scope.stoggle=function(scope){var node;node=scope.$modelValue;_stoggle(node);return scope.toggle()};_stoggle=function(node){var a,l,len,len1,len2,m,n,o,ref,ref1,ref2;ref=["nodes","nodes_cond"];for(l=0,len=ref.length;l<len;l++){n=ref[l];if(node["_"+n]){node[n]=[];ref1=node["_"+n];for(m=0,len1=ref1.length;m<len1;m++){a=ref1[m];node[n].push(a)}delete node["_"+n]}}if(node._nodes_filter){if(node.nodes){ref2=node.nodes;for(o=0,len2=ref2.length;o<len2;o++){n=ref2[o];n.onChange=$scope.execFilters}}$scope.filters[node._nodes_filter]=node;return $scope.execFilters()}};$scope.toggle=function(scope){return scope.toggle()};$scope.download=function(scope){var node;node=scope.$modelValue;return _download(node)};_download=function(node){var d;d=$q.defer();d.notify("Trying to get datas");$scope.waiting=true;$http.get(""+window.viewPrefix+$scope.currentCfg.cfgNum+"/"+node.cnodes).then(function(response){var a,data,l,len;data=response.data;if(!data){d.reject("Empty response from server")}else if(data.error){if(data.error.match(/setDefault$/)){if(node["default"]){node.nodes=node["default"].slice(0)}else{node.nodes=[]}delete node.cnodes;d.resolve("Set data to default value")}else{d.reject("Server return an error: "+data.error)}}else{delete node.cnodes;if(!node.type){node.type="keyTextContainer"}node.nodes=[];for(l=0,len=data.length;l<len;l++){a=data[l];if(a.template){a._nodes=templates(a.template,a.title)}node.nodes.push(a)}d.resolve("OK")}return $scope.waiting=false},function(response){readError(response);return d.reject("")});return d.promise};$scope.openCnode=function(scope){return $scope.download(scope).then(function(){return scope.toggle()})};setHelp=function(scope){while(!scope.$modelValue.help&&scope.$parentNodeScope){scope=scope.$parentNodeScope}return $scope.helpUrl=scope.$modelValue.help||"start.html#configuration"};$scope.displayForm=function(scope){var f,l,len,n,node,ref;node=scope.$modelValue;if(node.cnodes){$scope.download(scope)}if(node._nodes){$scope.stoggle(scope)}$scope.currentNode=node;$scope.currentScope=scope;f=node.type?node.type:"text";if(node.nodes||node._nodes||node.cnodes){$scope.form=f!=="text"?f:"mini"}else{$scope.form=f;$scope.getKey(node)}if(node.type&&node.type==="simpleInputContainer"){ref=node.nodes;for(l=0,len=ref.length;l<len;l++){n=ref[l];$scope.getKey(n)}}$scope.showT=false;return setHelp(scope)};$scope.getKey=function(node){var d,i,l,len,n,ref,tmp;d=$q.defer();if(!node.data){$scope.waiting=true;if(node.get&&typeof node.get==="object"){node.data=[];tmp=[];ref=node.get;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];node.data[i]={title:n,id:n};tmp.push($scope.getKey(node.data[i]))}$q.all(tmp).then(function(){return d.resolve(node.data)},function(response){d.reject(response.statusLine);return $scope.waiting=false})}else{$http.get(""+window.viewPrefix+$scope.currentCfg.cfgNum+"/"+(node.get?node.get:node.title)).then(function(response){var data;data=response.data;if((data.value===null||data.error&&data.error.match(/setDefault$/))&&node["default"]!==null){node.data=node["default"]}else{node.data=data.value}if(node.type&&node.type.match(/^int$/)){node.data=parseInt(node.data,10)}else if(node.type&&node.type.match(/^(saml(Service|Assertion)|blackWhiteList)$/)&&!(typeof node.data==="object")){node.data=node.data.split(";")}$scope.waiting=false;return d.resolve(node.data)},function(response){readError(response);return d.reject(response.status)})}}else{d.resolve(node.data)}return d.promise};pathEvent=function(event,next,current){var n;n=next.match(new RegExp("#!?/view/(latest|[0-9]+)"));if(n===null){return $location.path("/view/latest")}else{console.log("Trying to get cfg number "+n[1]);return $scope.getCfg(n[1])}};$scope.$on("$locationChangeSuccess",pathEvent);$scope.getCfg=function(n){if($scope.currentCfg.cfgNum!==n){return $http.get(""+window.viewPrefix+n).then(function(response){var d;$scope.currentCfg=response.data;d=new Date($scope.currentCfg.cfgDate*1e3);$scope.currentCfg.date=d.toLocaleString();console.log("Metadatas of cfg "+n+" loaded");$location.path("/view/"+n);return $scope.init()},function(response){return readError(response).then(function(){$scope.currentCfg.cfgNum=0;return $scope.init()})})}else{return $scope.waiting=false}};$scope.getLanguage=function(lang){$scope.lang=lang;$scope.form="white";$scope.init();return $scope.showM=false};$scope.init=function(){var tmp;tmp=null;$scope.waiting=true;$scope.data=[];$scope.confirmNeeded=false;$scope.forceSave=false;$q.all([$translator.init($scope.lang),$http.get(window.staticPrefix+"struct.json").then(function(response){tmp=response.data;return console.log("Structure loaded")})]).then(function(){console.log("Starting structure binding");$scope.data=tmp;tmp=null;if($scope.currentCfg.cfgNum!==0){setScopeVars($scope)}else{$scope.message={title:"emptyConf",message:"__zeroConfExplanations__"};$scope.showModal("message.html")}$scope.form="home";return $scope.waiting=false},readError);$scope.activeModule="viewer";return $scope.myStyle={color:"#ffb84d"}};c=$location.path().match(new RegExp("^/view/(latest|[0-9]+)"));if(!c){console.log("Redirecting to /view/latest");return $location.path("/view/latest")}}])}).call(this);
(function(){var llapp;llapp=angular.module("llngManager",["ui.tree","ui.bootstrap","llApp","ngCookies"]);llapp.controller("TreeCtrl",["$scope","$http","$location","$q","$uibModal","$translator","$cookies","$htmlParams",function($scope,$http,$location,$q,$uibModal,$translator,$cookies,$htmlParams){var _download,_getAll,_stoggle,c,id,pathEvent,readError,setHelp;$scope.links=window.links;$scope.menu=$htmlParams.menu;$scope.menulinks=window.menulinks;$scope.staticPrefix=window.staticPrefix;$scope.formPrefix=window.formPrefix;$scope.availableLanguages=window.availableLanguages;$scope.waiting=true;$scope.showM=false;$scope.showT=false;$scope.form="home";$scope.currentCfg={};$scope.viewPrefix=window.viewPrefix;$scope.message={};$scope.result="";$scope.translateTitle=function(node){return $translator.translateField(node,"title")};$scope.translateP=$translator.translateP;$scope.translate=$translator.translate;$scope.helpUrl="start.html#configuration";$scope.setShowHelp=function(val){var d;if(val==null){val=!$scope.showH}$scope.showH=val;d=new Date(Date.now());d.setFullYear(d.getFullYear()+1);return $cookies.put("showhelp",val?"true":"false",{expires:d})};$scope.showH=$cookies.get("showhelp")==="false"?false:true;if($scope.showH==null){$scope.setShowHelp(true)}readError=function(response){var e,j;e=response.status;j=response.statusLine;$scope.waiting=false;if(e===403){$scope.message={title:"forbidden",message:"",items:[]}}else if(e===401){console.log("Authentication needed");$scope.message={title:"authenticationNeeded",message:"__waitOrF5__",items:[]}}else if(e===400){$scope.message={title:"badRequest",message:j,items:[]}}else if(e>0){$scope.message={title:"badRequest",message:j,items:[]}}else{$scope.message={title:"networkProblem",message:"",items:[]}}return $scope.showModal("message.html")};$scope.showModal=function(tpl,init){var d,modalInstance;modalInstance=$uibModal.open({templateUrl:tpl,controller:"ModalInstanceCtrl",size:"lg",resolve:{elem:function(){return function(s){return $scope[s]}},set:function(){return function(f,s){return $scope[f]=s}},init:function(){return init}}});d=$q.defer();modalInstance.result.then(function(msgok){$scope.message={title:"",message:"",items:[]};return d.resolve(msgok)},function(msgnok){$scope.message={title:"",message:"",items:[]};return d.reject(msgnok)});return d.promise};$scope.menuClick=function(button){if(button.popup){window.open(button.popup)}else{if(!button.action){button.action=button.title}switch(typeof button.action){case"function":button.action($scope.currentNode,$scope);break;case"string":$scope[button.action]();break;default:console.log(typeof button.action)}}return $scope.showM=false};$scope.home=function(){$scope.form="home";return $scope.showM=false};$scope.downloadConf=function(){return window.open($scope.viewPrefix+$scope.currentCfg.cfgNum+"?full=1")};id=1;$scope._findContainer=function(){return $scope._findScopeContainer().$modelValue};$scope._findScopeContainer=function(){var cs;cs=$scope.currentScope;while(!cs.$modelValue.type.match(/Container$/)){cs=cs.$parentNodeScope}return cs};$scope._findScopeByKey=function(k){var cs;cs=$scope.currentScope;while(!(cs.$modelValue.title===k)){cs=cs.$parentNodeScope}return cs};_getAll=function(node){var d,d2;d=$q.defer();d2=$q.defer();if(node._nodes){_stoggle(node);d.resolve()}else if(node.cnodes){_download(node).then(function(){return d.resolve()})}else if(node.nodes||node.data){d.resolve()}else{$scope.getKey(node).then(function(){return d.resolve()})}d.promise.then(function(){var l,len,n,ref,t;t=[];if(node.nodes){ref=node.nodes;for(l=0,len=ref.length;l<len;l++){n=ref[l];t.push(_getAll(n))}}return $q.all(t).then(function(){return d2.resolve()})});return d2.promise};$scope.down=function(){var i,ind,l,len,n,p,ref,tmp;id=$scope.currentNode.id;p=$scope.currentScope.$parentNodeScope.$modelValue;ind=p.nodes.length;ref=p.nodes;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];if(n.id===id){ind=i}}if(ind<p.nodes.length-1){tmp=p.nodes[ind];p.nodes[ind]=p.nodes[ind+1];p.nodes[ind+1]=tmp}return ind};$scope.up=function(){var i,ind,l,len,n,p,ref,tmp;id=$scope.currentNode.id;p=$scope.currentScope.$parentNodeScope.$modelValue;ind=-1;ref=p.nodes;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];if(n.id===id){ind=i}}if(ind>0){tmp=p.nodes[ind];p.nodes[ind]=p.nodes[ind-1];p.nodes[ind-1]=tmp}return ind};$scope.inSelect=function(value){var l,len,n,ref;ref=$scope.currentNode.select;for(l=0,len=ref.length;l<len;l++){n=ref[l];if(n.k===value){return true}}return false};$scope.changeRuleTitle=function(node){return node.title=node.comment.length>0?node.comment:node.re};$scope.filters={};$scope.execFilters=function(scope){var filter,func,ref;scope=scope?scope:$scope;ref=$scope.filters;for(filter in ref){func=ref[filter];if($scope.filters.hasOwnProperty(filter)){return window.filterFunctions[filter](scope,$q,func)}}return false};$scope.stoggle=function(scope){var node;node=scope.$modelValue;_stoggle(node);return scope.toggle()};_stoggle=function(node){var a,l,len,len1,len2,m,n,o,ref,ref1,ref2;ref=["nodes","nodes_cond"];for(l=0,len=ref.length;l<len;l++){n=ref[l];if(node["_"+n]){node[n]=[];ref1=node["_"+n];for(m=0,len1=ref1.length;m<len1;m++){a=ref1[m];node[n].push(a)}delete node["_"+n]}}if(node._nodes_filter){if(node.nodes){ref2=node.nodes;for(o=0,len2=ref2.length;o<len2;o++){n=ref2[o];n.onChange=$scope.execFilters}}$scope.filters[node._nodes_filter]=node;return $scope.execFilters()}};$scope.toggle=function(scope){return scope.toggle()};$scope.download=function(scope){var node;node=scope.$modelValue;return _download(node)};_download=function(node){var d;d=$q.defer();d.notify("Trying to get datas");$scope.waiting=true;$http.get(""+window.viewPrefix+$scope.currentCfg.cfgNum+"/"+node.cnodes).then(function(response){var a,data,l,len;data=response.data;if(!data){d.reject("Empty response from server")}else if(data.error){if(data.error.match(/setDefault$/)){if(node["default"]){node.nodes=node["default"].slice(0)}else{node.nodes=[]}delete node.cnodes;d.resolve("Set data to default value")}else{d.reject("Server return an error: "+data.error)}}else{delete node.cnodes;if(!node.type){node.type="keyTextContainer"}node.nodes=[];for(l=0,len=data.length;l<len;l++){a=data[l];if(a.template){a._nodes=templates(a.template,a.title)}node.nodes.push(a)}d.resolve("OK")}return $scope.waiting=false},function(response){readError(response);return d.reject("")});return d.promise};$scope.openCnode=function(scope){return $scope.download(scope).then(function(){return scope.toggle()})};setHelp=function(scope){while(!scope.$modelValue.help&&scope.$parentNodeScope){scope=scope.$parentNodeScope}return $scope.helpUrl=scope.$modelValue.help||"start.html#configuration"};$scope.displayForm=function(scope){var f,l,len,n,node,ref;node=scope.$modelValue;if(node.cnodes){$scope.download(scope)}if(node._nodes){$scope.stoggle(scope)}$scope.currentNode=node;$scope.currentScope=scope;f=node.type?node.type:"text";if(node.nodes||node._nodes||node.cnodes){$scope.form=f!=="text"?f:"mini"}else{$scope.form=f;$scope.getKey(node)}if(node.type&&node.type==="simpleInputContainer"){ref=node.nodes;for(l=0,len=ref.length;l<len;l++){n=ref[l];$scope.getKey(n)}}$scope.showT=false;return setHelp(scope)};$scope.getKey=function(node){var d,i,l,len,n,ref,tmp;d=$q.defer();if(!node.data){$scope.waiting=true;if(node.get&&typeof node.get==="object"){node.data=[];tmp=[];ref=node.get;for(i=l=0,len=ref.length;l<len;i=++l){n=ref[i];node.data[i]={title:n,id:n};tmp.push($scope.getKey(node.data[i]))}$q.all(tmp).then(function(){return d.resolve(node.data)},function(response){d.reject(response.statusLine);return $scope.waiting=false})}else{$http.get(""+window.viewPrefix+$scope.currentCfg.cfgNum+"/"+(node.get?node.get:node.title)).then(function(response){var data;data=response.data;if((data.value===null||data.error&&data.error.match(/setDefault$/))&&node["default"]!==null){node.data=node["default"]}else{node.data=data.value}if(node.data.toString().match(/_Hidden_$/)){node.type="text";node.data="######"}if(