Tackling Featured Datasets

This commit is contained in:
Maxime Beauchemin 2016-02-24 16:48:15 -08:00
parent 71b11117d7
commit 8dcd5e0628
8 changed files with 71 additions and 60 deletions

View File

@ -1,7 +1,8 @@
import logging
import os
from flask import Flask
from flask import Flask, redirect
from flask.ext.appbuilder import SQLA, AppBuilder, IndexView
from flask.ext.appbuilder.baseviews import expose
from flask.ext.migrate import Migrate
from panoramix import config
@ -20,7 +21,9 @@ migrate = Migrate(app, db, directory=APP_DIR + "/migrations")
class MyIndexView(IndexView):
index_template = 'panoramix/featured_datasets.html'
@expose('/')
def index(self):
return redirect('/panoramix/featured')
appbuilder = AppBuilder(
app, db.session,

View File

@ -0,0 +1,45 @@
{% extends "refactor/basic.html" %}
{% block body %}
<div class="container">
<div class="header">
<h3><i class='fa fa-star'></i> Featured Datasets </h3>
</div>
<hr/>
<table class="table table-hover dataTable table-bordered" 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>
<div class="intable-longtext">
<h4>{{ dataset.table_name }}</h4>
<p>{{ utils.markdown(dataset.description) | safe }}</p>
</div>
</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>
<hr/>
</div>
{% endblock %}
{% block head_css %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="/static/assets/node_modules/datatables-bootstrap3-plugin/media/css/datatables-bootstrap3.css" />
{% endblock %}
{% block tail_js %}
{{ super() }}
<script src="/static/assets/javascripts/dist/featured.entry.js"></script>
{% endblock %}

View File

@ -0,0 +1,14 @@
var $ = window.$ = require('jquery');
var jQuery = window.jQuery = $;
require('datatables');
require('datatables-bootstrap3-plugin');
require('bootstrap');
$(document).ready(function() {
$('#dataset-table').DataTable({
"bPaginate": false,
"order": [[ 1, "asc" ]]
});
$('#dataset-table_info').remove();
$('#dataset-table').show();
} );

View File

@ -2,6 +2,7 @@ var $ = window.$ = require('jquery');
var jQuery = window.jQuery = $;
require('select2');
require('datatables');
require('bootstrap');
var ace = require('brace');
require('brace/mode/sql');

View File

@ -46,6 +46,7 @@
"d3-tip": "^0.6.7",
"d3.layout.cloud": "^1.2.0",
"datatables": "^1.10.9",
"datatables-bootstrap3-plugin": "^0.4.0",
"exports-loader": "^0.6.3",
"font-awesome": "^4.5.0",
"gridster": "^0.5.6",

View File

@ -10,6 +10,7 @@ var config = {
//dashboard: APP_DIR + '/javascripts/dist/dashboard.js',
explore: APP_DIR + '/javascripts/explore.js',
sql: APP_DIR + '/javascripts/sql.js',
featured: APP_DIR + '/javascripts/featured.js',
},
output: {
path: BUILD_DIR,

View File

@ -1,54 +0,0 @@
{% extends "panoramix/base.html" %}
{% block content %}
<div class="header">
<h3><i class='fa fa-star'></i> Featured Datasets </h3>
</div>
<hr/>
<table class="table table-hover dataTable table-bordered" 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>
<div class="intable-longtext">
<h4>{{ dataset.table_name }}</h4>
<p>{{ utils.markdown(dataset.description) | safe }}</p>
</div>
</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>
<hr/>
{% endblock %}
{% block head_css %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="/static/assets/vendor/dataTables/dataTables.bootstrap.css" />
{% endblock %}
{% block tail_js %}
{{ super() }}
<script src="/static/assets/vendor/dataTables/jquery.dataTables.min.js"></script>
<script src="/static/assets/vendor/dataTables/dataTables.bootstrap.js"></script>
<script>
$(document).ready(function() {
$('#dataset-table').DataTable({
"bPaginate": false,
"order": [[ 1, "asc" ]]
});
$('#dataset-table_info').remove();
$('#dataset-table').show();
} );
</script>
{% endblock %}

View File

@ -64,7 +64,7 @@ appbuilder.add_view_no_menu(TableColumnInlineView)
appbuilder.add_link(
"Featured Datasets",
href='/panoramix/featured_datasets',
href='/panoramix/featured',
category='Sources',
category_icon='fa-table',
icon="fa-star")
@ -703,8 +703,8 @@ class Panoramix(BaseView):
art=ascii_art.error), 500
@has_access
@expose("/featured_datasets", methods=['GET'])
def featured_datasets(self):
@expose("/featured", methods=['GET'])
def featured(self):
session = db.session()
datasets_sqla = (
session.query(models.SqlaTable)
@ -718,7 +718,7 @@ class Panoramix(BaseView):
)
featured_datasets = datasets_sqla + datasets_druid
return self.render_template(
'panoramix/featured_datasets.html',
'refactor/featured.html',
featured_datasets=featured_datasets,
utils=utils)