Revision c1b9f1da
Revert du export(json) dans le contrôleur proxy car il engendre plus de problèmes qu'il n'en résoud (certaines requêtes HTML ou sur des images sont interprétées comme des requêtes JSON, ce qui donne des résultats inattendus et souvent erronés).
Modification de vigigraph pour la récupération du timestamp de début des graphes d'un hôte. La récupération se fait désormais via une méthode du contrôleur rpc, qui relaye "manuellement" la requête via get_through_proxy.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@5132 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/controllers/rpc.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
"""RPC controller for the combobox of vigigraph""" |
3 | 3 |
|
4 |
import time, urlparse |
|
4 |
import time, urlparse, urllib2
|
|
5 | 5 |
import logging |
6 | 6 |
|
7 | 7 |
# La fonction parse_qsl a été déplacée dans Python 2.6. |
... | ... | |
23 | 23 |
|
24 | 24 |
from vigilo.turbogears.controllers import BaseController |
25 | 25 |
from vigilo.turbogears.helpers import get_current_user |
26 |
from vigilo.turbogears.controllers.proxy import get_through_proxy |
|
26 | 27 |
|
27 | 28 |
from vigilo.models.session import DBSession |
28 | 29 |
from vigilo.models.tables import Host |
... | ... | |
272 | 273 |
indicators = [ind.name for ind in indicators] |
273 | 274 |
return dict(items=indicators) |
274 | 275 |
|
276 |
class StartTimeSchema(schema.Schema): |
|
277 |
"""Schéma de validation pour la méthode L{getIndicators}.""" |
|
278 |
host = validators.String(not_empty=True) |
|
279 |
nocache = validators.String(if_missing=None) |
|
280 |
|
|
281 |
# @TODO définir un error_handler différent pour remonter l'erreur via JS. |
|
282 |
@validate( |
|
283 |
validators = StartTimeSchema(), |
|
284 |
error_handler = process_form_errors) |
|
285 |
@expose('json') |
|
286 |
def startTime(self, host, nocache): |
|
287 |
return get_through_proxy( |
|
288 |
'vigirrd', host, |
|
289 |
'/starttime?host=%s' % urllib2.quote(host, '') |
|
290 |
) |
|
275 | 291 |
|
276 | 292 |
class FullHostPageSchema(schema.Schema): |
277 | 293 |
"""Schéma de validation pour la méthode L{fullHostPage}.""" |
vigigraph/public/js/graph.js | ||
---|---|---|
18 | 18 |
this.refreshTimer = null; |
19 | 19 |
|
20 | 20 |
new Request.JSON({ |
21 |
url: app_path + 'vigirrd/' + |
|
22 |
encodeURIComponent(this.host) + '/starttime', |
|
21 |
url: app_path + 'rpc/startTime', |
|
23 | 22 |
onSuccess: function (data) { |
24 | 23 |
this.startTime = data.starttime; |
25 | 24 |
}.bind(this) |
Also available in: Unified diff