root / hci / trunk / eneraptor-web-app / grails-app / controllers / com / eneraptor / hci / SysLogController.groovy @ 6
History | View | Annotate | Download (1.62 KB)
1 |
package com.eneraptor.hci
|
---|---|
2 |
|
3 |
class SysLogController { |
4 |
|
5 |
def index = { }
|
6 |
|
7 |
def main = {
|
8 |
|
9 |
} |
10 |
|
11 |
def browse = {
|
12 |
|
13 |
flash['warnings'] = null |
14 |
|
15 |
def entries = LoggedData.list()
|
16 |
Map devices = new HashMap() |
17 |
Map icons = new HashMap() |
18 |
List unknownDevices = new ArrayList() |
19 |
DeviceInfo.list().each { |
20 |
devices[it.deviceId] = it.friendlyName |
21 |
if(it.iconPath) { |
22 |
icons[it.deviceId] = it.iconPath |
23 |
} |
24 |
} |
25 |
entries.each { |
26 |
if(!devices[it.deviceId]) { |
27 |
if(!unknownDevices.contains(it.deviceId)) { |
28 |
unknownDevices << it.deviceId
|
29 |
} |
30 |
} |
31 |
} |
32 |
unknownDevices.each { |
33 |
if(!flash['warnings']) flash['warnings'] = "" |
34 |
flash['warnings'] += "<p>There was found at least one log entry for a device with id <b>${it}</b>, which is <b>unknown</b> to HCI. You should <b>add this device</b> by <b>" + g.link(controller: 'config', action: 'addDevice', params: ['deviceId' : it], "clicking here") + "</b>.</p>" |
35 |
} |
36 |
|
37 |
[data: entries, devices: devices, icons: icons] |
38 |
|
39 |
} |
40 |
|
41 |
def detail = {
|
42 |
|
43 |
def detailsOf = LoggedData.findById(params.id)
|
44 |
if(!detailsOf) {
|
45 |
flash['errors'] = "<p>There is no logged data with id ${params.id}</p>" |
46 |
redirect(action: 'browse') |
47 |
return false |
48 |
} |
49 |
return detailsOf.getProperties()
|
50 |
} |
51 |
|
52 |
def deleteEntry = {
|
53 |
|
54 |
def entry = LoggedData.findById(params.id)
|
55 |
if(entry) {
|
56 |
entry.delete() |
57 |
flash['confirms'] = "<p>Log entry with id " + params.id + " deleted successfully.</p>" |
58 |
redirect(action: 'browse') |
59 |
} else {
|
60 |
flash['errors'] = "<p>Cannot find log entry with id " + params.id + "</p>" |
61 |
redirect(action: 'browse') |
62 |
} |
63 |
|
64 |
} |
65 |
|
66 |
} |