Revision 50

View differences:

hci/trunk/eneraptor-web-app/.settings/org.eclipse.wst.common.component
5 5
        <wb-resource deploy-path="/" source-path="/navigation-1.1.1-grails-app-services"/>
6 6
        <wb-resource deploy-path="/" source-path="/navigation-1.1.1-grails-app-taglib"/>
7 7
        <wb-resource deploy-path="/" source-path="/flot-0.2.2-grails-app-taglib"/>
8
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-conf"/>
9
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-controllers"/>
10
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-domain"/>
11
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-i18n"/>
12
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-realms"/>
13
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-services"/>
14
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-taglib"/>
15
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-grails-app-views"/>
16
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-src-java"/>
17
        <wb-resource deploy-path="/" source-path="/shiro-1.1.2-src-groovy"/>
8
        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-controllers"/>
9
        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-i18n"/>
10
        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-services"/>
11
        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-taglib"/>
12
        <wb-resource deploy-path="/" source-path="/pdf-0.6-grails-app-views"/>
18 13
    </wb-module>
19 14
</project-modules>
hci/trunk/eneraptor-web-app/application.properties
1 1
#Grails Metadata file
2
#Thu Jan 13 08:59:17 CET 2011
2
#Wed Jan 26 14:49:47 CET 2011
3 3
app.grails.version=1.3.6
4 4
app.name=eneraptor-web-app
5 5
app.servlet.version=2.4
6
app.version=0.3
6
app.version=0.4
7 7
plugins.flot=0.2.2
8 8
plugins.hibernate=1.3.6
9 9
plugins.navigation=1.1.1
10
plugins.pdf=0.6
10 11
plugins.tomcat=1.3.6
hci/trunk/eneraptor-web-app/grails-app/services/com/eneraptor/hci/MainMenuService.groovy
43 43
		
44 44
		statisticsSubMenu = new ArrayList()
45 45
		statisticsSubMenu.add(new MenuItem("Overview","statistics","main"))
46
		statisticsSubMenu.add(new MenuItem("Graphs","statistics","graphs"))
47
		statisticsSubMenu.add(new MenuItem("Reports","statistics","reports"))
46
		statisticsSubMenu.add(new MenuItem("Saved graphs","statistics","graphs"))
47
		statisticsSubMenu.add(new MenuItem("Create a new graph","statistics","newGraph"))
48
		statisticsSubMenu.add(new MenuItem("Make reports","statistics","newReport"))
48 49
		
49 50
		actionsSubMenu = new ArrayList()
50 51
		actionsSubMenu.add(new MenuItem("Overview","actions","main"))
hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/StatisticsController.groovy
19 19
			
20 20
	}
21 21
	
22
	def reports = { }
23
	
24 22
	def newGraph = {
25 23
		
26 24
		List graphTypes = ["min","max","avg","sum"]
......
96 94
	
97 95
	def showGraph = {
98 96
		
99
		def graphToShow = EneGraph.get(params['graphId'])
97
		def graphToShow = EneGraph.get(params['id'])
100 98
		String query
101 99
		
102 100
		List data = new ArrayList()
......
104 102
		def db_sql = new Sql(dataSource)
105 103
		
106 104
		if(graphToShow.timeFrameType == "day") {
107
			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
105
			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
108 106
				data << [it.dt.getTime(), it.vl]
109 107
			}
110 108
		} else if (graphToShow.timeFrameType == "month") {
111
			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
109
			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
112 110
				data << [it.dt.getTime(), it.vl]
113 111
			}
114 112
		} else if (graphToShow.timeFrameType == "year") {
115
			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "') group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
113
			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
116 114
				data << [it.dt.getTime(), it.vl]
117 115
			}
118 116
		} else if (graphToShow.timeFrameType == "custom") {
......
125 123
				def currDateStart = new Date((long)currDateStartMillis)
126 124
				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
127 125
				def currDateStop = new Date((long)currDateStopMillis)
128
				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "')) "
126
				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
129 127
				if (i < (graphToShow.innerSections-1) ) query += "union "
130 128
			}
131 129
			query += "order by dt asc"
......
137 135
		[data:data]
138 136
		
139 137
	}
138
	
139
	def editGraph = {
140
		
141
		EneGraph chosenGraph = EneGraph.get(params['id'])
142
		
143
		List graphTypes = ["min","max","avg","sum"]
144
		List graphTypesFriendly = ["Minimum value","Maximum value","Average value","Cumulative"]
145
		
146
		List devices = new ArrayList()
147
		List devicesFriendly = new ArrayList()
148
		
149
		DeviceInfo.list().each {
150
			devices << it.deviceId
151
			devicesFriendly << it.friendlyName
152
		}
153
		
154
		[graph: chosenGraph, graphTypes:graphTypes, graphTypesFriendly:graphTypesFriendly, devices:devices, devicesFriendly:devicesFriendly]
155
		
156
	}
157
	
158
	def editGraphDo = {
159
	
160
		String errors = ""
161
		
162
		EneGraph graphToEdit = EneGraph.get(params['graphId'])
163
		
164
		graphToEdit.name = params['graphName']
165
		graphToEdit.type = params['graphType']
166
		graphToEdit.timeFrameType = params['timeFrameType']
167
		graphToEdit.timeFrameStart = params['mainTimeFrameStart']
168
		graphToEdit.timeFrameEnd = params['mainTimeFrameEnd']
169
		graphToEdit.innerSections = params['mainTimeFrameInnerSections'] as int
170
		graphToEdit.advHoursTimeFrameStart = params['advHoursStart'] as int
171
		graphToEdit.advHoursTimeFrameEnd = params['advHoursEnd'] as int 
172
		graphToEdit.advDayTimeFrameStart = params['advDayStart'] as int
173
		graphToEdit.advDayTimeFrameEnd = params['advDayEnd'] as int
174
		graphToEdit.advMonthTimeFrameStart = params['advMonthStart'] as int
175
		graphToEdit.advMonthTimeFrameEnd = params['advMonthEnd'] as int
176
		graphToEdit.deviceId = params['deviceId']
177
		
178
		if(!graphToEdit.validate()) {
179
			errors += "<p>Graph could not be modified - there were some input errors. Please check if all input values are valid.</p>"
180
			flash['errors'] = errors
181
			redirect(action:'editGraph')
182
		} else {
183
			if(graphToEdit.save()){
184
				flash['confirms'] = "<p>Graph modified succesfully!</p>"
185
				redirect(action:'graphs')
186
			} else {
187
				flash['errors'] = "<p>There was an error while modifying graph.</p>"
188
				redirect(action:'editGraph')
189
			}
190
		}
191
		
192
		return true
193
			
194
	}
195
	
196
	def newReport = {
197
		
198
		def graphsAll = EneGraph.list()
199
		def graphs = new ArrayList()
200
		def graphsKeys = new ArrayList()
201
		graphsAll.each {
202
			graphs << it.name
203
			graphsKeys << it.id
204
		}
205
		
206
		[graphs:graphs, graphsKeys:graphsKeys]
207
		
208
	}
