-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[add] Save filters to dashboard #3183
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b5543d8
[add] Save filters to dashboard
roganw 581f610
format code
roganw 10e366e
fix CI error
roganw 5df2088
add semicolon semi
roganw b043d7e
fix none object
roganw b38bac4
add test data
roganw 5c11b9f
fix urllib to urllib.parse
roganw 4bbe05d
add space
roganw 5d815b2
update test case
roganw adfd694
remove 'return'
roganw 396e375
fix error
roganw f46ea38
update test case
roganw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
from superset.viz import viz_types | ||
from superset.models.helpers import AuditMixinNullable, ImportMixin, set_perm | ||
install_aliases() | ||
import urllib | ||
from urllib import parse # noqa | ||
|
||
config = app.config | ||
|
@@ -322,6 +323,18 @@ def table_names(self): | |
|
||
@property | ||
def url(self): | ||
if self.json_metadata: | ||
# add default_filters to the preselect_filters of dashboard | ||
json_metadata = json.loads(self.json_metadata) | ||
default_filters = json_metadata.get('default_filters') | ||
if default_filters: | ||
filters = '' | ||
if isinstance(default_filters, str): | ||
filters = urllib.quote(default_filters) | ||
elif isinstance(default_filters, unicode): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this py3 compatible? can we add test coverage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I will check these later. |
||
filters = urllib.quote(default_filters.encode('utf8')) | ||
return "/superset/dashboard/{}/?preselect_filters={}".format( | ||
self.slug or self.id, filters) | ||
return "/superset/dashboard/{}/".format(self.slug or self.id) | ||
|
||
@property | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function calls
this.updateFilterParamsInUrl
3 times. Perhaps clearer logic would be an if statement that validates that there is a slice and column, put all the logic within that block, and callthis.updateFilterParamsInUrl
once at the very end