Skip to content

Commit

Permalink
Merge pull request #1283 from getredash/fix/gs_dup_columns
Browse files Browse the repository at this point in the history
Fix: schema browser was unstable after opening a table
  • Loading branch information
arikfr authored Sep 11, 2016
2 parents 6cbc39c + b9d1e43 commit e42f93f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
27 changes: 27 additions & 0 deletions rd_ui/app/scripts/directives/query_directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,32 @@
}
}

function schemaBrowser() {
return {
restrict: 'E',
scope: {
schema: '='
},
templateUrl: '/views/directives/schema_browser.html',
link: function ($scope) {
$scope.showTable = function(table) {
table.collapsed = !table.collapsed;
$scope.$broadcast('vsRepeatTrigger');
}

$scope.getSize = function(table) {
var size = 18;

if (!table.collapsed) {
size += 18 * table.columns.length;
}

return size;
}
}
}
}

function queryTimePicker() {
return {
restrict: 'E',
Expand Down Expand Up @@ -332,5 +358,6 @@
.directive('queryEditor', ['QuerySnippet', queryEditor])
.directive('queryRefreshSelect', queryRefreshSelect)
.directive('queryTimePicker', queryTimePicker)
.directive('schemaBrowser', schemaBrowser)
.directive('queryFormatter', ['$http', 'growl', queryFormatter]);
})();
17 changes: 17 additions & 0 deletions rd_ui/app/views/directives/schema_browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="schema-container">
<div class="p-t-5 p-b-5">
<input type="text" placeholder="Search schema..." class="form-control" ng-model="schemaFilter">
</div>

<div class="schema-browser" vs-repeat vs-size="getSize(table)">
<div ng-repeat="table in schema | filter:schemaFilter track by table.name">
<div class="table-name" ng-click="showTable(table)">
<i class="fa fa-table"></i> <strong><span title="{{table.name}}">{{table.name}}</span><span
ng-if="table.size !== undefined"> ({{table.size}})</span></strong>
</div>
<div collapse="table.collapsed">
<div ng-repeat="column in table.columns track by column" style="padding-left:16px;">{{column}}</div>
</div>
</div>
</div>
</div>
19 changes: 1 addition & 18 deletions rd_ui/app/views/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,7 @@ <h3>
<! -- editor -->
<div class="container">
<div class="row bg-white p-b-5" ng-if="sourceMode" resizable r-directions="['bottom']" r-height="300" style="min-height:100px;">

<div class="col-md-3 schema-container hidden-sm hidden-xs" ng-show="hasSchema">
<div class="p-t-5 p-b-5">
<input type="text" placeholder="Search schema..." class="form-control" ng-model="schemaFilter">
</div>

<div class="schema-browser" vs-repeat>
<div ng-repeat="table in schema | filter:schemaFilter track by table.name">
<div class="table-name" ng-click="table.collapsed = !table.collapsed">
<i class="fa fa-table"></i> <strong><span title="{{table.name}}">{{table.name}}</span><span
ng-if="table.size !== undefined"> ({{table.size}})</span></strong>
</div>
<div collapse="table.collapsed">
<div ng-repeat="column in table.columns track by column" style="padding-left:16px;">{{column}}</div>
</div>
</div>
</div>
</div>
<schema-browser schema="schema" class="col-md-3 hidden-sm hidden-xs schema-container" ng-show="hasSchema"></schema-browser>

<div ng-class="editorSize" style="height:100%;">
<div class="p-5">
Expand Down

0 comments on commit e42f93f

Please sign in to comment.