Revision 6

View differences:

hci/trunk/eneraptor-web-app/grails-app/views/config/connection.gsp
42 42
		<p>You can test connectivity by pressing the 'Test connection' link below. This will show a simple report under it.</p>
43 43
		<p>Note that any configuration changes (Logic's IP, port, etc.) should be saved first.</p>
44 44
		<br />
45
		<g:remoteLink controller="logicRequest" action="testConnection" update="testResponse" before="\$('testResponse').update('Testing... (Please wait)')" after="\$('testResponse').pulsate({pulses: 2, duration: 0.5})">Test connection</g:remoteLink>
45
		<g:remoteLink controller="logicRequest" action="testConnection" update="testResponse" before="\$('testResponse').update('Testing... (Please wait)')" after="\$('testResponse').pulsate({pulses: 2, duration: 0.5})"><erptr:icon w="connect"></erptr:icon>Test connection</g:remoteLink>
46 46
		<br /><br />
47 47
		<div id="testResponse"></div>
48 48
		
hci/trunk/eneraptor-web-app/grails-app/views/config/dbInfo.gsp
1
<p>Database configuration:</p>
2
<table width="100%">
3
	<thead>
4
		<tr>
5
			<th>Name</th>
6
			<th>Value</th>
7
			<th>Description</th>
8
		</tr>
9
	</thead>
10
	<tbody>
11
		<g:each in="${databaseInfo}" var="row">
12
			<tr>
13
				<td>${row.name}</td>
14
				<td>${row.setting}</td>
15
				<td>${row.description}</td>
16
			</tr>
17
		</g:each>
18
	</tbody>
19
</table>
hci/trunk/eneraptor-web-app/grails-app/views/config/hci.gsp
7 7

  
8 8
<body>
9 9
	
10
	<erptr:box title="HCI configuration">
11
		<g:form name="hci-config-form" action="saveHci">
10
	<erptr:box title="Information">
12 11
		
13
			<label for="hci-version">HCI Version</label>
14
			<g:textField name="hci-version" value="${conf.findByConfigId('hci-version').configVal}" disabled="true" />
12
		<p>HCI Version: &nbsp;&nbsp;&nbsp;<span style="font-family:monospace;">${conf.findByConfigId('hci-version').configVal}</span></p>
15 13
			
16
		</g:form>
14
		<p style="float: left;">Disk usage: &nbsp;&nbsp;&nbsp;</p>
15
		<div style="float:left;">
16
			<div style="width: 100px;border:1px solid grey;">
17
				<div style="width:${percent}px;background:grey;">
18
					&nbsp;
19
				</div>
20
			</div>
21
		</div>
22
		<span> &nbsp;&nbsp;&nbsp; ${percent}% (free space ${(int)freeSpace} MB) </span>
23
		<g:if test="${percent >= 95}">
24
				<i style="color:red;">&nbsp;&nbsp;&nbsp;Warning: disk is almost full. You should erase some old log entries.</i>
25
		</g:if>
26
		
17 27
	</erptr:box>
18 28
	
19 29
	<erptr:box title="Known devices">
......
21 31
		<table width="100%">
22 32
			<thead>
23 33
				<tr>
24
					<th width="28px">&nbsp;</th>
25 34
					<th width="200px">Device ID</th>
26 35
					<th width="200px">Friendly name</th>
36
					<th width="100px">Capable of making</th>
27 37
					<th>Description</th>
28 38
					<th width="60px">Options</th>
29 39
	            </tr>
......
31 41
			<tbody>
32 42
				<g:each in="${devices}" var="device">
33 43
					<tr>
34
						<td>
44
						<td><p>
35 45
							<g:if test="${device.iconPath}">
36
							 <erptr:icon w="${device.iconPath}" />
46
								<erptr:icon w="${device.iconPath}" /> &nbsp;
37 47
							</g:if>
38
						</td>
39
						<td>${device.deviceId}</td>
40
						<td>${device.friendlyName}</td>
41
						<td>${device.description}</td>
42
						<td>todo</td>
48
						${device.deviceId}</p></td>
49
						<td><p>${device.friendlyName}</p></td>
50
						<td><p>
51
							<g:if test="${device.inputDevice && device.outputDevice}">
52
								measurements, actions
53
							</g:if>
54
							<g:if test="${device.inputDevice && !device.outputDevice}">
55
								measurements
56
							</g:if>
57
							<g:if test="${!device.inputDevice && device.outputDevice}">
58
								actions
59
							</g:if>
60
						</p></td>
61
						<td><p>${device.description}</p></td>
62
						<td><center><erptr:changeDeleteOptions table="Hci" for="${device.id}" /></center></td>
43 63
					</tr>
44 64
				</g:each>
45 65
			</tbody>
......
57 77
	
58 78
	</erptr:box>
59 79
	
80
	<erptr:box title="Database information">
81
	
82
		<p>Eneraptor system uses PostgreSQL database management system to store log data and HCI configuration.</p>
83
		
84
		<br />
85
		
86
		<div id="dbConfigHolder">
87
			<g:remoteLink action="dbInfo" update="dbConfigHolder"><erptr:icon w="eye" />View database configuration</g:remoteLink>
88
		</div>
89
		
90
		<br />
91
		
92
		<g:link action="dbExec"><erptr:icon w="database_edit" />Execute SQL queries manually</g:link>
93
		
94
	</erptr:box>
95
	
60 96
</body>
61 97

  
62 98
</html>
hci/trunk/eneraptor-web-app/grails-app/views/config/addDevice.gsp
23 23
					
24 24
			<br />
25 25
			
26
			<label for="inputDevice">Can measure data</label>
27
			<g:checkBox name ="inputDevice" value="${params['inputDevice']}" />
28
			<erptr:helpLink for="inputDevice"/>
29
			
30
			<br />
31
			
32
			<label for="outputDevice">Can run actions</label>
33
			<g:checkBox name ="outputDevice" value="${params['outputDevice']}" />
34
			<erptr:helpLink for="outputDevice"/>
35
			
36
			<br />
37
			
26 38
			<label for="description">Short decription</label>
27 39
			<g:textArea name="description">${params['description']}</g:textArea>
28 40
					
hci/trunk/eneraptor-web-app/grails-app/views/config/dbExec.gsp
1
<html>
2

  
3
<head>
4
	<title>Configuration &raquo; Manual SQL querying</title>
5
	<meta name="layout" content="main" />
6
</head>
7

  
8
<body>
9

  
10
	<g:if test="${sqlResult}">
11
		<erptr:box title="SQL query result">
12
			<p>The SQL query has been executed. Result:</p>
13
			<div>
14
				
15
				<g:if test="${wasError}">
16
					<g:each in="${sqlResult}" var="row">
17
						<p>${row.toString()}</p>
18
					</g:each>
19
				</g:if>
20
				<g:else>
21
				
22
					<table width="100%">
23
						<thead>
24
							<tr>
25
								<g:each in="${keys}" var="key">
26
									<th>${key}</th>
27
								</g:each>
28
							</tr>
29
						</thead>
30
						<tbody>
31
							<g:each in="${sqlResult}" var="row">
32
								<tr>
33
								<g:each in="${keys}" var="key">
34
									<td>${row[key.toString()]}</td>
35
								</g:each>
36
								</tr>
37
							</g:each>
38
						</tbody>
39
					</table>
40
					
41
				</g:else>
42
				
43
			</div>
44
		</erptr:box>
45
	</g:if>
46
	
47
	<erptr:box title="Manual SQL querying">
48
	
49
		<p style="color:red;"><erptr:icon w="error" /><i>Caution: Changing database contents and configuration may cause system errors and as a result the HCI may stop working. Use only if you are completely sure of what you are doing.</i></p>
50
		
51
		<g:form name="sqlQueryForm" action="dbExec">
52
		
53
			<p>SQL query:</p>
54
		
55
			<g:textArea name="sqlQuery" style="width:100%;height:150px;"></g:textArea>
56
			
57
			<br /><br />
58
			
59
			<g:submitButton name="sqlQueryFormSubmit" value="Execute" />
60
			
61
			<div style="float:right;">
62
			<g:link target="_blank" url="http://www.postgresql.org/docs/9.0/static/sql.html"><erptr:icon w="help" />SQL language documentation</g:link>
63
			</div>
64
		
65
		</g:form>
66
	
67
	</erptr:box>
68
	
69
</body>
70

  
71
</html>
hci/trunk/eneraptor-web-app/grails-app/views/config/changeHciEntry.gsp
1
<html>
2

  
3
<head>
4
	<title>Configuration &raquo; HCI</title>
5
	<meta name="layout" content="main" />
6
</head>
7

  
8
<body>
9
	
10
	<erptr:box title="Change device properties">
11
	
12
		<g:form name="change-device-form" action="changeHciEntrySave">
13
		
14
			<label for="deviceId">Device ID *</label>
15
			<g:textField name="deviceId" value="${deviceId}" />
16
			<erptr:helpLink for="deviceId"/>
17
			
18
			<br />
19
			
20
			<label for="friendlyName">Friendly name *</label>
21
			<g:textField name="friendlyName" value="${friendlyName}" />
22
			<erptr:helpLink for="friendlyName"/>
23
					
24
			<br />
25
			
26
			<label for="inputDevice">Can measure data</label>
27
			<g:checkBox name ="inputDevice" value="${inputDevice}" />
28
			<erptr:helpLink for="inputDevice"/>
29
			
30
			<br />
31
			
32
			<label for="outputDevice">Can run actions</label>
33
			<g:checkBox name ="outputDevice" value="${outputDevice}" />
34
			<erptr:helpLink for="outputDevice"/>
35
			
36
			<br />
37
			
38
			<label for="description">Short description</label>
39
			<g:textArea name="description">${description}</g:textArea>
40
					
41
			<br />
42
			
43
			<label for="iconPath">Icon</label>
44
			<g:textField name="iconPath" value="${iconPath}" />
45
					
46
			<br />
47
			
48
			<erptr:helpBox />
49
			
50
			<g:hiddenField name="id" value="${id}" />
51
			
52
			<g:actionSubmit action="hci" value="Cancel" />
53
			<g:submitButton name="save" value="Save changes" />
54
			
55
		</g:form>
56
	
57
	</erptr:box>
58
	
59
</body>
60

  
61
</html>
hci/trunk/eneraptor-web-app/grails-app/views/logicRequest/updateMeasurements.gsp
1
${output}
hci/trunk/eneraptor-web-app/grails-app/views/sysState/actions.gsp
1
<html>
2

  
3
<head>
4
	<title>System State &raquo; Last actions taken</title>
5
	<meta name="layout" content="main" />
6
</head>
7

  
8
<body>
9

  
10
	<erptr:box title="Last actions taken">
11
		<form id="actionsForm">
12
			<table>
13
				<thead>
14
					<tr>
15
						<th style="width:20px;">&nbsp;</th>
16
						<th style="width:200px;">Device</th>
17
						<th>Action taken</th>
18
						<th style="width:200px;">Time executed</th>
19
					</tr>
20
				</thead>
21
				<tbody>
22
					<g:each in="${outDevicesData}" var="outDevice">
23
						<tr>
24
							<td>
25
								&nbsp;<g:checkBox name="${outDevice.deviceId}" />
26
							</td>
27
							<td><p>
28
							<g:if test="${outDevice.icon}">
29
								<erptr:icon w="${outDevice.icon}" />&nbsp;
30
							</g:if>
31
							${outDevice.friendlyName}</p></td>
32
							<td><p>${outDevice.loggedData?.reportedData ?: '<i>no actions have been executed on this device yet</i>'}</p></td>
33
							<td><p>${outDevice.loggedData?.dateRecieved ?: '<i>never</i>'}</p></td>
34
						</tr>
35
					</g:each>
36
				</tbody>
37
			</table>
38

  
39
			<p><a href="#" onclick="checkToggle('actionsForm');return false;">Check / uncheck</a> all.</p>
40

  
41
		</form>
42
	</erptr:box>
43
	
44
	<js:checkBoxToggle />
45

  
46
</body>
47

  
48
</html>
hci/trunk/eneraptor-web-app/grails-app/views/sysState/measure.gsp
1
<html>
2

  
3
<head>
4
	<title>System State &raquo; Last measurements</title>
5
	<meta name="layout" content="main" />
6
</head>
7

  
8
<body>
9

  
10
	<erptr:box title="Last measurements">
11
		<form id="measureForm" action="measureUpdate">
12
			<table>
13
				<thead>
14
					<tr>
15
						<th style="width:20px;">&nbsp;</th>
16
						<th style="width:200px;">Device</th>
17
						<th>Value</th>
18
						<th style="width:200px;">Time measured</th>
19
					</tr>
20
				</thead>
21
				<tbody>
22
					<g:each in="${inDevicesData}" var="inDevice">
23
						<tr>
24
							<td>
25
								&nbsp;<g:checkBox name="${inDevice.deviceId}" />
26
							</td>
27
							<td><p>
28
							<g:if test="${inDevice.icon}">
29
								<erptr:icon w="${inDevice.icon}" />&nbsp;
30
							</g:if>
31
							${inDevice.friendlyName}</p></td>
32
							<td><p>${inDevice.loggedData?.reportedData ?: '<i>this device has not returned any value yet</i>'}</p></td>
33
							<td><p>${inDevice.loggedData?.dateRecieved ?: '<i>never</i>'}</p></td>
34
						</tr>
35
					</g:each>
36
				</tbody>
37
			</table>
38
			
39
			<p><a href="#" onclick="checkToggle('measureForm');return false;">Check / uncheck</a> all.</p>
40
			
41
			<table style="border:0px;">
42
				<tr>
43
					<td style="width:25px;border:0px;"><g:submitButton name="measureFormSubmit" type="image" src="${resource(dir:'img/icons/',file:'arrow_refresh.png')}" onclick="\$('refreshLabel').innerHTML = 'Refreshing... Please wait.';" /></td>
44
					<td style="border:0px;"><p id="refreshLabel" style="position:relative;top:-2px">Refresh selected devices' values manually</p></td>
45
				</tr>
46
			</table>
47
			
48
		</form>		
49
	</erptr:box>
50
	
51
	<js:checkBoxToggle />
52

  
53
</body>
54

  
55
</html>
hci/trunk/eneraptor-web-app/grails-app/views/sysState/main.gsp
6 6
</head>
7 7

  
8 8
<body>
9
	<p>Deluje!</p>
9
	
10
	<erptr:box title="Welcome">
11
		<p>Welcome to Eneraptor's administration web application (HCI)!</p>
12
	</erptr:box>
13

  
14
	<erptr:box title="Last measurements overview">
15
		<table>
16
			<thead>
17
				<tr>
18
					<th style="width:200px;">Device</th>
19
					<th>Value</th>
20
					<th style="width:200px;">Time measured</th>
21
				</tr>
22
			</thead>
23
			<tbody>
24
				<g:each in="${inDevicesData}" var="inDevice">
25
					<tr>
26
						<td><p>
27
						<g:if test="${inDevice.icon}">
28
							<erptr:icon w="${inDevice.icon}" />&nbsp;
29
						</g:if>
30
						${inDevice.friendlyName}</p></td>
31
						<td><p>${inDevice.loggedData?.reportedData ?: '<i>this device has not returned any value yet</i>'}</p></td>
32
						<td><p>${inDevice.loggedData?.dateRecieved ?: '<i>never</i>'}</p></td>
33
					</tr>
34
				</g:each>
35
			</tbody>
36
		</table>
37
		<br />
38
		
39
		<g:link action="measure"><erptr:icon w="monitor" />&nbsp;View details and options</g:link>
40

  
41
	</erptr:box>
42

  
43
	<erptr:box title="Last actions taken overview">
44
		<table>
45
			<thead>
46
				<tr>
47
					<th style="width:200px;">Device</th>
48
					<th>Action taken</th>
49
					<th style="width:200px;">Time executed</th>
50
				</tr>
51
			</thead>
52
			<tbody>
53
				<g:each in="${outDevicesData}" var="outDevice">
54
					<tr>
55
						<td><p>
56
						<g:if test="${outDevice.icon}">
57
							<erptr:icon w="${outDevice.icon}" />&nbsp;
58
						</g:if>
59
						${outDevice.friendlyName}</p></td>
60
						<td><p>${outDevice.loggedData?.reportedData ?: '<i>no actions have been executed on this device yet</i>'}</p></td>
61
						<td><p>${outDevice.loggedData?.dateRecieved ?: '<i>never</i>'}</p></td>
62
					</tr>
63
				</g:each>
64
			</tbody>
65
		</table>
66
		<br />
67
		
68
		<g:link action="actions"><erptr:icon w="lightning" />&nbsp;View details and options</g:link>
69
		
70
	</erptr:box>
71

  
10 72
</body>
11 73

  
12 74
</html>
hci/trunk/eneraptor-web-app/grails-app/views/sysState/measureUpdate.gsp
1
<!-- This page gets rendered only if there were errors  -->
2
<html>
3

  
4
<head>
5
	<title>System State &raquo; Error updating measurements manually</title>
6
	<meta name="layout" content="main" />
7
</head>
8

  
9
<body>
10

  
11
	<erptr:box title="Updating measurements manually failed">
12
		
13
		<p>Unfortunately, there were some errors while trying to send the request to the logic unit. You can check the output below.</p>
14
		<p>Please try sending the request again. If sending fails again, check <g:link controller="config" action="connection">HCI to Logic connection settings</g:link>.</p>
15
		<br />
16
		
17
		<div>${errorExplanation}</div>
18
		
19
	</erptr:box>
20

  
21
</body>
22

  
23
</html>
hci/trunk/eneraptor-web-app/grails-app/views/layouts/main.gsp
25 25
   			<div id="top-panel">
26 26
       			<div id="panel">
27 27
           			<ul>
28
              			<erptr:subMenu menu="${controllerName}" />
28
              			<erptr:subMenu menu="${controllerName}" chosen="${actionName}" />
29 29
           			</ul>
30 30
       			</div><!-- /panel -->
31 31
 			</div><!-- /top-pannel -->
......
43 43
						${flash.confirms}
44 44
					</erptr:confirmBox>
45 45
				</g:if>
46
				<g:if test="${flash.warnings}">
47
					<erptr:warningBox>
48
						${flash.warnings}
49
					</erptr:warningBox>
50
				</g:if>
46 51
       			<g:layoutBody />
47 52
       		</div><!-- /content -->
48 53
 		</div><!-- /wrapper -->
......
65 70
		<g:if test="${flash.errors}">
66 71
			new Effect.Shake('errorBox', {duration: 0.2, distance: 5})	
67 72
		</g:if>
73
		<g:if test="${flash.warnings}">
74
			new Effect.Pulsate('warningBox',{pulses:2, duration: 0.2, from: 0.5})
75
		</g:if>
68 76
	}
