Skip to content

Commit

Permalink
Add: ability to set dashboard level filters from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
arikfr committed Jun 29, 2017
1 parent 019a099 commit 248c540
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion client/app/pages/dashboards/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,20 @@ function DashboardCtrl($rootScope, $routeParams, $location, $timeout, $q, $uibMo
};

this.editDashboard = () => {
const previousFiltersState = this.dashboard.dashboard_filters_enabled;
$uibModal.open({
component: 'editDashboardDialog',
resolve: {
dashboard: () => this.dashboard,
},
}).result.then((dashboard) => { this.dashboard = dashboard; });
}).result.then((dashboard) => {
const shouldRenderDashboard = !previousFiltersState && dashboard.dashboard_filters_enabled;
this.dashboard = dashboard;

if (shouldRenderDashboard) {
renderDashboard(this.dashboard);
}
});
};

this.addWidget = () => {
Expand Down
7 changes: 7 additions & 0 deletions client/app/pages/dashboards/edit-dashboard-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ <h4 class="modal-title">Edit: {{$ctrl.dashboard.name}}</h4>
<input type="text" class="form-control" placeholder="Dashboard Name" ng-model="$ctrl.dashboard.name">
</p>

<p ng-if="$ctrl.dashboard.id">
<label>
<input name="input" type="checkbox" ng-model="$ctrl.dashboard.dashboard_filters_enabled">
Use Dashboard Level Filters
</label>
</p>

<div gridster="$ctrl.gridsterOptions" ng-if="$ctrl.items | notEmpty">
<ul>
<li gridster-item="item" ng-repeat="item in $ctrl.items" class="widget panel panel-default gs-w">
Expand Down
1 change: 1 addition & 0 deletions client/app/pages/dashboards/edit-dashboard-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const EditDashboardDialog = {
slug: this.dashboard.id,
name: this.dashboard.name,
version: this.dashboard.version,
dashboard_filters_enabled: this.dashboard.dashboard_filters_enabled,
layout: JSON.stringify(layout),
};

Expand Down
2 changes: 1 addition & 1 deletion redash/handlers/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def post(self, dashboard_slug):
require_object_modify_permission(dashboard, self.current_user)

updates = project(dashboard_properties, ('name', 'layout', 'version',
'is_draft'))
'is_draft', 'dashboard_filters_enabled'))

# SQLAlchemy handles the case where a concurrent transaction beats us
# to the update. But we still have to make sure that we're not starting
Expand Down

0 comments on commit 248c540

Please sign in to comment.