mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 01:25:38 -05:00
Port most notebook model code over to be behind a service (#3068)
- Defines a new NotebookService in Azure Data Studio which will be used to interact with notebooks. Since notebooks can require per-file instantiation the provider is just used to create & track managers for a given URI. - Inject this into notebook.component.ts and pass required parameters that'll be used to properly initialize a manger into the method. Actual initialization not done yet. - Port over & recompile notebook model code - Define most required APIs in sqlops.proposed.d.ts. In the future, these will be used by extensions to contribute their own providers.
This commit is contained in:
@@ -5,17 +5,44 @@
|
||||
|
||||
import './notebookStyles';
|
||||
|
||||
import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, ViewChildren } from '@angular/core';
|
||||
import { nb } from 'sqlops';
|
||||
|
||||
import { OnInit, Component, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild } from '@angular/core';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import * as themeColors from 'vs/workbench/common/theme';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
|
||||
import { CommonServiceInterface } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { AngularDisposable } from 'sql/base/common/lifecycle';
|
||||
|
||||
import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import * as themeColors from 'vs/workbench/common/theme';
|
||||
import { ICellModel, CellTypes } from 'sql/parts/notebook/cellViews/interfaces';
|
||||
import { CellTypes, CellType } from 'sql/parts/notebook/models/contracts';
|
||||
import { ICellModel } from 'sql/parts/notebook/models/modelInterfaces';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { INotebookService, INotebookParams } from 'sql/services/notebook/notebookService';
|
||||
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||
|
||||
class CellModelStub implements ICellModel {
|
||||
public cellUri: URI;
|
||||
constructor(public id: string,
|
||||
public language: string,
|
||||
public source: string,
|
||||
public cellType: CellType,
|
||||
public trustedMode: boolean = false,
|
||||
public active: boolean = false
|
||||
) { }
|
||||
|
||||
equals(cellModel: ICellModel): boolean {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
toJSON(): nb.ICell {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: NOTEBOOK_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('./notebook.component.html'))
|
||||
@@ -27,20 +54,18 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
constructor(
|
||||
@Inject(forwardRef(() => CommonServiceInterface)) private _bootstrapService: CommonServiceInterface,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
||||
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
|
||||
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
|
||||
@Inject(IConnectionManagementService) private connectionManagementService: IConnectionManagementService,
|
||||
@Inject(INotificationService) private notificationService: INotificationService,
|
||||
@Inject(INotebookService) private notebookService: INotebookService,
|
||||
@Inject(IBootstrapParams) private notebookParams: INotebookParams
|
||||
) {
|
||||
super();
|
||||
|
||||
// Todo: This is mock data for cells. Will remove this code when we have a service
|
||||
let cell1: ICellModel = {
|
||||
id: '1', language: 'sql', source: 'select * from sys.tables', cellType: CellTypes.Code, active: false
|
||||
};
|
||||
let cell2: ICellModel = {
|
||||
id: '2', language: 'sql', source: 'select 1', cellType: CellTypes.Code, active: false
|
||||
};
|
||||
let cell3: ICellModel = {
|
||||
id: '3', language: 'markdown', source: '## This is test!', cellType: CellTypes.Markdown, active: false
|
||||
};
|
||||
// TODO NOTEBOOK REFACTOR: This is mock data for cells. Will remove this code when we have a service
|
||||
let cell1 : ICellModel = new CellModelStub ('1', 'sql', 'select * from sys.tables', CellTypes.Code);
|
||||
let cell2 : ICellModel = new CellModelStub ('2', 'sql', 'select 1', CellTypes.Code);
|
||||
let cell3 : ICellModel = new CellModelStub ('3', 'markdown', '## This is test!', CellTypes.Markdown);
|
||||
this.cells.push(cell1, cell2, cell3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user