Skip to content

Commit

Permalink
Merge pull request #144 from flask-dashboard/graph_names
Browse files Browse the repository at this point in the history
Graph names
  • Loading branch information
FlyingBird95 committed May 21, 2018
2 parents 32f5393 + eaa26a6 commit 61a99ad
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions flask_monitoringdashboard/core/forms/daterange.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SelectDateRangeForm(FlaskForm):
""" Used for selecting two dates, which together specify a range. """
start_date = DateField('Start date', format=DATE_FORMAT, validators=[validators.data_required()])
end_date = DateField('End date', format=DATE_FORMAT, validators=[validators.data_required()])
submit = SubmitField('Submit')
title = 'Select two dates for reducing the size of the graph'
submit = SubmitField('Update')
title = 'Select the time interval'

def get_days(self):
"""
Expand Down
10 changes: 7 additions & 3 deletions flask_monitoringdashboard/core/forms/double_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DoubleSliderForm(FlaskForm):
"""
slider0 = IntegerRangeField()
slider1 = IntegerRangeField()
submit = SubmitField('Submit')
submit = SubmitField('Update')
title = 'Select two numbers below for reducing the size of the graph'
subtitle = ['Subtitle0', 'Subtitle1']

Expand Down Expand Up @@ -54,15 +54,19 @@ def content(self):
self.submit(class_="btn btn-primary btn-block"))


def get_double_slider_form(slider_max=[100, 100], subtitle=None):
def get_double_slider_form(slider_max=(100, 100), title=None, subtitle=None):
"""
Return a SliderForm with the range from 0 to slider_max
:param slider_max: maximum value for the slider
:param title: override the default title
:param subtitle: override the default titles of the 2 sliders
:return: a SliderForm with the range (0 ... slider_max)
"""
form = DoubleSliderForm(request.form)
form.min_value = [1, 1]
form.min_value = (1, 1)
form.max_value = slider_max
if title:
form.title = title
if subtitle:
form.subtitle = subtitle
if 'slider0' in request.form:
Expand Down
7 changes: 5 additions & 2 deletions flask_monitoringdashboard/core/forms/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SliderForm(FlaskForm):
Class for generating a slider that can be used to reduce the graph.
"""
slider = IntegerRangeField()
submit = SubmitField('Submit')
submit = SubmitField('Update')
title = 'Select a number below for reducing the size of the graph'

def get_slider_value(self):
Expand All @@ -38,15 +38,18 @@ def content(self):
self.submit(class_="btn btn-primary btn-block"))


def get_slider_form(slider_max=100):
def get_slider_form(slider_max=100, title=None):
"""
Return a SliderForm with the range from 0 to slider_max
:param slider_max: maximum value for the slider
:param title: override the default title
:return: a SliderForm with the range (0 ... slider_max)
"""
form = SliderForm(request.form)
form.min_value = 1
form.max_value = slider_max
if title:
form.title = title
if 'slider' in request.form:
form.start_value = request.form['slider']
else:
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/templates/fmd_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h4>Flask Monitoring Dashboard</h4>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav navbar-sidenav nav-pills" id="exampleAccordion">
<ul class="navbar-nav navbar-sidenav nav-pills" id="exampleAccordion" style="overflow: hidden">
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="Rules">
<a class="nav-link {{ active_if_is(rules_endpoint) }}" href="{{ url_for(rules_endpoint) }}">
<i class="fa fa-fw fa-wrench"></i>
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/views/dashboard/version_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@secure
def version_usage():
with session_scope() as db_session:
form = get_slider_form(count_versions(db_session))
form = get_slider_form(count_versions(db_session), 'Select the number of versions')
graph = version_usage_graph(form)
return render_template('fmd_dashboard/graph.html', graph=graph, title=TITLE,
information=get_information(AXES_INFO, CONTENT_INFO), form=form)
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/views/details/time_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def users(end):
with session_scope() as db_session:
details = get_endpoint_details(db_session, end)
form = get_slider_form(count_users(db_session, end))
form = get_slider_form(count_users(db_session, end), title='Select the number of users')
graph = users_graph(end, form)

return render_template('fmd_dashboard/graph-details.html', details=details, graph=graph, form=form,
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/views/details/time_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@secure
def versions(end):
with session_scope() as db_session:
form = get_slider_form(count_versions_end(db_session, end))
form = get_slider_form(count_versions_end(db_session, end), title='Select the number of versions')
details = get_endpoint_details(db_session, end)
graph = versions_graph(db_session, end, form)
return render_template('fmd_dashboard/graph-details.html', details=details, graph=graph,
Expand Down
3 changes: 2 additions & 1 deletion flask_monitoringdashboard/views/details/version_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def version_ip(end):
with session_scope() as db_session:
details = get_endpoint_details(db_session, end)
form = get_double_slider_form([count_ip(db_session, end), count_versions_end(db_session, end)],
subtitle=['Amount of IP-addresses', 'Amount of Versions'])
subtitle=['IP-addresses', 'Versions'],
title='Select the number of IP-addresses and versions')
graph = version_ip_graph(db_session, end, form)
return render_template('fmd_dashboard/graph-details.html', details=details, graph=graph, form=form,
title='{} for {}'.format(TITLE, end),
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/views/details/version_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def version_user(end):
with session_scope() as db_session:
details = get_endpoint_details(db_session, end)
form = get_double_slider_form([count_users(db_session, end), count_versions_end(db_session, end)],
subtitle=['Amount of Users', 'Amount of Versions'])
subtitle=['Users', 'Versions'], title='Select the number of users and versions')
graph = version_user_graph(db_session, end, form)
return render_template('fmd_dashboard/graph-details.html', details=details, graph=graph, form=form,
title='{} for {}'.format(TITLE, end),
Expand Down

0 comments on commit 61a99ad

Please sign in to comment.