Lemonldap-NG-Manager
view release on metacpan or search on metacpan
site/htdocs/static/js/sessions.js view on Meta::CPAN
// History custom values
cv = "";
for (key in l) {
value = l[key];
if (!key.match(/^(_utime|ipAddr|error)$/)) {
cv += `, ${key} : ${value}`;
}
}
tab = cv.split(', ');
tab.sort();
cv = tab.join(', ');
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
});
}
// 5. Other keys (attributes and macros)
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;
}
});
// Sort by real and spoofed attributes
real = [];
spoof = [];
for (p = 0, len5 = tmp.length; p < len5; p++) {
element = tmp[p];
if (element.title.match(new RegExp('^' + $scope.impPrefix + '.+$'))) {
console.debug(element, '-> real attribute');
real.push(element);
} else {
//console.debug element, '-> spoofed attribute'
spoof.push(element);
}
}
tmp = spoof.concat(real);
res.push({
title: '__attributesAndMacros__',
nodes: tmp
});
return {
_utime: time,
nodes: res
};
};
$scope.currentScope = scope;
sessionId = scope.$modelValue.session;
$http.get(`${scriptname}sessions/${sessionType}/${sessionId}`).then(function (response) {
$scope.currentSession = transformSession(response.data);
return $scope.currentSession.id = sessionId;
});
return $scope.showT = false;
};
$scope.localeDate = function (s) {
var d;
d = new Date(s * 1000);
return d.toLocaleString();
};
$scope.isValid = function (epoch, type) {
var isValid, now, path;
path = $location.path();
now = Date.now() / 1000;
console.debug("Path", path);
console.debug("Session epoch", epoch);
console.debug("Current date", now);
console.debug("Session TTL", sessionTTL);
isValid = now - epoch < sessionTTL || $location.path().match(/^\/persistent/);
if (type === 'msg') {
console.debug("Return msg");
if (isValid) {
return "info";
} else {
return "warning";
}
} else if (type === 'style') {
console.debug("Return style");
if (isValid) {
return {};
} else {
return {
'color': '#627990',
'font-style': 'italic'
};
}
} else {
console.debug("Return isValid");
return isValid;
}
};
$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();
};
( run in 2.887 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )