Skip to content

Commit

Permalink
Added dashboard standalone page (#1429)
Browse files Browse the repository at this point in the history
* Added dashboard standalone page

* Deleted additional template, parameterized dashboard.html for standalone

* Only wrap add-slice-container for standalone instead of including whole modal

* Use standalone_mode argument passed from both explore view and dashboard view
  • Loading branch information
vera-liu committed Oct 26, 2016
1 parent 5944643 commit 64d1964
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion caravel/templates/caravel/basic.html
Expand Up @@ -21,7 +21,7 @@

<body>
{% block navbar %}
{% if not viz or viz.request.args.get("standalone") != "true" %}
{% if not standalone_mode %}
<header class="top" role="header">
{% include 'appbuilder/navbar.html' %}
</header>
Expand Down
54 changes: 29 additions & 25 deletions caravel/templates/caravel/dashboard.html
Expand Up @@ -71,7 +71,9 @@ <h6><strong>Choose how frequent should the dashboard refresh</strong></h6>
</div>
</div>
</div>
<div id="add-slice-container"></div>
{% if not standalone_mode %}
<div id="add-slice-container"></div>
{% endif %}

<div class="title">
<div class="row">
Expand All @@ -83,31 +85,33 @@ <h1>
<span class="favstar" class_name="Dashboard" obj_id="{{ dashboard.id }}"></span>
</h1>
</div>
<div class="col-md-4">
<div class="btn-group pull-right" role="group" >
<button type="button" id="refresh_dash" class="btn btn-default btn-sm" data-toggle="tooltip" title="Force refresh the whole dashboard">
<i class="fa fa-refresh"></i>
</button>
<button type="button" id="add-slice" class="btn btn-default btn-sm {{ "disabled disabledButton" if not dash_save_perm }}" data-toggle="modal" data-target="#add_slice_modal">
<i class="fa fa-plus" data-toggle="tooltip" title="Add a new slice to the dashboard"></i>
</button>
<button type="button" id="refresh_dash_periodic" class="btn btn-default btn-sm" data-toggle="modal" data-target="#refresh_modal">
<i class="fa fa-clock-o" data-toggle="tooltip" title="Decide how frequent should the dashboard refresh"></i>
</button>
<button type="button" id="filters" class="btn btn-default btn-sm" data-toggle="tooltip" title="View the list of active filters">
<i class="fa fa-filter"></i>
</button>
<button type="button" id="css" class="btn btn-default btn-sm{{ "disabled disabledButton" if not dash_edit_perm }} " data-toggle="modal" data-target="#css_modal">
<i class="fa fa-css3" data-toggle="tooltip" title="Edit the dashboard's CSS"></i>
</button>
<a id="editdash" class="btn btn-default btn-sm{{ "disabled disabledButton" if not dash_edit_perm }} " href="/dashboardmodelview/edit/{{ dashboard.id }}" title="Edit this dashboard's property" data-toggle="tooltip" >
<i class="fa fa-edit"></i>
</a>
<button type="button" id="savedash" class="btn btn-default btn-sm {{ "disabled disabledButton" if not dash_save_perm }}" data-toggle="tooltip" title="Save the current positioning and CSS">
<i class="fa fa-save"></i>
</button>
{% if not standalone_mode %}
<div class="col-md-4">
<div class="btn-group pull-right" role="group" >
<button type="button" id="refresh_dash" class="btn btn-default btn-sm" data-toggle="tooltip" title="Force refresh the whole dashboard">
<i class="fa fa-refresh"></i>
</button>
<button type="button" id="add-slice" class="btn btn-default btn-sm {{ "disabled disabledButton" if not dash_save_perm }}" data-toggle="modal" data-target="#add_slice_modal">
<i class="fa fa-plus" data-toggle="tooltip" title="Add a new slice to the dashboard"></i>
</button>
<button type="button" id="refresh_dash_periodic" class="btn btn-default btn-sm" data-toggle="modal" data-target="#refresh_modal">
<i class="fa fa-clock-o" data-toggle="tooltip" title="Decide how frequent should the dashboard refresh"></i>
</button>
<button type="button" id="filters" class="btn btn-default btn-sm" data-toggle="tooltip" title="View the list of active filters">
<i class="fa fa-filter"></i>
</button>
<button type="button" id="css" class="btn btn-default btn-sm{{ "disabled disabledButton" if not dash_edit_perm }} " data-toggle="modal" data-target="#css_modal">
<i class="fa fa-css3" data-toggle="tooltip" title="Edit the dashboard's CSS"></i>
</button>
<a id="editdash" class="btn btn-default btn-sm{{ "disabled disabledButton" if not dash_edit_perm }} " href="/dashboardmodelview/edit/{{ dashboard.id }}" title="Edit this dashboard's property" data-toggle="tooltip" >
<i class="fa fa-edit"></i>
</a>
<button type="button" id="savedash" class="btn btn-default btn-sm {{ "disabled disabledButton" if not dash_save_perm }}" data-toggle="tooltip" title="Save the current positioning and CSS">
<i class="fa fa-save"></i>
</button>
</div>
</div>
</div>
{% endif %}
</div>
</div>

Expand Down
6 changes: 4 additions & 2 deletions caravel/views.py
Expand Up @@ -1346,7 +1346,7 @@ def explore(self, datasource_type, datasource_id):
headers=generate_download_headers("csv"),
mimetype="application/csv")
elif request.args.get("standalone") == "true":
return self.render_template("caravel/standalone.html", viz=viz_obj)
return self.render_template("caravel/standalone.html", viz=viz_obj, standalone_mode=True)
else:
return self.render_template(
"caravel/explore.html",
Expand Down Expand Up @@ -1796,12 +1796,14 @@ def dashboard(**kwargs): # noqa
dash_edit_perm = check_ownership(dash, raise_if_false=False)
dash_save_perm = \
dash_edit_perm and self.can_access('can_save_dash', 'Caravel')
standalone = request.args.get("standalone") == "true"
return self.render_template(
"caravel/dashboard.html", dashboard=dash,
user_id=g.user.get_id(),
templates=templates,
dash_save_perm=dash_save_perm,
dash_edit_perm=dash_edit_perm)
dash_edit_perm=dash_edit_perm,
standalone_mode=standalone)

@has_access
@expose("/sync_druid/", methods=['POST'])
Expand Down

0 comments on commit 64d1964

Please sign in to comment.