Revision 11 hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy

View differences:

SysLogController.groovy
1 1
package com.eneraptor.hci
2 2

  
3
import groovy.sql.*
4
import java.sql.*
5

  
3 6
class SysLogController {
4

  
7

  
8
	def dataSource
9
	
5 10
    def index = { }
6 11
	
7 12
	def main = {
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
		
27
		[totalSpace: totalSpace, freeSpace: freeSpace, percent: percent]
28
		
9 29
	}
10 30
	
11 31
	def browse = {
......
62 82
		}
63 83
		
64 84
	}
85
	
86
	def graph = {
87
		
88
		List devices = new ArrayList()
89
		List data = new ArrayList()
90
		
91
		DeviceInfo.findAllByInputDevice(true).each {
92
			devices << it
93
		}
94
		
95
		if(params['dataList'])
96
			data = params['dataList']
97
		else if(params['deviceId'] && params['fromDate'] && params['tillDate']) {
98
			
99
			def c = LoggedData.createCriteria()
100
			def results = c {
101
				and {
102
					eq("deviceId",params['deviceId'])
103
					between("dateRecieved",params['fromDate'],params['tillDate'])
104
				}
105
				order("dateRecieved","asc")
106
			}
107
			
108
			results.each {
109
				data << [it.dateRecieved.getTime(),it.reportedData]
110
			}
111
			
112
		}
113
		
114
		[data: data, devices: devices, params:params]
115
		
116
	}
65 117
	
66 118
}

Also available in: Unified diff