Index: hci/trunk/eneraptor-web-app/web-app/css/style.css
===================================================================
--- hci/trunk/eneraptor-web-app/web-app/css/style.css	(revision 67)
+++ hci/trunk/eneraptor-web-app/web-app/css/style.css	(revision 68)
@@ -416,7 +416,8 @@
 
 .sysLog-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
 .sysLog-browse{background:transparent url(../img/icons/magnifier.png) no-repeat left;}
-.sysLog-graph{background:transparent url(../img/icons/chart_curve.png) no-repeat left;}
+.sysLog-graph{background:transparent url(../img/icons/chart_line.png) no-repeat left;}
+.sysLog-live{background:transparent url(../img/icons/chart_line_go.png) no-repeat left;}
 .sysLog-export{background:transparent url(../img/icons/disk_multiple.png) no-repeat left;}
 .sysLog-clear{background:transparent url(../img/icons/bin.png) no-repeat left;}
 
Index: hci/trunk/eneraptor-web-app/web-app/img/icons/chart_line_go.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: hci/trunk/eneraptor-web-app/web-app/img/icons/chart_line_go.png
===================================================================
--- hci/trunk/eneraptor-web-app/web-app/img/icons/chart_line_go.png	(revision 0)
+++ hci/trunk/eneraptor-web-app/web-app/img/icons/chart_line_go.png	(revision 68)

Property changes on: hci/trunk/eneraptor-web-app/web-app/img/icons/chart_line_go.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy	(revision 67)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy	(revision 68)
@@ -332,5 +332,56 @@
 		redirect(action:'clear')
 		
 	}
+	
+	def live = {
+	
+		List devices = new ArrayList()
+		
+		def crit1 = DeviceInfo.createCriteria()
+		devices = crit1 {
+			and {
+				eq("inputDevice",true)
+				eq("hwSet",session.hwSet)
+			}
+			order("friendlyName","asc")
+		}
+		
+		[devices: devices]
+		
+	}
+	
+	def liveGraph = {
+		
+		List data = new ArrayList()
+		java.util.Date now = new java.util.Date()
+		
+		if(params['deviceId'] && params['timeSpan']) {
+			
+			System.out.println("[LiveGraph] Getting for " + params.deviceId + ", time span " + params.timeSpan);
+			
+			java.util.Date beforeNMinutes = new java.util.Date(
+				now.time - (60000 * (params.timeSpan as int))
+			)
+			
+			def c = LoggedData.createCriteria()
+			def results = c {
+				and {
+					eq("deviceId",params['deviceId'])
+					between("dateRecieved",beforeNMinutes,now)
+				}
+				order("dateRecieved","asc")
+			}
+			
+			results.each {
+				data << [it.dateRecieved.getTime(),it.reportedData]
+			}
+			
+			System.out.println(data);
+			
+		}
+		
+		[params:params, data:data]
+			
+	}
 	
 }
Index: hci/trunk/eneraptor-web-app/grails-app/views/sysLog/live.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/sysLog/live.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/sysLog/live.gsp	(revision 68)
@@ -0,0 +1,86 @@
+<html>
+
+<head>
+	<title>Log &raquo; Live graph</title>
+	<meta name="layout" content="main" />
+	<flot:resources />
+</head>
+
+<body>
+
+	<erptr:box title="Select device">
+		<p>Please, select a device, refresh rate and time span.</p>
+		
+		<form action="javascript:startLiveGraph();">
+			<label for="deviceId">Device ID</label>
+			<g:select name="deviceId" from="${devices}" optionValue="friendlyName" optionKey="deviceId" value="${params.deviceId}" style="width:300px;" />
+			<br /><br />
+			<label for="refreshRate">Refresh rate</label>
+			<g:select name="refreshRate" from="${1..60}" style="width:50px;" /><span>&nbsp;seconds</span>
+			<br /><br />
+			<label for="timeSpan">Time span</label>
+			<g:select name="timeSpan" from="${1..60}" style="width:50px;" /><span>&nbsp;minutes</span>
+			<br /><br />
+			<g:submitButton name="liveGraphSubmit" value="Start" />
+		</form>
+		
+	</erptr:box>
+
+	<erptr:box title="Live graph">
+		<g:javascript>
+			var running = false;
+			var deviceId;
+			var refreshRate;
+			var timeSpan;
+			var data = [[]];
+			var options = {
+				lines: { show: true },
+				points: { show: true },
+				xaxis: { mode: "time", timeformat: "%y/%m/%d %H:%M" }
+			};
+		</g:javascript>
+		<p name="textOut" id="textOut" style="font-family:monospace;">Ready.</p>
+		<div class="chart">
+			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
+		</div>
+	</erptr:box>
+	
+	<g:javascript>
+	function startLiveGraph() {
+		
+		running = true;
+		deviceId = $('deviceId').value;
+		refreshRate = $('refreshRate').value * 1000;
+		timeSpan = $('timeSpan').value;
+		
+		graphUpdate(deviceId,refreshRate,timeSpan);
+		
+	}
+	
+	function graphUpdate(deviceId,refreshRate,timeSpan) {
+		var dataurl = '${g.createLink(action:'liveGraph')}?deviceId=' + deviceId + '&timeSpan=' + timeSpan;
+			
+		function onDataReceived(series) {
+			data = [];
+		    data.push(series);
+		    jQuery.plot(jQuery("#placeholder"), data, options);
+		    $('textOut').innerHTML = "Refreshed on " + new Date() + ".";
+		}
+		
+		jQuery.ajax({
+            url: dataurl,
+            method: 'GET',
+            dataType: 'json',
+            success: onDataReceived
+        });
+        
+        if(running) {
+        	setTimeout("graphUpdate(deviceId,refreshRate,timeSpan)",refreshRate);
+        }
+        
+	}
+	</g:javascript>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp	(revision 67)
+++ hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp	(revision 68)
@@ -14,7 +14,7 @@
 		
 		<form action="graph">
 			<label for="deviceId">Device ID</label>
-			<g:select name="deviceId" from="${devices}" optionValue="friendlyName" optionKey="deviceId" value="${params.deviceId}" />
+			<g:select name="deviceId" from="${devices}" optionValue="friendlyName" optionKey="deviceId" value="${params.deviceId}" style="width:300px;" />
 			<br /><br />
 			<label for="fromDate">From</label>
 			<g:datePicker name="fromDate" value="${params.fromDate}" />
Index: hci/trunk/eneraptor-web-app/grails-app/views/sysLog/liveGraph.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/sysLog/liveGraph.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/sysLog/liveGraph.gsp	(revision 68)
@@ -0,0 +1,3 @@
+{
+    data: ${data}
+}
Index: hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy	(revision 67)
+++ hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy	(revision 68)
@@ -37,7 +37,8 @@
 		sysLogSubMenu = new ArrayList()
 		sysLogSubMenu.add(new MenuItem("Overview","sysLog","main"))
 		sysLogSubMenu.add(new MenuItem("Browse","sysLog","browse"))
-		sysLogSubMenu.add(new MenuItem("View logged data graphically","sysLog","graph"))
+		sysLogSubMenu.add(new MenuItem("View graphically","sysLog","graph"))
+		sysLogSubMenu.add(new MenuItem("Live graph","sysLog","live"))
 		sysLogSubMenu.add(new MenuItem("Export","sysLog","export"))
 		sysLogSubMenu.add(new MenuItem("Clear","sysLog","clear"))
 		
