Project

General

Profile

Revision ea0410f0

IDea0410f05ef1779a99e646611d134de6eb8858ae
Parent 873b686a
Child 36a40ff7

Added by Francois POIROTTE about 9 years ago

Revert "Modifications de la légende de VigiMap"

This reverts commit ec5e7a22beec9e346ac23cd9592b0140cac74a00.
C'est une évolution, pas une anomalie.

Change-Id: I1804fe12c210b55c96895d9700672782a54ebfea
Refs: #1283,#1312,#1319,#1284
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/1882
Tested-by: Build system <>
Reviewed-by: Francois POIROTTE <>

View differences:

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',
96 95
        ]
97 96
    },
98 97
    cmdclass=cmdclass,
vigiboard/config/app_cfg.py
137 137
    'hls',
138 138
    'status',
139 139
#    'test',
140
    'map',
141 140
)
142 141

  
143 142
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
        # 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

  
190
        options = [('', u'')] + \
191
                    [( str(s.idstatename), s.statename ) for s in states]
202 192
        return [
203
            twf.MultipleSelectField(
193
            twf.SingleSelectField(
204 194
                'state',
205 195
                label_text=l_('Current state'),
206 196
                options=options,
207 197
                validator=twf.validators.OneOf(
208
                    valid,
209
                    if_invalid=[],
210
                    if_missing=[],
198
                    dict(options).keys(),
199
                    if_invalid=None,
200
                    if_missing=None,
211 201
                ),
212 202
            ),
213 203
        ]
......
216 206
        if state != ITEMS:
217 207
            return
218 208

  
219
        states = []
220
        for value in search.get('state'):
209
        if search.get('state'):
221 210
            try:
222
                states.append(int(value))
211
                query.add_filter(Event.current_state == int(search['state']))
223 212
            except (ValueError, TypeError):
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))
213
                # On ignore silencieusement le critère de recherche erroné.
214
                pass
232 215

  
233 216
    def get_sort_criterion(self, query, column):
234 217
        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.
48 47
    fields = [
49 48
        twf.HiddenField('page'),
50 49
        twf.HiddenField('sort'),

Also available in: Unified diff