Index: hci/trunk/eneraptor-web-app/grails-app/views/actions/view.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/actions/view.gsp	(revision 57)
+++ hci/trunk/eneraptor-web-app/grails-app/views/actions/view.gsp	(revision 58)
@@ -8,9 +8,22 @@
 <body>
 	
 	<erptr:box title="View scenarios">
-		<p>TODO</p>
+		<p>Scenarios are saved internally in the logic module.</p>
+		<p>You can view and edit them here.</p>
 	</erptr:box>
+	
+	<erptr:box title="Scenarios">
+		<div name="scenariosHolder" id="scenariosHolder" >
+			<p><img src="${resource(dir:'img/',file:'spinner.gif')}" style="float:left;position:relative;top:-2px;" />&nbsp;&nbsp;Retrieving scenarios. Please wait...</p>
+		</div>
+	</erptr:box>
 
+	<g:javascript>
+	function includeToOnLoadDo() {
+		new Ajax.Updater('scenariosHolder','<g:createLink action="getActions" />',{asynchronous:true,evalScripts:true});
+	}
+	</g:javascript>
+
 </body>
 
 </html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/actions/getActions.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/actions/getActions.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/actions/getActions.gsp	(revision 58)
@@ -0,0 +1,36 @@
+<g:if test="${replyError}">
+	<center>
+		<p>Could not retrieve scenarios from the logic.</p>
+		<p>Please try again by <g:link action="view">refreshing</g:link> this page.</p>
+		<br />
+		<p><i>Error: ${replyError}</i></p>
+	</center>
+</g:if>
+<g:else>
+	<table>
+		<thead>
+			<tr>
+				<th><p>Name (short description)</p></th>
+				<th><p>Id</p></th>
+				<th><p>Main input device</p></th>
+				<th><p>Output device</p></th>
+				<th style="width:60px;"><p>Options</p></th>
+			</tr>
+		</thead>
+		<tbody>
+			<g:each in="${scenarios}" var="scenario">
+				<tr>
+					<td><p><g:link action="viewAction" params="[actionId: scenario[0]]" >${scenario[1].encodeAsHTML()}</g:link></p></td>
+					<td><p>${scenario[0]}</p></td>
+					<td><p>${scenario[2]}</p></td>
+					<td><p>${scenario[3]}</p></td>
+					<td>
+						<g:link title="View" action="viewAction" params="[actionId: scenario[0]]" ><erptr:icon w="script" /></g:link>
+						<g:link title="Edit" action="editAction" params="[actionId: scenario[0]]" ><erptr:icon w="pencil" /></g:link>
+						<g:link title="Delete" action="deleteAction" params="[actionId: scenario[0]]" ><erptr:icon w="delete" /></g:link>
+					</td>
+				</tr>
+			</g:each>
+		</tbody>
+	</table>
+</g:else>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/actions/viewAction.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/actions/viewAction.gsp	(revision 0)
+++ hci/trunk/eneraptor-web-app/grails-app/views/actions/viewAction.gsp	(revision 58)
@@ -0,0 +1,67 @@
+<html>
+
+<head>
+	<title>Scenarios &raquo; View scenario</title>
+	<meta name="layout" content="main" />
+</head>
+
+<body>
+	
+	<erptr:box title="Scenario: ${scenario.name}">
+		
+		<p>Scenario Id: <b>${scenario.id}</b></p>
+		<p>Scenario name (short description): <b>${scenario.name}</b></p>
+		<br />
+		<p>Measuring device: <b>${scenario.inDevice}</b></p>
+		<p>Controlling device: <b>${scenario.outDevice}</b></p>
+		<br />
+		<p>Measuring device values:</p>
+		<table>
+			<thead>
+				<tr>
+					<th><p>Minimal value</p></th>
+					<th><p>Optimal value</p></th>
+					<th><p>Maximal value</p></th>
+					<th><p>Tolerance</p></th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td><p>${scenario.minVal}</p></td>
+					<td><p>${scenario.optVal}</p></td>
+					<td><p>${scenario.maxVal}</p></td>
+					<td><p>&plusmn; ${scenario.tolerance}</p></td>
+				</tr>
+			</tbody>
+		</table>
+		<br />
+		
+		<p>Checking frequency: <b>${scenario.check_active} seconds</b> when active, <b>${scenario.check_idle} seconds</b> when idle.</p>
+		<br />
+		
+		<p>Reaction:</p>
+		<table>
+			<thead>
+				<tr>
+					<th><p>Calculation type</p></th>
+					<th><p>Alpha value</p></th>
+					<th><p>Action to execute</p></th>
+					<th><p>Parameters</p></th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td><p>${scenario.reaction}</p></td>
+					<td><p>${scenario.alpha}</p></td>
+					<td><p style="font-family:monospace;">${scenario.action}</p></td>
+					<td><p style="font-family:monospace;">${scenario.params} ${scenario.param}</p></td>
+				</tr>
+			</tbody>
+		</table>
+		<br />
+
+	</erptr:box>
+
+</body>
+
+</html>
\ No newline at end of file
Index: hci/trunk/eneraptor-web-app/grails-app/views/layouts/main.gsp
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/views/layouts/main.gsp	(revision 57)
+++ hci/trunk/eneraptor-web-app/grails-app/views/layouts/main.gsp	(revision 58)
@@ -105,15 +105,18 @@
 	<g:javascript>
 	function onLoadDo() {
 		<g:if test="${flash.confirms}">
-			new Effect.Pulsate('confirmBox',{pulses:2, duration: 0.2, from: 0.5})
+			new Effect.Pulsate('confirmBox',{pulses:2, duration: 0.2, from: 0.5});
 			new Effect.Fade('confirmBox', {duration: 3, delay: 3});		
 		</g:if>
 		<g:if test="${flash.errors}">
-			new Effect.Shake('errorBox', {duration: 0.2, distance: 5})	
+			new Effect.Shake('errorBox', {duration: 0.2, distance: 5});	
 		</g:if>
 		<g:if test="${flash.warnings}">
-			new Effect.Pulsate('warningBox',{pulses:2, duration: 0.2, from: 0.5})
+			new Effect.Pulsate('warningBox',{pulses:2, duration: 0.2, from: 0.5});
 		</g:if>
+		<g:if test="${includeToOnLoadDo}">
+			includeToOnLoadDo();
+		</g:if>
 	}
 	</g:javascript>
 	
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/ActionsController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/ActionsController.groovy	(revision 57)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/ActionsController.groovy	(revision 58)
@@ -1,11 +1,148 @@
 package com.eneraptor.hci
 
