Skip to content

Commit

Permalink
Enable documentation links and versions of data sources (re getredash#6
Browse files Browse the repository at this point in the history
…).

Refs getredash#537, getredash#553.

Co-authored-by: Marina Samuel <msamuel@mozilla.com>
Co-authored-by: Allen Short <ashort@mozilla.com>
  • Loading branch information
2 people authored and jezdez committed Mar 25, 2019
1 parent c468b85 commit 9952f1e
Show file tree
Hide file tree
Showing 27 changed files with 563 additions and 508 deletions.
6 changes: 6 additions & 0 deletions client/app/assets/less/redash/query.less
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ a.label-tag {

.datasource-small {
visibility: hidden;
display: none !important;
}

.query-fullscreen .query-metadata__mobile {
Expand Down Expand Up @@ -582,6 +583,11 @@ nav .rg-bottom {
display: none;
}

.datasource-small {
visibility: visible;
display: inline-block !important;
}

.query-fullscreen {
flex-direction: column;
overflow: hidden;
Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/data-sources/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="database-source">
<a class="visual-card" ng-href="data_sources/{{dataSource.id}}" ng-repeat="dataSource in $ctrl.dataSources" title="{{dataSource.name}}">
<img ng-src="/static/images/db-logos/{{dataSource.type}}.png" alt="{{dataSource.name}}">
<h3>{{dataSource.name}}</h3>
<h3>{{dataSource.name}}</h3> - {{dataSource.type_name}}
</a>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ <h3>
{{ds.name}}
</ui-select-choices>
</ui-select>
<datasource-link datasource-id="query.data_source_id"></datasource-link>
<datasource-version datasource-id="query.data_source_id"></datasource-version>
</div>

<div class="editor__left__schema" ng-if="sourceMode">
Expand Down
2 changes: 2 additions & 0 deletions redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def add_group(self, group, view_only=False):
db.session.add(dsg)
return dsg

setattr(self, 'data_source_groups', dsg)

def remove_group(self, group):
DataSourceGroup.query.filter(
DataSourceGroup.group == group,
Expand Down
52 changes: 32 additions & 20 deletions redash/query_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class NotSupported(Exception):

class BaseQueryRunner(object):
noop_query = None
configuration_properties = None

def __init__(self, configuration):
self.syntax = 'sql'
Expand All @@ -79,6 +80,12 @@ def annotate_query(cls):
def configuration_schema(cls):
return {}

@classmethod
def add_configuration_property(cls, property, value):
if cls.configuration_properties is None:
raise NotImplementedError()
cls.configuration_properties[property] = value

def test_connection(self):
if self.noop_query is None:
raise NotImplementedError()
Expand Down Expand Up @@ -153,31 +160,36 @@ class BaseHTTPQueryRunner(BaseQueryRunner):
url_title = 'URL base path'
username_title = 'HTTP Basic Auth Username'
password_title = 'HTTP Basic Auth Password'
configuration_properties = {
'url': {
'type': 'string',
'title': url_title,
},
'username': {
'type': 'string',
'title': username_title,
},
'password': {
'type': 'string',
'title': password_title,
},
"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."
),
},
}

@classmethod
def configuration_schema(cls):
schema = {
'type': 'object',
'properties': {
'url': {
'type': 'string',
'title': cls.url_title,
},
'username': {
'type': 'string',
'title': cls.username_title,
},
'password': {
'type': 'string',
'title': cls.password_title,
},
'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."
},
},
'properties': cls.configuration_properties,
'secret': ['password'],
'order': ['url', 'username', 'password']
}
Expand Down
83 changes: 42 additions & 41 deletions redash/query_runner/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,47 @@ def _get_query_results(jobs, project_id, location, job_id, start_index):

class BigQuery(BaseQueryRunner):
noop_query = "SELECT 1"
configuration_properties = {
'projectId': {
'type': 'string',
'title': 'Project ID'
},
'jsonKeyFile': {
"type": "string",
'title': 'JSON Key File'
},
'totalMBytesProcessedLimit': {
"type": "number",
'title': 'Scanned Data Limit (MB)'
},
'userDefinedFunctionResourceUri': {
"type": "string",
'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
},
'useStandardSql': {
"type": "boolean",
'title': "Use Standard SQL (Beta)",
},
'location': {
"type": "string",
"title": "Processing Location",
"default": "US",
},
'loadSchema': {
"type": "boolean",
"title": "Load Schema"
},
'maximumBillingTier': {
"type": "number",
"title": "Maximum Billing Tier"
},
"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."
},
}

