Revision 70 hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy

View differences:

StatisticsController.groovy
617 617
			if(chGrph) {
618 618
				
619 619
				List datas = new ArrayList()
620
				List datasList = new ArrayList()
620 621
				
621 622
				chGrph.graphs.each {
622
					datas << "{label: '" + it.name + "', data: " + graphDataService.getGraphData(it).toString() + "}"
623
					def grphData = graphDataService.getGraphData(it)
624
					datasList << grphData
625
					datas << "{label: '" + it.name + "', data: " + grphData.toString() + "}"
623 626
				}
624 627
				
625
				return [data: datas]
628
				if(!params.outputDevice) params.outputDevice = 'none'
626 629
				
630
				List outputDevices = new ArrayList()
631
				
632
				def crit1 = DeviceInfo.createCriteria()
633
				outputDevices = crit1 {
634
					and {
635
						eq("outputDevice",true)
636
						eq("hwSet",session.hwSet)
637
					}
638
					order("friendlyName","asc")
639
				}
640
				
641
				// Fetch action logged data if needed
642
				List actionLog = new ArrayList()
643
				if(params.outputDevice != 'none') {
644
					
645
					// Find time span
646
					long min = Long.MAX_VALUE
647
					long max = 0
648
					datasList.each { series ->
649
						series.each {
650
							if(it[0] < min) min = it[0]
651
							if(it[0] > max) max = it[0]
652
						}
653
					}
654
					
655
					def crit2 = LoggedData.createCriteria()
656
					actionLog = crit2 {
657
						and {
658
							eq("deviceId",params.outputDevice)
659
							between("dateRecieved",new java.util.Date(min),new java.util.Date(max))
660
						}
661
						order("dateRecieved","asc")
662
					}
663
				}
664
				
665
				return [data: datas,actionLog:actionLog,outputDevices:outputDevices]
666
				
627 667
			} else {
628 668
				flash.errors = "<p>Invalid graph ID!</p>"
629 669
				redirect(action:'graphs')

Also available in: Unified diff