-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from rdytech/NEP-17500-update-tag-filter
NEP-17500 Filter dashboards by array of tags
- Loading branch information
Showing
24 changed files
with
568 additions
and
28 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
# TODO: the gui delete has a confirmation step, this API call does not. | ||
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all charts either | ||
# 1 belong to only an expected dashboard before deleting | ||
# 2 or do not belong to any dashboards | ||
# ( not sure if this needed at this point ) | ||
|
||
module Superset | ||
module Chart | ||
class BulkDelete < Superset::Request | ||
attr_reader :chart_ids | ||
|
||
def initialize(chart_ids: []) | ||
@chart_ids = chart_ids | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "chart_ids array of integers expected" unless chart_ids.is_a?(Array) | ||
raise InvalidParameterError, "chart_ids array must contain Integer only values" unless chart_ids.all? { |item| item.is_a?(Integer) } | ||
|
||
logger.info("Attempting to delete charts with id: #{chart_ids.join(', ')}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route, params) | ||
end | ||
|
||
private | ||
|
||
def params | ||
{ q: "!(#{chart_ids.join(',')})" } | ||
end | ||
|
||
def route | ||
"chart/" | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Superset | ||
module Chart | ||
class Delete < Superset::Request | ||
attr_reader :chart_id | ||
|
||
def initialize(chart_id: ) | ||
@chart_id = chart_id | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "chart_id integer is required" unless chart_id.present? && chart_id.is_a?(Integer) | ||
|
||
logger.info("Attempting to delete chart with id: #{chart_id}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route) | ||
end | ||
|
||
private | ||
|
||
def route | ||
"chart/#{chart_id}" | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# TODO: the gui delete has a confirmation step, this API call does not. | ||
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all dashboards either | ||
# 1 have an expected set of charts or filters before deleting | ||
# 2 or do not have any charts or filters linked to them | ||
# ( not sure if this needed at this point ) | ||
|
||
module Superset | ||
module Dashboard | ||
class BulkDelete < Superset::Request | ||
attr_reader :dashboard_ids | ||
|
||
def initialize(dashboard_ids: []) | ||
@dashboard_ids = dashboard_ids | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "dashboard_ids array of integers expected" unless dashboard_ids.is_a?(Array) | ||
raise InvalidParameterError, "dashboard_ids array must contain Integer only values" unless dashboard_ids.all? { |item| item.is_a?(Integer) } | ||
|
||
logger.info("Attempting to delete dashboards with id: #{dashboard_ids.join(', ')}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route, params) | ||
end | ||
|
||
private | ||
|
||
def params | ||
{ q: "!(#{dashboard_ids.join(',')})" } | ||
end | ||
|
||
def route | ||
"dashboard/" | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
module Superset | ||
module Dashboard | ||
class Delete < Superset::Request | ||
|
||
attr_reader :dashboard_id, :confirm_zero_charts | ||
|
||
def initialize(dashboard_id: , confirm_zero_charts: true) | ||
@dashboard_id = dashboard_id | ||
@confirm_zero_charts = confirm_zero_charts | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "dashboard_id integer is required" unless dashboard_id.present? && dashboard_id.is_a?(Integer) | ||
|
||
confirm_zero_charts_on_dashboard if confirm_zero_charts | ||
|
||
logger.info("Attempting to delete dashboard with id: #{dashboard_id}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route) | ||
end | ||
|
||
private | ||
|
||
def confirm_zero_charts_on_dashboard | ||
raise "Error: Dashboard includes #{dashboard_charts.count} charts. Please delete all charts before deleting the dashboard or override and set confirm_zero_charts: false" if dashboard_charts.count.positive? | ||
end | ||
|
||
def dashboard_charts | ||
@dashboard_charts ||= Superset::Dashboard::Charts::List.new(dashboard_id).rows | ||
end | ||
|
||
def route | ||
"dashboard/#{dashboard_id}" | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
# TODO: the gui delete has a confirmation step, this API call does not. | ||
# Potentially we could add a confirm_delete parameter to the constructor that would ensure that all datasets either | ||
# 1 belong to only an expected charts or filters before deleting | ||
# 2 or do not belong to any charts or filters | ||
# ( not sure if this needed at this point ) | ||
|
||
module Superset | ||
module Dataset | ||
class BulkDelete < Superset::Request | ||
attr_reader :dataset_ids | ||
|
||
def initialize(dataset_ids: []) | ||
@dataset_ids = dataset_ids | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "dataset_ids array of integers expected" unless dataset_ids.is_a?(Array) | ||
raise InvalidParameterError, "dataset_ids array must contain Integer only values" unless dataset_ids.all? { |item| item.is_a?(Integer) } | ||
|
||
logger.info("Attempting to delete datasets with id: #{dataset_ids.join(', ')}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route, params) | ||
end | ||
|
||
private | ||
|
||
def params | ||
{ q: "!(#{dataset_ids.join(',')})" } | ||
end | ||
|
||
def route | ||
"dataset/" | ||
end | ||
end | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
module Superset | ||
module Dataset | ||
class Delete < Superset::Request | ||
attr_reader :dataset_id | ||
|
||
def initialize(dataset_id: ) | ||
@dataset_id = dataset_id | ||
end | ||
|
||
def perform | ||
raise InvalidParameterError, "dataset_id integer is required" unless dataset_id.present? && dataset_id.is_a?(Integer) | ||
|
||
logger.info("Attempting to delete dataset with id: #{dataset_id}") | ||
response | ||
end | ||
|
||
def response | ||
@response ||= client.delete(route) | ||
end | ||
|
||
private | ||
|
||
def route | ||
"dataset/#{dataset_id}" | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.