Module: check_mk
Branch: master
Commit: 24513fe9e4da5633d4281536be03744a0a6e5078
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=24513fe9e4da56…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Nov 30 16:20:10 2011 +0100
Mobile: show counts in list overviews
---
web/htdocs/mobile.py | 3 ++-
web/htdocs/views.py | 9 +++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/mobile.py b/web/htdocs/mobile.py
index 645b7cb..aea183a 100644
--- a/web/htdocs/mobile.py
+++ b/web/htdocs/mobile.py
@@ -134,9 +134,10 @@ def page_index():
for view_name, view in html.available_views.items():
if view.get("mobile") and not view.get("hidden"):
url = "mobile_view.py?view_name=%s" % view_name
+ count = views.show_view(view, only_count = True)
if view.get("mustsearch"):
url += "#filter"
- items.append((url, view["title"]))
+ items.append((url, '%s <span
class="ui-li-count">%d</span>' % (view["title"],
count)))
jqm_page_index(_("Check_MK Mobile"), items)
jqm_page_footer()
mobile_html_foot()
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 47c7c17..740e9a8 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1164,7 +1164,7 @@ def prepare_display_options():
# Display view with real data. This is *the* function everying
# is about.
def show_view(view, show_heading = False, show_buttons = True,
- show_footer = True, render_function = None):
+ show_footer = True, render_function = None, only_count=False):
display_options = prepare_display_options()
# User can override the layout settings via HTML variables (buttons)
@@ -1274,17 +1274,22 @@ def show_view(view, show_heading = False, show_buttons = True,
painter_options.sort()
# Fetch data. Some views show data only after pressing [Search]
- if (not view["mustsearch"]) or html.var("search"):
+ if (only_count or (not view["mustsearch"]) or
html.var("search")):
# names for additional columns (through Stats: headers)
add_columns = datasource.get("add_columns", [])
# tablename may be a function instead of a livestatus tablename
# In that case that function is used to compute the result.
+
if type(tablename) == type(lambda x:None):
rows = tablename(columns, query, only_sites, get_limit(),
all_active_filters)
else:
rows = query_data(datasource, columns, add_columns, query, only_sites,
get_limit())
+ # TODO: Use livestatus Stats: instead of fetching rows!
+ if only_count:
+ return len(rows)
+
# Now add join information, if there are join columns
if len(join_painters) > 0:
do_table_join(datasource, rows, filterheaders, join_painters, join_columns,
only_sites)