69 77
	</g:javascript>
70 78
	
hci/trunk/eneraptor-web-app/grails-app/views/sysLog/browse.gsp
24 24
					<tr>
25 25
						<td class="a-center">${entry.id}</td>
26 26
						<td><a href="#">${entry.dateRecieved}</a></td>
27
						<td><a href="#">${entry.deviceId}</a></td>
27
						<td><a href="#">
28
							<g:if test="${icons[entry.deviceId]}">
29
								<erptr:icon w="${icons[entry.deviceId]}" />
30
							</g:if>
31
							<g:if test="${devices[entry.deviceId]}">
32
								${devices[entry.deviceId]}
33
							</g:if>
34
							<g:else>
35
								${entry.deviceId}
36
							</g:else>
37
						</a></td>
28 38
						<td>${entry.reportedData}</td>
29 39
						<td><erptr:logEntryOptions for="${entry.id}" /></td>
30 40
					</tr>
hci/trunk/eneraptor-web-app/grails-app/views/sysLog/detail.gsp
1
<html>
2

  
3
<head>
4
	<title>Log &raquo; Log entry details</title>
5
	<meta name="layout" content="main" />
6
</head>
7

  
8
<body>
9
	
10
	<erptr:box title="Details for log entry ${params.id}">
11
	
12
		<div>Id:</div>
