Revision 9773b809
Corrections dans le template !OpenSearch de VigiGraph.
Utilisation du module paginate de TG2 pour la recherche des hôtes.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2820 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/controllers/rpc.py | ||
---|---|---|
15 | 15 |
from pylons.i18n import ugettext as _, lazy_ugettext as l_ |
16 | 16 |
from tg import expose, response, request, redirect, tmpl_context, \ |
17 | 17 |
config, url, exceptions, validate, flash |
18 |
from tg.decorators import paginate |
|
18 | 19 |
from repoze.what.predicates import not_anonymous |
19 | 20 |
from formencode import validators, schema |
20 | 21 |
|
... | ... | |
250 | 251 |
PerfDataSource.idservice), |
251 | 252 |
(SUPITEM_GROUP_TABLE, or_( |
252 | 253 |
SUPITEM_GROUP_TABLE.c.idsupitem == LowLevelService.idhost, |
253 |
SUPITEM_GROUP_TABLE.c.idsupitem == LowLevelService.idservice, |
|
254 |
SUPITEM_GROUP_TABLE.c.idsupitem == |
|
255 |
LowLevelService.idservice, |
|
254 | 256 |
)), |
255 | 257 |
).filter(LowLevelService.idhost == idhost |
256 | 258 |
).filter(SUPITEM_GROUP_TABLE.c.idgroup.in_(supitemgroups) |
... | ... | |
303 | 305 |
PerfDataSource.idservice), |
304 | 306 |
(SUPITEM_GROUP_TABLE, or_( |
305 | 307 |
SUPITEM_GROUP_TABLE.c.idsupitem == LowLevelService.idhost, |
306 |
SUPITEM_GROUP_TABLE.c.idsupitem == LowLevelService.idservice, |
|
308 |
SUPITEM_GROUP_TABLE.c.idsupitem == |
|
309 |
LowLevelService.idservice, |
|
307 | 310 |
)), |
308 | 311 |
).filter(GraphGroup.idgroup == idgraphgroup |
309 | 312 |
).filter(LowLevelService.idhost == idhost |
... | ... | |
371 | 374 |
GRAPH_PERFDATASOURCE_TABLE.c.idgraph), |
372 | 375 |
(SUPITEM_GROUP_TABLE, or_( |
373 | 376 |
SUPITEM_GROUP_TABLE.c.idsupitem == Host.idhost, |
374 |
SUPITEM_GROUP_TABLE.c.idsupitem == LowLevelService.idservice, |
|
377 |
SUPITEM_GROUP_TABLE.c.idsupitem == |
|
378 |
LowLevelService.idservice, |
|
375 | 379 |
)), |
376 | 380 |
).filter(Host.name.ilike('%' + host + '%') |
377 | 381 |
).filter(Graph.name.ilike('%' + graph + '%') |
... | ... | |
414 | 418 |
|
415 | 419 |
# @TODO définir un error_handler différent pour remonter l'erreur via JS. |
416 | 420 |
@validate( |
417 |
validators=SearchHostAndGraphSchema(),
|
|
421 |
validators=SelectHostAndGraphSchema(),
|
|
418 | 422 |
error_handler=process_form_errors) |
419 | 423 |
@expose('json') |
420 | 424 |
def selectHostAndGraph(self, host, graph, nocache): |
... | ... | |
613 | 617 |
if start is None: |
614 | 618 |
start = int(time.time()) - int(duration) |
615 | 619 |
|
616 |
# @TODO définir des validateurs sur les paramètres |
|
617 | 620 |
start = int(start) |
618 | 621 |
duration = int(duration) |
619 | 622 |
|
... | ... | |
685 | 688 |
if start is None: |
686 | 689 |
start = int(time.time()) - int(duration) |
687 | 690 |
|
688 |
# @TODO définir des validateurs sur les paramètres |
|
689 | 691 |
start = int(start) |
690 | 692 |
duration = int(duration) |
691 | 693 |
|
... | ... | |
705 | 707 |
|
706 | 708 |
return dict(searchhostform=searchhostform) |
707 | 709 |
|
708 |
class SearchHostSchema(schema.Schema): |
|
709 |
query = validators.String(if_missing=None) |
|
710 |
|
|
711 |
@validate( |
|
712 |
validators=SearchHostSchema(), |
|
713 |
error_handler=process_form_errors) |
|
714 | 710 |
@expose('searchhost.html') |
715 |
def searchHost(self, query): |
|
711 |
@paginate('hosts', items_per_page=10) |
|
712 |
def searchHost(self, *args, **kwargs): |
|
716 | 713 |
""" |
717 | 714 |
Affiche les résultats de la recherche par nom d'hôte. |
718 | 715 |
La requête de recherche (L{query}) correspond à un préfixe |
... | ... | |
723 | 720 |
@param query: Prefixe de recherche sur les noms d'hôtes |
724 | 721 |
@type query: C{unicode} |
725 | 722 |
""" |
726 |
|
|
723 |
query = kwargs.get('query') |
|
727 | 724 |
if not query: |
728 | 725 |
redirect("searchHostForm") |
729 | 726 |
|
... | ... | |
749 | 746 |
).filter(Host.name.like(query+'%') |
750 | 747 |
).order_by( |
751 | 748 |
Host.name.asc(), |
752 |
).all()
|
|
749 |
) |
|
753 | 750 |
return dict(hosts=hosts) |
754 | 751 |
|
755 | 752 |
# VIGILO_EXIG_VIGILO_PERF_0030:Moteur de recherche des graphes |
... | ... | |
761 | 758 |
@return: document |
762 | 759 |
@rtype: document xml |
763 | 760 |
""" |
764 |
|
|
765 |
# @TODO: une URL relative ne suffit-elle pas |
|
766 |
# ex: /public |
|
767 |
here = "http://" |
|
768 |
here += request.host |
|
769 |
dir_l = url('/public') |
|
770 |
|
|
771 |
result = dict(here=here, dir=dir_l) |
|
772 |
|
|
773 |
return result |
|
761 |
return dict() |
|
774 | 762 |
|
775 | 763 |
def getListIndicators(self, graph=None): |
776 | 764 |
""" |
Also available in: Unified diff