209
	
210
	def makeReport = {
211
		
212
		def graphToShow = EneGraph.get(params['id'])
213
		String query
214
		
215
		List data = new ArrayList()
216
		List detailedData = new ArrayList()
217
		def results
218
		def innerTimeFrameHalf = 0;
219
		def db_sql = new Sql(dataSource)
220
		
221
		if(graphToShow.timeFrameType == "day") {
222
			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
223
				data << [it.dt.getTime(), it.vl]
224
				detailedData << [it.dt.toString().substring(0,10), it.vl]
225
			}
226
		} else if (graphToShow.timeFrameType == "month") {
227
			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
228
				data << [it.dt.getTime(), it.vl]
229
				detailedData << [it.dt.toString().substring(0,7), it.vl]
230
			}
231
		} else if (graphToShow.timeFrameType == "year") {
232
			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
233
				data << [it.dt.getTime(), it.vl]
234
				detailedData << [it.dt.toString().substring(0,4), it.vl]
235
			}
236
		} else if (graphToShow.timeFrameType == "custom") {
237
			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
238
			innerTimeFrameHalf = (long)(innerTimeFrame/2)
239
			query = ""
240
			for(int i = 0; i < graphToShow.innerSections;i++) {
241
				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
242
				def currDate = new Date((long)currDateMillis)
243
				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
244
				def currDateStart = new Date((long)currDateStartMillis)
245
				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
246
				def currDateStop = new Date((long)currDateStopMillis)
247
				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
248
				if (i < (graphToShow.innerSections-1) ) query += "union "
249
			}
250
			query += "order by dt asc"
251
			db_sql.eachRow(query) {
252
				data << [it.dt.getTime(), it.vl]
253
				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
254
			}
255
		}
256
		
257
		[data:data, detailedData:detailedData, graph:graphToShow]
258
		
259
	}
260
	
261
	def exportReport = {
262
		
263
		if(params['exportType'] == 'pdf') {
264
			exportReportPdf(params:params)
265
		} else if(params['exportType'] == 'xml') {
266
			exportReportXml(params:params)
267
		} else if(params['exportType'] == 'csv') {
268
			exportReportCsv(params:params)
269
		} else {
270
			flash['errors'] = "<p>The specified export type is not valid!</p>"
271
			redirect(action:'graphs')
272
		}
273
		
274
		return true
275
		
276
	}
277
	
278
	def exportReportPdf = {
279
		
280
		redirect(controller: 'pdf', action: 'pdfLink', params:[pdfController: 'pdf',pdfAction:'reportToPdf',reportId:params['reportId']])
281
		
282
	}
283
	
284
	def exportReportXml = {
285
		
286
		def cont = ""
287
		
288
		def graphToShow = EneGraph.get(params['reportId'])
289
		String query
290
		
291
		List data = new ArrayList()
292
		List detailedData = new ArrayList()
293
		def results
294
		def innerTimeFrameHalf = 0;
295
		def db_sql = new Sql(dataSource)
296
		
297
		if(graphToShow.timeFrameType == "day") {
298
			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
299
				data << [it.dt.getTime(), it.vl]
300
				detailedData << [it.dt.toString().substring(0,10), it.vl]
301
			}
302
		} else if (graphToShow.timeFrameType == "month") {
303
			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
304
				data << [it.dt.getTime(), it.vl]
305
				detailedData << [it.dt.toString().substring(0,7), it.vl]
306
			}
307
		} else if (graphToShow.timeFrameType == "year") {
308
			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
309
				data << [it.dt.getTime(), it.vl]
310
				detailedData << [it.dt.toString().substring(0,4), it.vl]
311
			}
312
		} else if (graphToShow.timeFrameType == "custom") {
313
			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
314
			innerTimeFrameHalf = (long)(innerTimeFrame/2)
315
			query = ""
316
			for(int i = 0; i < graphToShow.innerSections;i++) {
317
				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
318
				def currDate = new Date((long)currDateMillis)
319
				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
320
				def currDateStart = new Date((long)currDateStartMillis)
321
				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
322
				def currDateStop = new Date((long)currDateStopMillis)
323
				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
324
				if (i < (graphToShow.innerSections-1) ) query += "union "
325
			}
326
			query += "order by dt asc"
327
			db_sql.eachRow(query) {
328
				data << [it.dt.getTime(), it.vl]
329
				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
330
			}
331
		}
332
		
333
			
334
		if(graphToShow.timeFrameType == 'custom') {
335
			cont += "<report>" + "\n"
336
			cont += "\t<desc>" + graphToShow.name + "</desc>" + "\n"
337
			cont += "\t<type>" + graphToShow.type + "</type>" + "\n"
338
			cont += "\t<device>" + graphToShow.deviceId + "</device>" + "\n"
339
			cont += "\t<timeframe>" + "\n"
340
			cont += "\t\t<type>" + graphToShow.timeFrameType + "</type>" + "\n"
341
			cont += "\t\t<start>" + graphToShow.timeFrameStart + "</start>" + "\n"
342
			cont += "\t\t<end>" + graphToShow.timeFrameEnd + "</end>" + "\n"
343
			cont += "\t\t<innernum>" + graphToShow.innerSections + "</innernum>" + "\n"
344
			cont += "\t</timeframe>" + "\n"
345
			cont += "\t<values>" + "\n"
346
			detailedData.each {
347
				cont += "\t\t<inner>" + "\n"
348
				cont += "\t\t\t<start>" + it[0] + "</start>" + "\n"
349
				cont += "\t\t\t<end>" + it[1] + "</end>" + "\n"
350
				cont += "\t\t\t<value>" + it[2] + "</value>" + "\n"
351
				cont += "\t\t</inner>" + "\n"
352
			}
353
			cont += "\t</values>" + "\n"
354
			cont += "</report>" + "\n"
355
		} else {
356
			cont += "<report>" + "\n"
357
			cont += "\t<desc>" + graphToShow.name + "</desc>" + "\n"
358
			cont += "\t<type>" + graphToShow.type + "</type>" + "\n"
359
			cont += "\t<device>" + graphToShow.deviceId + "</device>" + "\n"
360
			cont += "\t<timeframe>" + "\n"
361
			cont += "\t\t<type>" + graphToShow.timeFrameType + "</type>" + "\n"
362
			cont += "\t\t<start>" + graphToShow.timeFrameStart + "</start>" + "\n"
363
			cont += "\t\t<end>" + graphToShow.timeFrameEnd + "</end>" + "\n"
364
			cont += "\t</timeframe>" + "\n"
365
			cont += "\t<values>" + "\n"
366
			detailedData.each {
367
				cont += "\t\t<inner>" + "\n"
368
				cont += "\t\t\t<time>" + it[0] + "</time>" + "\n"
369
				cont += "\t\t\t<value>" + it[1] + "</value>" + "\n"
370
				cont += "\t\t</inner>" + "\n"
371
			}
372
			cont += "\t</values>" + "\n"
373
			cont += "</report>" + "\n"
374
		}
