+
+
diff --git a/client/app/pages/queries/schema-browser.js b/client/app/pages/queries/schema-browser.js
index 604c114d..ece96de5 100644
--- a/client/app/pages/queries/schema-browser.js
+++ b/client/app/pages/queries/schema-browser.js
@@ -20,6 +20,7 @@ function SchemaBrowserCtrl($scope) {
const SchemaBrowser = {
bindings: {
schema: '<',
+ onRefresh: '&',
},
controller: SchemaBrowserCtrl,
template,
diff --git a/client/app/pages/queries/view.js b/client/app/pages/queries/view.js
index 3c1dc568..369be50f 100644
--- a/client/app/pages/queries/view.js
+++ b/client/app/pages/queries/view.js
@@ -43,26 +43,31 @@ function QueryViewCtrl($scope, Events, $route, $routeParams, $http, $location, $
return dataSourceId;
}
- function updateSchema() {
- $scope.hasSchema = false;
- $scope.editorSize = 'col-md-12';
- DataSource.getSchema({ id: $scope.query.data_source_id }, (data) => {
- if (data && data.length > 0) {
+ function toggleSchemaBrowser(hasSchema) {
+ $scope.hasSchema = hasSchema;
+ $scope.editorSize = hasSchema ? 'col-md-9' : 'col-md-12';
+ }
+
+ function getSchema(refresh = undefined) {
+ DataSource.getSchema({ id: $scope.query.data_source_id, refresh }, (data) => {
+ const hasSchema = data && (data.length > 0);
+ if (hasSchema) {
$scope.schema = data;
data.forEach((table) => {
table.collapsed = true;
});
-
- $scope.editorSize = 'col-md-9';
- $scope.hasSchema = true;
- } else {
- $scope.schema = undefined;
- $scope.hasSchema = false;
- $scope.editorSize = 'col-md-12';
}
+ toggleSchemaBrowser(hasSchema);
});
}
+ function updateSchema() {
+ toggleSchemaBrowser(false);
+ getSchema();
+ }
+
+ $scope.refreshSchema = () => getSchema(true);
+
function updateDataSources(dataSources) {
// Filter out data sources the user can't query (or used by current query):
$scope.dataSources = dataSources.filter(dataSource =>
diff --git a/client/app/services/data-source.js b/client/app/services/data-source.js
index d7a9cbc8..b6d42379 100644
--- a/client/app/services/data-source.js
+++ b/client/app/services/data-source.js
@@ -3,7 +3,7 @@ function DataSource($resource) {
get: { method: 'GET', cache: false, isArray: false },
query: { method: 'GET', cache: false, isArray: true },
test: { method: 'POST', cache: false, isArray: false, url: 'api/data_sources/:id/test' },
- getSchema: { method: 'GET', cache: true, isArray: true, url: 'api/data_sources/:id/schema' },
+ getSchema: { method: 'GET', cache: false, isArray: true, url: 'api/data_sources/:id/schema' },
};
const DataSourceResource = $resource('api/data_sources/:id', { id: '@id' }, actions);