| 1 |
(function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
var categories, hiddenAttributes, llapp, max, menu, overScheme, schemes; |
| 11 |
|
| 12 |
|
| 13 |
max = 25; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
schemes = { |
| 18 |
_whatToTrace: [ |
| 19 |
|
| 20 |
function (t, v) { |
| 21 |
return `groupBy=substr(${t},1)`; |
| 22 |
}, |
| 23 |
|
| 24 |
function (t, v) { |
| 25 |
return `${t}=${v}*&groupBy=${t}`; |
| 26 |
}, function (t, v) { |
| 27 |
return `${t}=${v}`; |
| 28 |
}], |
| 29 |
ipAddr: [function (t, v) { |
| 30 |
return `groupBy=net(${t},16,1)`; |
| 31 |
}, function (t, v) { |
| 32 |
if (!v.match(/:/)) { |
| 33 |
v = v + '.'; |
| 34 |
} |
| 35 |
return `${t}=${v}*&groupBy=net(${t},32,2)`; |
| 36 |
}, function (t, v) { |
| 37 |
if (!v.match(/:/)) { |
| 38 |
v = v + '.'; |
| 39 |
} |
| 40 |
return `${t}=${v}*&groupBy=net(${t},48,3)`; |
| 41 |
}, function (t, v) { |
| 42 |
if (!v.match(/:/)) { |
| 43 |
v = v + '.'; |
| 44 |
} |
| 45 |
return `${t}=${v}*&groupBy=net(${t},128,4)`; |
| 46 |
}, function (t, v) { |
| 47 |
return `${t}=${v}&groupBy=_whatToTrace`; |
| 48 |
}, function (t, v, q) { |
| 49 |
return q.replace(/\&groupBy.*$/, '') + `&_whatToTrace=${v}`; |
| 50 |
}], |
| 51 |
_startTime: [function (t, v) { |
| 52 |
return `groupBy=substr(${t},8)`; |
| 53 |
}, function (t, v) { |
| 54 |
return `${t}=${v}*&groupBy=substr(${t},10)`; |
| 55 |
}, function (t, v) { |
| 56 |
return `${t}=${v}*&groupBy=substr(${t},11)`; |
| 57 |
}, function (t, v) { |
| 58 |
return `${t}=${v}*&groupBy=substr(${t},12)`; |
| 59 |
}, function (t, v) { |
| 60 |
return `${t}=${v}*&groupBy=_whatToTrace`; |
| 61 |
}, function (t, v, q) { |
| 62 |
return q.replace(/\&groupBy.*$/, '') + `&_whatToTrace=${v}`; |
| 63 |
}], |
| 64 |
doubleIp: [function (t, v) { |
| 65 |
return t; |
| 66 |
}, function (t, v) { |
| 67 |
return `_whatToTrace=${v}&groupBy=ipAddr`; |
| 68 |
}, function (t, v, q) { |
| 69 |
return q.replace(/\&groupBy.*$/, '') + `&ipAddr=${v}`; |
| 70 |
}], |
| 71 |
_session_uid: [ |
| 72 |
|
| 73 |
function (t, v) { |
| 74 |
return `groupBy=substr(${t},1)`; |
| 75 |
}, |
| 76 |
|
| 77 |
function (t, v) { |
| 78 |
return `${t}=${v}*&groupBy=${t}`; |
| 79 |
}, function (t, v) { |
| 80 |
return `${t}=${v}`; |
| 81 |
}] |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
overScheme = { |
| 88 |
_whatToTrace: function (t, v, level, over) { |
| 89 |
|
| 90 |
|
| 91 |
console.debug('overScheme => level', level, 'over', over); |
| 92 |
|
| 93 |
|
| 94 |
if (v.length >= level + over) return null; |
| 95 |
if (level === 1 && v.length > over) { |
| 96 |
return `${t}=${v}*&groupBy=substr(${t},${level + over + 1})`; |
| 97 |
} else { |
| 98 |
return null; |
| 99 |
} |
| 100 |
}, |
| 101 |
|
| 102 |
ipAddr: function (t, v, level, over) { |
| 103 |
console.debug('overScheme => level', level, 'over', over); |
| 104 |
if (level > 0 && level < 4 && !v.match(/^\d+\.\d/) && over < 2) { |
| 105 |
return `${t}=${v}*&groupBy=net(${t},${16 * level + 4 * (over + 1)},${1 + level + over})`; |
| 106 |
} else { |
| 107 |
return null; |
| 108 |
} |
| 109 |
}, |
| 110 |
_startTime: function (t, v, level, over) { |
| 111 |
console.debug('overScheme => level', level, 'over', over); |
| 112 |
if (level > 3) { |
| 113 |
return `${t}=${v}*&groupBy=substr(${t},${10 + level + over})`; |
| 114 |
} else { |
| 115 |
return null; |
| 116 |
} |
| 117 |
}, |
| 118 |
_session_uid: function (t, v, level, over) { |
| 119 |
console.debug('overScheme => level', level, 'over', over); |
| 120 |
if (level === 1 && v.length > over) { |
| 121 |
return `${t}=${v}*&groupBy=substr(${t},${level + over + 1})`; |
| 122 |
} else { |
| 123 |
return null; |
| 124 |
} |
| 125 |
} |
| 126 |
}; |
| 127 |
hiddenAttributes = '_password'; |
| 128 |
|
| 129 |
|
| 130 |
categories = { |
| 131 |
dateTitle: ['_utime', '_startTime', '_updateTime', '_lastAuthnUTime', '_lastSeen'], |
| 132 |
connectionTitle: ['ipAddr', '_timezone', '_url'], |
| 133 |
authenticationTitle: ['_session_id', '_user', '_password', 'authenticationLevel'], |
| 134 |
modulesTitle: ['_auth', '_userDB', '_passwordDB', '_issuerDB', '_authChoice', '_authMulti', '_userDBMulti', '_2f'], |
| 135 |
saml: ['_idp', '_idpConfKey', '_samlToken', '_lassoSessionDump', '_lassoIdentityDump'], |
| 136 |
groups: ['groups', 'hGroups'], |
| 137 |
ldap: ['dn'], |
| 138 |
OpenIDConnect: ['_oidc_id_token', '_oidc_OP', '_oidc_access_token', '_oidc_refresh_token', '_oidc_access_token_eol', '_oidcConnectedRP', '_oidcConnectedRPIDs'], |
| 139 |
sfaTitle: ['_2fDevices'], |
| 140 |
oidcConsents: ['_oidcConsents'] |
| 141 |
}; |
| 142 |
|
| 143 |
|
| 144 |
menu = { |
| 145 |
session: [{ |
| 146 |
title: 'deleteSession', |
| 147 |
icon: 'trash' |
| 148 |
}, { |
| 149 |
title: 'globalLogout', |
| 150 |
icon: 'trash' |
| 151 |
}], |
| 152 |
home: [] |
| 153 |
}; |
| 154 |
llapp = angular.module('llngSessionsExplorer', ['ui.tree', 'ui.bootstrap', 'llApp']); |
| 155 |
|
| 156 |
|
| 157 |
llapp.controller('SessionsExplorerCtrl', ['$scope', '$translator', '$location', '$q', '$http', function ($scope, $translator, $location, $q, $http) { |
| 158 |
var autoId, c, pathEvent, sessionType; |
| 159 |
$scope.links = links; |
| 160 |
$scope.menulinks = menulinks; |
| 161 |
$scope.staticPrefix = staticPrefix; |
| 162 |
$scope.scriptname = scriptname; |
| 163 |
$scope.formPrefix = formPrefix; |
| 164 |
$scope.impPrefix = impPrefix; |
| 165 |
$scope.sessionTTL = sessionTTL; |
| 166 |
$scope.availableLanguages = availableLanguages; |
| 167 |
$scope.waiting = true; |
| 168 |
$scope.showM = false; |
| 169 |
$scope.showT = true; |
| 170 |
$scope.data = []; |
| 171 |
$scope.currentScope = null; |
| 172 |
$scope.currentSession = null; |
| 173 |
$scope.menu = menu; |
| 174 |
|
| 175 |
$scope.translateP = $translator.translateP; |
| 176 |
$scope.translate = $translator.translate; |
| 177 |
$scope.translateTitle = function (node) { |
| 178 |
return $translator.translateField(node, 'title'); |
| 179 |
}; |
| 180 |
sessionType = 'global'; |
| 181 |
|
| 182 |
$scope.menuClick = function (button) { |
| 183 |
if (button.popup) { |
| 184 |
window.open(button.popup); |
| 185 |
} else { |
| 186 |
if (!button.action) { |
| 187 |
button.action = button.title; |
| 188 |
} |
| 189 |
switch (typeof button.action) { |
| 190 |
case 'function': |
| 191 |
button.action($scope.currentNode, $scope); |
| 192 |
break; |
| 193 |
case 'string': |
| 194 |
$scope[button.action](); |
| 195 |
break; |
| 196 |
default: |
| 197 |
console.warn('Unknown action type', typeof button.action); |
| 198 |
} |
| 199 |
} |
| 200 |
return $scope.showM = false; |
| 201 |
}; |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
$scope.deleteOIDCConsent = function (rp, epoch) { |
| 206 |
var items; |
| 207 |
items = document.querySelectorAll(`.data-${epoch}`); |
| 208 |
$scope.waiting = true; |
| 209 |
$http['delete'](`${scriptname}sessions/OIDCConsent/${sessionType}/${$scope.currentSession.id}?rp=${rp}&epoch=${epoch}`).then(function (response) { |
| 210 |
var e, i, len, results; |
| 211 |
$scope.waiting = false; |
| 212 |
results = []; |
| 213 |
for (i = 0, len = items.length; i < len; i++) { |
| 214 |
e = items[i]; |
| 215 |
results.push(e.remove()); |
| 216 |
} |
| 217 |
return results; |
| 218 |
}, function (resp) { |
| 219 |
return $scope.waiting = false; |
| 220 |
}); |
| 221 |
return $scope.showT = false; |
| 222 |
}; |
| 223 |
|
| 224 |
$scope.deleteSession = function () { |
| 225 |
$scope.waiting = true; |
| 226 |
return $http['delete'](`${scriptname}sessions/${sessionType}/${$scope.currentSession.id}`).then(function (response) { |
| 227 |
$scope.currentSession = null; |
| 228 |
$scope.currentScope.remove(); |
| 229 |
return $scope.waiting = false; |
| 230 |
}, function (resp) { |
| 231 |
return $scope.waiting = false; |
| 232 |
}); |
| 233 |
}; |
| 234 |
$scope.globalLogout = function () { |
| 235 |
$scope.waiting = true; |
| 236 |
return $http['post'](`${scriptname}sessions/glogout/${sessionType}/${$scope.currentSession.id}`).then(function (response) { |
| 237 |
$scope.currentSession = null; |
| 238 |
$scope.currentScope.remove(); |
| 239 |
return $scope.waiting = false; |
| 240 |
}, function (resp) { |
| 241 |
return $scope.waiting = false; |
| 242 |
}); |
| 243 |
}; |
| 244 |
|
| 245 |
$scope.stoggle = function (scope) { |
| 246 |
var node; |
| 247 |
node = scope.$modelValue; |
| 248 |
if (node.nodes.length === 0) { |
| 249 |
$scope.updateTree(node.value, node.nodes, node.level, node.over, node.query, node.count); |
| 250 |
} |
| 251 |
return scope.toggle(); |
| 252 |
}; |
| 253 |
|
| 254 |
$scope.displaySession = function (scope) { |
| 255 |
var sessionId, transformSession; |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
transformSession = function (session) { |
| 260 |
var _insert, array, attr, attrs, category, cv, element, epoch, i, j, k, key, l, len, len1, len2, len3, len4, len5, m, name, o, oidcConsent, p, real, ref, ref1, res, sfDevice, spoof, subres, tab, time, title, tmp, value; |
| 261 |
_insert = function (re, title) { |
| 262 |
var cv, i, key, len, reg, tab, tmp, val, value, vk; |
| 263 |
tmp = []; |
| 264 |
reg = new RegExp(re); |
| 265 |
cv = ""; |
| 266 |
for (key in session) { |
| 267 |
value = session[key]; |
| 268 |
if (key.match(reg) && value) { |
| 269 |
cv += `${value}:${key},`; |
| 270 |
delete session[key]; |
| 271 |
} |
| 272 |
} |
| 273 |
if (cv) { |
| 274 |
cv = cv.replace(/,$/, ''); |
| 275 |
tab = cv.split(','); |
| 276 |
tab.sort(); |
| 277 |
tab.reverse(); |
| 278 |
for (i = 0, len = tab.length; i < len; i++) { |
| 279 |
val = tab[i]; |
| 280 |
vk = val.split(':'); |
| 281 |
tmp.push({ |
| 282 |
title: vk[1], |
| 283 |
value: $scope.localeDate(vk[0]) |
| 284 |
}); |
| 285 |
} |
| 286 |
return res.push({ |
| 287 |
title: title, |
| 288 |
nodes: tmp |
| 289 |
}); |
| 290 |
} |
| 291 |
}; |
| 292 |
time = session._utime; |
| 293 |
|
| 294 |
for (key in session) { |
| 295 |
value = session[key]; |
| 296 |
if (!value) { |
| 297 |
delete session[key]; |
| 298 |
} else { |
| 299 |
if (typeof session === 'string' && value.match(/; /)) { |
| 300 |
session[key] = value.split('; '); |
| 301 |
} |
| 302 |
if (typeof session[key] !== 'object') { |
| 303 |
if (hiddenAttributes.match(new RegExp('\b' + key + '\b'))) { |
| 304 |
session[key] = '********'; |
| 305 |
} else if (key.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)) { |
| 306 |
session[key] = $scope.localeDate(value); |
| 307 |
} else if (key.match(/^(_startTime|_updateTime)$/)) { |
| 308 |
session[key] = $scope.strToLocaleDate(value); |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
} |
| 313 |
res = []; |
| 314 |
|
| 315 |
for (category in categories) { |
| 316 |
attrs = categories[category]; |
| 317 |
subres = []; |
| 318 |
for (i = 0, len = attrs.length; i < len; i++) { |
| 319 |
attr = attrs[i]; |
| 320 |
if (session[attr]) { |
| 321 |
if (attr === "_2fDevices" && session[attr]) { |
| 322 |
array = JSON.parse(session[attr]); |
| 323 |
if (array.length > 0) { |
| 324 |
subres.push({ |
| 325 |
title: "type", |
| 326 |
value: "name", |
| 327 |
epoch: "date", |
| 328 |
td: "0" |
| 329 |
}); |
| 330 |
for (j = 0, len1 = array.length; j < len1; j++) { |
| 331 |
sfDevice = array[j]; |
| 332 |
for (key in sfDevice) { |
| 333 |
value = sfDevice[key]; |
| 334 |
if (key === 'type') { |
| 335 |
title = value; |
| 336 |
} |
| 337 |
if (key === 'name') { |
| 338 |
name = value; |
| 339 |
} |
| 340 |
if (key === 'epoch') { |
| 341 |
epoch = value; |
| 342 |
} |
| 343 |
} |
| 344 |
subres.push({ |
| 345 |
title: title, |
| 346 |
value: name, |
| 347 |
epoch: epoch, |
| 348 |
td: "1" |
| 349 |
}); |
| 350 |
} |
| 351 |
} |
| 352 |
delete session[attr]; |
| 353 |
} else if (session[attr].toString().match(/"rp":\s*"[\w-]+"/)) { |
| 354 |
subres.push({ |
| 355 |
title: "RP", |
| 356 |
value: "scope", |
| 357 |
epoch: "date", |
| 358 |
td: "0" |
| 359 |
}); |
| 360 |
array = JSON.parse(session[attr]); |
| 361 |
for (k = 0, len2 = array.length; k < len2; k++) { |
| 362 |
oidcConsent = array[k]; |
| 363 |
for (key in oidcConsent) { |
| 364 |
value = oidcConsent[key]; |
| 365 |
if (key === 'rp') { |
| 366 |
title = value; |
| 367 |
} |
| 368 |
if (key === 'scope') { |
| 369 |
name = value; |
| 370 |
} |
| 371 |
if (key === 'epoch') { |
| 372 |
epoch = value; |
| 373 |
} |
| 374 |
} |
| 375 |
subres.push({ |
| 376 |
title: title, |
| 377 |
value: name, |
| 378 |
epoch: epoch, |
| 379 |
td: "2" |
| 380 |
}); |
| 381 |
} |
| 382 |
delete session[attr]; |
| 383 |
} else if (session[attr].toString().match(/\w+/)) { |
| 384 |
subres.push({ |
| 385 |
title: attr, |
| 386 |
value: session[attr], |
| 387 |
epoch: '' |
| 388 |
}); |
| 389 |
delete session[attr]; |
| 390 |
} else { |
| 391 |
delete session[attr]; |
| 392 |
} |
| 393 |
} else { |
| 394 |
delete session[attr]; |
| 395 |
} |
| 396 |
} |
| 397 |
if (subres.length > 0) { |
| 398 |
res.push({ |
| 399 |
title: `__${category}__`, |
| 400 |
nodes: subres |
| 401 |
}); |
| 402 |
} |
| 403 |
} |
| 404 |
|
| 405 |
_insert('^openid', 'OpenID'); |
| 406 |
_insert('^notification_(.+)', '__notificationsDone__'); |
| 407 |
|
| 408 |
if (session._loginHistory) { |
| 409 |
tmp = []; |
| 410 |
if (session._loginHistory.successLogin) { |
| 411 |
ref = session._loginHistory.successLogin; |
| 412 |
for (m = 0, len3 = ref.length; m < len3; m++) { |
| 413 |
l = ref[m]; |
| 414 |
|
| 415 |
cv = ""; |
| 416 |
for (key in l) { |
| 417 |
value = l[key]; |
| 418 |
if (!key.match(/^(_utime|ipAddr|error)$/)) { |
| 419 |
cv += `, ${key} : ${value}`; |
| 420 |
} |
| 421 |
} |
| 422 |
tab = cv.split(', '); |
| 423 |
tab.sort(); |
| 424 |
cv = tab.join(', '); |
| 425 |
tmp.push({ |
| 426 |
t: l._utime, |
| 427 |
title: $scope.localeDate(l._utime), |
| 428 |
value: `Success (IP ${l.ipAddr})` + cv |
| 429 |
}); |
| 430 |
} |
| 431 |
} |
| 432 |
if (session._loginHistory.failedLogin) { |
| 433 |
ref1 = session._loginHistory.failedLogin; |
| 434 |
for (o = 0, len4 = ref1.length; o < len4; o++) { |
| 435 |
l = ref1[o]; |
| 436 |
|
| 437 |
cv = ""; |
| 438 |
for (key in l) { |
| 439 |
value = l[key]; |
| 440 |
if (!key.match(/^(_utime|ipAddr|error)$/)) { |
| 441 |
cv += `, ${key} : ${value}`; |
| 442 |
} |
| 443 |
} |
| 444 |
tab = cv.split(', '); |
| 445 |
tab.sort(); |
| 446 |
cv = tab.join(', '); |
| 447 |
tmp.push({ |
| 448 |
t: l._utime, |
| 449 |
title: $scope.localeDate(l._utime), |
| 450 |
value: `Error ${l.error} (IP ${l.ipAddr})` + cv |
| 451 |
}); |
| 452 |
} |
| 453 |
} |
| 454 |
delete session._loginHistory; |
| 455 |
tmp.sort(function (a, b) { |
| 456 |
return b.t - a.t; |
| 457 |
}); |
| 458 |
res.push({ |
| 459 |
title: '__loginHistory__', |
| 460 |
nodes: tmp |
| 461 |
}); |
| 462 |
} |
| 463 |
|
| 464 |
tmp = []; |
| 465 |
for (key in session) { |
| 466 |
value = session[key]; |
| 467 |
tmp.push({ |
| 468 |
title: key, |
| 469 |
value: value |
| 470 |
}); |
| 471 |
} |
| 472 |
tmp.sort(function (a, b) { |
| 473 |
if (a.title > b.title) { |
| 474 |
return 1; |
| 475 |
} else if (a.title < b.title) { |
| 476 |
return -1; |
| 477 |
} else { |
| 478 |
return 0; |
| 479 |
} |
| 480 |
}); |
| 481 |
|
| 482 |
real = []; |
| 483 |
spoof = []; |
| 484 |
for (p = 0, len5 = tmp.length; p < len5; p++) { |
| 485 |
element = tmp[p]; |
| 486 |
if (element.title.match(new RegExp('^' + $scope.impPrefix + '.+$'))) { |
| 487 |
console.debug(element, '-> real attribute'); |
| 488 |
real.push(element); |
| 489 |
} else { |
| 490 |
|
| 491 |
spoof.push(element); |
| 492 |
} |
| 493 |
} |
| 494 |
tmp = spoof.concat(real); |
| 495 |
res.push({ |
| 496 |
title: '__attributesAndMacros__', |
| 497 |
nodes: tmp |
| 498 |
}); |
| 499 |
return { |
| 500 |
_utime: time, |
| 501 |
nodes: res |
| 502 |
}; |
| 503 |
}; |
| 504 |
$scope.currentScope = scope; |
| 505 |
sessionId = scope.$modelValue.session; |
| 506 |
$http.get(`${scriptname}sessions/${sessionType}/${sessionId}`).then(function (response) { |
| 507 |
$scope.currentSession = transformSession(response.data); |
| 508 |
return $scope.currentSession.id = sessionId; |
| 509 |
}); |
| 510 |
return $scope.showT = false; |
| 511 |
}; |
| 512 |
$scope.localeDate = function (s) { |
| 513 |
var d; |
| 514 |
d = new Date(s * 1000); |
| 515 |
return d.toLocaleString(); |
| 516 |
}; |
| 517 |
$scope.isValid = function (epoch, type) { |
| 518 |
var isValid, now, path; |
| 519 |
path = $location.path(); |
| 520 |
now = Date.now() / 1000; |
| 521 |
console.debug("Path", path); |
| 522 |
console.debug("Session epoch", epoch); |
| 523 |
console.debug("Current date", now); |
| 524 |
console.debug("Session TTL", sessionTTL); |
| 525 |
isValid = now - epoch < sessionTTL || $location.path().match(/^\/persistent/); |
| 526 |
if (type === 'msg') { |
| 527 |
console.debug("Return msg"); |
| 528 |
if (isValid) { |
| 529 |
return "info"; |
| 530 |
} else { |
| 531 |
return "warning"; |
| 532 |
} |
| 533 |
} else if (type === 'style') { |
| 534 |
console.debug("Return style"); |
| 535 |
if (isValid) { |
| 536 |
return {}; |
| 537 |
} else { |
| 538 |
return { |
| 539 |
'color': '#627990', |
| 540 |
'font-style': 'italic' |
| 541 |
}; |
| 542 |
} |
| 543 |
} else { |
| 544 |
console.debug("Return isValid"); |
| 545 |
return isValid; |
| 546 |
} |
| 547 |
}; |
| 548 |
$scope.strToLocaleDate = function (s) { |
| 549 |
var arrayDate, d; |
| 550 |
arrayDate = s.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/); |
| 551 |
if (!arrayDate.length) { |
| 552 |
return s; |
| 553 |
} |
| 554 |
d = new Date(`${arrayDate[1]}-${arrayDate[2]}-${arrayDate[3]}T${arrayDate[4]}:${arrayDate[5]}:${arrayDate[6]}`); |
| 555 |
return d.toLocaleString(); |
| 556 |
}; |
| 557 |
|
| 558 |
$scope.getLanguage = function (lang) { |
| 559 |
$scope.lang = lang; |
| 560 |
$scope.form = 'white'; |
| 561 |
$scope.init(); |
| 562 |
return $scope.showM = false; |
| 563 |
}; |
| 564 |
|
| 565 |
pathEvent = function (event, next, current) { |
| 566 |
var n; |
| 567 |
n = next.match(/#!?\/(\w+)/); |
| 568 |
sessionType = 'global'; |
| 569 |
if (n === null) { |
| 570 |
$scope.type = '_whatToTrace'; |
| 571 |
} else if (n[1].match(/^(persistent|offline)$/)) { |
| 572 |
sessionType = RegExp.$1; |
| 573 |
$scope.type = '_session_uid'; |
| 574 |
} else { |
| 575 |
$scope.type = n[1]; |
| 576 |
} |
| 577 |
return $scope.init(); |
| 578 |
}; |
| 579 |
$scope.$on('$locationChangeSuccess', pathEvent); |
| 580 |
|
| 581 |
autoId = 0; |
| 582 |
$scope.updateTree = function (value, node, level, over, currentQuery, count) { |
| 583 |
var query, scheme, tmp; |
| 584 |
$scope.waiting = true; |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
scheme = schemes[$scope.type] ? schemes[$scope.type] : $scope.type === '_updateTime' ? schemes._startTime : schemes._whatToTrace; |
| 591 |
|
| 592 |
query = scheme[level]($scope.type, value, currentQuery); |
| 593 |
|
| 594 |
if (count > max && overScheme[$scope.type]) { |
| 595 |
if (tmp = overScheme[$scope.type]($scope.type, value, level, over, currentQuery)) { |
| 596 |
over++; |
| 597 |
query = tmp; |
| 598 |
level = level - 1; |
| 599 |
} else { |
| 600 |
over = 0; |
| 601 |
} |
| 602 |
} else { |
| 603 |
over = 0; |
| 604 |
} |
| 605 |
|
| 606 |
$http.get(`${scriptname}sessions/${sessionType}?${query}`).then(function (response) { |
| 607 |
var data, i, n; |
| 608 |
data = response.data; |
| 609 |
if (data.result) { |
| 610 |
for (i = 0; i < data.values.length; i++) { |
| 611 |
n = data.values[i]; |
| 612 |
autoId++; |
| 613 |
n.id = `node${autoId}`; |
| 614 |
if (level < scheme.length - 1) { |
| 615 |
n.nodes = []; |
| 616 |
n.level = level + 1; |
| 617 |
n.query = query; |
| 618 |
n.over = over; |
| 619 |
|
| 620 |
if ($scope.type.match(/^(?:start|update)Time$/)) { |
| 621 |
|
| 622 |
n.title = n.value.replace(/^(\d{8})(\d{2})(\d{2})$/, |
| 623 |
|
| 624 |
'$2:$3').replace(/^(\d{8})(\d{2})(\d)$/, |
| 625 |
|
| 626 |
'$2:$30').replace(/^(\d{8})(\d{2})$/, |
| 627 |
|
| 628 |
'$2h').replace(/^(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'); |
| 629 |
} |
| 630 |
} |
| 631 |
node.push(n); |
| 632 |
} |
| 633 |
if (value === '') { |
| 634 |
$scope.total = data.total; |
| 635 |
} |
| 636 |
} |
| 637 |
return $scope.waiting = false; |
| 638 |
}, function (resp) { |
| 639 |
return $scope.waiting = false; |
| 640 |
}); |
| 641 |
|
| 642 |
console.debug("Selection", sessionType); |
| 643 |
$scope.navssoStyle = { |
| 644 |
color: '#777' |
| 645 |
}; |
| 646 |
$scope.offlineStyle = { |
| 647 |
color: '#777' |
| 648 |
}; |
| 649 |
$scope.persistentStyle = { |
| 650 |
color: '#777' |
| 651 |
}; |
| 652 |
if (sessionType === 'global') { |
| 653 |
$scope.navssoStyle = { |
| 654 |
color: '#333' |
| 655 |
}; |
| 656 |
} |
| 657 |
if (sessionType === 'offline') { |
| 658 |
$scope.offlineStyle = { |
| 659 |
color: '#333' |
| 660 |
}; |
| 661 |
} |
| 662 |
if (sessionType === 'persistent') { |
| 663 |
return $scope.persistentStyle = { |
| 664 |
color: '#333' |
| 665 |
}; |
| 666 |
} |
| 667 |
}; |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
$scope.init = function () { |
| 672 |
$scope.waiting = true; |
| 673 |
$scope.data = []; |
| 674 |
$scope.currentScope = null; |
| 675 |
$scope.currentSession = null; |
| 676 |
$q.all([$translator.init($scope.lang), $scope.updateTree('', $scope.data, 0, 0)]).then(function () { |
| 677 |
return $scope.waiting = false; |
| 678 |
}, function (resp) { |
| 679 |
return $scope.waiting = false; |
| 680 |
}); |
| 681 |
|
| 682 |
$scope.activeModule = "sessions"; |
| 683 |
return $scope.myStyle = { |
| 684 |
color: '#ffb84d' |
| 685 |
}; |
| 686 |
}; |
| 687 |
|
| 688 |
|
| 689 |
c = $location.path().match(/^\/(\w+)/); |
| 690 |
return $scope.type = c ? c[1] : '_whatToTrace'; |
| 691 |
}]); |
| 692 |
|
| 693 |
})(); |