375
		
376
		render(text: cont,contentType:"text/xml",encoding:"UTF-8")
377
		
378
	}
379
	
380
	def exportReportCsv = {
381
		
382
		def cont = ""
383
		
384
		def graphToShow = EneGraph.get(params['reportId'])
385
		String query
386
		
387
		List data = new ArrayList()
388
		List detailedData = new ArrayList()
389
		def results
390
		def innerTimeFrameHalf = 0;
391
		def db_sql = new Sql(dataSource)
392
		
393
		if(graphToShow.timeFrameType == "day") {
394
			db_sql.eachRow "select date_trunc('day',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('day',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('day',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('day',ld.date_recieved) order by date_trunc('day',ld.date_recieved) asc", {
395
				data << [it.dt.getTime(), it.vl]
396
				detailedData << [it.dt.toString().substring(0,10), it.vl]
397
			}
398
		} else if (graphToShow.timeFrameType == "month") {
399
			db_sql.eachRow "select date_trunc('month',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('month',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('month',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('month',ld.date_recieved) order by date_trunc('month',ld.date_recieved) asc", {
400
				data << [it.dt.getTime(), it.vl]
401
				detailedData << [it.dt.toString().substring(0,7), it.vl]
402
			}
403
		} else if (graphToShow.timeFrameType == "year") {
404
			db_sql.eachRow "select date_trunc('year',ld.date_recieved) dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and date_trunc('year',ld.date_recieved) >= '" + graphToShow.timeFrameStart + "' and date_trunc('year',ld.date_recieved) <= '" + graphToShow.timeFrameEnd + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ") group by date_trunc('year',ld.date_recieved) order by date_trunc('year',ld.date_recieved) asc", {
405
				data << [it.dt.getTime(), it.vl]
406
				detailedData << [it.dt.toString().substring(0,4), it.vl]
407
			}
408
		} else if (graphToShow.timeFrameType == "custom") {
409
			def innerTimeFrame = (long)((graphToShow.timeFrameEnd.getTime() - graphToShow.timeFrameStart.getTime()) / graphToShow.innerSections)
410
			innerTimeFrameHalf = (long)(innerTimeFrame/2)
411
			query = ""
412
			for(int i = 0; i < graphToShow.innerSections;i++) {
413
				def currDateMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame) + innerTimeFrame/2
414
				def currDate = new Date((long)currDateMillis)
415
				def currDateStartMillis = graphToShow.timeFrameStart.getTime() + (i*innerTimeFrame)
416
				def currDateStart = new Date((long)currDateStartMillis)
417
				def currDateStopMillis = graphToShow.timeFrameStart.getTime() + ((i+1)*innerTimeFrame)
418
				def currDateStop = new Date((long)currDateStopMillis)
419
				query += "(select timestamp without time zone '" + currDate.toTimestamp() + "' dt, " + graphToShow['type'] + "(to_number(ld.reported_data,'9999999999D99999')) vl from logged_data as ld where (device_id = '" + graphToShow['deviceId'] + "' and ld.date_recieved >= '" + currDateStart.toTimestamp() + "' and ld.date_recieved <= '" + currDateStop.toTimestamp() + "' and date_part('hour',ld.date_recieved) >= " + graphToShow.advHoursTimeFrameStart + " and date_part('hour',ld.date_recieved) <= " + graphToShow.advHoursTimeFrameEnd + " and date_part('day',ld.date_recieved) >= " + graphToShow.advDayTimeFrameStart + " and date_part('day',ld.date_recieved) <= " + graphToShow.advDayTimeFrameEnd + " and date_part('month',ld.date_recieved) >= " + graphToShow.advMonthTimeFrameStart + " and date_part('month',ld.date_recieved) <= " + graphToShow.advMonthTimeFrameEnd + ")) "
420
				if (i < (graphToShow.innerSections-1) ) query += "union "
421
			}
422
			query += "order by dt asc"
423
			db_sql.eachRow(query) {
424
				data << [it.dt.getTime(), it.vl]
425
				detailedData << [(new Date(it.dt.getTime()-innerTimeFrameHalf)).toTimestamp().toString(),(new Date(it.dt.getTime()+innerTimeFrameHalf)).toTimestamp().toString(), it.vl]
426
			}
427
		}
428
		
429
			
430
		if(graphToShow.timeFrameType == 'custom') {
431
			detailedData.each {
432
				cont += it[0] + "," + it[1] + "," + it[2] + "\n"
433
			}
434
		} else {
435
			detailedData.each {
436
				cont += it[0] + "," + it[1] + "\n"
437
			}
438
		}
439
		
440
		render(text: cont,contentType:"text/csv",encoding:"UTF-8")
441
		
442
	}
140 443
	
141 444
}
hci/trunk/eneraptor-web-app/grails-app/views/sysLog/graph.gsp
30 30
	<erptr:box title="Graphical representation of logged data">
31 31
		<g:javascript>
32 32
			var data = [${data}];
33
			var options = { lines: { show: true }, points: { show: true } };
33
			var options = {
34
				lines: { show: true },
35
				points: { show: true },
36
				xaxis: { mode: "time", timeformat: "%y/%m/%d %H:%M" }
37
			};
34 38
		</g:javascript>
35 39
		<div class="chart">
36 40
			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
hci/trunk/eneraptor-web-app/grails-app/views/statistics/makeReport.gsp
1
<html>
2

  
3
<head>
4
	<title>Statistics &raquo; Report</title>
5
	<meta name="layout" content="main" />
6
	<flot:resources />
7
</head>
8

  
9
<body>
10

  
11
	<erptr:box title="Report info">
12
	
13
		<p>Description: <b>${graph.name}</b></p>
14
		<p>Type: <b>${graph.type}</b> / <b>${graph.timeFrameType}</b></p>
15
		<p>From <b>${graph.timeFrameStart}</b> till <b>${graph.timeFrameEnd}</b></p>
16
		<p>Device ID: <b>${graph.deviceId}</b></p>
17
	
18
	</erptr:box>
19
	
20
	<erptr:box title="Graph">
21

  
22
		<g:javascript>
23
			var data = [${data}];
24
			var options = {
25
				lines: { show: true },
26
				points: { show: true },
27
				xaxis: { mode: "time", timeformat: "%y/%m/%d %H:%M" }
28
			};
29
		</g:javascript>
30
		<div class="chart">
31
			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
32
		</div>		
33

  
34
	</erptr:box>
35

  
36
	<erptr:box title="Report data">
37
	
38
		<g:if test="${graph.timeFrameType == 'custom'}">
39
			<table>
40
				<thead>
41
					<tr>
42
						<th><p>From</p></th>
43
						<th><p>Till</p></th>
44
						<th><p>Value (${graph.type})</p></th>
45
						<th><p>Rounded</p></th>
46
					</tr>
