Revision 76 hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy
SysLogController.groovy | ||
---|---|---|
334 | 334 |
} |
335 | 335 |
|
336 | 336 |
def live = { |
337 |
|
|
338 |
List outputDevices = new ArrayList() |
|
339 |
|
|
340 |
def crit1 = DeviceInfo.createCriteria() |
|
341 |
outputDevices = crit1 { |
|
342 |
and { |
|
343 |
eq("outputDevice",true) |
|
344 |
eq("hwSet",session.hwSet) |
|
345 |
} |
|
346 |
order("friendlyName","asc") |
|
347 |
} |
|
348 |
outputDevices << new DeviceInfo(deviceId: 'all',friendlyName: 'All') |
|
337 | 349 |
|
338 | 350 |
List devices = new ArrayList() |
339 | 351 |
|
340 |
def crit1 = DeviceInfo.createCriteria()
|
|
341 |
devices = crit1 {
|
|
352 |
def crit2 = DeviceInfo.createCriteria()
|
|
353 |
devices = crit2 {
|
|
342 | 354 |
and { |
343 | 355 |
eq("inputDevice",true) |
344 | 356 |
eq("hwSet",session.hwSet) |
... | ... | |
346 | 358 |
order("friendlyName","asc") |
347 | 359 |
} |
348 | 360 |
|
349 |
[devices: devices] |
|
361 |
[devices: devices,outputDevices:outputDevices]
|
|
350 | 362 |
|
351 | 363 |
} |
352 | 364 |
|
353 | 365 |
def liveGraph = { |
354 | 366 |
|
355 | 367 |
List data = new ArrayList() |
368 |
|
|
356 | 369 |
java.util.Date now = new java.util.Date() |
370 |
java.util.Date beforeNMinutes = new java.util.Date( |
|
371 |
now.time - (60000 * (params.timeSpan as int)) |
|
372 |
) |
|
357 | 373 |
|
374 |
List actionLog = new ArrayList() |
|
375 |
List actionData = new ArrayList() |
|
376 |
|
|
358 | 377 |
if(params['deviceId'] && params['timeSpan']) { |
359 | 378 |
|
360 |
java.util.Date beforeNMinutes = new java.util.Date( |
|
361 |
now.time - (60000 * (params.timeSpan as int)) |
|
362 |
) |
|
363 |
|
|
364 | 379 |
def c = LoggedData.createCriteria() |
365 | 380 |
def results = c { |
366 | 381 |
and { |
... | ... | |
376 | 391 |
|
377 | 392 |
} |
378 | 393 |
|
379 |
[params:params, data:data]
|
|
394 |
if(params.outputDevice != 'none') {
|
|
380 | 395 |
|
396 |
if(params.outputDevice != 'all') { |
|
397 |
def crit2 = LoggedData.createCriteria() |
|
398 |
actionData = crit2 { |
|
399 |
and { |
|
400 |
eq("deviceId",params.outputDevice) |
|
401 |
between("dateRecieved",beforeNMinutes,now) |
|
402 |
} |
|
403 |
order("dateRecieved","asc") |
|
404 |
} |
|
405 |
} else { |
|
406 |
|
|
407 |
List allOutputDevices = new ArrayList() |
|
408 |
allOutputDevices = DeviceInfo.findAllByOutputDevice(true) |
|
409 |
|
|
410 |
def crit3 = LoggedData.createCriteria() |
|
411 |
actionData = crit3 { |
|
412 |
and { |
|
413 |
"in"("deviceId",allOutputDevices*.deviceId) |
|
414 |
between("dateRecieved",beforeNMinutes,now) |
|
415 |
} |
|
416 |
order("dateRecieved","asc") |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
actionData.each { |
|
421 |
actionLog << [it.dateRecieved.getTime(),it.reportedData] |
|
422 |
} |
|
423 |
|
|
424 |
} |
|
425 |
|
|
426 |
[params:params, data:data, actionLog:actionLog] |
|
427 |
|
|
381 | 428 |
} |
382 | 429 |
|
383 | 430 |
} |
Also available in: Unified diff