dist_templates_modules_graphs_DATA = \
src/templates/modules/graphs/box.html \
- src/templates/modules/graphs/preview.html
+ src/templates/modules/graphs/preview.html \
+ src/templates/modules/graphs/thumbnail.html \
+ src/templates/modules/graphs/thumbnail-bar.html
templates_modules_menudir = $(templates_modulesdir)/menu
</h3>
</div>
+{% module GraphThumbnailBar(graph) %}
+
<a href="{{ graph.make_url(interval="week") }}">
<img class="img-responsive img-thumbnail" src="{{ graph.make_image_url() }}"
alt="{{ graph.title }}">
--- /dev/null
+<div class="row">
+ {% for interval in ("1h", "12h", "1d", "week", "month", "year") %}
+ <div class="col-md-2">
+ {% module GraphThumbnail(graph, interval=interval) %}
+ </div>
+ {% end %}
+</div>
--- /dev/null
+<img class="img-responsive img-thumbnail"
+ src="{{ graph.make_thumbnail_url(**args) }}" alt="{{ graph.title }}">
SUPPORTED_FORMATS = ("pdf", "png", "svg")
- url = r"/graph/([\w\-]+)(?:/([\w\d\.]+))?\.(%s)" % "|".join(SUPPORTED_FORMATS)
+ url = r"/graph(/thumbnail)?/([\w\-]+)(?:/([\w\d\.]+))?\.(%s)" % "|".join(SUPPORTED_FORMATS)
- def get(self, template_name, object_id, format):
+ def get(self, thumbnail, template_name, object_id, format):
# Get the requested dimensions of the image
height = self.get_argument_int("height", None)
width = self.get_argument_int("width", None)
"interval" : interval,
"height" : height,
"width" : width,
+ "thumbnail" : bool(thumbnail),
# Include the title in the PDF exports
"with_title" : format == "pdf",
return self._make_url(url, **kwargs)
+ def make_thumbnail_url(self, **kwargs):
+ if self.object_id:
+ url = "/graph/thumbnail/%(template)s/%(object_id)s.%(format)s"
+ else:
+ url = "/graph/thumbnail/%(template)s.%(format)s"
+
+ return self._make_url(url, **kwargs)
+
def make_url(self, **kwargs):
if self.object_id:
url = "/graph/%(template)s/%(object_id)s"
class GraphBoxPreviewModule(base.BaseUIModule):
def render(self, graph):
return self.render_string("modules/graphs/preview.html", graph=graph)
+
+
+class GraphThumbnailModule(base.BaseUIModule):
+ def render(self, graph, **kwargs):
+ return self.render_string("modules/graphs/thumbnail.html", graph=graph, args=kwargs)
+
+
+class GraphThumbnailBarModule(base.BaseUIModule):
+ def render(self, graph):
+ return self.render_string("modules/graphs/thumbnail-bar.html", graph=graph)