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 committed Jul 25, 2018
1 parent cf7f8cf commit 31a2ca7
Showing 33 changed files with 206 additions and 3 deletions.
12 changes: 11 additions & 1 deletion client/app/components/queries/schema-browser.html
Original file line number Diff line number Diff line change
@@ -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.schemaFilter track by table.name">
<div ng-repeat="table in $ctrl.schema | filter:$ctrl.schemaFilter | filter: {name: '!'+$ctrl.versionFilter}">
<div class="table-name" ng-click="$ctrl.showTable(table)">
<i class="fa fa-table"></i>
<strong>
14 changes: 14 additions & 0 deletions client/app/components/queries/schema-browser.js
Original file line number Diff line number Diff line change
@@ -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');
@@ -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.paste', hierarchy.join('.'));
@@ -32,7 +44,9 @@ function SchemaBrowserCtrl($rootScope, $scope) {
const SchemaBrowser = {
bindings: {
schema: '<',
tabletogglestring: '<',
onRefresh: '&',
flipToggleVersionedTables: '&',
},
controller: SchemaBrowserCtrl,
template,
2 changes: 1 addition & 1 deletion client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
@@ -90,7 +90,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>

11 changes: 11 additions & 0 deletions redash/query_runner/athena.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/axibase_tsd.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/big_query.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/cass.py
Original file line number Diff line number Diff line change
@@ -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']
6 changes: 6 additions & 0 deletions redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/dynamodb_sql.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/elasticsearch.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/google_analytics.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/google_spreadsheets.py
Original file line number Diff line number Diff line change
@@ -167,6 +167,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'],
6 changes: 6 additions & 0 deletions redash/query_runner/graphite.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/hive_ds.py
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 6 additions & 0 deletions redash/query_runner/impala_ds.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/influx_db.py
Original file line number Diff line number Diff line change
@@ -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']
6 changes: 6 additions & 0 deletions redash/query_runner/jql.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/memsql_ds.py
Original file line number Diff line number Diff line change
@@ -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."
}

},
6 changes: 6 additions & 0 deletions redash/query_runner/mongodb.py
Original file line number Diff line number Diff line change
@@ -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']
6 changes: 6 additions & 0 deletions redash/query_runner/mssql.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/mysql.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/oracle.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/pg.py
Original file line number Diff line number Diff line change
@@ -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'],
6 changes: 6 additions & 0 deletions redash/query_runner/presto.py
Original file line number Diff line number Diff line change
@@ -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']
6 changes: 6 additions & 0 deletions redash/query_runner/python.py
Original file line number Diff line number Diff line change
@@ -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."
}
},
}
6 changes: 6 additions & 0 deletions redash/query_runner/salesforce.py
Original file line number Diff line number Diff line change
@@ -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"],
6 changes: 6 additions & 0 deletions redash/query_runner/script.py
Original file line number Diff line number Diff line change
@@ -57,6 +57,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': ['path']
6 changes: 6 additions & 0 deletions redash/query_runner/snowflake.py
Original file line number Diff line number Diff line change
@@ -46,6 +46,12 @@ def configuration_schema(cls):
},
"database": {
"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": ["user", "password", "account", "database", "warehouse"],
Loading

0 comments on commit 31a2ca7

Please sign in to comment.