mirror of
https://github.com/apache/superset.git
synced 2024-09-12 16:49:40 -04:00
Adding owner to sqlatables and changing some of the formatting using DataTables
This commit is contained in:
parent
30df7be258
commit
6155ff8de6
27
panoramix/migrations/versions/2591d77e9831_user_id.py
Normal file
27
panoramix/migrations/versions/2591d77e9831_user_id.py
Normal file
@ -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)
|
default_endpoint = Column(Text)
|
||||||
database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False)
|
database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False)
|
||||||
is_featured = Column(Boolean, default=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 = relationship(
|
||||||
'Database', backref='tables', foreign_keys=[database_id])
|
'Database', backref='tables', foreign_keys=[database_id])
|
||||||
offset = Column(Integer, default=0)
|
offset = Column(Integer, default=0)
|
||||||
|
@ -4,15 +4,14 @@
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-title{
|
.small_table {
|
||||||
font-size: 26px;
|
width: 170px;
|
||||||
font-weight: strong;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
#data-title{
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#dataset-table {
|
||||||
border-bottom: 1px solid #dddddd;
|
border-bottom: 1px solid #dddddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
@ -4,24 +4,38 @@
|
|||||||
<div class="main-text">
|
<div class="main-text">
|
||||||
Featured Datasets
|
Featured Datasets
|
||||||
</div>
|
</div>
|
||||||
<table class = "table table-hover">
|
<table class = "table table-hover" id="dataset-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Table</th>
|
<th>Table</th>
|
||||||
<th>Database</th>
|
<th>Database</th>
|
||||||
|
<th>Owner</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for dataset in featured_datasets %}
|
{% for dataset in featured_datasets %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href='{{ dataset.default_endpoint }}' class="data-title">{{ dataset.table_name }}</a>
|
<div id="data-title">{{ dataset.table_name }}</div>
|
||||||
</br> {{ dataset.description }}
|
</br> {{ dataset.description }}
|
||||||
</td>
|
</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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% 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_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):
|
class ColumnInlineView(CompactCRUDMixin, PanoramixModelView):
|
||||||
datamodel = SQLAInterface(models.Column)
|
datamodel = SQLAInterface(models.Column)
|
||||||
@ -140,8 +148,8 @@ class TableView(PanoramixModelView, DeleteMixin):
|
|||||||
list_columns = ['table_link', 'database', 'changed_by', 'changed_on_']
|
list_columns = ['table_link', 'database', 'changed_by', 'changed_on_']
|
||||||
add_columns = ['table_name', 'database', 'default_endpoint', 'offset']
|
add_columns = ['table_name', 'database', 'default_endpoint', 'offset']
|
||||||
edit_columns = [
|
edit_columns = [
|
||||||
'table_name', 'is_featured', 'database', 'description', 'main_dttm_col',
|
'table_name', 'is_featured', 'database', 'description', 'owner',
|
||||||
'default_endpoint', 'offset']
|
'main_dttm_col', 'default_endpoint', 'offset']
|
||||||
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
related_views = [TableColumnInlineView, SqlMetricInlineView]
|
||||||
base_order = ('changed_on','desc')
|
base_order = ('changed_on','desc')
|
||||||
description_columns = {
|
description_columns = {
|
||||||
@ -539,8 +547,8 @@ class Panoramix(BaseView):
|
|||||||
art=ascii_art.error), 500
|
art=ascii_art.error), 500
|
||||||
|
|
||||||
@has_access
|
@has_access
|
||||||
@expose("/datasets", methods=['GET'])
|
@expose("/featured_datasets", methods=['GET'])
|
||||||
def datasets(self):
|
def featured_datasets(self):
|
||||||
session = db.session()
|
session = db.session()
|
||||||
datasets_sqla = (session.query(models.SqlaTable)
|
datasets_sqla = (session.query(models.SqlaTable)
|
||||||
.filter_by(is_featured=True).all())
|
.filter_by(is_featured=True).all())
|
||||||
|
Loading…
Reference in New Issue
Block a user