Skip to content

Commit

Permalink
add toggle_table_string (re #130)
Browse files Browse the repository at this point in the history
Makes the _v of the schema browser toggle into a configurable string
per data source. It is not required and if it is not filled in the
toggle will not appear in the schema browser.
  • Loading branch information
alison985 authored and jezdez committed Mar 5, 2018
1 parent 5a22ec5 commit 55a3e90
Show file tree
Hide file tree
Showing 35 changed files with 199 additions and 16 deletions.
4 changes: 3 additions & 1 deletion client/app/components/queries/schema-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

<button class="btn btn-default"
title="Toggle Versioned Tables"
ng-click="$ctrl.flipToggleVersionedTables($ctrl.versionToggle)">
ng-click="$ctrl.flipToggleVersionedTables($ctrl.versionToggle, $ctrl.tabletogglestring)"
ng-if="$ctrl.tabletogglestring && $ctrl.tabletogglestring != ''"
>
<span class="fa " ng-class="{'fa-toggle-on': $ctrl.versionToggle == true, 'fa-toggle-off': !$ctrl.versionToggle}">
<input type="checkbox" id="versioned-tables-toggle" ng-model="$ctrl.versionToggle" hidden/>
</span>
Expand Down
6 changes: 4 additions & 2 deletions client/app/components/queries/schema-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ function SchemaBrowserCtrl($rootScope, $scope) {

this.isEmpty = function isEmpty() {
return this.schema === undefined || this.schema.length === 0;
this.flipToggleVersionedTables = (versionToggle) => {
};
this.flipToggleVersionedTables = (versionToggle, toggleString) => {
if (versionToggle === false) {
this.versionToggle = true;
this.versionFilter = '_v';
this.versionFilter = toggleString;
} else {
this.versionToggle = false;
this.versionFilter = 'abcdefghijklmnop';
Expand All @@ -43,6 +44,7 @@ function SchemaBrowserCtrl($rootScope, $scope) {
const SchemaBrowser = {
bindings: {
schema: '<',
tabletogglestring: '<',
onRefresh: '&',
flipToggleVersionedTables: '&',
},
Expand Down
5 changes: 3 additions & 2 deletions client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ <h3>
{{ds.name}}
</ui-select-choices>
</ui-select>
<a ng-if="dataSource.options.doc_url != ''" ng-href={{dataSource.options.doc_url}}>{{dataSource.type_name}} documentation</a>
<a ng-if="dataSource.options.doc_url != '' && dataSource.options.doc_url" ng-href={{dataSource.options.doc_url}}>{{dataSource.type_name}} documentation</a>
<span ng-if="dataSource.options.doc_url == '' || !dataSource.options.doc_url">{{ dataSource.type_name }} documentation</span>
<get-data-source-version id='data-source-version'></get-data-source-version>
</div>

<div class="editor__left__schema" ng-if="sourceMode">
<schema-browser class="schema-container" schema="schema" on-refresh="refreshSchema()"></schema-browser>
<schema-browser class="schema-container" schema="schema" tabletogglestring="dataSource.options.toggle_table_string" on-refresh="refreshSchema()"></schema-browser>
</div>
<div ng-if="!sourceMode" style="flex-grow: 1;">&nbsp;</div>

Expand Down
13 changes: 3 additions & 10 deletions redash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,10 @@ def to_dict(self, all=False, with_permissions_for=None):
'type_name': self.query_runner.name()
}

schema = get_configuration_schema_for_query_runner_type(self.type)
self.options.set_schema(schema)
d['options'] = self.options.to_dict(mask_secrets=True)
if all:
schema = get_configuration_schema_for_query_runner_type(self.type)
self.options.set_schema(schema)
d['options'] = self.options.to_dict(mask_secrets=True)
d['queue_name'] = self.queue_name
d['scheduled_queue_name'] = self.scheduled_queue_name
d['groups'] = self.groups
Expand All @@ -581,13 +581,6 @@ def to_dict(self, all=False, with_permissions_for=None):
DataSourceGroup.group == with_permissions_for,
DataSourceGroup.data_source == self).one()[0]

doc_url = self.options.get('doc_url')
try:
if doc_url:
d['options'].update(doc_url=doc_url)
except:
d['options'] = {'doc_url': doc_url}

return d

def __unicode__(self):
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/activedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": "https://github.com/klahnakoski/ActiveData/tree/dev/docs"
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["host_url"]
Expand Down
11 changes: 11 additions & 0 deletions redash/query_runner/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ def configuration_schema(cls):
'type': 'boolean',
'title': 'Use Glue Data Catalog',
},
"doc_url": {
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['region', 's3_staging_dir'],
'order': ['region', 'aws_access_key', 'aws_secret_key', 's3_staging_dir', 'schema'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/axibase_tsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def configuration_schema(cls):
'trust_certificate': {
'type': 'boolean',
'title': 'Trust SSL Certificate'
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['username', 'password', 'hostname', 'protocol', 'port'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['jsonKeyFile', 'projectId'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/cass.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['keyspace', 'host']
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def configuration_schema(cls):
"dbname": {
"type": "string",
"title": "Database Name"
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["dbname"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/dynamodb_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["access_key", "secret_key"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"secret": ["basic_auth_password"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/google_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def configuration_schema(cls):
'jsonKeyFile': {
"type": "string",
'title': 'JSON Key File'
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['jsonKeyFile'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/google_spreadsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['jsonKeyFile'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['url'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/hive_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["host"]
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/impala_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["host"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/influx_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['url']
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/jql.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['url', 'username', 'password'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/memsql_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def configuration_schema(cls):
},
"password": {
"type": "string"
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}

},
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['connectionString', 'dbName']
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["db"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ def configuration_schema(cls):
'port': {
'type': 'number',
'default': 3306,
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"order": ['host', 'port', 'user', 'passwd', 'db'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["servicename", "user", "password", "host", "port"],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"order": ['host', 'port', 'user', 'password'],
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
'required': ['host']
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Documentation URL",
"default": cls.default_doc_url
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
}
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def configuration_schema(cls):
"type": "string",
"title": "Salesforce API Version",
"default": DEFAULT_API_VERSION
},
"toggle_table_string": {
"type": "string",
"title": "Toggle Table String",
"default": "_v",
"info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight."
}
},
"required": ["username", "password", "token"],
Expand Down
Loading

0 comments on commit 55a3e90

Please sign in to comment.