Skip to content

Commit

Permalink
Numerous improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jul 20, 2015
1 parent d268b6b commit 4334373
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 194 deletions.
93 changes: 93 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,93 @@
# Contributing

Contributions are welcome and are greatly appreciated! Every
little bit helps, and credit will always be given.

You can contribute in many ways:

## Types of Contributions

### Report Bugs

Report bugs through Gihub

If you are reporting a bug, please include:

- Your operating system name and version.
- Any details about your local setup that might be helpful in
troubleshooting.
- Detailed steps to reproduce the bug.

### Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with "bug" is
open to whoever wants to implement it.

### Implement Features

Look through the GitHub issues for features. Anything tagged with
"feature" is open to whoever wants to implement it.

We've created the operators, hooks, macros and executors we needed, but we
made sure that this part of Airflow is extensible. New operators,
hooks and operators are very welcomed!

### Documentation

Airflow could always use better documentation,
whether as part of the official Airflow docs,
in docstrings, `docs/*.rst` or even on the web as blog posts or
articles.

### Submit Feedback

The best way to send feedback is to file an issue on Github.

If you are proposing a feature:

- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to
implement.
- Remember that this is a volunteer-driven project, and that
contributions are welcome :)

## Latests Documentation

[API Documentation](http://pythonhosted.com/airflow)

## Testing

Install development requirements:

pip install -r requirements.txt

Tests can then be run with:

./run_unit_tests.sh

Lint the project with:

flake8 changes tests

## API documentation

Generate the documentation with:

cd docs && ./build.sh


## Pull Request Guidelines

Before you submit a pull request from your forked repo, check that it
meets these guidelines:

1. The pull request should include tests, either as doctests,
unit tests, or both.
2. If the pull request adds functionality, the docs should be updated
as part of the same PR. Doc string are often sufficient, make
sure to follow the sphinx compatible standards.
3. The pull request should work for Python 2.6, 2.7, and ideally python 3.3.
`from __future__ import ` will be required in every `.py` file soon.
4. Code will be reviewed by re running the unittests, flake8 and syntax
should be as rigorous as the core Python project.
5. Please rebase and resolve all conflicts before submitting.
8 changes: 7 additions & 1 deletion TODO.md
@@ -1,2 +1,8 @@
# TODO
* Multi-filters
* STOCK CHART + compare time ranges
* Save a chart
* Datasource + Owner
* Column description
* Label
* CSV
* Bookmarks / url shortener
Binary file modified app.db
Binary file not shown.
2 changes: 1 addition & 1 deletion app/templates/appbuilder/navbar.html
Expand Up @@ -5,7 +5,7 @@
{% set languages = appbuilder.languages %}

<div class="navbar {{menu.extra_classes}}" role="navigation">
<div class="container">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
Expand Down
99 changes: 82 additions & 17 deletions app/templates/panoramix/datasource.html
Expand Up @@ -6,18 +6,25 @@
height: 70px;
overflow: auto;
}
.no-gutter > [class*='col-'] {
padding-right:0;
padding-left:0;
}
form div.select2-container.form-control {
margin-bottom: 5px;
}
</style>
{% endblock %}
{% block content %}
<div class="container">
<div class="container-fluid">
<div class="col-md-3">
<h3>
{{ datasource.datasource_name }}
<a href="/datasourcemodelview/edit/{{ datasource.id }}"><span class="glyphicon glyphicon-edit"></span></a>
</h3>

