Feature/webview for model view (#1463)

* support webview for view model

* formatting

* remove unused imports
This commit is contained in:
Abbie Petchtes
2018-05-23 09:51:44 -07:00
committed by GitHub
parent 1461929f86
commit 36a8991682
10 changed files with 325 additions and 72 deletions

View File

@@ -80,6 +80,13 @@ class ModelBuilderImpl implements sqlops.ModelBuilder {
return builder;
}
webView(): sqlops.ComponentBuilder<sqlops.WebViewComponent> {
let id = this.getNextComponentId();
let builder: ComponentBuilderImpl<sqlops.WebViewComponent> = this.getComponentBuilder(new WebViewWrapper(this._proxy, this._handle, id), id);
this._componentBuilders.set(id, builder);
return builder;
}
button(): sqlops.ComponentBuilder<sqlops.ButtonComponent> {
let id = this.getNextComponentId();
let builder: ComponentBuilderImpl<sqlops.ButtonComponent> = this.getComponentBuilder(new ButtonWrapper(this._proxy, this._handle, id), id);
@@ -94,16 +101,16 @@ class ModelBuilderImpl implements sqlops.ModelBuilder {
return builder;
}
dashboardWidget(widgetId: string): sqlops.ComponentBuilder<sqlops.WidgetComponent> {
dashboardWidget(widgetId: string): sqlops.ComponentBuilder<sqlops.DashboardWidgetComponent> {
let id = this.getNextComponentId();
let builder = this.getComponentBuilder<sqlops.WidgetComponent>(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWidget, id), id);
let builder = this.getComponentBuilder<sqlops.DashboardWidgetComponent>(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWidget, id), id);
this._componentBuilders.set(id, builder);
return builder;
}
dashboardWebview(webviewId: string): sqlops.ComponentBuilder<sqlops.WebviewComponent> {
dashboardWebview(webviewId: string): sqlops.ComponentBuilder<sqlops.DashboardWebviewComponent> {
let id = this.getNextComponentId();
let builder: ComponentBuilderImpl<sqlops.WebviewComponent> = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWebview, id), id);
let builder: ComponentBuilderImpl<sqlops.DashboardWebviewComponent> = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWebview, id), id);
this._componentBuilders.set(id, builder);
return builder;
}
@@ -523,6 +530,34 @@ class CheckBoxWrapper extends ComponentWrapper implements sqlops.CheckBoxCompone
}
}
class WebViewWrapper extends ComponentWrapper implements sqlops.WebViewComponent {
constructor(proxy: MainThreadModelViewShape, handle: number, id: string) {
super(proxy, handle, ModelComponentTypes.WebView, id);
this.properties = {};
this._emitterMap.set(ComponentEventType.onMessage, new Emitter<any>());
}
public get message(): any {
return this.properties['message'];
}
public set message(v: any) {
this.setProperty('message', v);
}
public get html(): string {
return this.properties['html'];
}
public set html(v: string) {
this.setProperty('html', v);
}
public get onMessage(): vscode.Event<any> {
let emitter = this._emitterMap.get(ComponentEventType.onMessage);
return emitter && emitter.event;
}
}
class RadioButtonWrapper extends ComponentWrapper implements sqlops.RadioButtonComponent {
constructor(proxy: MainThreadModelViewShape, handle: number, id: string) {