From c97b0b6026f634f16b7cd48bcea23a408878d7dc Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Sun, 13 Dec 2015 10:03:06 -0800 Subject: [PATCH] Slightly better layout for explore page --- panoramix/forms.py | 2 + .../versions/55179c7f25c7_sqla_descr.py | 22 +++++ panoramix/models.py | 8 ++ panoramix/static/panoramix.css | 15 +++- panoramix/templates/panoramix/explore.html | 80 +++++++++---------- panoramix/views.py | 4 +- panoramix/viz.py | 18 +---- 7 files changed, 88 insertions(+), 61 deletions(-) create mode 100644 panoramix/migrations/versions/55179c7f25c7_sqla_descr.py diff --git a/panoramix/forms.py b/panoramix/forms.py index cc29ecf64f..f287f5ca03 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -339,6 +339,7 @@ class FormFactory(object): slice_name = HiddenField() previous_viz_type = HiddenField(default=viz.viz_type) collapsed_fieldsets = HiddenField() + viz_type = self.field_dict.get('viz_type') filter_cols = datasource.filterable_column_names or [''] for i in range(10): @@ -361,6 +362,7 @@ class FormFactory(object): if s: setattr(QueryForm, s, px_form_fields[s]) + # datasource type specific form elements if datasource.__class__.__name__ == 'SqlaTable': QueryForm.fieldsets += ({ diff --git a/panoramix/migrations/versions/55179c7f25c7_sqla_descr.py b/panoramix/migrations/versions/55179c7f25c7_sqla_descr.py new file mode 100644 index 0000000000..aade0b930a --- /dev/null +++ b/panoramix/migrations/versions/55179c7f25c7_sqla_descr.py @@ -0,0 +1,22 @@ +"""sqla_descr + +Revision ID: 55179c7f25c7 +Revises: 315b3f4da9b0 +Create Date: 2015-12-13 08:38:43.704145 + +""" + +# revision identifiers, used by Alembic. +revision = '55179c7f25c7' +down_revision = '315b3f4da9b0' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('tables', sa.Column('description', sa.Text(), nullable=True)) + + +def downgrade(): + op.drop_column('tables', 'description') diff --git a/panoramix/models.py b/panoramix/models.py index f1547a34c7..73d060d30c 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -225,6 +225,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): id = Column(Integer, primary_key=True) table_name = Column(String(250), unique=True) main_dttm_col = Column(String(250)) + description = Column(Text) default_endpoint = Column(Text) database_id = Column(Integer, ForeignKey('dbs.id'), nullable=False) database = relationship( @@ -241,6 +242,9 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): return ( "[{self.database}].[{self.table_name}]" "(id:{self.id})").format(self=self) + @property + def full_name(self): + return "[{self.database}].[{self.table_name}]".format(self=self) @property def dttm_cols(self): @@ -694,6 +698,10 @@ class Datasource(Model, AuditMixinNullable, Queryable): "[{self.cluster_name}].[{self.datasource_name}]" "(id:{self.id})").format(self=self) + @property + def full_name(self): + return "[{self.cluster_name}].[{self.datasource_name}]".format(self=self) + def __repr__(self): return self.datasource_name diff --git a/panoramix/static/panoramix.css b/panoramix/static/panoramix.css index bbdb22b9f1..8c4108fec0 100644 --- a/panoramix/static/panoramix.css +++ b/panoramix/static/panoramix.css @@ -10,6 +10,19 @@ form div { .navbar-brand a { color: white; } + +.notbtn { + cursor: default; +} + +span.title-block { + background-color: #EEE; + border-radius: 4px; + padding: 6px 12px; + margin: 0px 10px; + font-size: 20px; +} + fieldset.fs-style { font-family: Verdana, Arial, sans-serif; font-size: small; @@ -18,7 +31,7 @@ fieldset.fs-style { background-color: #F4F4F4; border-radius: 6px; padding: 10px; - margin: 10px 0px; + margin: 0px 0px 10px 0px; } legend.legend-style { font-size: 14px; diff --git a/panoramix/templates/panoramix/explore.html b/panoramix/templates/panoramix/explore.html index e3dd9589b1..811597e6e2 100644 --- a/panoramix/templates/panoramix/explore.html +++ b/panoramix/templates/panoramix/explore.html @@ -2,26 +2,44 @@ {% block content_fluid %} {% set datasource = viz.datasource %} {% set form = viz.form %} + +{% macro panofield(fieldname)%} +
+ {% set field = form.get_field(fieldname)%} +
+ {{ viz.get_form_override(fieldname, 'label') or field.label }} + {% if field.description %} + + {% endif %} + {{ field(class_=form.field_css_classes(field.name)) }} +
+
+{% endmacro %} +
-
-
-

- {{ datasource.name }} +

+ + {{ form.get_field("viz_type")(class_="select2") }} + query +
+ +
+
-
- {% for fieldset in form.fieldsets %}
{% if fieldset.label %} @@ -38,30 +56,14 @@
{% for fieldname in fieldset.fields %} {% if not fieldname.__iter__ %} -
- {% set field = form.get_field(fieldname)%} -
- {{ viz.get_form_override(fieldname, 'label') or field.label }} - {% if field.description %} - - {% endif %} - {{ field(class_=form.field_css_classes(field.name)) }} -
-
+ {{ panofield(fieldname) }} {% else %}
{% for name in fieldname %}
{% if name %} - {% set field = form.get_field(name)%} - {{ viz.form_overrides.label or field.label }} - {% if field.description %} - - {% endif %} - {{ field(class_=form.field_css_classes(field.name)) }} + {{ panofield(name) }} {% endif %}
{% endfor %} @@ -90,7 +92,6 @@
-
-
{{ form.slice_id() }} {{ form.slice_name() }} @@ -122,20 +122,10 @@ -
+
-

{{ viz.verbose_name }} - {% if False %} - - {{ "{0:0.4f}".format(results.duration.total_seconds()) }} s - - {% endif %} - query -

-
{% block messages %} {% endblock %} {% include 'appbuilder/flash.html' %} @@ -175,6 +165,7 @@
+
{% endblock %} @@ -234,6 +225,7 @@ $('legend').click(function () { toggle_fieldset($(this), true); }); + $("#viz_type").change(function() {$("#query").submit();}); collapsed_fieldsets = get_collapsed_fieldsets(); for(var i=0; i