@classmethod
def enabled(cls):
Expand All @@ -90,47 +131,7 @@ def enabled(cls):
def configuration_schema(cls):
return {
'type': 'object',
'properties': {
'projectId': {
'type': 'string',
'title': 'Project ID'
},
'jsonKeyFile': {
"type": "string",
'title': 'JSON Key File'
},
'totalMBytesProcessedLimit': {
"type": "number",
'title': 'Scanned Data Limit (MB)'
},
'userDefinedFunctionResourceUri': {
"type": "string",
'title': 'UDF Source URIs (i.e. gs://bucket/date_utils.js, gs://bucket/string_utils.js )'
},
'useStandardSql': {
"type": "boolean",
'title': "Use Standard SQL",
"default": True,
},
'location': {
"type": "string",
"title": "Processing Location",
},
'loadSchema': {
"type": "boolean",
"title": "Load Schema"
},
'maximumBillingTier': {
"type": "number",
"title": "Maximum Billing Tier"
},
"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."
}
},
'properties': cls.configuration_properties,
'required': ['jsonKeyFile', 'projectId'],
"order": ['projectId', 'jsonKeyFile', 'loadSchema', 'useStandardSql', 'location', 'totalMBytesProcessedLimit', 'maximumBillingTier', 'userDefinedFunctionResourceUri'],
'secret': ['jsonKeyFile']
Expand Down
75 changes: 38 additions & 37 deletions redash/query_runner/cass.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ def default(self, o):

class Cassandra(BaseQueryRunner):
noop_query = "SELECT dateof(now()) FROM system.local"
configuration_properties = {
'host': {
'type': 'string',
},
'port': {
'type': 'number',
'default': 9042,
},
'keyspace': {
'type': 'string',
'title': 'Keyspace name'
},
'username': {
'type': 'string',
'title': 'Username'
},
'password': {
'type': 'string',
'title': 'Password'
},
'protocol': {
'type': 'number',
'title': 'Protocol Version',
'default': 3
},
'timeout': {
'type': 'number',
'title': 'Timeout',
'default': 10
},
"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."
},
}

@classmethod
def enabled(cls):
Expand All @@ -32,43 +69,7 @@ def enabled(cls):
def configuration_schema(cls):
return {
'type': 'object',
'properties': {
'host': {
'type': 'string',
},
'port': {
'type': 'number',
'default': 9042,
},
'keyspace': {
'type': 'string',
'title': 'Keyspace name'
},
'username': {
'type': 'string',
'title': 'Username'
},
'password': {
'type': 'string',
'title': 'Password'
},
'protocol': {
'type': 'number',
'title': 'Protocol Version',
'default': 3
},
'timeout': {
'type': 'number',
'title': 'Timeout',
'default': 10
},
"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."
}
},
'properties': cls.configuration_properties,
'required': ['keyspace', 'host']
}

Expand Down
39 changes: 21 additions & 18 deletions redash/query_runner/dynamodb_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@


class DynamoDBSQL(BaseSQLQueryRunner):
noop_query = "SELECT 1"
configuration_properties = {
"region": {
"type": "string",
"default": "us-east-1"
},
"access_key": {
"type": "string",
},
"secret_key": {
"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."
},
}

@classmethod
def configuration_schema(cls):
return {
"type": "object",
"properties": {
"region": {
"type": "string",
"default": "us-east-1"
},
"access_key": {
"type": "string",
},
"secret_key": {
"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."
}
},
"properties": cls.configuration_properties,
"required": ["access_key", "secret_key"],
"secret": ["secret_key"]
}
Expand Down
Loading

0 comments on commit 9952f1e

Please sign in to comment.