47
				</thead>
48
				<tbody>
49
					<g:each in="${detailedData}" var="dent">
50
						<tr>
51
							<td><p>${dent[0]}</p></td>
52
							<td><p>${dent[1]}</p></td>
53
							<td><p>${dent[2]}</p></td>
54
							<td><p>${((double)dent[2]).round(1)}</p></td>
55
						</tr>
56
					</g:each>
57
				</tbody>
58
			</table>
59
		</g:if>
60
		<g:else>
61
			<table>
62
				<thead>
63
					<tr>
64
						<th><p>Time</p></th>
65
						<th><p>Value (${graph.type})</p></th>
66
						<th><p>Rounded</p></th>
67
					</tr>
68
				</thead>
69
				<tbody>
70
					<g:each in="${detailedData}" var="dent">
71
						<tr>
72
							<td><p>${dent[0]}</p></td>
73
							<td><p>${dent[1]}</p></td>
74
							<td><p>${((double)dent[1]).round(1)}</p></td>
75
						</tr>
76
					</g:each>
77
				</tbody>
78
			</table>
79
		</g:else>
80
	
81
	</erptr:box>
82
	
83
	<erptr:box title="Export (save) report">
84
	
85
		<g:form method="GET" name="exportReportForm" action="exportReport" target="_blank">
86
		
87
			<label for="exportType">Export type</label>
88
			<g:select name="exportType" from="['Portable document format (.pdf)','Extensible markub language (.xml)','Comma-separated values (.csv)']" keys="['pdf','xml','csv']"></g:select>
89
			<br /><br />
90
			
91
			<g:hiddenField name="reportId" value="${graph.id}" />
92
			
93
			<g:submitButton name="exportReportSubmit" value="Export" />
94
		
95
		</g:form>
96
	
97
	</erptr:box>
98

  
99
</body>
100

  
101
</html>
hci/trunk/eneraptor-web-app/grails-app/views/statistics/newGraph.gsp
29 29
			
30 30
				<label for="timeFrameType">Time frame type</label>
31 31
				<select name="timeFrameType" id="timeFrameType" >				
32
					<option onclick="changeTimeFrameType('day')" value="day" selected="${timeFrameType == 'day'}">Daily</option>
33
					<option onclick="changeTimeFrameType('month')" value="month" selected="${timeFrameType == 'month'}">Monthly</option>
34
					<option onclick="changeTimeFrameType('year')" value="year" selected="${timeFrameType == 'year'}">Yearly</option>
35
					<option onclick="changeTimeFrameType('custom')" value="custom" selected="${timeFrameType == 'custom'}">Custom</option>
32
					<option onclick="changeTimeFrameType('day')" value="day" >Daily</option>
33
					<option onclick="changeTimeFrameType('month')" value="month" >Monthly</option>
34
					<option onclick="changeTimeFrameType('year')" value="year" >Yearly</option>
35
					<option onclick="changeTimeFrameType('custom')" value="custom" >Custom</option>
36 36
				</select>
37 37
				<br />
38 38
				
hci/trunk/eneraptor-web-app/grails-app/views/statistics/graphs.gsp
15 15
					<th><p>Graph name (short description)</p></th>
16 16
					<th><p>For device</p></th>
17 17
					<th><p>Type</p></th>
18
					<th><p>Options</p></th>
18
					<th style="width:78px;"><p>Options</p></th>
19 19
				</tr>
20 20
			</thead>
21 21
			<tbody>
22 22
				<g:each in="${savedGraphs}" var="savedGraph">
23 23
					<tr>
24
						<td><p><erptr:icon w="chart_curve" /><g:link action="showGraph" params="[graphId: savedGraph.id]">${savedGraph.name}</g:link></p></td>
24
						<td><p><erptr:icon w="chart_curve" /><g:link action="showGraph" id="${savedGraph.id}" >${savedGraph.name}</g:link></p></td>
25 25
						<td><p>${savedGraph.deviceId}</p></td>
26 26
						<td><p>${savedGraph.type}</p></td>
27
						<td><p>TODO</p></td>
27
						<td><p>
28
							<g:link action="showGraph" id="${savedGraph.id}" title="View graph only" ><erptr:icon w="chart_line" /></g:link>
29
							<g:link action="makeReport" id="${savedGraph.id}" title="Make report" ><erptr:icon w="report" /></g:link>
30
							<g:link action="editGraph" id="${savedGraph.id}" title="Edit" ><erptr:icon w="pencil" /></g:link>
31
							<g:link action="deleteGraph" id="${savedGraph.id}" title="Delete" ><erptr:icon w="delete" /></g:link>
32
						</p></td>
28 33
					</tr>
29 34
				</g:each>
30 35
			</tbody>
hci/trunk/eneraptor-web-app/grails-app/views/statistics/main.gsp
8 8
<body>
9 9
	
10 10
	<erptr:box title="Statistics">
11
		<p>TODO</p>
11
		<p>Here you can view different information gathered by Eneraptor.</p>
12
		<p>You can create many types of graphs (charts) and reports, which you can export.</p>
13
		<p>Once you <g:link action="newGraph">create a new graph</g:link>, you can find it in the <g:link action="graphs">Graphs and reports</g:link> section. There you can either view it, modify it, delete it or create a report from it.</p>
12 14
	</erptr:box>
13 15

  
14 16
</body>
hci/trunk/eneraptor-web-app/grails-app/views/statistics/newReport.gsp
1
<html>
2

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

  
8
<body>
9
	
10
	<erptr:box title="Statistics">
11
		<p>Reports are created automatically from graphs.</p>
12
		<br />
13
		<p>Please choose a graph to make report from:</p>
14
		
15
		<g:form method="GET" name="newReportForm" action="makeReport">
16
			<g:select name="id" from="${graphs}" keys="${graphsKeys}" style="width:600px;" />
17
			<br /><br />
18
			
19
			<g:submitButton name="newReportSubmit" value="View report" />
20
			
21
		</g:form>
22
		
23
	</erptr:box>
24

  
25
</body>
26

  
27
</html>
hci/trunk/eneraptor-web-app/grails-app/views/statistics/editGraph.gsp
1
<html>
2

  
3
<head>
4
	<title>Statistics &raquo; Edit graph</title>
5
	<meta name="layout" content="main" />
6
	<flot:resources />
7
</head>
8

  
9
<body>
10

  
11
	<erptr:box title="Edit graph">
12
		
13
		<g:form name="editGraphForm" action="editGraphDo">
14
		
15
			<fieldset>
16
				<legend>General information</legend>
17
				
18
				<label for="graphName">Graph name (short description)</label>
19
				<g:textField name="graphName" style="width:500px;" value="${graph.name}" />
20
				<br /><br />
21
				<label for="deviceId">Device</label>
22
				<g:select name="deviceId" from="${devicesFriendly}" keys="${devices}" value="${graph.deviceId}" />
23
				<br /><br />
24
				
25
			</fieldset>
26
			
