Revision 6892ebac
Séparation des historiques lors de l'affichage de plusieurs évènements
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@526 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/root.py | ||
---|---|---|
225 | 225 |
events = VigiboardRequest() |
226 | 226 |
events.add_filter(Events.hostname == host, |
227 | 227 |
Events.servicename == service) |
228 |
|
|
228 |
del events.filter[2] |
|
229 |
|
|
229 | 230 |
# Vérification qu'il y a au moins 1 évènement qui correspond |
230 | 231 |
if events.num_rows() == 0 : |
231 | 232 |
redirect('/') |
... | ... | |
233 | 234 |
events.format_events(0, events.num_rows()) |
234 | 235 |
events.format_history() |
235 | 236 |
events.generate_tmpl_context() |
236 |
|
|
237 | 237 |
return dict( |
238 | 238 |
events = events.events, |
239 | 239 |
id_first_row = 1, |
vigiboard/controllers/vigiboardrequest.py | ||
---|---|---|
309 | 309 |
event, |
310 | 310 |
{'class': class_tr[i%2]}, |
311 | 311 |
{'class' : self.bouton_severity[event.severity] + \ |
312 |
self.class_ack[event.status], |
|
313 |
'style' : 'text-align: center'}, |
|
312 |
self.class_ack[event.status]}, |
|
314 | 313 |
{'class' : self.bouton_severity[event.severity] + \ |
315 | 314 |
self.class_ack[event.status] }, |
316 | 315 |
{'src' : '/images/%s2.png' % \ |
... | ... | |
351 | 350 |
).filter(EventHistory.idevent.in_(self.idevents) |
352 | 351 |
).order_by(desc(EventHistory.timestamp) |
353 | 352 |
).order_by(desc(EventHistory.idhistory)) |
354 |
|
|
353 |
print history |
|
355 | 354 |
if history.count() == 0: |
356 | 355 |
self.hist = [] |
357 | 356 |
return |
358 |
hists = []
|
|
357 |
hists = {}
|
|
359 | 358 |
i = 0 |
360 | 359 |
class_tr = ['odd', 'even'] |
361 | 360 |
hostname = self.events[1][0].hostname |
362 | 361 |
servicename = self.events[1][0].servicename |
363 |
|
|
362 |
hist_tmp = [] |
|
363 |
last_idevent = history[0].idevent |
|
364 | 364 |
for hist in history : |
365 |
|
|
366 |
if last_idevent != hist.idevent: |
|
367 |
hists[last_idevent] = hist_tmp |
|
368 |
last_idevent = hist.idevent |
|
369 |
hist_tmp = [] |
|
365 | 370 |
|
366 | 371 |
# La liste pour l'historique actuel comporte dans l'ordre : |
367 |
# Son identifiant |
|
368 |
# Son nom d'hôte |
|
369 |
# Son nom de service |
|
370 | 372 |
# Le moment où il a été généré |
371 | 373 |
# Qui l'a généré |
372 | 374 |
# Le type d'action qui a été appliqué |
... | ... | |
377 | 379 |
# La classe de la sévérité s'il y a |
378 | 380 |
|
379 | 381 |
if hist.value : |
380 |
hists.append([ |
|
381 |
hist.idhistory, |
|
382 |
hostname, |
|
383 |
servicename, |
|
382 |
hist_tmp.append([ |
|
384 | 383 |
hist.timestamp, |
385 | 384 |
hist.username, |
386 | 385 |
hist.type_action, |
... | ... | |
390 | 389 |
{'class':self.class_severity[min(int(hist.value),7)]} |
391 | 390 |
]) |
392 | 391 |
else: |
393 |
hists.append([ |
|
394 |
hist.idhistory, |
|
395 |
hostname, |
|
396 |
servicename, |
|
392 |
hist_tmp.append([ |
|
397 | 393 |
hist.timestamp, |
398 | 394 |
hist.username, |
399 | 395 |
hist.type_action, |
... | ... | |
404 | 400 |
]) |
405 | 401 |
i = i + 1 |
406 | 402 |
|
403 |
hists[last_idevent] = hist_tmp |
|
407 | 404 |
self.hist = hists |
408 | 405 |
|
409 | 406 |
def generate_tmpl_context(self): |
vigiboard/public/css/vigiboard_style.css | ||
---|---|---|
35 | 35 |
border-style: solid; |
36 | 36 |
border-width: 1px 1px 1px 1px; |
37 | 37 |
border-color: #FFFFFF; |
38 |
padding: 3px; |
|
38 |
padding: 3px 10px 3px 10px;
|
|
39 | 39 |
empty-cells: show; |
40 | 40 |
} |
41 | 41 |
|
42 |
.vigitable .fleche_detail { |
|
43 |
padding: 3px; |
|
44 |
} |
|
42 | 45 |
|
43 | 46 |
tr.odd { |
44 | 47 |
background-color: #F8F8F8; |
vigiboard/templates/vigiboard.html | ||
---|---|---|
5 | 5 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
6 | 6 |
|
7 | 7 |
<xi:include href="vigiboard_event_table.html" /> |
8 |
<xi:include href="vigiboard_history_table.html" /> |
|
9 | 8 |
|
10 | 9 |
<head> |
11 | 10 |
<meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/> |
... | ... | |
38 | 37 |
<div py:if="flash" py:content="XML(flash)" /> |
39 | 38 |
</py:with> |
40 | 39 |
<div class="main_content"> |
41 |
${event_table(events,page,pages,id_first_row,id_last_row,total_row,event_edit_status_options)} |
|
42 |
<br /><br /> |
|
43 |
${history_table(history,hist_error)} |
|
40 |
${event_table(events,page,pages,id_first_row,id_last_row,total_row,event_edit_status_options,history,hist_error)} |
|
44 | 41 |
</div> |
45 | 42 |
|
46 | 43 |
</body> |
vigiboard/templates/vigiboard_event_table.html | ||
---|---|---|
3 | 3 |
py:strip=""> |
4 | 4 |
|
5 | 5 |
|
6 |
<xi:include href="vigiboard_history_table.html" /> |
|
6 | 7 |
|
7 |
<py:def function="event_table(events,page,pages,id_first_row,id_last_row,total_row,edit_event_status_options)"> |
|
8 |
<py:def function="event_table(events,page,pages,id_first_row,id_last_row,total_row,edit_event_status_options,history,hist_error)">
|
|
8 | 9 |
<?python from genshi import HTML ?> |
9 | 10 |
|
10 | 11 |
<py:if test="len(events) > 1"> |
... | ... | |
41 | 42 |
|
42 | 43 |
<py:for each="(event,class_tr,class_td_severity,class_td_date,img_fleche,img_statu,plugin) in events[1:]"> |
43 | 44 |
<tr py:attrs="class_tr"> |
44 |
<td py:attrs="class_td_severity"><a href="javascript:vigiboard_historydialog('${event.idevent}')" class="HistoryLien"><img src="${tg.url(img_fleche['src'])}" style="width:20px"/></a></td> |
|
45 |
<td style="padding: 3px;" py:attrs="class_td_severity"><a href="javascript:vigiboard_historydialog('${event.idevent}')" class="HistoryLien"><img src="${tg.url(img_fleche['src'])}" style="width:20px"/></a></td>
|
|
45 | 46 |
<td py:attrs="class_td_date"><span style="font-weight: bold;">${event.get_date('timestamp_active')}</span><br />[${event.get_since_date('timestamp_active')}]</td> |
46 | 47 |
<td py:attrs="class_td_date" style="text-align:center">${event.occurence}</td> |
47 | 48 |
<td>${event.hostname}</td> |
... | ... | |
59 | 60 |
<td py:attrs="class_td_date" style="text-align: center"><input type="checkbox" class="Edit_EventsCheckBox" value="${event.idevent}"/></td> |
60 | 61 |
|
61 | 62 |
</tr> |
63 |
<py:if test="hist_error == True"> |
|
64 |
<tr><td colspan="${10+len(plugin)}"> |
|
65 |
${history_table(history[event.idevent],hist_error)} |
|
66 |
</td></tr> |
|
67 |
</py:if> |
|
62 | 68 |
</py:for> |
63 | 69 |
|
64 | 70 |
</tbody> |
vigiboard/templates/vigiboard_history_table.html | ||
---|---|---|
9 | 9 |
</p> |
10 | 10 |
|
11 | 11 |
<py:if test="history and len(history) > 0"> |
12 |
<table style="width: 100%"> |
|
12 |
<table style="width: 100%;margin-bottom: 30px;">
|
|
13 | 13 |
<thead> |
14 | 14 |
<tr style="background-color:#F8F8F8;font-weight:bold"> |
15 |
<td>ID</td> |
|
16 |
<td>Host</td> |
|
17 |
<td>Service</td> |
|
18 | 15 |
<td>Time</td> |
19 | 16 |
<td>User</td> |
20 | 17 |
<td>Type</td> |
... | ... | |
23 | 20 |
</tr> |
24 | 21 |
</thead> |
25 | 22 |
<tbody> |
26 |
<py:for each="(id,host,service,time,user,type,value,text,class_tr,class_value) in history">
|
|
23 |
<py:for each="(time,user,type,value,text,class_tr,class_value) in history"> |
|
27 | 24 |
<tr py:attrs="class_tr"> |
28 |
<td>${id}</td> |
|
29 |
<td>${host}</td> |
|
30 |
<td>${service}</td> |
|
31 | 25 |
<td>${time}</td> |
32 | 26 |
<td>${user}</td> |
33 | 27 |
<td>${type}</td> |
Also available in: Unified diff