]> git.ipfire.org Git - collecty.git/commitdiff
Allow generating thumbnails of graph images
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 14 Dec 2015 00:11:58 +0000 (01:11 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 14 Dec 2015 00:11:58 +0000 (01:11 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/collecty/constants.py
src/collecty/plugins/base.py

index e07ce4c417aaac559d3de138f940b1c62047cc7b..bae6ed42bac5610c516e7ccc8b9c09391fcfbc7c 100644 (file)
@@ -57,3 +57,6 @@ GRAPH_DEFAULT_ARGUMENTS = (
 
 GRAPH_DEFAULT_WIDTH = 768
 GRAPH_DEFAULT_HEIGHT = 480
 
 GRAPH_DEFAULT_WIDTH = 768
 GRAPH_DEFAULT_HEIGHT = 480
+
+THUMBNAIL_DEFAULT_WIDTH = 80
+THUMBNAIL_DEFAULT_HEIGHT = 20
index 7a613161734eeb9df2f88d509b2a9114ddd3bace..ec91599aa6d56be43f1e6c717d8297697f7ef6c5 100644 (file)
@@ -516,15 +516,23 @@ class GraphTemplate(object):
                return self.plugin.log
 
        def _make_command_line(self, interval, format=DEFAULT_IMAGE_FORMAT,
                return self.plugin.log
 
        def _make_command_line(self, interval, format=DEFAULT_IMAGE_FORMAT,
-                       width=None, height=None, with_title=True):
-               args = []
+                       width=None, height=None, with_title=True, thumbnail=False):
+               args = [e for e in GRAPH_DEFAULT_ARGUMENTS]
 
 
-               args += GRAPH_DEFAULT_ARGUMENTS
+               # Set the default dimensions
+               default_height, default_width = GRAPH_DEFAULT_HEIGHT, GRAPH_DEFAULT_WIDTH
+
+               # A thumbnail doesn't have a legend and other labels
+               if thumbnail:
+                       args.append("--only-graph")
+
+                       default_height = THUMBNAIL_DEFAULT_HEIGHT
+                       default_width = THUMBNAIL_DEFAULT_WIDTH
 
                args += [
                        "--imgformat", format,
 
                args += [
                        "--imgformat", format,
-                       "--height", "%s" % (height or self.height),
-                       "--width", "%s" % (width or self.width),
+                       "--height", "%s" % (height or default_height),
+                       "--width", "%s" % (width or default_width),
                ]
 
                args += self.rrd_graph_args
                ]
 
                args += self.rrd_graph_args