+import grails.converters.*
+
 class ActionsController {
-
+
+	def hciLogicCommService
+	
     def main = { }
 	
-	def view = { }
+	def view = {
+		
+		[includeToOnLoadDo: true]
+		
+	}
 	
+	def getActions = {
+		
+		String reqStr = "<?xml version=\"1.0\"?><hci-request type=\"getScenarios\"></hci-request>"
+		Map reply = hciLogicCommService.getReplyToRequest(reqStr)
+		
+		if(reply['status'] == 'error' || reply['content'] == null) {
+			return [replyError: reply['content']]
+		} else {
+			def filteredResponse = reply['content'].minus("<?xml version=\"1.0\"?>")
+			//System.out.println("[eneraptor-hci] Recieved reply (filtered): " + filteredResponse)
+			def rootNode = XML.parse(filteredResponse)
+			if(rootNode.@type == "getScenarios") {
+				List scenarios = new ArrayList()
+				rootNode.scenariotree.scenario.each {
+					scenarios << [it.@id.text(),it.@name.text(),it.inDevice.@id.text(),it.outDevice.@id.text()]
+				}
+				[scenarios:scenarios]
+			} else {
+				return [replyError: "The response is invalid. Check logic's IP and port numbers."]
+			}
+		}
+				
+	}
+	
 	def add = { }
+	
+	def viewAction = {
+		
+		String reqStr = "<?xml version=\"1.0\"?><hci-request type=\"getScenarios\"></hci-request>"
+		Map reply = hciLogicCommService.getReplyToRequest(reqStr)
+		
+		if(reply['status'] == 'error' || reply['content'] == null) {
+			flash['errors'] = "<p>Error connecting with logic: " + reply['content'] + "</p>"
+			redirect(action:'view')
+			return false
+		} else {
+			def filteredResponse = reply['content'].minus("<?xml version=\"1.0\"?>")
+			def rootNode = XML.parse(filteredResponse)
+			if(rootNode.@type == "getScenarios") {
+				def scenarioNode = rootNode.scenariotree[0].scenario.find {
+					it.@id.text() == params['actionId']
+				}
+				if(scenarioNode == null) {
+					flash['errors'] = "<p>Could not find a scanario with the id " + params['actionId'] + ".</p>"
+					redirect(action:'view')
+					return false
+				} else {
+					Map scenario = new HashMap()
+					scenario['id'] = scenarioNode.@id.text()
+					scenario['name'] = scenarioNode.@name.text()
+					scenario['inDevice'] = scenarioNode.inDevice.@id.text()
+					scenario['outDevice'] = scenarioNode.outDevice.@id.text()
+					scenario['reaction'] = scenarioNode.reaction.@func.text()
+					scenario['check_idle'] = scenarioNode.check_idle.@val.text()
+					scenario['check_active'] = scenarioNode.check_active.@val.text()
+					scenario['alpha'] = scenarioNode.alpha.@val.text()
+					scenario['params'] = scenarioNode.params.@val.text()
+					scenario['minVal'] = scenarioNode.inDevAalues.@minval.text()
+					scenario['maxVal'] = scenarioNode.inDevAalues.@maxval.text()
+					scenario['optVal'] = scenarioNode.inDevAalues.@optval.text()
+					scenario['tolerance'] = scenarioNode.inDevAalues.@tolerance.text()
+					scenario['action'] = scenarioNode.action.@act.text()
+					scenario['param'] = scenarioNode.param.@par.text()
+					
+					return [scenario:scenario]
+				}
+			} else {
+				flash['errors'] = "<p>Error connecting with logic: The response is invalid. Check logic's IP and port numbers.</p>"
+				redirect(action:'view')
+				return false
+			}
+		}
+		
+	}
+	
+	def deleteAction = {
+		
+		// First part: get XML from logic and modify
+		
+		String reqStr = "<?xml version=\"1.0\"?><hci-request type=\"getScenarios\"></hci-request>"
+		Map reply = hciLogicCommService.getReplyToRequest(reqStr)
+		
+		if(reply['status'] == 'error' || reply['content'] == null) {
+			flash['errors'] = "<p>Error connecting with logic: " + reply['content'] + "</p>"
+			redirect(action:'view')
+			return false
+		} else {
+			def filteredResponse = reply['content'].minus("<?xml version=\"1.0\"?>")
+			def rootNode = new groovy.util.XmlParser().parseText(filteredResponse)
+			if(rootNode.@type == "getScenarios") {
+				def scenarioTree = rootNode.scenariotree[0]
+				def nodeToRemove = scenarioTree.scenario.find {
+					it.@id == params['actionId']
+				}
+				scenarioTree.remove(nodeToRemove)
+				
+				def writer = new StringWriter()
+				new XmlNodePrinter(new PrintWriter(writer)).print(scenarioTree)
+				def result = writer.toString()
+				
+				result = "<?xml version=\"1.0\"?><hci-request type=\"setScenarios\">" + result + "</hci-request>"
+				
+				// Second part: give modified XML to logic
+				
+				Map reply2 = hciLogicCommService.getReplyToRequest(result)
+				
+				if(reply2['status'] == 'error' || reply2['content'] == null) {
+					flash['errors'] = "<p>Error connecting with logic: " + reply2['content'] + "</p>"
+					redirect(action:'view')
+					return false
+				} else {
+					def rootNode2 = XML.parse(reply2['content'])
+					if(rootNode2.@type.text() == "setScenarios") {
+						flash['confirms'] = "<p>Scenario deleted successfully.</p>"
+						redirect(action:'view')
+						return true
+					} else {
+						flash['errors'] = "<p>Error connecting with logic: The response is invalid. Check logic's IP and port numbers.</p>"
+						redirect(action:'view')
+						return false
+					}
+				}
+				
+			} else {
+				flash['errors'] = "<p>Error connecting with logic: The response is invalid. Check logic's IP and port numbers.</p>"
+				redirect(action:'view')
+				return false
+			}
+		}
+	}
 	
 }
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/LogicRequestController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/LogicRequestController.groovy	(revision 57)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/LogicRequestController.groovy	(revision 58)
@@ -1,5 +1,7 @@
 package com.eneraptor.hci
 
