Fix #4047 Redesign notebook model to handle single client session (#4371)

* Start single client session based on the default kernel or saved kernel in NB.

* Added kernel displayName to standardKernel.
Modified name to allign wtih Juptyer Kernel.name.
So we can show the displayName during startup and use the name to start the session.

* Change session.OnSessionReady event in KernelDropDown

* Added model.KernelChnaged for switching kernel in the same provider

* Fixed session.Ready sequence

* Fixed merge issues

* Solve merged issue

* Fixed wrong kernel name in saved NB

* Added new event in Model to notify kernel change.
Toolbar depends on ModelReady to load

* Change attachTo to wait for ModelReady like KenelDropDown

* sanitizeSavedKernelInfo to fix invalid kernel and display_name. For example: PySpark1111 and PySpark 1111


* Added _contextsChangingEmitter to change loadContext msg when changing kernel

* Resolve PR comments
This commit is contained in:
Yurong He
2019-03-11 17:59:13 -07:00
committed by GitHub
parent b44d2b1bb3
commit 118d2c7273
20 changed files with 425 additions and 313 deletions

View File

@@ -220,6 +220,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
private async doLoad(): Promise<void> {
try {
await this.setNotebookManager();
await this.loadModel();
this.setLoading(false);
this._modelReadyDeferred.resolve(this._model);
@@ -243,10 +244,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
let providerId = 'sql'; // this is tricky; really should also depend on the connection profile
this.setContextKeyServiceWithProviderId(providerId);
this.fillInActionsForCurrentContext();
for (let providerId of this._notebookParams.providers) {
let notebookManager = await this.notebookService.getOrCreateNotebookManager(providerId, this._notebookParams.notebookUri);
this.notebookManagers.push(notebookManager);
}
let model = new NotebookModel({
factory: this.modelFactory,
notebookUri: this._notebookParams.notebookUri,
@@ -268,10 +266,17 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this._model = this._register(model);
this.updateToolbarComponents(this._model.trustedMode);
this._modelRegisteredDeferred.resolve(this._model);
model.backgroundStartSession();
await model.startSession(this.model.notebookManager);
this.detectChanges();
}
private async setNotebookManager() {
for (let providerId of this._notebookParams.providers) {
let notebookManager = await this.notebookService.getOrCreateNotebookManager(providerId, this._notebookParams.notebookUri);
this.notebookManagers.push(notebookManager);
}
}
private async awaitNonDefaultProvider(): Promise<void> {
// Wait on registration for now. Long-term would be good to cache and refresh
await this.notebookService.registrationComplete;
@@ -348,12 +353,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
protected initActionBar() {
let kernelContainer = document.createElement('div');
let kernelDropdown = new KernelsDropdown(kernelContainer, this.contextViewService, this.modelRegistered);
let kernelDropdown = new KernelsDropdown(kernelContainer, this.contextViewService, this.modelReady);
kernelDropdown.render(kernelContainer);
attachSelectBoxStyler(kernelDropdown, this.themeService);
let attachToContainer = document.createElement('div');
let attachToDropdown = new AttachToDropdown(attachToContainer, this.contextViewService, this.modelRegistered,
let attachToDropdown = new AttachToDropdown(attachToContainer, this.contextViewService, this.modelReady,
this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService);
attachToDropdown.render(attachToContainer);
attachSelectBoxStyler(attachToDropdown, this.themeService);