13
		<erptr:rawInfoBox>${params.id}</erptr:rawInfoBox>
14
		<br />
15
		
16
		<div>Entered on:</div>
17
		<erptr:rawInfoBox>${dateRecieved}</erptr:rawInfoBox>
18
		<br />
19
		
20
		<div>Device id:</div>
21
		<erptr:rawInfoBox>${deviceId}</erptr:rawInfoBox>
22
		<br />
23
		
24
		<div>Data:</div>
25
		<erptr:rawInfoBox><pre>${reportedData}</pre></erptr:rawInfoBox>
26
		<br />
27
		
28
	</erptr:box>
29
	
30
</body>
31

  
32
</html>
hci/trunk/eneraptor-web-app/grails-app/views/sysLog/main.gsp
6 6
</head>
7 7

  
8 8
<body>
9
	<p>Deluje!</p>
9
	
10
	<erptr:box title="Log">
11
		<p>TODO: Some information about log.</p>
12
	</erptr:box>
13
	
14
	<erptr:box title="Disk usage">
15
		<p>TODO: Some information about log.</p>
16
	</erptr:box>
17

  
10 18
</body>
11 19

  
12 20
</html>
hci/trunk/eneraptor-web-app/grails-app/taglib/com/eneraptor/hci/ErptrJSTagLib.groovy
1
package com.eneraptor.hci
2

  
3
class ErptrJSTagLib {
4

  
5
	static namespace = 'js'
6
	
7
	def checkBoxToggle = {
8
		
9
		out << "<script type='text/javascript'>"
10
		out << "var toggleCheck = false;"
11
		out << "function checkToggle(formId) {"
12
		out << "  if (toggleCheck == false) toggleCheck = true; else toggleCheck = false;"
13
		out << "  for (var i = 0; i < document.getElementById(formId).elements.length; i++) {"
14
		out << "    if(document.getElementById(formId).elements[i].type == 'checkbox')"
15
		out << "      document.getElementById(formId).elements[i].checked = toggleCheck;"
16
		out << "  }"
17
		out << "}"
18
		out << "</script>"
19
		
20
	}
21
	
22
}
hci/trunk/eneraptor-web-app/grails-app/taglib/com/eneraptor/hci/ErptrTagLib.groovy
32 32
				out << g.createLink(controller: "${it.name}", action: "${it.url}")
