mirror of https://github.com/apache/superset.git
Adding owner to sqlatables and changing some of the formatting using DataTables
This commit is contained in:
parent
30df7be258
commit
6155ff8de6
|
@ -0,0 +1,27 @@
|
|||
"""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'):
|
||||
op.drop_constraint(None, 'tables', type_='foreignkey')
|
||||
op.drop_column('tables', 'user_id')
|
||||
|
|
@ -229,6 +229,8 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
|||
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)
|
||||
|
|
|
@ -4,15 +4,14 @@
|
|||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.data-title{
|
||||
font-size: 26px;
|
||||
font-weight: strong;
|
||||
.small_table {
|
||||
width: 170px;
|
||||
}
|
||||
|
||||
table {
|
||||
#data-title{
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
#dataset-table {
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
|
@ -4,24 +4,38 @@
|
|||
<div class="main-text">
|
||||
Featured Datasets
|
||||
</div>
|
||||
<table class = "table table-hover">
|
||||
<table class = "table table-hover" id="dataset-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Table</th>
|
||||
<th>Database</th>
|
||||
<th>Owner</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for dataset in featured_datasets %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href='{{ dataset.default_endpoint }}' class="data-title">{{ dataset.table_name }}</a>
|
||||
<div id="data-title">{{ dataset.table_name }}</div>
|
||||
</br> {{ dataset.description }}
|
||||
</td>
|
||||
<td>{{ dataset.database }}</td>
|
||||
<td class="small_table">{{ dataset.database }}</td>
|
||||
<td class="small_table">{{ dataset.owner }}</td>
|
||||
<td class="small_table"><button type="button" class="btn btn-primary" href="{{ dataset.default_endpoint }}">Visualize it!</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
{% block tail %}
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css" />
|
||||
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#dataset-table').DataTable();
|
||||
} );
|
||||
</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")
|
||||
|
||||
|
||||
|
||||
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', 'is_featured', '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 = {
|
||||
|
@ -539,8 +547,8 @@ class Panoramix(BaseView):
|
|||
art=ascii_art.error), 500
|
||||
|
||||
@has_access
|
||||
@expose("/datasets", methods=['GET'])
|
||||
def datasets(self):
|
||||
@expose("/featured_datasets", methods=['GET'])
|
||||
def featured_datasets(self):
|
||||
session = db.session()
|
||||
datasets_sqla = (session.query(models.SqlaTable)
|
||||
.filter_by(is_featured=True).all())
|
||||
|
|
Loading…
Reference in New Issue