Module: check_mk
Branch: master
Commit: 85d60143af2b5c3353df8dd18d79e42386253149
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=85d60143af2b5c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 24 14:09:45 2011 +0200
Dashboard: Preservice dashboard display_options in sorter title links
---
web/htdocs/views.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index d860b01..3bf420a 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1079,6 +1079,14 @@ def show_view(view, show_heading = False, show_buttons = True, show_footer = Tru
# If display option 'M' is set, then all links are targetet to the 'main'
# frame. Also the display options are removed since the view in the main
# frame should be displayed in standard mode.
+ #
+ # But there is one special case: The sorter links! These links need to know
+ # about the provided display_option parameter. The links could use
+ # "html.display_options" but this contains the implicit options which should
+ # not be added to the URLs. So the real parameters need to be preserved for
+ # this case. It is stored in the var "html.display_options"
+ if html.var('display_options'):
+ html.title_display_options = html.var("display_options")
if 'M' not in display_options:
html.set_link_target("main")
html.del_var("display_options")
@@ -2286,8 +2294,8 @@ def paint_header(view, p):
]
if html.has_var('_body_class'):
params.append(('_body_class', html.var('_body_class')))
- if html.has_var('display_options'):
- params.append(('display_options', html.var('display_options')))
+ if hasattr(html, 'title_display_options'):
+ params.append(('display_options', html.title_display_options))
t = "<a class=\"%s\" href=\"%s\" title=\"%s\" target=\"_self\">%s</a>" % \
(get_primary_sorter_order(view, painter),
Module: check_mk
Branch: master
Commit: e3c8fa17c84375c271855898458c0046499f8dff
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e3c8fa17c84375…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 24 13:36:37 2011 +0200
Remove *new* user sorters also from view sorters
---
web/htdocs/views.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 661d90b..d860b01 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2253,11 +2253,12 @@ def sort_url(view, painter):
sorter.remove(this_desc_sorter)
else:
# First click: add this sorter as primary user sorter
- # Maybe the sorter is already in the user sorters, remove it
- if this_asc_sorter in user_sort:
- user_sort.remove(this_asc_sorter)
- if this_desc_sorter in user_sort:
- user_sort.remove(this_desc_sorter)
+ # Maybe the sorter is already in the user sorters or view sorters, remove it
+ for s in [ user_sort, view_sort ]:
+ if this_asc_sorter in s:
+ s.remove(this_asc_sorter)
+ if this_desc_sorter in s:
+ s.remove(this_desc_sorter)
# Now add the sorter as primary user sorter
sorter = group_sort + [this_asc_sorter] + user_sort + view_sort
Module: check_mk
Branch: master
Commit: 92c3458fe566164848d4c9b7c372ca32aecf80bb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=92c3458fe56616…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 24 13:13:45 2011 +0200
Fixed wrong sort lists
---
web/htdocs/views.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index f2dda0d..661d90b 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2245,19 +2245,19 @@ def sort_url(view, painter):
this_asc_sorter = (sorter_name, False)
this_desc_sorter = (sorter_name, True)
- if sorter and this_asc_sorter == sorter[0]:
+ if user_sort and this_asc_sorter == user_sort[0]:
# Second click: Change from asc to desc order
sorter[sorter.index(this_asc_sorter)] = this_desc_sorter
- elif sorter and this_desc_sorter == sorter[0]:
+ elif user_sort and this_desc_sorter == user_sort[0]:
# Third click: Remove this sorter
sorter.remove(this_desc_sorter)
else:
# First click: add this sorter as primary user sorter
# Maybe the sorter is already in the user sorters, remove it
- if this_asc_sorter in sorter:
- sorter.remove(this_asc_sorter)
- if this_desc_sorter in sorter:
- sorter.remove(this_desc_sorter)
+ if this_asc_sorter in user_sort:
+ user_sort.remove(this_asc_sorter)
+ if this_desc_sorter in user_sort:
+ user_sort.remove(this_desc_sorter)
# Now add the sorter as primary user sorter
sorter = group_sort + [this_asc_sorter] + user_sort + view_sort
Module: check_mk
Branch: master
Commit: 5e9b4018e1a6cec2b34088393aa2b476b6671381
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5e9b4018e1a6ce…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 24 13:09:05 2011 +0200
The last clicked sort column will always become the primary user sorter
---
web/htdocs/views.py | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index fd4e0de..f2dda0d 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2238,20 +2238,27 @@ def sort_url(view, painter):
sorter = group_sort + user_sort + view_sort
# Now apply the sorter of the current column:
- # - Negate when already in sorters
+ # - Negate/Disable when at first position
+ # - Move to the first position when already in sorters
# - Add in the front of the user sorters when not set
sorter_name = get_sorter_name_of_painter(painter)
this_asc_sorter = (sorter_name, False)
this_desc_sorter = (sorter_name, True)
- if this_asc_sorter in sorter:
+ if sorter and this_asc_sorter == sorter[0]:
# Second click: Change from asc to desc order
sorter[sorter.index(this_asc_sorter)] = this_desc_sorter
- elif this_desc_sorter in sorter:
+ elif sorter and this_desc_sorter == sorter[0]:
# Third click: Remove this sorter
sorter.remove(this_desc_sorter)
else:
- # First click: add this sorter
+ # First click: add this sorter as primary user sorter
+ # Maybe the sorter is already in the user sorters, remove it
+ if this_asc_sorter in sorter:
+ sorter.remove(this_asc_sorter)
+ if this_desc_sorter in sorter:
+ sorter.remove(this_desc_sorter)
+ # Now add the sorter as primary user sorter
sorter = group_sort + [this_asc_sorter] + user_sort + view_sort
return ','.join([ ('-' if s[1] else '') + s[0] for s in sorter ])
Module: check_mk
Branch: master
Commit: dd15c7c4c8088a97baec0ddce19c81324fa96172
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd15c7c4c8088a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 24 13:04:05 2011 +0200
Fixed header title highlight of the first sorter
---
web/htdocs/views.py | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 8d27ef4..fd4e0de 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2192,11 +2192,11 @@ def get_sorter_name_of_painter(painter):
elif painter['name'] in multisite_sorters:
return painter['name']
-def get_primary_sorter_order(painter):
+def get_primary_sorter_order(view, painter):
sorter_name = get_sorter_name_of_painter(painter)
this_asc_sorter = (sorter_name, False)
this_desc_sorter = (sorter_name, True)
- user_sort = parse_url_sorters(html.var('sort'))
+ group_sort, user_sort, view_sort = get_separated_sorters(view)
if user_sort and this_asc_sorter == user_sort[0]:
return 'asc'
elif user_sort and this_desc_sorter == user_sort[0]:
@@ -2204,31 +2204,37 @@ def get_primary_sorter_order(painter):
else:
return ''
-def sort_url(view_sorters, group_painters, painter):
- """
- The following sorters need to be handled in this order:
-
- 1. group by sorter (needed in grouped views)
- 2. user defined sorters (url sorter)
- 3. configured view sorters
- """
- sort = html.var('sort', None)
- sorter = []
-
+def get_separated_sorters(view):
group_sort = [ (get_sorter_name_of_painter(multisite_painters[p[0]]), False)
- for p in group_painters
+ for p in view['group_painters']
if p[0] in multisite_painters ]
- view_sort = [ s for s in view_sorters if not s[0] in group_sort ]
+ view_sort = [ s for s in view['sorters'] if not s[0] in group_sort ]
# Get current url individual sorters. Parse the "sort" url parameter,
# then remove the group sorters. The left sorters must be the user
# individual sorters for this view.
# Then remove the user sorters from the view sorters
- user_sort = parse_url_sorters(sort)
+ user_sort = parse_url_sorters(html.var('sort'))
substract_sorters(user_sort, group_sort)
substract_sorters(view_sort, user_sort)
+ return group_sort, user_sort, view_sort
+
+
+def sort_url(view, painter):
+ """
+ The following sorters need to be handled in this order:
+
+ 1. group by sorter (needed in grouped views)
+ 2. user defined sorters (url sorter)
+ 3. configured view sorters
+ """
+ sort = html.var('sort', None)
+ sorter = []
+
+ group_sort, user_sort, view_sort = get_separated_sorters(view)
+
sorter = group_sort + user_sort + view_sort
# Now apply the sorter of the current column:
@@ -2268,7 +2274,7 @@ def paint_header(view, p):
# - Keep the _body_class variable (e.g. for dashlets)
if view.get('user_sortable', True) and get_sorter_name_of_painter(painter) is not None:
params = [
- ('sort', sort_url(view['sorters'], view['group_painters'], painter)),
+ ('sort', sort_url(view, painter)),
]
if html.has_var('_body_class'):
params.append(('_body_class', html.var('_body_class')))
@@ -2276,7 +2282,7 @@ def paint_header(view, p):
params.append(('display_options', html.var('display_options')))
t = "<a class=\"%s\" href=\"%s\" title=\"%s\" target=\"_self\">%s</a>" % \
- (get_primary_sorter_order(painter),
+ (get_primary_sorter_order(view, painter),
html.makeuri(params, 'sort'),
_('Sort by %s') % t, t)