27
			<fieldset>
28
				<legend>Graph type</legend>
29
				
30
				<label for="graphType">Calculation type</label>
31
				<g:select from="${graphTypesFriendly}" value="${graph.type}" name="graphType" keys="${graphTypes}" />
32
				<br /><br />
33
			
34
				<label for="timeFrameType">Time frame type</label>
35
				<g:select name="timeFrameType" from="['Daily','Monthly','Yearly','Custom']" keys="['day','month','year','custom']" value="${graph.timeFrameType}" />
36
				<br /><br />
37
				
38
			</fieldset>
39
			
40
			<fieldset>
41
				<legend>Main time frame</legend>
42
				
43
				<label for="mainTimeFrameStart">From</label>
44
				<g:datePicker name="mainTimeFrameStart" value="${graph.timeFrameStart}" />
45
				<br /><br />
46
				<label for="mainTimeFrameEnd">From</label>
47
				<g:datePicker name="mainTimeFrameEnd" value="${graph.timeFrameEnd}" />
48
				<br /><br />
49
				<label for="mainTimeFrameInnerSections">Number of inner intervals</label>
50
				<input onkeyup="checkInnerSections();" type="text" id="mainTimeFrameInnerSections" name="mainTimeFrameInnerSections" value="${graph.innerSections}" />
51
				<br /><br />
52
				
53
			</fieldset>
54
			
55
			<fieldset>
56
				<legend>Advanced options</legend>
57
				
58
				<label for="advHoursStart">Include only hours from</label>
59
				<g:select name="advHoursStart" from="${0..23}" value="${graph.advHoursTimeFrameStart}" />
60
				<span> to </span>
61
				<g:select name="advHoursEnd" from="${0..23}" value="${graph.advHoursTimeFrameEnd}" />
62
				<br /><br />
63
				<label for="advDayStart">Include only days from</label>
64
				<g:select name="advDayStart" from="${1..31}" value="${graph.advDayTimeFrameStart}" />
65
				<span> to </span>
66
				<g:select name="advDayEnd" from="${1..31}" value="${graph.advDayTimeFrameEnd}" />
67
				<br /><br />
68
				<label for="advMonthStart">Include only months from</label>
69
				<g:select name="advMonthStart" from="${1..12}" value="${graph.advMonthTimeFrameStart}" />
70
				<span> to </span>
71
				<g:select name="advMonthEnd" from="${1..12}" value="${graph.advMonthTimeFrameEnd}" />
72
				<br /><br />
73
				
74
			</fieldset>
75
			
76
			<g:hiddenField name="graphId" type="hidden" value="${graph.id}" />
77
			
78
			<g:submitButton name="editGraphSubmit" value="Save changes" />
79
			<g:actionSubmit name="editGraphCancel" value="Cancel" action="graphs" />
80
		
81
		</g:form>
82
		
83
	</erptr:box>
84
	
85
	<g:javascript>
86
		function checkInnerSections() {
87
			var sText = $('mainTimeFrameInnerSections').value;
88
			var validChars = "0123456789";
89
			var isNumber = true;
90
			var currChar;
91
					 
92
			for (i = 0; i < sText.length; i++) { 
93
				currChar = sText.charAt(i); 
94
				if (validChars.indexOf(currChar) == -1) {
95
					isNumber = false;
96
					break;
97
				}
98
			}
99
			
100
			if(isNumber == false) {
101
				$('mainTimeFrameInnerSections').value = sText.substring(0,(sText.length)-1)
102
			}
103
			
104
		}
105
	</g:javascript>
106

  
107
</body>
108

  
109
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo.gsp
1
<html>
2
  <head>
3
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4
    <meta name="layout" content="main" />
5
    <title>Simple PDF demo</title>
6
    <style>
7
      .code_table {
8
        width:80%;
9
        background-color:#b2b2b2;
10
      }
11
      .code_table tr {padding:2px;}
12
      .code_table td {
13
        padding:7px;
14
        background-color: #fff;
15
      }
16
    </style>
17
  </head>
18
    <body>
19
    <h1>Grails PDF Plugin demo page</h1>
20
    
21
    <h2>Tag Documentation / Live Examples / Functional Testing</h2>
22
    <h3>pdfLink tag:</h3>
23
    
24
    <table class="code_table">
25
      <thead>
26
        <tr>
27
          <th>Description</th>
28
          <th>Sample Source/HTML output</th>
29
          <th>In Action</th>
30
        </tr>
31
      </thead>
32
      <tbody>
33
        <tr><td colspan="3"><em>URL method examples:</em></td></tr>
34
        <tr>
35
          <td rowspan="2" >Simple Usage:</td>
36
          <td>
37
            <code>&lt;g:pdfLink url="/pdf/demo2"&gt;PDF View&lt;/g:pdfLink&gt;</code>
38
          </td>
39
          <td rowspan="2">
40
            <g:pdfLink url="/pdf/demo2">PDF View</g:pdfLink>
41
          </td>
42
        </tr>
43
        <tr>
44
          <td>
45
            <code>
46
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2"&gt;<br />
47
            PDF View <br />
48
            &lt;/a&gt;
49
            </code>
50
          </td>
51
        </tr>
52
        <tr>
53
          <td rowspan="2" >Simple Usage w/ Get data:</td>
54
          <td>
55
            <code>&lt;g:pdfLink url="/pdf/demo2/5?name=bob&age=22"&gt;PDF View&lt;/g:pdfLink&gt;</code>
56
          </td>
57
          <td rowspan="2">
58
            <g:pdfLink url="/pdf/demo2/5?name=bob&age=22">PDF View</g:pdfLink>
59
          </td>
60
        </tr>
61
        <tr>
62
          <td>
63
            <code>
64
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2%2F5%3Fname%3Dbob%26age%3D22"&gt;<br />
65
            PDF View <br />
66
            &lt;/a&gt;
67
            </code>
68
          </td>
69
        </tr>
70
        <tr>
71
          <td rowspan="2" >Custom filename</td>
72
          <td>
73
            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf"&gt;sample.pdf&lt;/g:pdfLink&gt;</code>
74
          </td>
75
          <td rowspan="2" > 
76
            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf">sample.pdf</g:pdfLink>
77
          </td>
78
        </tr>
79
        <tr>
80
          <td>
81
            <code>
82
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt;<br />
83
            sample.pdf<br />
84
            &lt;/a&gt;
85
            </code>
86
          </td>
87
        </tr>
88
        <tr>
89
          <td rowspan="2">Bundled icon</td>
90
          <td>
91
            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true"/&gt;</code>
92
          </td>
93
          <td rowspan="2">
94
            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true"/>
95
          </td>
96
        </tr>
97
        <tr>
98
          <td>
99
            <code>
100
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt; <br />
101
            &lt;img border="0" alt="PDF Version" src="/pdf/images/pdf_button.png" /&gt; <br />
102
            &lt;/a&gt;
103
            </code>
104
          </td>
105
        </tr>