33 33
				out << "' class='"
34 34
				out << "${it.name}-${it.url}"
35
				out << "'>${it.label}</a></li>"
35
				out << "'>"
36
				if(attrs.chosen == it.url) out << "<u>"
37
				out << it.label
38
				if(attrs.chosen == it.url) out << "</u>"
39
				out << "</a></li>"
36 40
			}
37 41
		}
38 42
		
......
62 66
	def confirmBox = { attrs, body ->
63 67
		out << "<div id='confirmBox'>"
64 68
		out << "<div class='confirmBoxContent'>"
65
		out << "<img style='float: left;margin:5px;' src='" + g.resource(dir: 'img/icons/', file:'tick.png') + "' />"
69
		out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'tick.png') + "' />"
66 70
		out << body()
67 71
		out << "</div>"
68 72
		out << "</div><br />"
......
71 75
	def errorBox = { attrs, body ->
72 76
		out << "<div id='errorBox'>"
73 77
		out << "<div class='errorBoxContent'>"
74
		out << "<img style='float: left;margin:5px;' src='" + g.resource(dir: 'img/icons/', file:'cross.png') + "' />"
78
		out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'cross.png') + "' />"
75 79
		out << body()
76 80
		out << "</div>"
77 81
		out << "</div><br />"
78 82
	}
