mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 17:23:19 -05:00
Added empty kernel and hook up with Kernel drop down (#3173)
* Initial toolbar work - This is in-progress and needs additional fixes * Resolve PR comments * Added empty kernel and hook up with Kernel dropdown * Resolve PR comments
This commit is contained in:
@@ -28,6 +28,11 @@ import { ModelFactory } from 'sql/parts/notebook/models/modelFactory';
|
||||
import * as notebookUtils from './notebookUtils';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { AddCellAction, KernelsDropdown, AttachToDropdown } from 'sql/parts/notebook/notebookActions';
|
||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
|
||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||
|
||||
@@ -41,10 +46,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
private _model: NotebookModel;
|
||||
private _isInErrorState: boolean = false;
|
||||
private _errorMessage: string;
|
||||
protected _actionBar: Taskbar;
|
||||
private _activeCell: ICellModel;
|
||||
protected isLoading: boolean;
|
||||
private notebookManager: INotebookManager;
|
||||
private _modelReadyDeferred = new Deferred<NotebookModel>();
|
||||
private _modelRegisteredDeferred = new Deferred<NotebookModel>();
|
||||
private profile: IConnectionProfile;
|
||||
|
||||
|
||||
@@ -55,7 +62,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
@Inject(IConnectionManagementService) private connectionManagementService: IConnectionManagementService,
|
||||
@Inject(INotificationService) private notificationService: INotificationService,
|
||||
@Inject(INotebookService) private notebookService: INotebookService,
|
||||
@Inject(IBootstrapParams) private notebookParams: INotebookParams
|
||||
@Inject(IBootstrapParams) private notebookParams: INotebookParams,
|
||||
@Inject(IInstantiationService) private instantiationService: IInstantiationService,
|
||||
@Inject(IContextMenuService) private contextMenuService: IContextMenuService,
|
||||
@Inject(IContextViewService) private contextViewService: IContextViewService
|
||||
) {
|
||||
super();
|
||||
this.profile = this.notebookParams!.profile;
|
||||
@@ -65,9 +75,14 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
ngOnInit() {
|
||||
this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
|
||||
this.updateTheme(this.themeService.getColorTheme());
|
||||
this.initActionBar();
|
||||
this.doLoad();
|
||||
}
|
||||
|
||||
public get modelRegistered(): Promise<NotebookModel> {
|
||||
return this._modelRegisteredDeferred.promise;
|
||||
}
|
||||
|
||||
protected get cells(): ReadonlyArray<ICellModel> {
|
||||
return this._model ? this._model.cells : [];
|
||||
}
|
||||
@@ -135,11 +150,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
notebookManager: this.notebookManager
|
||||
}, false, this.profile);
|
||||
model.onError((errInfo: INotification) => this.handleModelError(errInfo));
|
||||
model.backgroundStartSession();
|
||||
await model.requestModelLoad(this.notebookParams.isTrusted);
|
||||
model.contentChanged((change) => this.handleContentChanged(change));
|
||||
this._model = model;
|
||||
this._register(model);
|
||||
this._modelRegisteredDeferred.resolve(this._model);
|
||||
model.backgroundStartSession();
|
||||
this._changeRef.detectChanges();
|
||||
}
|
||||
|
||||
@@ -170,6 +186,38 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
this.notificationService.error(error);
|
||||
}
|
||||
|
||||
protected initActionBar() {
|
||||
let kernelInfoText = document.createElement('div');
|
||||
kernelInfoText.className ='notebook-info-label';
|
||||
kernelInfoText.innerText = 'Kernel: ';
|
||||
|
||||
let kernelsDropdown = new KernelsDropdown(this.contextViewService, this.modelRegistered);
|
||||
let kernelsDropdownTemplateContainer = document.createElement('div');
|
||||
kernelsDropdownTemplateContainer.className = 'notebook-toolbar-dropdown';
|
||||
kernelsDropdown.render(kernelsDropdownTemplateContainer);
|
||||
attachSelectBoxStyler(kernelsDropdown, this.themeService);
|
||||
|
||||
let attachToDropdown = new AttachToDropdown(this.contextViewService);
|
||||
let attachToDropdownTemplateContainer = document.createElement('div');
|
||||
attachToDropdownTemplateContainer.className = 'notebook-toolbar-dropdown';
|
||||
attachToDropdown.render(attachToDropdownTemplateContainer);
|
||||
attachSelectBoxStyler(attachToDropdown, this.themeService);
|
||||
|
||||
let attachToInfoText = document.createElement('div');
|
||||
attachToInfoText.className ='notebook-info-label';
|
||||
attachToInfoText.innerText = 'Attach To: ';
|
||||
|
||||
let taskbar = <HTMLElement>this.toolbar.nativeElement;
|
||||
this._actionBar = new Taskbar(taskbar, this.contextMenuService);
|
||||
this._actionBar.context = this;
|
||||
this._actionBar.setContent([
|
||||
{ element: kernelInfoText },
|
||||
{ element: kernelsDropdownTemplateContainer },
|
||||
{ element: attachToInfoText },
|
||||
{ element: attachToDropdownTemplateContainer }
|
||||
]);
|
||||
}
|
||||
|
||||
public async save(): Promise<boolean> {
|
||||
try {
|
||||
let saved = await this._model.saveModel();
|
||||
|
||||
Reference in New Issue
Block a user