mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Showing slices on datasource edit form (#2645)
* Showing slices on datasource edit form * fixing build
This commit is contained in:
parent
e055e6d2c2
commit
03c42b5b87
@ -331,6 +331,11 @@ class DruidDatasource(Model, BaseDatasource):
|
|||||||
'datasource_name', 'is_hidden', 'description', 'default_endpoint',
|
'datasource_name', 'is_hidden', 'description', 'default_endpoint',
|
||||||
'cluster_name', 'offset', 'cache_timeout', 'params'
|
'cluster_name', 'offset', 'cache_timeout', 'params'
|
||||||
)
|
)
|
||||||
|
slices = relationship(
|
||||||
|
'Slice',
|
||||||
|
primaryjoin=(
|
||||||
|
"DruidDatasource.id == foreign(Slice.datasource_id) and "
|
||||||
|
"Slice.datasource_type == 'druid'"))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def database(self):
|
def database(self):
|
||||||
|
@ -155,7 +155,7 @@ class DruidDatasourceModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
'datasource_link', 'changed_on_', 'offset']
|
'datasource_link', 'changed_on_', 'offset']
|
||||||
related_views = [DruidColumnInlineView, DruidMetricInlineView]
|
related_views = [DruidColumnInlineView, DruidMetricInlineView]
|
||||||
edit_columns = [
|
edit_columns = [
|
||||||
'datasource_name', 'cluster', 'description', 'owner',
|
'datasource_name', 'cluster', 'slices', 'description', 'owner',
|
||||||
'is_hidden',
|
'is_hidden',
|
||||||
'filter_select_enabled', 'fetch_values_from',
|
'filter_select_enabled', 'fetch_values_from',
|
||||||
'default_endpoint', 'offset', 'cache_timeout']
|
'default_endpoint', 'offset', 'cache_timeout']
|
||||||
@ -164,6 +164,14 @@ class DruidDatasourceModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
page_size = 500
|
page_size = 500
|
||||||
base_order = ('datasource_name', 'asc')
|
base_order = ('datasource_name', 'asc')
|
||||||
description_columns = {
|
description_columns = {
|
||||||
|
'slices': _(
|
||||||
|
"The list of slices associated with this table. By "
|
||||||
|
"altering this datasource, you may change how these associated "
|
||||||
|
"slices behave. "
|
||||||
|
"Also note that slices need to point to a datasource, so "
|
||||||
|
"this form will fail at saving if removing slices from a "
|
||||||
|
"datasource. If you want to change the datasource for a slice, "
|
||||||
|
"overwrite the slice from the 'explore view'"),
|
||||||
'offset': _("Timezone offset (in hours) for this datasource"),
|
'offset': _("Timezone offset (in hours) for this datasource"),
|
||||||
'description': Markup(
|
'description': Markup(
|
||||||
"Supports <a href='"
|
"Supports <a href='"
|
||||||
@ -185,6 +193,7 @@ class DruidDatasourceModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
}
|
}
|
||||||
base_filters = [['id', DatasourceFilter, lambda: []]]
|
base_filters = [['id', DatasourceFilter, lambda: []]]
|
||||||
label_columns = {
|
label_columns = {
|
||||||
|
'slices': _("Associated Slices"),
|
||||||
'datasource_link': _("Data Source"),
|
'datasource_link': _("Data Source"),
|
||||||
'cluster': _("Cluster"),
|
'cluster': _("Cluster"),
|
||||||
'description': _("Description"),
|
'description': _("Description"),
|
||||||
|
@ -177,6 +177,11 @@ class SqlaTable(Model, BaseDatasource):
|
|||||||
foreign_keys=[database_id])
|
foreign_keys=[database_id])
|
||||||
schema = Column(String(255))
|
schema = Column(String(255))
|
||||||
sql = Column(Text)
|
sql = Column(Text)
|
||||||
|
slices = relationship(
|
||||||
|
'Slice',
|
||||||
|
primaryjoin=(
|
||||||
|
"SqlaTable.id == foreign(Slice.datasource_id) and "
|
||||||
|
"Slice.datasource_type == 'table'"))
|
||||||
|
|
||||||
baselink = "tablemodelview"
|
baselink = "tablemodelview"
|
||||||
export_fields = (
|
export_fields = (
|
||||||
|
@ -142,7 +142,7 @@ class TableModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
'link', 'database', 'changed_on_']
|
'link', 'database', 'changed_on_']
|
||||||
add_columns = ['database', 'schema', 'table_name']
|
add_columns = ['database', 'schema', 'table_name']
|
||||||
edit_columns = [
|
edit_columns = [
|
||||||
'table_name', 'sql', 'filter_select_enabled',
|
'table_name', 'sql', 'filter_select_enabled', 'slices',
|
||||||
'fetch_values_predicate', 'database', 'schema',
|
'fetch_values_predicate', 'database', 'schema',
|
||||||
'description', 'owner',
|
'description', 'owner',
|
||||||
'main_dttm_col', 'default_endpoint', 'offset', 'cache_timeout']
|
'main_dttm_col', 'default_endpoint', 'offset', 'cache_timeout']
|
||||||
@ -150,6 +150,14 @@ class TableModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
||||||
base_order = ('changed_on', 'desc')
|
base_order = ('changed_on', 'desc')
|
||||||
description_columns = {
|
description_columns = {
|
||||||
|
'slices': _(
|
||||||
|
"The list of slices associated with this table. By "
|
||||||
|
"altering this datasource, you may change how these associated "
|
||||||
|
"slices behave. "
|
||||||
|
"Also note that slices need to point to a datasource, so "
|
||||||
|
"this form will fail at saving if removing slices from a "
|
||||||
|
"datasource. If you want to change the datasource for a slice, "
|
||||||
|
"overwrite the slice from the 'explore view'"),
|
||||||
'offset': _("Timezone offset (in hours) for this datasource"),
|
'offset': _("Timezone offset (in hours) for this datasource"),
|
||||||
'table_name': _(
|
'table_name': _(
|
||||||
"Name of the table that exists in the source database"),
|
"Name of the table that exists in the source database"),
|
||||||
@ -179,6 +187,7 @@ class TableModelView(SupersetModelView, DeleteMixin): # noqa
|
|||||||
}
|
}
|
||||||
base_filters = [['id', DatasourceFilter, lambda: []]]
|
base_filters = [['id', DatasourceFilter, lambda: []]]
|
||||||
label_columns = {
|
label_columns = {
|
||||||
|
'slices': _("Associated Slices"),
|
||||||
'link': _("Table"),
|
'link': _("Table"),
|
||||||
'changed_by_': _("Changed By"),
|
'changed_by_': _("Changed By"),
|
||||||
'database': _("Database"),
|
'database': _("Database"),
|
||||||
|
@ -48,9 +48,10 @@ metadata = Model.metadata # pylint: disable=no-member
|
|||||||
def set_related_perm(mapper, connection, target): # noqa
|
def set_related_perm(mapper, connection, target): # noqa
|
||||||
src_class = target.cls_model
|
src_class = target.cls_model
|
||||||
id_ = target.datasource_id
|
id_ = target.datasource_id
|
||||||
ds = db.session.query(src_class).filter_by(id=int(id_)).first()
|
if id_:
|
||||||
if ds:
|
ds = db.session.query(src_class).filter_by(id=int(id_)).first()
|
||||||
target.perm = ds.perm
|
if ds:
|
||||||
|
target.perm = ds.perm
|
||||||
|
|
||||||
|
|
||||||
class Url(Model, AuditMixinNullable):
|
class Url(Model, AuditMixinNullable):
|
||||||
|
Loading…
Reference in New Issue
Block a user