root / hci / trunk / eneraptor-web-app / grails-app / controllers / com / eneraptor / hci / ChooseHwSetController.groovy @ 66
History | View | Annotate | Download (1.58 KB)
1 |
package com.eneraptor.hci
|
---|---|
2 |
|
3 |
class ChooseHwSetController { |
4 |
|
5 |
def index = { }
|
6 |
|
7 |
def main = {
|
8 |
|
9 |
def hwSets = HardwareSet.list()
|
10 |
|
11 |
[hwSets: hwSets]
|
12 |
|
13 |
} |
14 |
|
15 |
def mainDo = {
|
16 |
|
17 |
HardwareSet chosenHwSet = HardwareSet.get(params['hwSet'])
|
18 |
|
19 |
if(chosenHwSet) {
|
20 |
|
21 |
session['hwSet'] = chosenHwSet
|
22 |
redirect(controller:'sysState',action:'main') |
23 |
return true |
24 |
|
25 |
} |
26 |
|
27 |
redirect(action:'main') |
28 |
return false |
29 |
|
30 |
} |
31 |
|
32 |
def addNew = { }
|
33 |
|
34 |
def addNewDo = {
|
35 |
|
36 |
HardwareSet newHwSet = new HardwareSet(params)
|
37 |
|
38 |
if(!newHwSet.validate()) {
|
39 |
redirect(action:'addNew',params:(params << ['invalid':true])) |
40 |
return false |
41 |
} else {
|
42 |
newHwSet.save() |
43 |
redirect(action:main)
|
44 |
return true |
45 |
} |
46 |
|
47 |
} |
48 |
|
49 |
def change = {
|
50 |
|
51 |
def chosenHwSet = HardwareSet.get(params.id)
|
52 |
|
53 |
if(chosenHwSet) {
|
54 |
session['hwSet'] = chosenHwSet
|
55 |
flash.confirms = "<p>Changed current hardware set to " + chosenHwSet.name + "</p>" |
56 |
redirect(controller:'sysState',action:'main') |
57 |
return true |
58 |
} else {
|
59 |
flash.errors = "<p>Could not change current hardware set (card). The ID specified is not valid!</p>"
|
60 |
redirect(controller:'sysState',action:'main') |
61 |
} |
62 |
|
63 |
return false |
64 |
|
65 |
} |
66 |
|
67 |
def delete = {
|
68 |
|
69 |
def hwSet = HardwareSet.get(params['id']) |
70 |
|
71 |
if(hwSet) {
|
72 |
|
73 |
session.hwSet = null
|
74 |
hwSet.delete() |
75 |
redirect(action:'main') |
76 |
return true |
77 |
|
78 |
} else {
|
79 |
flash.errors = '<p>Could not delete hardware set (card). The ID specified is invalid.</p>'
|
80 |
redirect(controller:'config',action:'logic') |
81 |
return false |
82 |
} |
83 |
|
84 |
} |
85 |
|
86 |
} |