Revision 66 hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/ConfigController.groovy

View differences:

ConfigController.groovy
33 33
		
34 34
		*/
35 35
		
36
		def allDevices = DeviceInfo.list()
36
		def allDevices = HardwareSet.get(session.hwSet.id).devices
37
		
37 38
		[conf: InternalConfig, devices: allDevices, totalSpace: totalSpace, freeSpace: freeSpace, percent: percent]		
38 39
	}
39 40
	
......
42 43
	
43 44
	def addDeviceSave = {
44 45
		def newDevice = new DeviceInfo(params)
46
		HardwareSet.get(session.hwSet.id).addToDevices(newDevice)
45 47
		if(newDevice.validate() && (params.inputDevice || params.outputDevice)) {
46 48
			newDevice.save()
47 49
			flash['confirms'] = "<p>New device added successfully.</p>"
......
107 109
	
108 110
	def logic = {
109 111
		
110
		[conf: InternalConfig]
112
		def hwSet = session.hwSet
111 113
		
114
		[hwSet:hwSet]
115
		
112 116
	}
113 117
	
114 118
	def connection = {
115 119
		
116
		[conf: InternalConfig]
120
		def hwSet = session.hwSet
117 121
		
122
		[hwSet: hwSet]
123
		
118 124
	}
119 125
	
120 126
	def saveConnection = {
121 127
		
122 128
		if(params['logic-ip'] == 'localhost') params['logic-ip'] = '127.0.0.1'
123 129
		
124
		if(params['logic-ip'] && params['logic-port']) {
125
			InternalConfig.findByConfigId('logic-ip').configVal = params['logic-ip']
126
			InternalConfig.findByConfigId('logic-port').configVal = params['logic-port']
130
		if(params['logic-ip'] && params['logic-port'] && params['logic-port'].isInteger()) {
131
			
132
			session.hwSet.IPaddress = params['logic-ip']
133
			session.hwSet.portNumber = (params['logic-port'] as int)
127 134
			flash['confirms'] = "<p>Changes saved.</p>"
128 135
			redirect(action: 'connection')
129 136
		} else {
130
			flash['errors'] = "<p>Logic IP address and port fields cannot be blank.</p>"
137
			flash['errors'] = "<p>Could not save changes.</p><p>Logic IP address and port fields cannot be blank. Port number must be an integer.</p>"
131 138
			redirect(action: 'connection')
132 139
		}
133 140
		
......
171 178
	def getHelp = {
172 179
		[what : params.what]
173 180
	}
181
	
182
	def database = { }
174 183
	
175 184
}

Also available in: Unified diff