Skip to content

Commit

Permalink
Tackling Featured Datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 25, 2016
1 parent 71b1111 commit 8dcd5e0
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 60 deletions.
7 changes: 5 additions & 2 deletions panoramix/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -20,7 +21,9 @@


class MyIndexView(IndexView):
index_template = 'panoramix/featured_datasets.html'
@expose('/')
def index(self):
return redirect('/panoramix/featured')

appbuilder = AppBuilder(
app, db.session,
Expand Down
45 changes: 45 additions & 0 deletions panoramix/assets/html/featured.html
Original file line number Diff line number Diff line change
@@ -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 %}

This comment has been minimized.

Copy link
@williaster

williaster Feb 26, 2016

Contributor

Nit-picky, but to make it easier to read I'd generally vote for matching the structure of the html page in templates, so the block head_css would go at the top where you'd expect to find header-related code.

{{ 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 %}
14 changes: 14 additions & 0 deletions panoramix/assets/javascripts/featured.js
Original file line number Diff line number Diff line change
@@ -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();
} );
1 change: 1 addition & 0 deletions panoramix/assets/javascripts/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions panoramix/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions panoramix/assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
54 changes: 0 additions & 54 deletions panoramix/templates/panoramix/featured_datasets.html

This file was deleted.

8 changes: 4 additions & 4 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TableColumnInlineView(CompactCRUDMixin, PanoramixModelView):

appbuilder.add_link(
"Featured Datasets",
href='/panoramix/featured_datasets',
href='/panoramix/featured',
category='Sources',
category_icon='fa-table',
icon="fa-star")
Expand Down Expand Up @@ -703,8 +703,8 @@ def show_traceback(self):
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)
Expand All @@ -718,7 +718,7 @@ def featured_datasets(self):
)
featured_datasets = datasets_sqla + datasets_druid
return self.render_template(
'panoramix/featured_datasets.html',
'refactor/featured.html',
featured_datasets=featured_datasets,
utils=utils)

Expand Down

0 comments on commit 8dcd5e0

Please sign in to comment.