mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
* Initial work of adding tab in the dashboard (#526) * refactor dashboard to have the home tab * formatting * fix grid layout issue * fix initailize issue in database dashboard * Add action bar to the panel and add close tab to the dashboard (#562) * add action bar to the panel and add close tab to the dashboard * formatting * Tab contribution (#564) * added contrib * disabled edit for extensions; fixed new name for insights contrib * fix merge issue * move file * formatting * fix builds * moving imports * Expand on tab contrib (#581) * added contrib * disabled edit for extensions; fixed new name for insights contrib * fix merge issue * move file * formatting * fix builds * adding to contrib * updated contrib * format * moving imports * updated contribution to map to current design * implemented actually using provider and edition filtering * Refactor and fix issues in close tab and add the placeholder for pin tab (#588) * refactor and fix issues in close tab and add the placeholder for pin tab * formatting * remove the redundant code * add clear all tabs in dashboard page init * Initial work for adding a feature tab dialog (#594) * initial work for add new dashboard tab * formatting * fix add panel action issue * fix breaking change * fix issues and tab and panels * formatting * minor fix * address comments * Add tab status to add extension tab dialog (#610) * add tab status to add extension tab dialog * add tab status to add extension tab dialog * rename add feature tab action * address comments * Webview widget (#618) * getting closer * webview widget now works * fix problem with rerendering webview * formatting * ensure that webview only shows up for extensions * formatting * comments * fix more compile issues * Change dashboard page init (#640) * changed init of serverpage * formatting * Webview tab (#638) * getting closer * webview widget now works * fix problem with rerendering webview * formatting * ensure that webview only shows up for extensions * formatting * comments * fix more compile issues * refacting stuff * added inital webview tab * piped through messaging and tested * Implement pin/unpin feature and always on tabs (#629) * implement pin/unpin feature * fix issue where insight can't be loaded after reopen * fix tab look and feel * implement always show tabs * make AddFeatureTabAction to track always show and pinned tabs * formatting * make dashboard tabs looks like the UX design * load always show before pinned tab * fix regression in panel for restore and connection dialog * fix merge conflict * don't worry about no widgets if its a webview (#656) * expose the dashboard server info when a webview is rendering (#644) * Fix few issues in dashboard command center (#655) * fix reloading insight wigets and create new tab when there is no extension * show possible tabIDs in the setting file * formatting * address comment * fix import name * fixes problem with size of webview widget being wrong (#654) * Refactor tab contribution to support content type (#685) * refactor tab contribution to support content type * formatting * address comment * fix rendering tab issue (#694) * Add layout option to panel for supporting horizontal and vertical navigation bar (#700) * Add left navigation panel for inner tab in the dashboard * add layout option in panel * remove panel option in dashboard Page * refactor widgets content * formatting * refactor webveiw content * delete unused file * address comment
117 lines
3.6 KiB
TypeScript
117 lines
3.6 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import 'vs/css!./webviewContent';
|
|
|
|
import { Component, forwardRef, Input, OnInit, Inject, ChangeDetectorRef, ElementRef } from '@angular/core';
|
|
|
|
import Event, { Emitter } from 'vs/base/common/event';
|
|
import Webview from 'vs/workbench/parts/html/browser/webview';
|
|
import { Parts } from 'vs/workbench/services/part/common/partService';
|
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
|
|
|
import { DashboardTab } from 'sql/parts/dashboard/common/interfaces';
|
|
import { TabConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
|
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
|
import { IDashboardWebview } from 'sql/services/dashboardWebview/common/dashboardWebviewService';
|
|
|
|
import * as data from 'data';
|
|
import { memoize } from 'vs/base/common/decorators';
|
|
|
|
@Component({
|
|
template: '',
|
|
selector: 'webview-content'
|
|
})
|
|
export class WebviewContent implements OnInit, IDashboardWebview {
|
|
@Input() private webviewId: string;
|
|
|
|
private _onResize = new Emitter<void>();
|
|
public readonly onResize: Event<void> = this._onResize.event;
|
|
private _onMessage = new Emitter<string>();
|
|
public readonly onMessage: Event<string> = this._onMessage.event;
|
|
private _onMessageDisposable: IDisposable;
|
|
private _webview: Webview;
|
|
private _html: string;
|
|
|
|
constructor(
|
|
@Inject(forwardRef(() => DashboardServiceInterface)) private _dashboardService: DashboardServiceInterface,
|
|
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef,
|
|
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef
|
|
) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this._dashboardService.dashboardWebviewService.registerWebview(this);
|
|
this._createWebview();
|
|
}
|
|
|
|
public layout(): void {
|
|
this._createWebview();
|
|
}
|
|
|
|
public get id(): string {
|
|
return this.webviewId;
|
|
}
|
|
|
|
@memoize
|
|
public get connection(): data.connection.Connection {
|
|
let currentConnection = this._dashboardService.connectionManagementService.connectionInfo.connectionProfile;
|
|
let connection: data.connection.Connection = {
|
|
providerName: currentConnection.providerName,
|
|
connectionId: currentConnection.id,
|
|
options: currentConnection.options
|
|
};
|
|
return connection;
|
|
}
|
|
|
|
@memoize
|
|
public get serverInfo(): data.ServerInfo {
|
|
return this._dashboardService.connectionManagementService.connectionInfo.serverInfo;
|
|
}
|
|
|
|
public setHtml(html: string): void {
|
|
this._html = html;
|
|
if (this._webview) {
|
|
this._webview.contents = [html];
|
|
this._webview.layout();
|
|
}
|
|
}
|
|
|
|
public sendMessage(message: string): void {
|
|
if (this._webview) {
|
|
this._webview.sendMessage(message);
|
|
}
|
|
}
|
|
|
|
private _createWebview(): void {
|
|
if (this._webview) {
|
|
this._webview.dispose();
|
|
}
|
|
|
|
if (this._onMessageDisposable) {
|
|
this._onMessageDisposable.dispose();
|
|
}
|
|
|
|
this._webview = new Webview(this._el.nativeElement,
|
|
this._dashboardService.partService.getContainer(Parts.EDITOR_PART),
|
|
this._dashboardService.contextViewService,
|
|
undefined,
|
|
undefined,
|
|
{
|
|
allowScripts: true,
|
|
enableWrappedPostMessage: true,
|
|
hideFind: true
|
|
}
|
|
);
|
|
this._onMessageDisposable = this._webview.onMessage(e => {
|
|
this._onMessage.fire(e);
|
|
});
|
|
this._webview.style(this._dashboardService.themeService.getTheme());
|
|
if (this._html) {
|
|
this._webview.contents = [this._html];
|
|
}
|
|
this._webview.layout();
|
|
}
|
|
}
|