Added SQL notebook IntelliSense (#4064)

* Added SQL notebook intelliSense

* Resolved PR comments.

* catch disconnect error
This commit is contained in:
Yurong He
2019-02-15 15:53:06 -08:00
committed by GitHub
parent ea0c326d3d
commit f43b3508e9
4 changed files with 31 additions and 18 deletions

View File

@@ -132,6 +132,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
ngOnDestroy() {
this.disconnect();
this.dispose();
if (this.notebookService) {
this.notebookService.removeNotebookEditor(this);
@@ -165,6 +166,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
if (cell !== this.model.activeCell) {
if (this.model.activeCell) {
this.disconnect();
this.model.activeCell.active = false;
}
this._model.activeCell = cell;
@@ -173,6 +175,14 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
}
}
private disconnect() {
if (this._model.defaultKernel.display_name === notebookConstants.SQL) {
if (this._model.activeCell && this._model.activeCell.cellType === CellTypes.Code && this._model.activeCell.cellUri) {
this.connectionManagementService.disconnect(this._model.activeCell.cellUri.toString()).catch(e => console.log(e));
}
}
}
public unselectActiveCell() {
if (this.model && this.model.activeCell) {
this.model.activeCell.active = false;