Skip to content

Commit

Permalink
Merge pull request #170 from alison985/130_modify_toggle_string_to_pe…
Browse files Browse the repository at this point in the history
…r_data_source

130 modify toggle string to per data source
  • Loading branch information
alison985 authored Jul 28, 2017
2 parents 437ec9b + e03c1a5 commit f2ed2fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
4 changes: 3 additions & 1 deletion client/app/pages/queries/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ <h3>
<div class="row bg-white p-b-5" ng-if="sourceMode" resizable r-directions="['bottom']" r-height="300" style="min-height:100px;">
<schema-browser class="col-md-3 hidden-sm hidden-xs schema-container"
schema="schema"
tabletogglestring="dataSource.options.toggle_table_string"
on-refresh="refreshSchema()"
ng-show="hasSchema">
</schema-browser>
Expand All @@ -102,7 +103,8 @@ <h3>
<span class="text-muted">Data Source</span>
<select id="data-source-selection" ng-disabled="!isQueryOwner" ng-model="query.data_source_id" ng-change="updateDataSource()"
ng-options="ds.id as ds.name for ds in dataSources"></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 class="pull-right">
Expand Down
5 changes: 3 additions & 2 deletions client/app/pages/queries/schema-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

<button class="btn btn-default"
title="Toggle Versioned Tables"
ng-click="$ctrl.flipToggleVersionedTables($ctrl.versionToggle)"
ng-if="dataSource.options.toggle_table_string != ''">
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
5 changes: 3 additions & 2 deletions client/app/pages/queries/schema-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function SchemaBrowserCtrl($scope) {
return size;
};

this.flipToggleVersionedTables = (versionToggle) => {
this.flipToggleVersionedTables = (versionToggle, toggleString) => {
if (versionToggle === false) {
this.versionToggle = true;
this.versionFilter = $scope.dataSource.options.toggle_table_string;
this.versionFilter = toggleString;
} else {
this.versionToggle = false;
this.versionFilter = 'abcdefghijklmnop';
Expand All @@ -35,6 +35,7 @@ function SchemaBrowserCtrl($scope) {
const SchemaBrowser = {
bindings: {
schema: '<',
tabletogglestring: '<',
onRefresh: '&',
flipToggleVersionedTables: '&',
},
Expand Down
14 changes: 4 additions & 10 deletions redash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,11 @@ 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 @@ -493,13 +494,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 and all != False:
d['options'].update(doc_url=doc_url)
except:
print d

return d

def __unicode__(self):
Expand Down

0 comments on commit f2ed2fd

Please sign in to comment.