/
ic_deviceFirmwareOverview.cgi
executable file
·351 lines (288 loc) · 13.9 KB
/
ic_deviceFirmwareOverview.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/bin/tclsh
source once.tcl
sourceOnce cgi.tcl
sourceOnce session.tcl
sourceOnce ic_common.tcl
sourceOnce common.tcl
loadOnce tclrpc.so
proc logDeviceAttributes {} {
global dev_descr
foreach val [array names dev_descr] {
puts "$val: $dev_descr($val)<br/>"
}
puts "<br/><br/>"
}
proc put_error {iface address} {
puts "<div id=\"ic_deviceparameters\">"
puts "<div id=\"id_body\">"
puts "Das Gerät mit der Seriennummer '$address' vom Interface '$iface' konnte nicht abgefragt werden!"
puts "</div>"
puts "</div>"
puts "</div>"
}
proc put_headerElem {} {
# The hidden input fields are necessary for the js function "FirmwareUpdate()"
puts "<input type=\"text\" id=\"global_iface\" class=\"hidden\">"
puts "<input type=\"text\" id=\"global_address\" class=\"hidden\">"
puts "<table id=\"devFwOverview\" cellspacing=\"0\" cellpadding=\"0\" class=\"tTable filterTable\">"
puts "<colgroup>"
puts "<col style=\"width:35%;\"/>"
puts "<col style=\"width:20%;\"/>"
puts "<col style=\"width:55px;\"/>"
puts "<col style=\"width:10%;\"/>"
puts "<col style=\"width:10%;\"/>"
puts "<col style=\"width:10%;\"/>"
# puts "<col style=\"width:10%;\"/>"
puts "<col style=\"width:auto;\"/>"
puts "</colgroup>"
puts "<th class=\"DeviceListHead\">\${thName}</th>"
puts "<th class=\"DeviceListHead\">\${thTypeDescriptor}</th>"
puts "<th class=\"DeviceListHead\">\${thPicture}</th>"
puts "<th class=\"DeviceListHead\">\${thSerialNumber}</th>"
puts "<th class=\"DeviceListHead\">\${thFirmware}</th>"
puts "<th class=\"DeviceListHead\">\${firmwareAvailOnCCU}</th>"
# puts "<th class=\"DeviceListHead\">Firmware state</th>"
puts "<th class=\"DeviceListHead\">\${thAction}</th>"
put_filter
puts "<script type=\"text/javascript\">"
puts "setGlobalIfaceAddress = function(iface, address) {"
puts "jQuery(\"#global_iface\").val(iface);"
puts "jQuery(\"#global_address\").val(address);"
puts "};"
puts "</script>"
}
proc getFilterElement {param} {
set html ""
append html "<div class=\"FilterCaption\" name=\"thFilter\" onclick=\"showFilter('filter_$param');\">Filter</div>"
append html "<div class=\"FilterBodyWrapper\" id=\"filter_$param\" style=\"display:none;\">"
append html "<div class=\"FilterBody\">"
append html "<input class=\"FilterText\" id=\"searchText_$param\" name=\"DeviceListPage.NameFilterText\" value=\"\" type=\"text\" onkeypress=\"checkEnterEsc(this.id, event.keyCode);\">"
append html "<div class=\"FilterButton\" name=\"filterSet\" onclick=\"setFilter('filter_$param');\">Setzen</div>"
append html "<div class=\"FilterButton\" name=\"filterClose\" onclick=\"closeFilter('filter_$param');\">Schliessen</div>"
append html "</div>"
append html "</div>"
return $html
}
proc put_filter {} {
puts "<tr>"
puts "<th class=\"Filter\" style=\"height:20px\">[getFilterElement NAME]</th>"
puts "<th class=\"Filter\">[getFilterElement TYPE]</th>"
puts "<th class=\"Filter\"></th>"
puts "<th class=\"Filter\">[getFilterElement ADDRESS]</th>"
puts "<th class=\"Filter\"></th>"
puts "<th class=\"Filter\"></th>"
puts "<th class=\"Filter\"></th>"
puts "</tr>"
}
proc put_end_body {} {
puts "</table>"
puts "<script type=\"text/javascript\">"
puts "translatePage(\"#devFwOverview\");"
puts "</script>"
}
proc getHTML {val} {
global iface dev_descr
set bidcosWiredID "BidCos-Wired"
set tdID ""
set html ""
if { ! [catch {set tmp $dev_descr($val)}] } {
set value $dev_descr($val)
if {[string equal $val "AVAILABLE_FIRMWARE"] == 1} {
if {([string equal $value "0.0"] == 1) || ([string equal $value "0.0.0"] == 1) || ([string equal $iface $bidcosWiredID] == 1)} {
# set value $dev_descr(FIRMWARE)
set value " -- "
}
}
if {[string equal $val "FIRMWARE"] == 1} {
set html "<td id='deviceFirmware_$dev_descr(ADDRESS)' name='$val'>$value</td>"
} else {
set html "<td name='$val'>$value</td>"
}
} else {
set html "<td name='$val'> -- </td>"
}
return $html
}
proc getActionPanel {} {
global dev_descr iface
set HmIPIdentifier "HmIP-RF"
set fw_update_rows ""
# This was the initial test button > set html "<td><div class=\"DeviceListButton\" name=\"btnConfigure\" onclick=\"alert('OK');\">Einstellen</div><td>"
set tableCell "<table id=\"id_firmware_table_$dev_descr(ADDRESS)\" class=\"j_translate tTable filterTable noBorder marginAuto\" style=cellspacing=\"0\">"
if {$iface != $HmIPIdentifier} {
catch {
if {([string equal $dev_descr(AVAILABLE_FIRMWARE) "0.0.0"] != 1) && ($dev_descr(AVAILABLE_FIRMWARE) != $dev_descr(FIRMWARE))} then {
set fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22007 noBorder\" ><span onclick=\"setGlobalIfaceAddress('$iface', '$dev_descr(ADDRESS)');FirmwareUpdate('$dev_descr(TYPE)');\" class=\"CLASS21000\">\${lblUpdate}</span></td></tr>"
} else {
# set fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22008 noBorder\">- -</td></tr>"
set fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22008 noBorder\"></td></tr>"
}
}
} else {
# This is a HmIP device
if {[catch {set firmwareUpdateState $dev_descr(FIRMWARE_UPDATE_STATE)}] == 0} {
switch $firmwareUpdateState {
"PERFORMING_UPDATE" {
set fw_update_rows "<tr><td class=\"_CLASS22006 noBorder\">\${lblDeviceFwPerformUpdate}</td></tr>"
}
"NEW_FIRMWARE_AVAILABLE" -
"DELIVER_FIRMWARE_IMAGE" {
set helpIdentifier "j_hmIPDeliverFirmwareHelp"
if {[catch {set devType $dev_descr(TYPE)}] == 0} {
if {[string first HmIPW- $devType] != -1} {
set helpIdentifier "j_hmIPWDeliverFirmwareHelp"
}
}
set fw_update_rows "<tr><td class=\"_CLASS22008 noBorder\"><div>\${lblDeviceFwDeliverFwImage}</div><div class=\"StdTableBtnHelp\"><img class=$helpIdentifier height=\"24\" width=\"24\"src=\"/ise/img/help.png\"></div></td></tr>"
}
"DO_UPDATE_PENDING" -
"READY_FOR_UPDATE" {
# set fw_update_rows "<tr><td>\${lblAvailableFirmwareVersion}</td><td class=\"_CLASS22006\">$dev_descr(AVAILABLE_FIRMWARE)</td></tr>"
append fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22007 noBorder\"><span onclick=\"setGlobalIfaceAddress('$iface', '$dev_descr(ADDRESS)');FirmwareUpdate('$dev_descr(TYPE)');\" class=\"CLASS21000\">\${lblUpdate}</span></td></tr>"
}
"LIVE_NEW_FIRMWARE_AVAILABLE" {
#new live update firmware available -> show update button if device supports it
#i.e. hap and drap versions smaller than 2.1 do not support it, so we check that here
if { (([string compare "HmIPW-DRAP" $dev_descr(TYPE)] == 0) || ([string compare "HmIP-HAP" $dev_descr(TYPE)] == 0) || ([string compare "HmIP-HAP-A" $dev_descr(TYPE)] == 0) || ([string compare "HmIP-HAP-B1" $dev_descr(TYPE)] == 0) || ([string compare "HmIP-HAP JS1" $dev_descr(TYPE)] == 0)) && ([regexp {[0-1]\.[0-9]*\.[0-9]*} $dev_descr(FIRMWARE)] || [regexp {2\.0\.[0-9]*} $dev_descr(FIRMWARE)]) } {
append fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22007 noBorder\"><span onclick=\"ShowInfoMsg(translateKey('hintDeviceDoesNotSupportAction'))\" class=\"CLASS21000\">\${lblUpdate}</span></td></tr>"
} else {
append fw_update_rows "<tr><td colspan=\"2\" class=\"_CLASS22007 noBorder\"><span onclick=\"setGlobalIfaceAddress('$iface', '$dev_descr(ADDRESS)');FirmwareUpdate('$dev_descr(TYPE)');\" class=\"CLASS21000\">\${lblUpdate}</span></td></tr>"
}
}
"LIVE_DELIVER_FIRMWARE_IMAGE" {
set fw_update_rows "<tr><td class=\"_CLASS22006 noBorder\">\${lblDeviceFwPerformUpdate}</td></tr>"
}
}
} else {
# This should never be reached....
puts "<script type=\"text/javascript\">conInfo(\"HmIP - FIRMWARE_UPDATE_STATE unknown error\");</script>"
}
}
append tableCell $fw_update_rows
append tableCell "</table>"
return "<td style=\"text-align:center;\" name=\"j_actionTD\">$tableCell</td>"
}
proc put_table_row {} {
global dev_descr iface
puts "<tr>"
puts "<td id=\"name\" name=\"NAME\"></td>"
puts "[getHTML TYPE]"
puts "<td class=\"DeviceListThumbnail\"><div id=\"pic\" class=\"thumbnail\" onmouseout=\"picDivHide(jg_250);\"></td>"
puts "[getHTML ADDRESS]"
puts "[getHTML FIRMWARE]"
puts "[getHTML AVAILABLE_FIRMWARE]"
# puts "[getHTML FIRMWARE_UPDATE_STATE]"
puts "[getActionPanel]"
puts "</tr>"
puts "<script type=\"text/javascript\>"
puts "var dev = DeviceList.getDeviceByAddress(\"$dev_descr(ADDRESS)\");"
puts "var nameTD = jQuery(\"#name\");"
puts "var picDIV = jQuery(\"#pic\");"
puts "nameTD.prop(\"id\", \"name\" + dev.id);"
puts "nameTD.html(dev.name);"
puts "picDIV.prop(\"id\", \"pic\" + dev.id);"
puts "picDIV.html(dev.thumbnailHTML);"
puts "picDIV.bind(\"mouseover\", function() {picDivShow(jg_250, dev.typeName, 250, '', this);});"
puts ""
puts "</script>"
}
proc put_actionHelp {} {
global dev_descr
puts "<script type=\"text/javascript\">"
puts "var tooltipHTML = \"<div>\"+translateKey(\"tooltipHmIPDeliverFirmwareImage\");+\"</div>\","
puts "tooltipElem = jQuery(\".j_hmIPDeliverFirmwareHelp\") ;"
puts "tooltipElem.data('powertip', tooltipHTML);"
puts "tooltipElem.powerTip({placement: 'sw', followMouse: false});"
# Wired-Tooltip
puts "var wired_tooltipHTML = \"<div>\"+translateKey(\"tooltipHmIPWDeliverFirmwareImage\");+\"</div>\","
puts "wired_tooltipElem = jQuery(\".j_hmIPWDeliverFirmwareHelp\") ;"
puts "wired_tooltipElem.data('powertip', wired_tooltipHTML);"
puts "wired_tooltipElem.powerTip({placement: 'sw', followMouse: false});"
puts "</script>"
}
cgi_eval {
cgi_input
#cgi_debug -on
http_head
if {[session_requestisvalid 0] > 0} then {
catch {import deviceList}
# convert the imported deviceList (which is in fact a string) into a tcl list.
set lDeviceList [lrange [string map {\{ "" \} ""} $deviceList] 0 end]
put_headerElem
for { set i 0 } { $i <= [llength $lDeviceList] } { incr i 2} {
array_clear dev_descr
set address [lindex $lDeviceList $i]
set iface [lindex $lDeviceList [expr $i + 1]]
if {([string equal $address ""] != 1) && ([string equal $iface ""] != 1)} {
if { [catch {array set dev_descr [xmlrpc $iface_url($iface) getDeviceDescription [list string $address]] } ] } then {
# put_error $iface $address
} else {
if {
([string length $dev_descr(TYPE)] > 0)
&& ([string equal $dev_descr(TYPE) "HM-RCV-50"] != 1)
&& ([string equal $dev_descr(TYPE) "HMW-RCV-50"] != 1)
&& ([string equal $dev_descr(TYPE) "HmIP-RCV-50"] != 1)
&& ([string first "VIR-" $dev_descr(TYPE)] == -1)
&& ([string equal $dev_descr(TYPE) "HM-CC-VG-1"] != 1)
&& ([string equal $dev_descr(TYPE) "HmIP-HEATING"] != 1)
} {
put_table_row
}
#logDeviceAttributes
}
}
}
put_end_body
put_actionHelp
puts "<script type=\"text/javascript\">"
puts "checkEnterEsc = function(elmId, key) {"
puts "var filterName = elmId.split(\"_\")\[1\];"
puts "switch (key) {"
puts "case 13:"
puts "setFilter(\"filter_\" + filterName);"
#puts "closeFilter(\"filter_\" + filterName);"
puts "break;"
puts "case 27:"
puts "closeFilter(\"filter_\" + filterName);"
puts "break;"
puts "}"
puts "};"
puts "showFilter = function(filter) {"
puts "jQuery(\"#\"+ filter).show();"
puts "jQuery(\"#searchText_\" + filter.split(\"_\")\[1\]).focus();"
puts "};"
puts "closeFilter = function(filter) {"
puts "jQuery(\"#\"+ filter).hide();"
puts "};"
puts "resetFilter = function() {"
puts "jQuery(\"\[name='invisible'\]\").show().attr(\"name\", \"\");"
puts "};"
puts "setFilter = function(filter) {"
puts "jQuery(\"#\"+ filter).hide();"
# searchFilter = NAME, TYPE or ADDRESS
puts "var searchFilter = filter.split(\"_\")\[1\];"
puts "var searchText = jQuery(\"#searchText_\" + searchFilter).val().toLowerCase();"
# filterElem = NAME, TYPE or ADDRESS
puts "arElements = jQuery(\"\[name='\"+searchFilter+\"'\]\");"
puts "jQuery.each(arElements, function(index, tableCell) {"
puts "var cellText = jQuery(tableCell).html().toLowerCase();"
puts "if (cellText.indexOf(searchText) < 0) {"
puts "jQuery(tableCell).parent().attr(\"name\", \"invisible\").hide();"
puts "} else {"
puts "jQuery(tableCell).parent().attr(\"name\", \"\").show();"
puts "}"
puts "})"
puts "};"
set footerHtml ""
append footerHtml "<table style='backgroud-color:white' border='0' cellspacing='8'>"
append footerHtml "<tr>"
append footerHtml "<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='WebUI.goBack();'>\${footerBtnPageBack}</div></td>"
append footerHtml "<td style='text-align:center; vertical-align:middle;'><div class='FooterButton CLASS04312' onclick='resetFilter();'>\${footerBtnResetFilter}</div></td>"
append footerHtml "<td style='text-align:center; vertical-align:middle;'><div class='FooterButton' onclick='WebUI.enter(DeviceFirmware);'>\${submenuDeviceFirmware}</div></td>"
append footerHtml "</tr>"
append footerHtml "</table>"
puts "setFooter(\"$footerHtml\");"
puts "setPath(\"<span onclick='WebUI.enter(SystemConfigPage);'>\"+translateKey('menuSettingsPage')+\"</span> > \"+translateKey('submenuDeviceFirmwareInformation'));"
puts "</script>"
}
}