Module: check_mk
Branch: master
Commit: bf850ffac08a787547b926444baeefc195dec705
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf850ffac08a78…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 10 15:12:52 2015 +0200
Improved styling of icon selector popup; fixed issue with multiple IconSelectors on a
single page
---
web/htdocs/htmllib.py | 8 ++++----
web/htdocs/js/checkmk.js | 11 ++---------
web/htdocs/pages.css | 17 +++++++----------
web/htdocs/valuespec.py | 14 +++++++-------
4 files changed, 20 insertions(+), 30 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 621e3c7..6386087 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -921,10 +921,10 @@ class html:
else:
self.status_icons[img] = tooltip
- def begin_popup_trigger(self, ident, data=None, params=None):
+ def begin_popup_trigger(self, ident, what, data=None, params=None):
self.write('<div class="popup_trigger">\n')
- onclick = 'toggle_popup(event, this, \'%s\', %s, %s)' % \
- (ident, data or 'null', params and
"'"+params+"'" or 'null')
+ onclick = 'toggle_popup(event, this, \'%s\', \'%s\', %s,
%s)' % \
+ (ident, what, data or 'null', params and
"'"+params+"'" or 'null')
self.write('<a class="popup_trigger"
href="javascript:void(0)" onclick="%s">\n' % onclick)
def end_popup_trigger(self):
@@ -953,7 +953,7 @@ class html:
v = v.encode('utf-8')
encoded_vars[k] = v
- self.begin_popup_trigger('add_visual',
+ self.begin_popup_trigger('add_visual', 'add_visual',
data='[\'%s\', %s, {\'name\': \'%s\'}]' %
(mode_name, self.attrencode(repr(encoded_vars)), self.var('view_name')))
self.write('<img class=statusicon
src="images/status_add_dashlet.png"
title="%s"></a></div>\n' % _("Add this view
to..."))
self.end_popup_trigger()
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index 3118790..2a39e56 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -592,7 +592,7 @@ function create_graph(data, params) {
visualadd.className = 'popup_trigger';
visualadd.onclick = function(host, service, view, source) {
return function(event) {
- toggle_popup(event, this, 'add_visual',
+ toggle_popup(event, this, 'add_visual', 'add_visual',
['pnpgraph',
{ 'host': host, 'service': service },
{ 'timerange': view, 'source': source }]
@@ -2264,20 +2264,13 @@ function handle_popup_close(event) {
close_popup();
}
-function toggle_popup(event, trigger_obj, what, data, params)
+function toggle_popup(event, trigger_obj, ident, what, data, params)
{
var params = typeof(params) === "undefined" ? '' :
'?'+params;
if(!event)
event = window.event;
var container = trigger_obj.parentNode;
- var ident;
- for (var i in container.parentNode.childNodes) {
- if (container.parentNode.childNodes[i] == container) {
- ident = i;
- break;
- }
- }
close_popup();
diff --git a/web/htdocs/pages.css b/web/htdocs/pages.css
index d8d28b0..b32ce62 100644
--- a/web/htdocs/pages.css
+++ b/web/htdocs/pages.css
@@ -908,7 +908,7 @@ body.main .popup_menu {
z-index: 10;
padding: 0;
- width: 300px;
+ min-width: 300px;
color: #fff;
background-color: #508AA1;
@@ -959,7 +959,6 @@ body.main table.footer .popup_menu a:hover {
margin: 0;
padding: 0;
border-bottom: 1px solid #e5e5e5;
- margin-bottom: 5px;
}
#popup_menu .icons li {
@@ -987,8 +986,10 @@ body.main table.footer .popup_menu a:hover {
#popup_menu .icons div {
clear: left;
- max-height: 200px;
+ height: 150px;
overflow-y: auto;
+ padding: 5px;
+ width: 312px;
}
#popup_menu .icons a {
@@ -1000,13 +1001,9 @@ body.main table.footer .popup_menu a:hover {
height: 20px;
}
-body.icon_upload {
- background: transparent;
-}
-
-body.icon_upload div.error,
-body.icon_upload div.success {
- margin: 0;
+#popup_menu .icons .image_button {
+ float: right;
+ margin: 4px;
}
/*--Various----------------------------------------------------------------.
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 46d9cd9..ef44e17 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -3285,7 +3285,7 @@ class IconSelector(ValueSpec):
html.hidden_field(varprefix + "_value", value or '', varprefix
+ "_value", add_var = True)
- html.begin_popup_trigger('icon_selector',
+ html.begin_popup_trigger(varprefix+'_icon_selector',
'icon_selector',
params=html.urlencode_vars([('value', value),
('varprefix', varprefix),
('allow_empty', self._allow_empty and
'1' or '0'),
@@ -3311,12 +3311,6 @@ class IconSelector(ValueSpec):
html.write('<a id="%s_%s_nav" class="%s_nav"
href="javascript:vs_iconselector_toggle(\'%s\',
\'%s\')">%s</a>' %
(varprefix, category_name, varprefix, varprefix, category_name,
category_alias))
html.write('</li>')
- import config# FIXME: Clean this up. But how?
- if defaults.omd_site and config.may('wato.icons'):
- back_param = html.has_var('back') and
'&back='+html.urlencode(html.var('back')) or ''
- html.write('<li><a
href="wato.py?mode=icons%s">%s</a></li>' %
- (back_param, _('Upload')))
-
html.write('</ul>')
# Now render the icons grouped by category
@@ -3329,6 +3323,12 @@ class IconSelector(ValueSpec):
onclick = 'vs_iconselector_select(event, \'%s\',
\'%s\')' % (varprefix, icon),
title = _('Choose this icon'), id = varprefix + '_i_'
+ icon))
html.write('</div>')
+
+ import config# FIXME: Clean this up. But how?
+ if defaults.omd_site and config.may('wato.icons'):
+ back_param = html.has_var('back') and
'&back='+html.urlencode(html.var('back')) or ''
+ html.buttonlink('wato.py?mode=icons' + back_param,
_('Manage'))
+
html.write('</div>')
def from_html_vars(self, varprefix):