Module: check_mk
Branch: master
Commit: d9af1d26e6d8ae38abe799b3b2c5e6f2f36de671
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9af1d26e6d8ae…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Sep 4 11:25:43 2017 +0200
ImageUpload(): Valuespec can now show current image
Change-Id: Icdaddbede38d705a2069683c79feb204754e603c
---
web/htdocs/valuespec.py | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 1718cbc..8a8f283 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -4003,11 +4003,32 @@ class FileUpload(ValueSpec):
class ImageUpload(FileUpload):
- def __init__(self, max_size=None, *args, **kwargs):
+ def __init__(self, max_size=None, show_current_image=False, *args, **kwargs):
self._max_size = max_size
+ self._show_current_image = show_current_image
FileUpload.__init__(self, *args, **kwargs)
+ def render_input(self, varprefix, value):
+ self.classtype_info()
+
+ if self._show_current_image and value:
+ html.open_table()
+ html.open_tr()
+ html.td(_("Current image:"))
+ html.td(html.render_img("data:image/png;base64,%s" %
base64.b64encode(value)))
+ html.close_tr()
+ html.open_tr()
+ html.td(_("Upload new:"))
+ html.open_td()
+ super(ImageUpload, self).render_input(varprefix, value)
+ html.close_td()
+ html.close_tr()
+ html.close_table()
+ else:
+ super(ImageUpload, self).render_input(varprefix, value)
+
+
def validate_value(self, value, varprefix):
from PIL import Image
from StringIO import StringIO