Skip to content

Commit

Permalink
Filter tables from schema browser (re getredash#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short authored and jezdez committed Mar 25, 2019
1 parent b1c5825 commit 848b101
Show file tree
Hide file tree
Showing 32 changed files with 200 additions and 8 deletions.
12 changes: 11 additions & 1 deletion client/app/components/queries/schema-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@
ng-click="$ctrl.onRefresh()">
<span class="zmdi zmdi-refresh"></span>
</button>

<button class="btn btn-default"
title="Toggle Versioned Tables"
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>
</button>
</div>

<div class="schema-browser" vs-repeat vs-size="$ctrl.getSize(table)">
<div ng-repeat="table in $ctrl.schema | filter:$ctrl.schemaFilterObject track by table.name">
<div ng-repeat="table in $ctrl.schema | filter:$ctrl.schemaFilterObject | filter: {name: '!'+$ctrl.versionFilter}">
<div class="table-name" ng-click="$ctrl.showTable(table)">
<i class="fa fa-table"></i>
<strong>
Expand Down
14 changes: 14 additions & 0 deletions client/app/components/queries/schema-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import template from './schema-browser.html';
function SchemaBrowserCtrl($rootScope, $scope) {
'ngInject';

this.versionToggle = false;
this.versionFilter = 'abcdefghijklmnop';

this.showTable = (table) => {
table.collapsed = !table.collapsed;
$scope.$broadcast('vsRepeatTrigger');
Expand All @@ -21,6 +24,15 @@ function SchemaBrowserCtrl($rootScope, $scope) {
this.isEmpty = function isEmpty() {
return this.schema === undefined || this.schema.length === 0;
};
this.flipToggleVersionedTables = (versionToggle, toggleString) => {
if (versionToggle === false) {
this.versionToggle = true;
this.versionFilter = toggleString;
} else {
this.versionToggle = false;
this.versionFilter = 'abcdefghijklmnop';
}
};

this.itemSelected = ($event, hierarchy) => {
$rootScope.$broadcast('query-editor.command', 'paste', hierarchy.join('.'));
Expand All @@ -44,7 +56,9 @@ function SchemaBrowserCtrl($rootScope, $scope) {
const SchemaBrowser = {
bindings: {
schema: '<',
tabletogglestring: '<',
onRefresh: '&',
flipToggleVersionedTables: '&',
},
controller: SchemaBrowserCtrl,
template,
Expand Down
2 changes: 1 addition & 1 deletion client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h3>
</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
6 changes: 6 additions & 0 deletions redash/query_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ def configuration_schema(cls):
'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."
},
},
'secret': ['password'],
'order': ['url', 'username', 'password']
Expand Down
6 changes: 6 additions & 0 deletions redash/query_runner/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def configuration_schema(cls):
'type': 'boolean',
'title': 'Use Glue Data Catalog',
},
"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 @@ -132,6 +132,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):
'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."
}
},
'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 @@ -61,6 +61,12 @@ def configuration_schema(cls):
'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."
}
},
'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 @@ -36,6 +36,12 @@ def configuration_schema(cls):
"type": "number",
"title": "Request Timeout",
"default": 30
},
"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 @@ -46,6 +46,12 @@ def configuration_schema(cls):
},
"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."
}
},
"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 @@ -62,6 +62,12 @@ def configuration_schema(cls):
'basic_auth_password': {
'type': 'string',
'title': 'Basic Auth Password'
},
"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": ['server', 'basic_auth_user', '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 @@ -102,6 +102,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 @@ -148,6 +148,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/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def configuration_schema(cls):
'verify': {
'type': 'boolean',
'title': 'Verify 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': ['url'],
Expand Down
12 changes: 9 additions & 3 deletions redash/query_runner/hive_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def configuration_schema(cls):
"username": {
"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."
}
},
"order": ["host", "port", "database", "username"],
"required": ["host"]
Expand Down Expand Up @@ -98,14 +104,14 @@ def _get_connection(self):
database=self.configuration.get('database', 'default'),
username=self.configuration.get('username', None),
)

return connection


def run_query(self, query, user):
connection = None
try:
connection = self._get_connection()
connection = self._get_connection()
cursor = connection.cursor()

cursor.execute(query)
Expand Down Expand Up @@ -214,7 +220,7 @@ def _get_connection(self):

# create connection
connection = hive.connect(thrift_transport=transport)

return connection


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 @@ -64,6 +64,12 @@ def configuration_schema(cls):
},
"timeout": {
"type": "number"
},
"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 @@ -57,6 +57,12 @@ def configuration_schema(cls):
'properties': {
'url': {
'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."
}
},
'required': ['url']
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 @@ -55,6 +55,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 @@ -134,6 +134,12 @@ def configuration_schema(cls):
'type': 'string',
'title': 'Replica Set 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': ['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 @@ -60,6 +60,12 @@ def configuration_schema(cls):
"db": {
"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": ["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 @@ -54,6 +54,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 @@ -63,6 +63,12 @@ def configuration_schema(cls):
"servicename": {
"type": "string",
"title": "DSN Service 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": ["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 @@ -95,6 +95,12 @@ def configuration_schema(cls):
"type": "string",
"title": "SSL Mode",
"default": "prefer"
},
"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 @@ -56,6 +56,12 @@ def configuration_schema(cls):
'username': {
'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."
},
},
'order': ['host', 'protocol', 'port', 'username', 'schema', 'catalog'],
'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 @@ -55,6 +55,12 @@ def configuration_schema(cls):
},
'additionalModulesPaths': {
'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/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 848b101

Please sign in to comment.