79 83
	
84
	def warningBox = { attrs, body ->
85
		out << "<div id='warningBox'>"
86
		out << "<div class='warningBoxContent'>"
87
		out << "<img style='float: left;margin:5px;position:relative;top:-2px;' src='" + g.resource(dir: 'img/icons/', file:'error.png') + "' />"
88
		out << body()
89
		out << "</div>"
90
		out << "</div><br />"
91
	}
92
	
80 93
	def logEntryOptions = { attrs ->
81 94
		out << "<a href='"
82 95
		out << g.createLink(action: 'detail', id: attrs.for)
......
94 107
		out << "</a>"
95 108
	}
96 109
	
110
	def changeDeleteOptions = { attrs ->
111
		out << "<a href='"
112
		out << g.createLink(action: 'change' + attrs.table + 'Entry', id: attrs.for)
113
		out << "'>"
114
		out << "<img src='"
115
		out << g.resource(dir: 'img/icons/', file: 'wrench_orange.png')
116
		out << "' />"
117
		out << "</a>"
118
		out << "<a href='"
119
		out << g.createLink(action: 'delete' + attrs.table + 'Entry', id: attrs.for)
120
		out << "'>"
121
		out << "<img src='"
122
		out << g.resource(dir: 'img/icons/', file: 'delete.png')
123
		out << "' />"
124
		out << "</a>"
125
	}
126
	
97 127
	def icon = { attrs ->
98 128
		out << "<img style='float:left;position:relative;bottom:2px;' src='"
99 129
		out << g.resource(dir: "img/icons/", file: attrs.w + ".png")
......
106 136
		
107 137
	}
108 138
	
139
	def rawInfoBox = { attrs, body ->
140
		out << "<div class='rawInfoBox'>"
141
		out << body()
142
		out << "</div>"
143
	}
144
	
109 145
}
hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/HciLogicCommService.groovy
1
package com.eneraptor.hci
2

  
3
class HciLogicCommService {
4

  
5
    static transactional = true
6

  
7
    Map getReplyToRequest(String requestContent) {
8
		
9
		Map reply = new HashMap()
10
		
11
		Socket logicSocket = null;
12
		PrintWriter toLogic = null;
13
		BufferedReader fromLogic = null;
14
		
15
		def ipAddress = InternalConfig.findByConfigId("logic-ip")['configVal']
16
		def portNum = InternalConfig.findByConfigId("logic-port")['configVal']
17

  
18
		try {
19
			logicSocket = new Socket(ipAddress, portNum as int);
20
			toLogic = new PrintWriter(logicSocket.getOutputStream(), true);
21
			fromLogic = new BufferedReader(new InputStreamReader(
22
										logicSocket.getInputStream()));
23
		} catch (UnknownHostException e) {
24
			reply['status'] = "error"
25
			reply['content'] = "Unknown host: "
26
			reply['content'] += e.getMessage()
27
			return reply
28
		} catch (IOException e) {
29
			reply['status'] = "error"
30
			reply['content'] += e.getMessage()
31
			return reply
32
		}
33
		
34
		reply['status'] = "ok"
35
		reply['content'] = ""
36
		toLogic.println(requestContent)
37
		List allLines = new ArrayList()
38
		allLines = fromLogic.readLines()
39
		allLines.each {
40
			reply['content'] += it.toString() + "\n"
41
		}
42
		
43
		return reply
44

  
45
    }
46
	
47
}
hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy
31 31
		
32 32
		sysStateSubMenu = new ArrayList()
33 33
		sysStateSubMenu.add(new MenuItem("Overview","sysState","main"))
34
		sysStateSubMenu.add(new MenuItem("Measurements","sysState","measure"))
34
		sysStateSubMenu.add(new MenuItem("Last measurements","sysState","measure"))
