mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 17:38:54 +00:00
add 'refresh schema' button to schema-browser
This commit is contained in:
parent
b2e747caef
commit
8b59815bf2
@ -415,6 +415,16 @@ counter-renderer counter-name {
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.schema-control {
|
||||||
|
display: flex;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.schema-control .form-control {
|
||||||
|
height: 30px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.schema-browser {
|
.schema-browser {
|
||||||
height: calc(100% - 45px);
|
height: calc(100% - 45px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
<div class="row bg-white p-b-5" ng-if="sourceMode" resizable r-directions="['bottom']" r-height="300" style="min-height:100px;">
|
<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-browser class="col-md-3 hidden-sm hidden-xs schema-container"
|
||||||
schema="schema"
|
schema="schema"
|
||||||
|
on-refresh="refreshSchema()"
|
||||||
ng-show="hasSchema">
|
ng-show="hasSchema">
|
||||||
</schema-browser>
|
</schema-browser>
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<div class="schema-container">
|
<div class="schema-container">
|
||||||
<div class="p-t-5 p-b-5">
|
<div class="schema-control">
|
||||||
<input type="text" placeholder="Search schema..." class="form-control" ng-model="$ctrl.schemaFilter">
|
<input type="text" placeholder="Search schema..." class="form-control" ng-model="$ctrl.schemaFilter">
|
||||||
|
<button class="btn btn-default"
|
||||||
|
title="Refresh Schema"
|
||||||
|
ng-click="$ctrl.onRefresh()">
|
||||||
|
<span class="zmdi zmdi-refresh"></span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="schema-browser" vs-repeat vs-size="$ctrl.getSize(table)">
|
<div class="schema-browser" vs-repeat vs-size="$ctrl.getSize(table)">
|
||||||
|
@ -20,6 +20,7 @@ function SchemaBrowserCtrl($scope) {
|
|||||||
const SchemaBrowser = {
|
const SchemaBrowser = {
|
||||||
bindings: {
|
bindings: {
|
||||||
schema: '<',
|
schema: '<',
|
||||||
|
onRefresh: '&',
|
||||||
},
|
},
|
||||||
controller: SchemaBrowserCtrl,
|
controller: SchemaBrowserCtrl,
|
||||||
template,
|
template,
|
||||||
|
@ -43,26 +43,31 @@ function QueryViewCtrl($scope, Events, $route, $routeParams, $http, $location, $
|
|||||||
return dataSourceId;
|
return dataSourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSchema() {
|
function toggleSchemaBrowser(hasSchema) {
|
||||||
$scope.hasSchema = false;
|
$scope.hasSchema = hasSchema;
|
||||||
$scope.editorSize = 'col-md-12';
|
$scope.editorSize = hasSchema ? 'col-md-9' : 'col-md-12';
|
||||||
DataSource.getSchema({ id: $scope.query.data_source_id }, (data) => {
|
}
|
||||||
if (data && data.length > 0) {
|
|
||||||
|
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;
|
$scope.schema = data;
|
||||||
data.forEach((table) => {
|
data.forEach((table) => {
|
||||||
table.collapsed = true;
|
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) {
|
function updateDataSources(dataSources) {
|
||||||
// Filter out data sources the user can't query (or used by current query):
|
// Filter out data sources the user can't query (or used by current query):
|
||||||
$scope.dataSources = dataSources.filter(dataSource =>
|
$scope.dataSources = dataSources.filter(dataSource =>
|
||||||
|
@ -3,7 +3,7 @@ function DataSource($resource) {
|
|||||||
get: { method: 'GET', cache: false, isArray: false },
|
get: { method: 'GET', cache: false, isArray: false },
|
||||||
query: { method: 'GET', cache: false, isArray: true },
|
query: { method: 'GET', cache: false, isArray: true },
|
||||||
test: { method: 'POST', cache: false, isArray: false, url: 'api/data_sources/:id/test' },
|
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);
|
const DataSourceResource = $resource('api/data_sources/:id', { id: '@id' }, actions);
|
||||||
|
Loading…
Reference in New Issue
Block a user