106
        <tr>
107
          <td rowspan="2">Bundled icon w/ link content</td>
108
          <td>
109
            <code>&lt;g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true" class="myPdfLink"&gt;Custom link&lt;/g:pdfLink&gt;</code>
110
          </td>
111
          <td rowspan="2">
112
            <g:pdfLink url="/pdf/demo2.gsp" filename="sample.pdf" icon="true" class="myPdfLink">Custom link</g:pdfLink>
113
          </td>
114
        </tr>
115
        <tr>
116
          <td>
117
            <code>
118
            &lt;a class="myPdfLink" title="pdf" href="/pdf/pdf/pdfLink?url=%2Fpdf%2Fdemo2.gsp&filename=sample.pdf"&gt; <br />
119
            &lt;img border="0" alt="PDF Version" src="/pdf/images/pdf_button.png" /&gt; <br />
120
            Custom link<br />
121
            &lt;/a&gt;
122
            </code>
123
          </td>
124
        </tr>
125
        <tr><td colspan="3"><em>String method examples:</em></td></tr>
126
  %{--  <tr>
127
          <td rowspan="2" >Simple Template Usage:</td>
128
          <td>
129
            <code>&lt;g:pdfLink template="demo2"&gt;template as PDF&lt;/g:pdfLink&gt;</code>
130
          </td>
131
          <td rowspan="2">
132
            <g:pdfLink template="demo2">template as PDF</g:pdfLink>
133
          </td>
134
        </tr>
135
        <tr>
136
          <td>
137
            <code>
138
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?template=demo2&filename=document.pdf"&gt;<br />
139
            PDF View <br />
140
            &lt;/a&gt;
141
            </code>
142
          </td>
143
        </tr> --}%
144
        <tr>
145
          <td rowspan="2" >Simple Controller Action Usage (action and id are optional):</td>
146
          <td>
147
            <code>&lt;g:pdfLink pdfController="pdf" pdfAction="demo2"&gt;GSP as PDF&lt;/g:pdfLink&gt;</code>
148
          </td>
149
          <td rowspan="2">
150
            <g:pdfLink pdfController="pdf" pdfAction="demo2">GSP as PDF</g:pdfLink>
151
          </td>
152
        </tr>
153
        <tr>
154
          <td>
155
            <code>
156
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2"&gt;<br />
157
            PDF View <br />
158
            &lt;/a&gt;
159
            </code>
160
          </td>
161
        </tr>
162
        <tr>
163
          <td rowspan="2" >Simple Controller Action + Id Usage:</td>
164
          <td>
165
            <code>&lt;g:pdfLink pdfController="pdf" pdfAction="demo2" pdfId="65432"&gt;GSP as PDF&lt;/g:pdfLink&gt;</code>
166
          </td>
167
          <td rowspan="2">
168
            <g:pdfLink pdfController="pdf" pdfAction="demo2" pdfId="65432">GSP as PDF</g:pdfLink>
169
          </td>
170
        </tr>
171
        <tr>
172
          <td>
173
            <code>
174
            &lt;a class="pdf" title="pdf" href="/pdf/pdf/pdfLink?&pdfController=pdf&pdfAction=demo2&pdfId=65432"&gt;<br />
175
            PDF View <br />
176
            &lt;/a&gt;
177
            </code>
178
          </td>
179
        </tr>
180
      </tbody>
181
    </table>
182
    
183
    <h3>pdfForm tag:</h3>
184
    <table class="code_table">
185
      <thead>
186
        <tr>
187
          <th>Description</th>
188
          <th>Sample Source/HTML output</th>
189
          <th>In Action</th>
190
        </tr>
191
      </thead>
192
      <tbody>
193
        <tr><td colspan="3"><em>GET method examples:</em></td></tr>
194
        <tr>
195
          <td rowspan="2" >Simple Usage:</td>
196
          <td>
197
            <code>&lt;g:pdfForm url="/pdf/demo2"&gt;...&lt;/g:pdfForm&gt;</code>
198
          </td>
199
          <td rowspan="2">
200
            <g:pdfForm url="/pdf/demo2" >
201
            name:<br />
202
            <g:textField name="name" size="10"/>
203
            <g:submitButton name="printPdf" value="pdf" />
204
            </g:pdfForm>
205
          </td>
206
        </tr>
207
        <tr>
208
          <td>
209
            <code>
210
            &lt;form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
211
            &lt;input type="hidden" value="/pdf/demo2" name="url"/&gt;<br />
212
            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
213
            ...<br /> 
214
            &lt;/form&gt;</code>
215
          </td>
216
        </tr>
217
        <tr>
218
          <td rowspan="2" >w/ Id and Filename:</td>
219
          <td>
220
            <code>&lt;g:pdfForm url="/pdf/demo2/1968" filename="sample.pdf"&gt;...&lt;/g:pdfForm&gt;</code>
221
          </td>
222
          <td rowspan="2">
223
            <g:pdfForm url="/pdf/demo2/1968" filename="sample.pdf">
224
            age:<br />
225
            <g:textField name="age" size="3"/>
226
            <g:submitButton name="printPdf" value="pdf" />
227
            </g:pdfForm>
228
          </td>
229
        </tr>
230
        <tr>
231
          <td>
232
            <code>
233
            &lt;form id="simplePdfForm" method="get" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
234
            &lt;input type="hidden" value="/pdf/demo2/1968" name="url"/&gt;<br />
235
            &lt;input type="hidden" value="sample.pdf" name="filename"/&gt;<br />
236
            ...<br /> 
237
            &lt;/form&gt;
238
            </code>
239
          </td>
240
        </tr>
241
        <tr><td colspan="3"><em>POST method examples:</em></td></tr>
242
        <tr>
243
          <td rowspan="2" >Controller and Action:</td>
244
          <td>
245
            <code>&lt;g:pdfForm controller="pdf" action="demo3" method="post"&gt;...&lt;/g:pdfForm&gt;</code>
246
          </td>
247
          <td rowspan="2">
248
            <g:pdfForm controller="pdf" action="demo3" method="post" >
249
            food:<br />
250
            <g:textField name="food" size="10"/>
251
            <g:submitButton name="printPdf" value="pdf" />
252
            </g:pdfForm>
253
          </td>
254
        </tr>
255
        <tr>
256
          <td>
257
            <code>
258
            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
259
            &lt;input type="hidden" value="pdf" name="pdfController"/&gt;<br />
260
            &lt;input type="hidden" value="demo3" name="pdfAction"/&gt;<br />
261
            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
262
            ...<br /> 
263
            &lt;/form&gt;
264
            </code>
265
          </td>
266
        </tr>
267
        <tr>
268
          <td rowspan="2" >Controller, Action, Id and Filename:</td>
269
          <td>
270
            <code>&lt;g:pdfForm controller="pdf" action="demo3" method="post"&gt;...&lt;/g:pdfForm&gt;</code>
271
          </td>
272
          <td rowspan="2">
