mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 19:00:09 -04:00
44 lines
900 B
JavaScript
44 lines
900 B
JavaScript
import template from './schema-browser.html';
|
|
|
|
function SchemaBrowserCtrl($rootScope, $scope) {
|
|
'ngInject';
|
|
|
|
this.showTable = (table) => {
|
|
table.collapsed = !table.collapsed;
|
|
$scope.$broadcast('vsRepeatTrigger');
|
|
};
|
|
|
|
this.getSize = (table) => {
|
|
let size = 22;
|
|
|
|
if (!table.collapsed) {
|
|
size += 18 * table.columns.length;
|
|
}
|
|
|
|
return size;
|
|
};
|
|
|
|
this.isEmpty = function isEmpty() {
|
|
return this.schema === undefined || this.schema.length === 0;
|
|
};
|
|
|
|
this.itemSelected = ($event, hierarchy) => {
|
|
$rootScope.$broadcast('query-editor.paste', hierarchy.join('.'));
|
|
$event.preventDefault();
|
|
$event.stopPropagation();
|
|
};
|
|
}
|
|
|
|
const SchemaBrowser = {
|
|
bindings: {
|
|
schema: '<',
|
|
onRefresh: '&',
|
|
},
|
|
controller: SchemaBrowserCtrl,
|
|
template,
|
|
};
|
|
|
|
export default function init(ngModule) {
|
|
ngModule.component('schemaBrowser', SchemaBrowser);
|
|
}
|