mirror of https://github.com/apache/superset.git
Merge pull request #89 from mistercrunch/featured_datasets
Featured datasets
This commit is contained in:
commit
d2ae6ceed6
|
@ -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')
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
"""user_id
|
||||
|
||||
Revision ID: 2591d77e9831
|
||||
Revises: 12d55656cbca
|
||||
Create Date: 2015-12-15 17:02:45.128709
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2591d77e9831'
|
||||
down_revision = '12d55656cbca'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('tables') as batch_op:
|
||||
batch_op.add_column(sa.Column('user_id', sa.Integer()))
|
||||
batch_op.create_foreign_key('user_id', 'ab_user', ['user_id'], ['id'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('tables') as batch_op:
|
||||
batch_op.drop_constraint('user_id', type_='foreignkey')
|
||||
batch_op.drop_column('user_id')
|
|
@ -228,6 +228,9 @@ 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)
|
||||
user_id = Column(Integer, ForeignKey('ab_user.id'))
|
||||
owner = relationship('User', backref='tables', foreign_keys=[user_id])
|
||||
database = relationship(
|
||||
'Database', backref='tables', foreign_keys=[database_id])
|
||||
offset = Column(Integer, default=0)
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
{% extends "panoramix/base.html" %}
|
||||
{% block content %}
|
||||
<h1><i class='fa fa-star'></i> Featured Datasets </h1>
|
||||
<hr/>
|
||||
<table class="table table-hover dataTable" id="dataset-table" style="display:None">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Table</th>
|
||||
<th>Database</th>
|
||||
<th>Owner</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for dataset in featured_datasets %}
|
||||
<tr>
|
||||
<td>
|
||||
<h4>{{ dataset.table_name }}</h4>
|
||||
<p>{{ dataset.description }}</p>
|
||||
</td>
|
||||
<td class="small_table">{{ dataset.database }}</td>
|
||||
<td class="small_table">{{ dataset.owner }}</td>
|
||||
<td class="small_table"><a class="btn btn-default" href="{{ dataset.default_endpoint }}"><i class='fa fa-line-chart'/></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
{% block head_css %}
|
||||
{{ super() }}
|
||||
<link rel="stylesheet" type="text/css" href="/static/lib/dataTables/dataTables.bootstrap.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block tail_js %}
|
||||
{{ super() }}
|
||||
<script src="/static/lib/dataTables/jquery.dataTables.min.js"></script>
|
||||
<script src="/static/lib/dataTables/dataTables.bootstrap.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#dataset-table').DataTable({
|
||||
"bPaginate": false,
|
||||
"order": [[ 1, "asc" ]]
|
||||
});
|
||||
$('#dataset-table').show();
|
||||
} );
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -59,6 +59,14 @@ class TableColumnInlineView(CompactCRUDMixin, PanoramixModelView):
|
|||
}
|
||||
appbuilder.add_view_no_menu(TableColumnInlineView)
|
||||
|
||||
appbuilder.add_link(
|
||||
"Featured Datasets",
|
||||
href='/panoramix/featured_datasets',
|
||||
category='Sources',
|
||||
category_icon='fa-table',
|
||||
icon="fa-star")
|
||||
|
||||
appbuilder.add_separator("Sources")
|
||||
|
||||
class ColumnInlineView(CompactCRUDMixin, PanoramixModelView):
|
||||
datamodel = SQLAInterface(models.Column)
|
||||
|
@ -140,8 +148,8 @@ 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',
|
||||
'default_endpoint', 'offset']
|
||||
'table_name', 'is_featured', 'database', 'description', 'owner',
|
||||
'main_dttm_col', 'default_endpoint', 'offset']
|
||||
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
||||
base_order = ('changed_on','desc')
|
||||
description_columns = {
|
||||
|
@ -538,6 +546,19 @@ class Panoramix(BaseView):
|
|||
title=ascii_art.stacktrace,
|
||||
art=ascii_art.error), 500
|
||||
|
||||
@has_access
|
||||
@expose("/featured_datasets", methods=['GET'])
|
||||
def featured_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