35
		sysStateSubMenu.add(new MenuItem("Last actions taken","sysState","actions"))
35 36
		
36 37
		sysLogSubMenu = new ArrayList()
37 38
		sysLogSubMenu.add(new MenuItem("Overview","sysLog","main"))
hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/ConfigController.groovy
1 1
package com.eneraptor.hci
2 2

  
3
class ConfigController {
3
import groovy.sql.*
4
import java.sql.*
5

  
6
class ConfigController {
7
	
8
	def dataSource
4 9

  
5 10
    def main = { }
6 11
	
7 12
	def hci = {
8
	
13
		
14
		def db_sql = new Sql(dataSource)
15
		
16
		def single = db_sql.firstRow("show data_directory")
17
		def loca = single.data_directory
18
		def partition = new File(loca)
19
		def totalSpace = partition.getTotalSpace()
20
		def freeSpace  = partition.getFreeSpace()
21
		
22
		totalSpace = (int)((totalSpace/1024)/1024)
23
		freeSpace = (int)((freeSpace/1024)/1024)
24
		
25
		def percent = 100 - ((int) ((freeSpace/totalSpace)*100))
26
		
9 27
		def allDevices = DeviceInfo.list()
10
		[conf: InternalConfig, devices: allDevices]		
28
		[conf: InternalConfig, devices: allDevices, totalSpace: totalSpace, freeSpace: freeSpace, percent: percent]		
11 29
	}
12 30
	
13 31
	def addDevice = {
......
15 33
	
16 34
	def addDeviceSave = {
17 35
		def newDevice = new DeviceInfo(params)
18
		if(newDevice.validate()) {
36
		if(newDevice.validate() && (params.inputDevice || params.outputDevice)) {
19 37
			newDevice.save()
20 38
			flash['confirms'] = "<p>New device added successfully.</p>"
21 39
			redirect(action:'hci')
22 40
		} else {
23 41
			flash['errors'] = "<p>New device was not saved. Check input data.</p>"
42
			if(!params.inputDevice && !params.outputDevice)
43
				flash['errors'] += "<p>Device must be capable of making masurements, actions or both. You have selected none.</p>"
24 44
			redirect(action:'addDevice', params: params)
25 45
		}
26 46
	}
27 47
	
48
	def deleteHciEntry = {
49
		
50
		def deviceToBeDeleted = DeviceInfo.findById(params.id)
51
		
52
		if(deviceToBeDeleted) {
53
			deviceToBeDeleted.delete()
54
			flash['confirms'] = "<p>Device deleted succesfully.</p>"
55
		} else {
56
			flash['errors'] = "<p>There was no device deleted.</p><p>There was no device with id ${params.id}.</p>"
57
		}
58
		redirect(action: 'hci')
59
		
60
	}
61
	
62
	def changeHciEntry = {
63
		
64
		def deviceToBeChanged = DeviceInfo.findById(params.id)
65
		if(!deviceToBeChanged) {
66
			flash['errors'] = "<p>There is no device with id ${params.id}.</p>"
67
			redirect(action: 'hci')
68
			return false
69
		}
70
		deviceToBeChanged.getProperties()
71
    }
72
	
73
	def changeHciEntrySave = {
74
		
75
		def deviceToBeUpdated = DeviceInfo.findById(params.id)
76
		deviceToBeUpdated.properties = params
77
		if(deviceToBeUpdated.save()) {
78
			flash['confirms'] = "<p>Device updated succesfully.</p>"
79
			redirect(action: 'hci')
80
		} else {
81
			flash['errors'] = "<p>Device was not changed.</p>"
82
			redirect(action:'changeHciEntry', params: params)
83
		}
84
		
85
	}
86
	
87
	def dbInfo = {
88
		
89
		List databaseInfo = new ArrayList()
90
		def db_sql = new Sql(dataSource)
91
		db_sql.eachRow "SHOW ALL", {
92
			databaseInfo << it.toRowResult()
93
		}
94
		
95
		[databaseInfo: databaseInfo]
96
		
97
	}
98
	
28 99
	def logic = {
29 100
		
30 101
		[conf: InternalConfig]
......
53 124
		
54 125
	}
55 126
	
127
	def dbExec = {
128
		
129
		if(params['sqlQuery']) {
130
			
131
			flash['confirms'] = null
132
			flash['errors'] = null
133
			
134
			def db_sql = new Sql(dataSource)
135
			List rows
136
			List keys = new ArrayList()
137
			boolean wasError = false
138
			try {
139
				rows = db_sql.rows(params['sqlQuery'])
140
				rows[0].each {
141
					keys << it.key
142
				}
143
				flash['confirms'] = "<p>SQL query executed succesfully. Chrck returned rows below.</p>"
144
			} catch (SQLException e) {
145
				rows = new ArrayList()
146
				if(e.getSQLState().equals("02000")) {
147
					keys << 'SQL query result'
148
					rows << ['SQL query result' : 'No rows were returned.']
149
					flash['confirms'] = "<p>SQL query executed succesfully.</p>"
150
				} else {
151
					rows << e
152
					rows << e.getSQLState()
153
					wasError = true
154
					flash['errors'] = "<p>There was an error while executing the SQL query. Check the report below.</p><p>The query was not executed</p>"
155
				}
156
			}
157
			return [sqlResult: rows, keys: keys, wasError: wasError]
158
		}
159
		
160
	}
161
	
56 162
	def getHelp = {
57 163
		[what : params.what]
58 164
	}
hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/LogicRequestController.groovy
3 3
class LogicRequestController {
4 4

  
5 5
	def reportService
6
	def hciLogicCommService
6 7
	
7 8
    def testConnection = {
8 9
		
......
12 13
		output += reportService.println("Logic port number: " + InternalConfig.findByConfigId('logic-port').configVal)
13 14
		
14 15
		output += reportService.println("Test started")
15
		output += reportService.println("<span style='color:red;'>Error: " + "Connection implementation missing.</span>")
16
		
17
		String reqStr = "<hci-request type='checkConnection'><data>012345</data></hci-request>"
18
		Map testReply = hciLogicCommService.getReplyToRequest(reqStr)
19
		
20
		if(testReply['status'] == "error") {
21
			output += reportService.println("<span style='color:red;'>Error: " + testReply['content'] + "</span>")
22
		} else {
23
			output += reportService.println("Connection established succesfully")
24
			if(testReply['content'] == "012345") {
25
				output += "<span style='color:green;'>Logic unit replied! The eneraptor system is set up properly.</span>"
26
			} else {
27
				output += reportService.println("<span style='color:red;'>The connection was established, but there was no reply from the logic unit.</span>")
28
				output += reportService.println("<span style='color:red;'>You should check the logic's port number and IP address.</span>");
29
			}
30
		}
31
		
16 32
		output += reportService.println("Test ended")
17 33
		
18 34
		[output:output]
hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysStateController.groovy
1 1
package com.eneraptor.hci
2 2

  
3 3
class SysStateController {
4

  
5
    def main = { }
4

  
5
	def reportService
6
	def hciLogicCommService
6 7
	
8
    def main = {
9
		
10
		List inDevices = DeviceInfo.findAllByInputDevice(true, [sort:'friendlyName', order:'asc'])
11
		List inDevicesData = new ArrayList()
12
		inDevices.each {
13
			Map inDeviceDataEntry = new HashMap()
14
			inDeviceDataEntry['friendlyName'] = it.friendlyName
15
			inDeviceDataEntry['icon'] = it.iconPath
16
			inDeviceDataEntry['loggedData'] = LoggedData.findByDeviceId(it.deviceId, [sort:'dateRecieved', order:'desc'])	
17
			inDevicesData << inDeviceDataEntry
18
		}
19
		
20
		List outDevices = DeviceInfo.findAllByOutputDevice(true, [sort:'friendlyName', order:'asc'])
21
		List outDevicesData = new ArrayList()
22
		outDevices.each {
23
			Map outDeviceDataEntry = new HashMap()
24
			outDeviceDataEntry['friendlyName'] = it.friendlyName
25
			outDeviceDataEntry['icon'] = it.iconPath
26
			outDeviceDataEntry['loggedData'] = LoggedData.findByDeviceId(it.deviceId, [sort:'dateRecieved', order:'desc'])
27
			outDevicesData << outDeviceDataEntry
28
		}
29
		
30
		[inDevicesData: inDevicesData, outDevicesData: outDevicesData]
31
		
32
	}
33
	
34
	def measure = {
35
		
36
		List inDevices = DeviceInfo.findAllByInputDevice(true, [sort:'friendlyName', order:'asc'])
37
		List inDevicesData = new ArrayList()
38
		inDevices.each {
39
			Map inDeviceDataEntry = new HashMap()
40
			inDeviceDataEntry['deviceId'] = it.deviceId
41
			inDeviceDataEntry['friendlyName'] = it.friendlyName
42
			inDeviceDataEntry['icon'] = it.iconPath
43
			inDeviceDataEntry['loggedData'] = LoggedData.findByDeviceId(it.deviceId, [sort:'dateRecieved', order:'desc'])
44
			inDevicesData << inDeviceDataEntry
45
		}
46
		
47
		[inDevicesData: inDevicesData]
48
		
49
    }
50
	
51
	def measureUpdate = {
52
		
53
		List devices = new ArrayList()
54
		
55
		DeviceInfo.findAllByInputDevice(true).each {
56
			if(params[it.deviceId] == "on")
57
				devices << it.deviceId
58
		}
59
		
60
		def output = "";
61
		
62
		if(devices.size == 0) {
63
			flash['errors'] = "<p>No device was selected. At least one device must be selected.</p>"
64
			redirect(action: 'measure')
65
			return false
66
		}
67
		
68
		output += reportService.println("Trying to update measurements manually for devices")
69
		devices.each {
70
			output += reportService.println(" - " + it)
71
		}
72
		output += reportService.println("Generating request xml")
73
		
74
		// generate request xml
75
		def reqXML = "<todo />"
76
		
77
		output += reportService.println("Request xml generated")
78
		output += reportService.println("Sending request")
79
		
80
		// send request
81
		Map rspXML = hciLogicCommService.getReplyToRequest(reqXML)
82
		
83
		if(rspXML['status'] == "error") {
84
			output += reportService.println("<span style='color:red;'>Error: " + rspXML['content'] + "</span>")
85
		} else {
86
			output += reportService.println("<span style='color:red;'>Error: implementation missing - TODO.</span>")
87
		}
88
		
89
		[errorExplanation: output]
90
		
91
	}
92
	
93
	def actions = {
94
		
95
		List outDevices = DeviceInfo.findAllByOutputDevice(true, [sort:'friendlyName', order:'asc'])
96
		List outDevicesData = new ArrayList()
97
		outDevices.each {
98
			Map outDeviceDataEntry = new HashMap()
99
			outDeviceDataEntry['deviceId'] = it.deviceId
100
			outDeviceDataEntry['friendlyName'] = it.friendlyName
101
			outDeviceDataEntry['icon'] = it.iconPath
102
			outDeviceDataEntry['loggedData'] = LoggedData.findByDeviceId(it.deviceId, [sort:'dateRecieved', order:'desc'])
103
			outDevicesData << outDeviceDataEntry
104
		}
105
		
106
		[outDevicesData: outDevicesData]
107
		
108
    }
109
	
7 110
}
hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy
10 10
	
11 11
	def browse = {
12 12
		
13
		flash['warnings'] = null
14
		
13 15
		def entries = LoggedData.list()
16
		Map devices = new HashMap()
17
		Map icons   = new HashMap()
18
		List unknownDevices = new ArrayList()
19
		DeviceInfo.list().each {
20
			devices[it.deviceId] = it.friendlyName
21
			if(it.iconPath) {
22
				icons[it.deviceId] = it.iconPath
23
			}
24
		}
25
		entries.each {
26
			if(!devices[it.deviceId]) {
27
				if(!unknownDevices.contains(it.deviceId)) {
28
					unknownDevices << it.deviceId
29
				}
30
			}
31
		}
32
		unknownDevices.each {
33
			if(!flash['warnings']) flash['warnings'] = ""
34
			flash['warnings'] += "<p>There was found at least one log entry for a device with id <b>${it}</b>, which is <b>unknown</b> to HCI. You should <b>add this device</b> by <b>" + g.link(controller: 'config', action: 'addDevice', params: ['deviceId' : it], "clicking here") + "</b>.</p>"
35
		}
14 36
		
15
		[data: entries]
37
		[data: entries, devices: devices, icons: icons]
16 38
		
17 39
	}
18 40
	
19 41
	def detail = {
20 42
		
43
		def detailsOf = LoggedData.findById(params.id)
44
		if(!detailsOf) {
45
			flash['errors'] = "<p>There is no logged data with id ${params.id}</p>"
46
			redirect(action: 'browse')
47
			return false
48
		}
49
		return detailsOf.getProperties()
21 50
	}
22 51
	
23 52
	def deleteEntry = {
hci/trunk/eneraptor-web-app/grails-app/domain/com/eneraptor/hci/DeviceInfo.groovy
6 6
	String friendlyName
7 7
	String description
8 8
	String iconPath
9
	boolean inputDevice
10
	boolean outputDevice
11
	
12
	 
9 13
	
10 14
    static constraints = {
11 15
		deviceId(blank: false, unique: true)
12 16
		friendlyName(blank: false, maxSize: 64)
13 17
		description(nullable: true, maxSize: 128)
14
		iconPath(nullable: true)
18
		iconPath(nullable: true)
19
		inputDevice(blank: false)
20
		outputDevice(blank: false)
15 21
    }
16 22
}
hci/trunk/eneraptor-web-app/test/unit/com/eneraptor/hci/ErptrJSTagLibTests.groovy
1
package com.eneraptor.hci
2

  
3
import grails.test.*
4

  
5
class ErptrJSTagLibTests extends TagLibUnitTestCase {
6
    protected void setUp() {
7
        super.setUp()
8
    }
9

  
10
    protected void tearDown() {
11
        super.tearDown()
12
    }
13

  
14
    void testSomething() {
15

  
16
    }
17
}
hci/trunk/eneraptor-web-app/test/unit/com/eneraptor/hci/HciLogicCommServiceTests.groovy
1
package com.eneraptor.hci
2

  
3
import grails.test.*
4

  
5
class HciLogicCommServiceTests extends GrailsUnitTestCase {
6
    protected void setUp() {
7
        super.setUp()
8
    }
9

  
10
    protected void tearDown() {
11
        super.tearDown()
12
    }
13

  
14
    void testSomething() {
15

  
16
    }
17
}
hci/trunk/eneraptor-web-app/web-app/css/style.css
9 9
body{
10 10
	font-size: 12px;
11 11
	font-family: Arial, Tahoma, Verdana;
12
	min-height: 700px;
12 13
}
13 14
a, a:visited{
14 15
	text-decoration:none;
......
345 346
	background:#E4F0C9;
346 347
	padding: 8px;
347 348
}
349

  
350
.warningBoxContent {
351
	border:1px solid #FCFFAB;
352
	background:#FDFFCC;
353
	padding: 8px;
354
}
355

  
356
.rawInfoBox {
357
	padding:10px;
358
	border:1px solid #FCFFAB;
359
	background:#FDFFCC;
360
	margin:5px;
361
	font-family:monospace;	
362
}
348 363
/*********************
349 364
	Icons
350 365
*********************/
......
387 402
*********************/
388 403

  
389 404
.sysState-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
390
.sysState-measure{background:transparent url(../img/icons/chart_bar.png) no-repeat left;}
405
.sysState-measure{background:transparent url(../img/icons/monitor.png) no-repeat left;}
406
.sysState-actions{background:transparent url(../img/icons/lightning.png) no-repeat left;}
391 407

  
392 408
.sysLog-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
393 409
.sysLog-browse{background:transparent url(../img/icons/magnifier.png) no-repeat left;}
394 410

  
395 411
.config-main{background:transparent url(../img/icons/eye.png) no-repeat left;}
396
.config-hci{background:transparent url(../img/icons/cog.png) no-repeat left;}
412
.config-hci{background:transparent url(../img/icons/application.png) no-repeat left;}
397 413
.config-logic{background:transparent url(../img/icons/cog.png) no-repeat left;}
398
.config-connection{background:transparent url(../img/icons/cog.png) no-repeat left;}
414
.config-connection{background:transparent url(../img/icons/connect.png) no-repeat left;}

Also available in: Unified diff