mirror of https://github.com/apache/superset.git
Adding a view for featured datasets
This commit is contained in:
parent
dcd36780ef
commit
30df7be258
|
@ -0,0 +1,23 @@
|
|||
"""is_featured
|
||||
|
||||
Revision ID: 12d55656cbca
|
||||
Revises: 55179c7f25c7
|
||||
Create Date: 2015-12-14 13:37:17.374852
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '12d55656cbca'
|
||||
down_revision = '55179c7f25c7'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('tables', sa.Column('is_featured', sa.Boolean(), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('tables', 'is_featured')
|
||||
|
|
@ -228,6 +228,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
|||
description = Column(Text)
|
||||
default_endpoint = Column(Text)
|
||||
database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False)
|
||||
is_featured = Column(Boolean, default=False)
|
||||
database = relationship(
|
||||
'Database', backref='tables', foreign_keys=[database_id])
|
||||
offset = Column(Integer, default=0)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
.main-text {
|
||||
text-align: center;
|
||||
font-size: 36px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.data-title{
|
||||
font-size: 26px;
|
||||
font-weight: strong;
|
||||
}
|
||||
|
||||
table {
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
{% extends "panoramix/base.html" %}
|
||||
{% block content %}
|
||||
<link rel="stylesheet" type="text/css" href="/static/featured_datasets.css" />
|
||||
<div class="main-text">
|
||||
Featured Datasets
|
||||
</div>
|
||||
<table class = "table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Table</th>
|
||||
<th>Database</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for dataset in featured_datasets %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href='{{ dataset.default_endpoint }}' class="data-title">{{ dataset.table_name }}</a>
|
||||
</br> {{ dataset.description }}
|
||||
</td>
|
||||
<td>{{ dataset.database }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
|
@ -140,7 +140,7 @@ class TableView(PanoramixModelView, DeleteMixin):
|
|||
list_columns = ['table_link', 'database', 'changed_by', 'changed_on_']
|
||||
add_columns = ['table_name', 'database', 'default_endpoint', 'offset']
|
||||
edit_columns = [
|
||||
'table_name', 'database', 'description', 'main_dttm_col',
|
||||
'table_name', 'is_featured', 'database', 'description', 'main_dttm_col',
|
||||
'default_endpoint', 'offset']
|
||||
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
||||
base_order = ('changed_on','desc')
|
||||
|
@ -538,6 +538,19 @@ class Panoramix(BaseView):
|
|||
title=ascii_art.stacktrace,
|
||||
art=ascii_art.error), 500
|
||||
|
||||
@has_access
|
||||
@expose("/datasets", methods=['GET'])
|
||||
def datasets(self):
|
||||
session = db.session()
|
||||
datasets_sqla = (session.query(models.SqlaTable)
|
||||
.filter_by(is_featured=True).all())
|
||||
datasets_druid = (session.query(models.Datasource)
|
||||
.filter_by(is_featured=True).all())
|
||||
featured_datasets = datasets_sqla + datasets_druid
|
||||
return self.render_template(
|
||||
'panoramix/featured_datasets.html',
|
||||
featured_datasets=featured_datasets)
|
||||
|
||||
appbuilder.add_view_no_menu(Panoramix)
|
||||
appbuilder.add_link(
|
||||
"Refresh Druid Metadata",
|
||||
|
|
Loading…
Reference in New Issue