Statistics
| Revision:

root / hci / trunk / eneraptor-web-app / grails-app / controllers / com / eneraptor / hci / ConfigController.groovy @ 3

History | View | Annotate | Download (1.25 KB)

1
package com.eneraptor.hci
2

    
3
class ConfigController {
4

    
5
    def main = { }
6
        
7
        def hci = {
8
        
9
                def allDevices = DeviceInfo.list()
10
                [conf: InternalConfig, devices: allDevices]                
11
        }
12
        
13
        def addDevice = {
14
        }
15
        
16
        def addDeviceSave = {
17
                def newDevice = new DeviceInfo(params)
18
                if(newDevice.validate()) {
19
                        newDevice.save()
20
                        flash['confirms'] = "<p>New device added successfully.</p>"
21
                        redirect(action:'hci')
22
                } else {
23
                        flash['errors'] = "<p>New device was not saved. Check input data.</p>"
24
                        redirect(action:'addDevice', params: params)
25
                }
26
        }
27
        
28
        def logic = {
29
                
30
                [conf: InternalConfig]
31
                
32
        }
33
        
34
        def connection = {
35
                
36
                [conf: InternalConfig]
37
                
38
        }
39
        
40
        def saveConnection = {
41
                
42
                if(params['logic-ip'] == 'localhost') params['logic-ip'] = '127.0.0.1'
43
                
44
                if(params['logic-ip'] && params['logic-port']) {
45
                        InternalConfig.findByConfigId('logic-ip').configVal = params['logic-ip']
46
                        InternalConfig.findByConfigId('logic-port').configVal = params['logic-port']
47
                        flash['confirms'] = "<p>Changes saved.</p>"
48
                        redirect(action: 'connection')
49
                } else {
50
                        flash['errors'] = "<p>Logic IP address and port fields cannot be blank.</p>"
51
                        redirect(action: 'connection')
52
                }
53
                
54
        }
55
        
56
        def getHelp = {
57
                [what : params.what]
58
        }
59
        
60
}