273
            <g:pdfForm controller="pdf" action="demo3" id="1942" method="post" filename="sample.pdf" >
274
            food:<br />
275
            <g:textField name="food" size="10"/>
276
            <g:submitButton name="printPdf" value="pdf" />
277
            </g:pdfForm>
278
          </td>
279
        </tr>
280
        <tr>
281
          <td>
282
            <code>
283
            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm" name="simplePdfForm"&gt;<br />
284
            &lt;input type="hidden" value="pdf" name="pdfController"/&gt;<br />
285
            &lt;input type="hidden" value="demo3" name="pdfAction"/&gt;<br />
286
            &lt;input type="hidden" value="document.pdf" name="filename"/&gt;<br />
287
            ...<br /> 
288
            &lt;/form&gt;
289
            </code>
290
          </td>
291
        </tr>
292
        <tr>
293
          <td rowspan="2" >Template:</td>
294
          <td>
295
            <code>&lt;g:pdfForm template="demo2" &gt;...&lt;/g:pdfForm&gt;</code>
296
          </td>
297
          <td rowspan="2">
298
            <g:pdfForm template="demo2" method="post">
299
            hometown:<br />
300
            <g:textField name="hometown" size="10"/>
301
            <g:submitButton name="printPdf" value="pdf" />
302
            </g:pdfForm>
303
          </td>
304
        </tr>
305
        <tr>
306
          <td>
307
            <code>
308
            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm"&gt;<br />
309
            &lt;input type="hidden" value="demo2" name="template"/&gt;<br />
310
            ...<br /> 
311
            &lt;/form&gt;
312
            </code>
313
          </td>
314
        </tr>
315
        <tr>
316
          <td rowspan="2" >Template and Filename:</td>
317
          <td>
318
            <code>&lt;g:pdfForm template="demo2" filename="sample.pdf"&gt;...&lt;/g:pdfForm&gt;</code>
319
          </td>
320
          <td rowspan="2">
321
            <g:pdfForm template="demo2" filename="sample.pdf" method="post">
322
            hometown:<br />
323
            <g:textField name="hometown" size="10"/>
324
            <g:submitButton name="printPdf" value="pdf" />
325
            </g:pdfForm>
326
          </td>
327
        </tr>
328
        <tr>
329
          <td>
330
            <code>
331
            &lt;form id="simplePdfForm" method="post" action="/pdf/pdf/pdfForm2" name="simplePdfForm"&gt;<br />
332
            &lt;input type="hidden" value="demo2" name="template"/&gt;<br />
333
            &lt;input type="hidden" value="sample.pdf" name="filename"/&gt;<br />
334
            ...<br /> 
335
            &lt;/form&gt;
336
            </code>
337
          </td>
338
        </tr>
339
      </tbody>
340
    </table>
341
  </body>
342
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/_demo2.gsp
1
<html>
2
  <head>
3
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4
    <title>Simple PDF demo2</title>
5
    <style>
6
      .sample_table {
7
        width:60%;
8
        background-color:#b2b2b2;
9
      }
10
      .sample_table th {
11
        text-align:center;
12
        text-decoration:underline;
13
      }
14
      .sample_table td {
15
        padding:7px;
16
        background-color: #fff;
17
      }
18
      .small_text {
19
        font-size:8pt;
20
      }
21
    </style>
22
  </head>
23
  <body>
24
    <h1>Sample PDF Output</h1>
25
    <h2>This is simple HTML</h2>
26
    <h2 style='color:red'>this has inline CSS</h2>
27
    
28
    <h3>Here is some data passed from the contorller...</h3>
29
    <p>Information gathered from the controller: ${randomString}</p>
30
    
31
    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
32
    <table class="sample_table">
33
      <thead>
34
        <tr>
35
          <th>ID</th>
36
          <th>Name</th>
37
          <th>Age</th>
38
        </tr>
39
      </thead>
40
      <tbody>
41
        <tr>
42
          <td>${id}</td>
43
          <td>${name}</td>
44
          <td>${age}</td>
45
        </tr>
46
        <tr>
47
          <td colspan="3" class="small_text">styled with css...</td>
48
        </tr>
49
      </tbody>
50
    </table> 
51
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
52
    
53
    <form>
54
      <p>checkbox:
55
    %{--	checkboxes used to cause an error in pdf generation, but now they simply don't show up...   --}%
56
        <input type="checkbox" checked="checked" name="sample_box" title="sample_box" /> 
57
      </p>
58
  %{--    text field sample   --}%
59
      <p>Text Input:
60
       <input name="textField" />
61
      </p>
62
    </form>
63
    
64
    <h3>Here is some information gathered from a form and handled grails render method (post variables):</h3>
65
    <p>Favorite food: ${pdf?.food}</p>
66
    <p>Favorite food: ${pdf?.food.toString()}</p>
67
    <p>Hometown: ${pdf?.hometown}</p> 
68
    
69
    <p>${pdf}</p>
70
    
71
    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
72
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
73
    
74
    <p>Images with absolute URI's also do just fine:</p>
75
    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
76
    
77
    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
78
  </body>
79
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/sampleInclude.gsp
1
<html>
2
  <head>
3
  </head>
4
  <body>
5
    <h1>hello world!</h1>
6
    <p>${bar}</p>
7
    <p>${today}</p>
8
    <p>${tomorrow}</p>
9
  </body>
10
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo2.gsp
1
<html>
2
  <head>
3
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4
    <title>Simple PDF demo2</title>
5
    <style>
6
      .sample_table {
7
        width:60%;
8
        background-color:#b2b2b2;
9
      }
10
      .sample_table th {
11
        text-align:center;
12
        text-decoration:underline;
13
      }
14
      .sample_table td {
15
        padding:7px;
16
        background-color: #fff;
17
      }
18
      .small_text {
19
        font-size:8pt;
20
      }
21
    </style>
22
  </head>
23
  <body>
24
    <h1>Sample PDF Output</h1>
25
    <h2>This is simple HTML</h2>
26
    <h2 style='color:red'>this has inline CSS</h2>
27
    
28
    <h3>Here is some data passed from the contorller...</h3>
29
    <p>Information gathered from the controller: ${randomString}</p>
30
    
31
    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
32
    <table class="sample_table">
33
      <thead>
34
        <tr>
35
          <th>ID</th>
36
          <th>Name</th>
37
          <th>Age</th>
38
        </tr>
39
      </thead>
40
      <tbody>
41
        <tr>
42
          <td>${id}</td>
43
          <td>${name}</td>
44
          <td>${age}</td>
45
        </tr>
46
        <tr>
47
          <td colspan="3" class="small_text">styled with css...</td>
48
        </tr>
49
      </tbody>
50
    </table> 
51
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
52
    
53
    <form>
54
      <p>checkbox:
55
    %{--	checkboxes used to cause an error in pdf generation, but now they simply don't show up...   --}%
56
        <input type="checkbox" checked="checked" name="sample_box" title="sample_box" /> 
57
      </p>
58
  %{--    text field sample   --}%
59
      <p>Text Input:
60
       <input name="textField" />
61
      </p>
62
    </form>
63
    
64
    
65
    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
66
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
67
    
68
    <p>Images with absolute URI's also do just fine:</p>
69
    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
70
    
71
    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
72
  </body>
73
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/demo3.gsp
1
<html>
2
  <head>
3
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4
    <meta name="layout" content="main" />
5
    <title>Simple PDF demo2</title>
6
    <style>
7
      .sample_table {
8
        width:60%;
9
        background-color:#b2b2b2;
10
      }
11
      .sample_table th {
12
        text-align:center;
13
        text-decoration:underline;
14
      }
15
      .sample_table td {
16
        padding:7px;
17
        background-color: #fff;
18
      }
19
      .small_text {
20
        font-size:8pt;
21
      }
22
    </style>
23
  </head>
24
  <body>
25
    <h1>Sample PDF Output</h1>
26
    <h2>This is simple HTML</h2>
27
    <h2 style='color:red'>this has inline CSS</h2>
28
    
29
    <h3>Here is some data passed from the contorller...</h3>
30
    <p>Information gathered from the controller: ${randomString}</p>
31
    
32
    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
33
    <table class="sample_table">
34
      <thead>
35
        <tr>
36
          <th>ID</th>
37
          <th>Name</th>
38
          <th>Age</th>
39
        </tr>
40
      </thead>
41
      <tbody>
42
        <tr>
43
          <td>${id}</td>
44
          <td>${name}</td>
45
          <td>${age}</td>
46
        </tr>
47
        <tr>
48
          <td colspan="3" class="small_text">styled with css...</td>
49
        </tr>
50
      </tbody>
51
    </table> 
52
    
53
    <h3>Here is some information gathered from a form and handled by a controller (post variables):</h3>
54
    <p>Favorite food: ${pdf?.food}</p>
55
    <p>Favorite food: ${pdf?.food.toString()}</p>
56
    <p>Hometown: ${pdf?.hometown}</p> 
57
    
58
    <p>${pdf}</p>
59
    
60
    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
61
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
62
    
63
    <p>Images with absolute URI's also do just fine:</p>
64
    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
65
    
66
    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
67
    
68
    <p>Varialbles passed into gsp that the plugin will render as PDF need to start with pdf. so for example the form field name was hometown and to reference that varialbe here we needed {pdf.hometown}</p>
69
    <code>
70
      ${content}
71
    </code>
72
  </body>
73
</html>
hci/trunk/eneraptor-web-app/grails-app/views/pdf/reportToPdf.gsp
1
<html>
2

  
3
<head>
4
	<title>Report</title>
5
	<style>
6
	body {
7
		font-family: monospace;
8
		font-size: small;
9
	}
10
	table {
11
		width:100%;
12
	}
13
	</style>
14
</head>
15

  
16
<body>
17

  
18
	<h1>${graph.name}</h1>
19
	<h2>Report info</h2>
20
	
21
	<p>Type: <b>${graph.type}</b> / <b>${graph.timeFrameType}</b><br />
22
	From <b>${graph.timeFrameStart}</b> till <b>${graph.timeFrameEnd}</b><br />
23
	Device ID: <b>${graph.deviceId}</b></p>
24
	
25
	<h2>Report data</h2>
26
	
27
	<g:if test="${graph.timeFrameType == 'custom'}">
28
		<table>
29
			<thead>
30
				<tr>
31
					<th>From</th>
32
					<th>Till</th>
33
					<th>Value (${graph.type})</th>
34
					<th>Rounded</th>
35
				</tr>
36
			</thead>
37
			<tbody>
38
				<g:each in="${detailedData}" var="dent">
39
					<tr>
40
						<td>${dent[0]}</td>
41
						<td>${dent[1]}</td>
42
						<td>${dent[2]}</td>
43
						<td>${((double)dent[2]).round(1)}</td>
44
					</tr>
45
				</g:each>
46
			</tbody>
47
		</table>
48
	</g:if>
49
	<g:else>
50
		<table>
51
			<thead>
52
				<tr>
53
					<th>Time</th>
54
					<th>Value (${graph.type})</th>
55
					<th>Rounded</th>
56
				</tr>
57
			</thead>
58
			<tbody>
59
				<g:each in="${detailedData}" var="dent">
60
					<tr>
61
						<td>${dent[0]}</td>
62
						<td>${dent[1]}</td>
63
						<td>${((double)dent[1]).round(1)}</td>
64
					</tr>
65
				</g:each>
66
			</tbody>
67
		</table>
68
	</g:else>
69

  
70
</body>
71

  
72
</html>
hci/trunk/eneraptor-web-app/.classpath
31 31
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
32 32
		</attributes>
33 33
	</classpathentry>
34
	<classpathentry excluding="BuildConfig.groovy|*DataSource.groovy|UrlMappings.groovy|Config.groovy|BootStrap.groovy|spring/resources.groovy" kind="src" path="shiro-1.1.2-grails-app-conf">
34
	<classpathentry kind="src" path="pdf-0.6-grails-app-controllers">
35 35
		<attributes>
36 36
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
37 37
		</attributes>
38 38
	</classpathentry>
39
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-controllers">
39
	<classpathentry kind="src" path="pdf-0.6-grails-app-i18n">
40 40
		<attributes>
41 41
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
42 42
		</attributes>
43 43
	</classpathentry>
44
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-domain">
44
	<classpathentry kind="src" path="pdf-0.6-grails-app-services">
45 45
		<attributes>
46 46
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
47 47
		</attributes>
48 48
	</classpathentry>
49
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-i18n">
49
	<classpathentry kind="src" path="pdf-0.6-grails-app-taglib">
50 50
		<attributes>
51 51
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
52 52
		</attributes>
53 53
	</classpathentry>
54
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-realms">
54
	<classpathentry kind="src" path="pdf-0.6-grails-app-views">
55 55
		<attributes>
56 56
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
57 57
		</attributes>
58 58
	</classpathentry>
59
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-services">
60
		<attributes>
61
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
62
		</attributes>
63
	</classpathentry>
64
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-taglib">
65
		<attributes>
66
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
67
		</attributes>
68
	</classpathentry>
69
	<classpathentry kind="src" path="shiro-1.1.2-grails-app-views">
70
		<attributes>
71
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
72
		</attributes>
73
	</classpathentry>
74
	<classpathentry kind="src" path="shiro-1.1.2-src-java">
75
		<attributes>
76
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
77
		</attributes>
78
	</classpathentry>
79
	<classpathentry kind="src" path="shiro-1.1.2-src-groovy">
80
		<attributes>
81
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
82
		</attributes>
83
	</classpathentry>
84 59
	<classpathentry kind="src" path="tomcat-1.3.6-src-groovy">
85 60
		<attributes>
86 61
			<attribute name="com.springsource.sts.grails.core.SOURCE_FOLDER" value="true"/>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff