in modules/frontend/app/components/page-queries/components/queries-notebook/controller.ts [90:202]
constructor($animate, $timeout, JavaTypes, errorParser, paragraph) {
const self = this;
self.id = 'paragraph-' + paragraphId++;
self.qryType = paragraph.qryType || 'query';
self.maxPages = 0;
self.filter = '';
self.useAsDefaultSchema = false;
self.localQueryMode = false;
self.csvIsPreparing = false;
self.scanningInProgress = false;
self.cancelQuerySubject = new Subject();
self.cancelExportSubject = new Subject();
_.assign(this, paragraph);
Object.defineProperty(this, 'gridOptions', {value: {
enableGridMenu: false,
enableColumnMenus: false,
flatEntityAccess: true,
fastWatch: true,
categories: [],
rebuildColumns() {
if (_.isNil(this.api))
return;
this.categories.length = 0;
this.columnDefs = _.reduce(self.meta, (cols, col, idx) => {
cols.push({
displayName: col.fieldName,
headerTooltip: _fullColName(col),
field: idx.toString(),
minWidth: 50,
cellClass: 'cell-left',
visible: self.columnFilter(col)
});
this.categories.push({
name: col.fieldName,
visible: self.columnFilter(col),
enableHiding: true
});
return cols;
}, []);
$timeout(() => this.api.core.notifyDataChange('column'));
},
adjustHeight() {
if (_.isNil(this.api))
return;
this.data = self.rows;
const height = Math.min(self.rows.length, 15) * 30 + 47;
// Remove header height.
this.api.grid.element.css('height', height + 'px');
$timeout(() => this.api.core.handleWindowResize());
},
onRegisterApi(api) {
$animate.enabled(api.grid.element, false);
this.api = api;
this.rebuildColumns();
this.adjustHeight();
}
}});
Object.defineProperty(this, 'chartHistory', {value: []});
Object.defineProperty(this, 'error', {value: {
root: {},
message: ''
}});
this.showLoading = (enable) => {
if (this.qryType === 'scan')
this.scanningInProgress = enable;
this.loading = enable;
};
this.setError = (err) => {
this.error.root = err;
this.error.message = errorParser.extractMessage(err);
let cause = err;
while (nonNil(cause)) {
if (nonEmpty(cause.className) &&
_.includes(['SQLException', 'JdbcSQLException', 'QueryCancelledException'], JavaTypes.shortClassName(cause.className))) {
this.error.message = errorParser.extractMessage(cause.message || cause.className);
break;
}
cause = cause.cause;
}
if (_.isEmpty(this.error.message) && nonEmpty(err.className)) {
this.error.message = 'Internal cluster error';
if (nonEmpty(err.className))
this.error.message += ': ' + err.className;
}
};
}