+import grails.converters.*
+
 class LogicRequestController {
 
 	def reportService
@@ -21,12 +23,14 @@
 			output += reportService.println("<span style='color:red;'>Error: " + testReply['content'] + "</span>")
 		} else {
 			output += reportService.println("Connection established succesfully")
-			if(testReply['content'] == "<logic-response type=\"checkConnection\"><data>12345</data></logic-response>") {
-				output += "<span style='color:green;'>Logic unit replied! The eneraptor system is set up properly.</span>"
+			def rootNode = XML.parse(testReply['content'])
+			if(rootNode.data == "12345") {
+				output += reportService.println("<span style='color:green;'>Logic unit replied! The eneraptor system is set up properly.</span>")
 			} else {
 				output += reportService.println("<span style='color:red;'>The connection was established, but there was no reply from the logic unit.</span>")
-				output += reportService.println("<span style='color:red;'>You should check the logic's port number and IP address.</span>");
-				output += reportService.println("<span style='color:red;'>Returned: " + testReply['content'].encodeAsHTML() + "</span>");
+				output += reportService.println("<span style='color:red;'>You should check the logic's port number and IP address.</span>")
+				output += reportService.println("<span style='color:red;'> Returned: " + testReply['content'].encodeAsHTML() + "</span>")
+				output += reportService.println("<span style='color:red;'>Should be: " + "<logic-response type=\"checkConnection\"><data>12345</data></logic-response>".encodeAsHTML() + "</span>")
 			}
 		}
 		
Index: hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy
===================================================================
--- hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 57)
+++ hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy	(revision 58)
@@ -440,5 +440,33 @@
 		render(text: cont,contentType:"text/csv",encoding:"UTF-8")
 		
 	}
+	
+	def deleteGraph = {
+	
+		if(params['id']) {
+			
+			def graphToDelete = EneGraph.get(params['id'])
+			if(graphToDelete) {
+				
+				graphToDelete.delete()
+				flash['confirms'] = "<p>Graph deleted successfully.</p>"
+				redirect(action:'graphs')
+				return true
+				
+			} else {
+				flash['errors'] = "<p>No graph was deleted. Graph ID invalid!</p>"
+				redirect(action:'graphs')
+				return false
+			}
+			
+		} else {
+		
+			flash['errors'] = "<p>No graph was deleted. Graph ID not specified!</p>"
+			redirect(action:'graphs')
+			return false
+		
+		}	
+		
+	}
 	
 }
Index: hci/trunk/eneraptor-web-app/target/eneraptor-web-app-0.4.war
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: hci/trunk/eneraptor-web-app/web-app/img/spinner.gif
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: hci/trunk/eneraptor-web-app/web-app/img/spinner.gif
===================================================================
--- hci/trunk/eneraptor-web-app/web-app/img/spinner.gif	(revision 0)
+++ hci/trunk/eneraptor-web-app/web-app/img/spinner.gif	(revision 58)

Property changes on: hci/trunk/eneraptor-web-app/web-app/img/spinner.gif
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
