Revision ec5e7a22
Modifications de la légende de VigiMap
Apporte les modifications suivantes :
- [#1312] Déplace la légende de VigiMap vers la barre de menu (affichage
permanent des compteurs)
- [#1319] Ajoute des liens dans la légende permettant d'accéder à une
vue filtrée dans VigiBoard portant sur les éléments de la carte se
trouvant dans l'état sélectionné.
- [#1283] Ajoute les icônes d'état dans la légende de VigiMap en plus du
code couleur habituel.
Ce changement implémente également la sélection multiple d'état dans
VigiBoard et rend obsolète la nécessité de pouvoir déplacer la légende
de VigiMap (#1284).
Change-Id: If2681f329c2cdb191d78136b1dcf3e6a50d108c0
Refs: #1283,#1312,#1319,#1284
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/1708
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Thomas BURGUIERE <thomas.burguiere@c-s.fr>
setup.py | ||
---|---|---|
92 | 92 |
'status = vigiboard.controllers.plugins.status:PluginStatus', |
93 | 93 |
'groups = vigiboard.controllers.plugins.groups:PluginGroups', |
94 | 94 |
'masked_events = vigiboard.controllers.plugins.masked_events:PluginMaskedEvents', |
95 |
'map = vigiboard.controllers.plugins.map:PluginMap', |
|
95 | 96 |
] |
96 | 97 |
}, |
97 | 98 |
cmdclass=cmdclass, |
vigiboard/config/app_cfg.py | ||
---|---|---|
137 | 137 |
'hls', |
138 | 138 |
'status', |
139 | 139 |
# 'test', |
140 |
'map', |
|
140 | 141 |
) |
141 | 142 |
|
142 | 143 |
base_config['csv_columns'] = ( |
vigiboard/controllers/plugins/details.py | ||
---|---|---|
187 | 187 |
def get_search_fields(self): |
188 | 188 |
states = DBSession.query(StateName.idstatename, StateName.statename |
189 | 189 |
).order_by(StateName.order.asc()).all() |
190 |
options = [('', u'')] + \ |
|
191 |
[( str(s.idstatename), s.statename ) for s in states] |
|
190 |
# Liste des valeurs acceptées pour la validation. |
|
191 |
valid = [] |
|
192 |
# Liste des options présentes dans le champ de sélection. |
|
193 |
options = [] |
|
194 |
for s in states: |
|
195 |
valid.extend([str(s.idstatename), s.statename]) |
|
196 |
options.append( ( |
|
197 |
str(s.idstatename), |
|
198 |
s.statename, |
|
199 |
{'title': l_(s.statename)} |
|
200 |
) ) |
|
201 |
|
|
192 | 202 |
return [ |
193 |
twf.SingleSelectField(
|
|
203 |
twf.MultipleSelectField(
|
|
194 | 204 |
'state', |
195 | 205 |
label_text=l_('Current state'), |
196 | 206 |
options=options, |
197 | 207 |
validator=twf.validators.OneOf( |
198 |
dict(options).keys(),
|
|
199 |
if_invalid=None,
|
|
200 |
if_missing=None,
|
|
208 |
valid,
|
|
209 |
if_invalid=[],
|
|
210 |
if_missing=[],
|
|
201 | 211 |
), |
202 | 212 |
), |
203 | 213 |
] |
... | ... | |
206 | 216 |
if state != ITEMS: |
207 | 217 |
return |
208 | 218 |
|
209 |
if search.get('state'): |
|
219 |
states = [] |
|
220 |
for value in search.get('state'): |
|
210 | 221 |
try: |
211 |
query.add_filter(Event.current_state == int(search['state']))
|
|
222 |
states.append(int(value))
|
|
212 | 223 |
except (ValueError, TypeError): |
213 |
# On ignore silencieusement le critère de recherche erroné. |
|
214 |
pass |
|
224 |
try: |
|
225 |
states.append(StateName.statename_to_value(value)) |
|
226 |
except: |
|
227 |
# On ignore silencieusement un critère de recherche erroné. |
|
228 |
pass |
|
229 |
|
|
230 |
if states: |
|
231 |
query.add_filter(Event.current_state.in_(states)) |
|
215 | 232 |
|
216 | 233 |
def get_sort_criterion(self, query, column): |
217 | 234 |
if column == 'details': |
vigiboard/controllers/plugins/map.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4: |
|
3 |
################################################################################ |
|
4 |
# |
|
5 |
# Copyright (C) 2007-2015 CS-SI |
|
6 |
# |
|
7 |
# This program is free software; you can redistribute it and/or modify |
|
8 |
# it under the terms of the GNU General Public License version 2 as |
|
9 |
# published by the Free Software Foundation. |
|
10 |
# |
|
11 |
# This program is distributed in the hope that it will be useful, |
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
# GNU General Public License for more details. |
|
15 |
# |
|
16 |
# You should have received a copy of the GNU General Public License |
|
17 |
# along with this program; if not, write to the Free Software |
|
18 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
19 |
################################################################################ |
|
20 |
""" |
|
21 |
Un plugin pour VigiBoard qui ajoute une colonne avec le nom de l'hôte |
|
22 |
sur lequel porte l'événement corrélé. |
|
23 |
""" |
|
24 |
import tw.forms as twf |
|
25 |
from pylons.i18n import lazy_ugettext as l_ |
|
26 |
from sqlalchemy.sql.expression import union_all |
|
27 |
from sqlalchemy.orm import aliased |
|
28 |
|
|
29 |
from vigilo.models.session import DBSession |
|
30 |
from vigilo.models import tables |
|
31 |
from vigiboard.controllers.plugins import VigiboardRequestPlugin, INNER |
|
32 |
|
|
33 |
class PluginMap(VigiboardRequestPlugin): |
|
34 |
""" |
|
35 |
Ajoute de quoi filtrer sur les cartes. |
|
36 |
""" |
|
37 |
def get_search_fields(self): |
|
38 |
return [ |
|
39 |
twf.HiddenField( |
|
40 |
'idmap', |
|
41 |
validator=twf.validators.Int(if_missing=None), |
|
42 |
) |
|
43 |
] |
|
44 |
|
|
45 |
def handle_search_fields(self, query, search, state, subqueries): |
|
46 |
if state != INNER or not search.get('idmap'): |
|
47 |
return |
|
48 |
idmap = int(search['idmap']) |
|
49 |
|
|
50 |
# Il s'agit d'un manager. On applique le filtre |
|
51 |
# indépendamment aux 2 sous-requêtes. |
|
52 |
if len(subqueries) == 2: |
|
53 |
mapnodells = DBSession.query( |
|
54 |
tables.MapNodeLls.idservice |
|
55 |
).filter(tables.MapNodeLls.idmap == idmap).subquery() |
|
56 |
|
|
57 |
mapnodehost = DBSession.query( |
|
58 |
tables.MapNodeHost.idhost |
|
59 |
).filter(tables.MapNodeHost.idmap == idmap).subquery() |
|
60 |
|
|
61 |
subqueries[0] = subqueries[0].join( |
|
62 |
(mapnodells, mapnodells.c.idservice == |
|
63 |
tables.LowLevelService.idservice), |
|
64 |
) |
|
65 |
|
|
66 |
subqueries[1] = subqueries[1].join( |
|
67 |
(mapnodehost, mapnodehost.c.idhost == |
|
68 |
tables.Host.idhost), |
|
69 |
) |
|
70 |
|
|
71 |
# Il s'agit d'un utilisateur normal. |
|
72 |
else: |
|
73 |
mapnodells = DBSession.query( |
|
74 |
tables.MapNodeLls.idservice.label('idsupitem') |
|
75 |
).filter(tables.MapNodeLls.idmap == idmap) |
|
76 |
|
|
77 |
mapnodehost = DBSession.query( |
|
78 |
tables.MapNodeHost.idhost.label('idsupitem') |
|
79 |
).filter(tables.MapNodeHost.idmap == idmap) |
|
80 |
|
|
81 |
union = union_all(mapnodells, mapnodehost, correlate=False).alias() |
|
82 |
subqueries[0] = subqueries[0].join( |
|
83 |
(union, union.c.idsupitem == tables.UserSupItem.idsupitem), |
|
84 |
) |
|
85 |
|
vigiboard/widgets/search_form.py | ||
---|---|---|
44 | 44 |
method = 'GET' |
45 | 45 |
style = 'display: none' |
46 | 46 |
|
47 |
# Paramètres liés à la pagination et au tri. |
|
47 | 48 |
fields = [ |
48 | 49 |
twf.HiddenField('page'), |
49 | 50 |
twf.HiddenField('sort'), |
Also available in: Unified diff