<hr>
<form method="GET">
<form id="query" method="GET" style="display: none;">
<div>{{ form.viz_type.label }}: {{ form.viz_type(class_="form-control select2") }}</div>
<div>{{ form.metrics.label }}: {{ form.metrics(class_="form-control select2") }}</div>
<div>{{ form.granularity.label }}: {{ form.granularity(class_="form-control select2_free_granularity") }}</div>
Expand All @@ -31,26 +38,23 @@ <h3>
<div>{{ form.limit.label }}: {{ form.limit(class_="form-control select2") }}</div>
<hr>
<h4>Filters</h4>
<div id="filters">
{% for i in range(10) %}
<div id="flt{{ i }}" class="{{ "hidden" if i != 1 }}">
<span class="" style="width: 100px;">{{ form['flt_col_' ~ i](class_="form-control select2 inc") }}</span>
<div class="row">
<span class="col col-md-3">{{ form['flt_op_' ~ i](class_="form-control select2 input-sm inc") }}</span>
<span class="col col-md-7">{{ form['flt_eq_' ~ i](class_="form-control inc") }}</span>
<button type="col col-md-2" class="btn btn-sm" aria-label="Delete filter">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</button>
</div>
<hr/>
<div id="flt0" style="display: none;">
<span class="">{{ form.flt_col_0(class_="form-control inc") }}</span>
<div class="row">
<span class="col col-sm-4">{{ form.flt_op_0(class_="form-control inc") }}</span>
<span class="col col-sm-6">{{ form.flt_eq_0(class_="form-control inc") }}</span>
<button type="button" class="btn btn-sm remove" aria-label="Delete filter">
<span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
</button>
</div>
{% endfor %}
</div>
<hr style="margin: 5px 0px;"/>
</div>
<div id="filters"></div>
<button type="button" id="plus" class="btn btn-sm" aria-label="Add a filter">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</button>
<hr>
<input type="submit" class="btn btn-primary" value="Druidify!">
<button type="button" class="btn btn-primary" id="druidify">Druidify!</button>
<hr style="margin-bottom: 0px;">
<img src="{{ url_for("static", filename="panoramix.png") }}" width=250>
</form><br>
Expand Down Expand Up @@ -81,7 +85,68 @@ <h3>Latest Segment Metadata</h3>
{{ super() }}
<script>
$( document ).ready(function() {
function getParam(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

$(".select2").select2();
$("form").slideDown("slow");

function set_filters(){
for (var i=1; i<10; i++){
var eq = getParam("flt_eq_" + i);
if (eq !=''){
add_filter(i);
}
}
}
set_filters();

function add_filter(i) {
cp = $("#flt0").clone();
$(cp).appendTo("#filters");
$(cp).slideDown("slow");
if (i != undefined){
$(cp).find("#flt_eq_0").val(getParam("flt_eq_" + i));
$(cp).find("#flt_op_0").val(getParam("flt_op_" + i));
$(cp).find("#flt_col_0").val(getParam("flt_col_" + i));
}

$(cp).find('select').select2();
$(cp).find('.remove').click(function() {
$(this).parent().parent().slideUp("slow", function(){$(this).remove()});
});
}
$("#plus").click(add_filter);
add_filter();
$("#druidify").click(function () {
var i = 1;

// removing empty filters
$("#filters > div").each(function(){
if ($(this).find("#flt_eq_0").val() == '')
$(this).slideUp();
});

// Assigning the right id to form elements in filters
$("#filters > div").each(function(){
$(this).attr("id", function(){return "flt_" + i;})
$(this).find("#flt_col_0")
.attr("id", function(){return "flt_col_" + i;})
.attr("name", function(){return "flt_col_" + i;});
$(this).find("#flt_op_0")
.attr("id", function(){return "flt_op_" + i;})
.attr("name", function(){return "flt_op_" + i;});
$(this).find("#flt_eq_0")
.attr("id", function(){return "flt_eq_" + i;})
.attr("name", function(){return "flt_eq_" + i;});
i++;
});
$("#query").submit();
});

function create_choices (term, data) {
if ($(data).filter(function() {
Expand Down
56 changes: 0 additions & 56 deletions app/templates/panoramix/noadmin.html

This file was deleted.

9 changes: 9 additions & 0 deletions app/templates/panoramix/viz_highcharts.html
Expand Up @@ -5,14 +5,23 @@

{% block tail %}
{{ super() }}
{% if viz.chart_type == "stock" %}
<script src="{{ url_for("static", filename="highstock.js") }}"></script>
{% else %}
<script src="{{ url_for("static", filename="highcharts.js") }}"></script>
{% endif %}
<script>
$( document ).ready(function() {
Highcharts.setOptions({
colors: [
"#FF5A5F", "#007A87", "#7B0051", "#00D1C1", "#8CE071", "#FFB400",
"#FFAA91", "#B4A76C", "#9CA299", "#565A5C"
],
global: {
useUTC: false
},


});
$("#viz_type").click(function(){
$("#queryform").submit();
Expand Down
11 changes: 8 additions & 3 deletions app/views.py
@@ -1,7 +1,8 @@
from datetime import timedelta
import logging
import json

from flask import request, redirect, flash
from flask import request, redirect, flash, Response
from flask.ext.appbuilder.models.sqla.interface import SQLAInterface
from flask.ext.appbuilder import ModelView, CompactCRUDMixin, BaseView, expose
from app import appbuilder, db, models, viz, utils
Expand Down Expand Up @@ -59,7 +60,7 @@ class QueryForm(OmgWtForm):
setattr(QueryForm, 'flt_col_' + str(i), SelectField(
'Filter 1', choices=[(s, s) for s in datasource.filterable_column_names]))
setattr(QueryForm, 'flt_op_' + str(i), SelectField(
'Filter 1', choices=[(m, m) for m in ['==', '!=', 'in',]]))
'Filter 1', choices=[(m, m) for m in ['in', 'not in']]))
setattr(QueryForm, 'flt_eq_' + str(i), TextField("Super"))
return QueryForm

Expand Down Expand Up @@ -122,6 +123,11 @@ def datasource(self, datasource_name):
datasource,
form_class=form_factory(datasource, request.args),
form_data=request.args, view=self)
if request.args.get("json"):
return Response(
json.dumps(obj.get_query(), indent=4),
status=200,
mimetype="application/json")
if obj.df is None or obj.df.empty:
return obj.render_no_data()
return obj.render()
Expand All @@ -130,7 +136,6 @@ def datasource(self, datasource_name):
@expose("/refresh_datasources/")
def refresh_datasources(self):
import requests
import json
endpoint = (
"http://{COORDINATOR_HOST}:{COORDINATOR_PORT}/"
"{COORDINATOR_BASE_ENDPOINT}/datasources"
Expand Down

0 comments on commit 4334373

Please sign in to comment.