mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
Remove unused code (#4873)
* removes unused features * remove more unused code; formatting * lock changes * fix run issue
This commit is contained in:
@@ -1,132 +0,0 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
-->
|
||||
|
||||
<div class="task-content">
|
||||
|
||||
<form #f="ngForm"
|
||||
(ngSubmit)="onSubmit(f)">
|
||||
|
||||
<span>General</span>
|
||||
|
||||
<table class="task-input-table">
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Database name:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
<input name="databaseName" type="text" id="databaseNameInput" class="task-text-input"
|
||||
ngModel required [disabled]="formSubmitted" #databaseName="ngModel" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!--
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Owner:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td style="width:100%">
|
||||
<input name="databaseOwner" type="text" id="databaseOwnerInput" class="task-text-input"
|
||||
ngModel required #databaseOwner="ngModel" />
|
||||
</td>
|
||||
<td style="width:auto; padding-left: 5px;">
|
||||
<button (click)="onSelectOwner()">...</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<label><input id="full-text-index" type="checkbox" /><span>Use full-text indexing</span></label>
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
|
||||
</table>
|
||||
|
||||
<span>{{databaseFilesLabel}}</span>
|
||||
<table class="task-input-table">
|
||||
<tr>
|
||||
<td>
|
||||
<p-dataTable [value]="databaseFiles" [tableStyle]="{'overflow': 'auto'}" [emptyMessage]="noRecordsFoundLabel">
|
||||
<p-column header="Logical Name" field="logicalName" ></p-column>
|
||||
<p-column header="File Type" field="fileType"></p-column>
|
||||
<p-column header="File Group" field="filegroup"></p-column>
|
||||
<p-column header="Initial Size" field="initialSize"></p-column>
|
||||
<p-column header="Autogrow" field="autogrow"></p-column>
|
||||
<p-column header="Path" field="path"></p-column>
|
||||
</p-dataTable>
|
||||
</td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td class="task-button-bar" style="padding-top: 5px">
|
||||
<button>Add</button>
|
||||
<button>Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
-->
|
||||
</table>
|
||||
|
||||
<!--
|
||||
<span>Options</span>
|
||||
<table class="task-input-table">
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Collation:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
<select>
|
||||
<option>default</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Recovery model:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
<select>
|
||||
<option>Full</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Compatability level:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
<select>
|
||||
<option>SQL Server vNext (140)</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="task-input-table-label-column">
|
||||
Containment type:
|
||||
</td>
|
||||
<td class="task-input-table-content-column">
|
||||
<select>
|
||||
<option>None</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
-->
|
||||
|
||||
<div class="task-button-bar">
|
||||
<button type="submit" id="ok-button" [disabled]="formSubmitted">OK</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ChangeDetectorRef, ElementRef, Component, forwardRef, Inject } from '@angular/core';
|
||||
import { NgForm } from '@angular/forms';
|
||||
|
||||
import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
import { IAdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
export const CREATEDATABASE_SELECTOR: string = 'createdatabase-component';
|
||||
|
||||
export interface DatabaseFile {
|
||||
logicalName: string;
|
||||
fileType: string;
|
||||
filegroup: string;
|
||||
initialSize: string;
|
||||
autogrow: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: CREATEDATABASE_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('sql/parts/admin/database/create/createDatabase.component.html'))
|
||||
})
|
||||
export class CreateDatabaseComponent implements ITaskDialogComponent {
|
||||
|
||||
public formSubmitted: boolean = false;
|
||||
|
||||
public ownerUri: string;
|
||||
|
||||
public connection: ConnectionManagementInfo;
|
||||
|
||||
public databaseFiles: DatabaseFile[] = [];
|
||||
|
||||
// tslint:disable:no-unused-variable
|
||||
private readonly databaseFilesLabel: string = nls.localize('createDatabase.databaseFiles', 'Database files:');
|
||||
private readonly noRecordsFoundLabel: string = nls.localize('createDatabase.noRecordsFound', 'No records found');
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(forwardRef(() => ChangeDetectorRef)) private _changeDetectorRef: ChangeDetectorRef,
|
||||
@Inject(IAdminService) private _adminService: IAdminService
|
||||
) {
|
||||
}
|
||||
|
||||
private getDatabaseInfo(form: NgForm): azdata.DatabaseInfo {
|
||||
return <azdata.DatabaseInfo>{
|
||||
options: {
|
||||
name: form.value.databaseName,
|
||||
owner: form.value.databaseOwner
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public onSubmit(form: NgForm): void {
|
||||
this._adminService.createDatabase(this.ownerUri, this.getDatabaseInfo(form));
|
||||
this.formSubmitted = true;
|
||||
this._changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
public onOk(): void { }
|
||||
|
||||
public onGenerateScript(): void { }
|
||||
|
||||
public onCancel(): void { }
|
||||
|
||||
public onSelectOwner(): void { }
|
||||
|
||||
public injectBootstapper(parameters: ITaskDialogComponentParams): void {
|
||||
let self = this;
|
||||
this.ownerUri = parameters.ownerUri;
|
||||
this._adminService.getDefaultDatabaseInfo(this.ownerUri).then(dbInfo => {
|
||||
let databaseFilesCount = dbInfo.options['databaseFilesCount'];
|
||||
for (let i = 0; i < databaseFilesCount; ++i) {
|
||||
self.databaseFiles[i] = {
|
||||
logicalName: dbInfo.options['databaseFiles.' + i + '.name'],
|
||||
fileType: dbInfo.options['databaseFiles.' + i + '.databaseFileType'],
|
||||
filegroup: dbInfo.options['databaseFiles.' + i + '.fileGroup'],
|
||||
initialSize: dbInfo.options['databaseFiles.' + i + '.initialSize'],
|
||||
autogrow: dbInfo.options['databaseFiles.' + i + '.autogrowth'],
|
||||
path: dbInfo.options['databaseFiles.' + i + '.folder']
|
||||
};
|
||||
}
|
||||
self._changeDetectorRef.detectChanges();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
-->
|
||||
|
||||
<h1>New Login</h1>
|
||||
|
||||
<h2>General</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
Login name:
|
||||
</td>
|
||||
<td>
|
||||
<input type="textbox" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
Password:
|
||||
</td>
|
||||
<td>
|
||||
<input type="textbox" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<button type="button">Cancel</button>
|
||||
<button type="button">Create Login</button>
|
||||
@@ -1,28 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ElementRef, Component, Inject, forwardRef } from '@angular/core';
|
||||
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { IDashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
|
||||
export const CREATELOGIN_SELECTOR: string = 'createlogin-component';
|
||||
|
||||
@Component({
|
||||
selector: CREATELOGIN_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('sql/parts/admin/security/createLogin.component.html'))
|
||||
})
|
||||
export class CreateLoginComponent {
|
||||
|
||||
public ownerUri: string;
|
||||
|
||||
public connection: ConnectionManagementInfo;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(IBootstrapParams) private _params: IDashboardComponentParams
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { NgModule, Inject, forwardRef, ApplicationRef, ComponentFactoryResolver, Type } from '@angular/core';
|
||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { IBootstrapParams, providerIterator } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { CreateLoginComponent } from 'sql/parts/admin/security/createLogin.component';
|
||||
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
// Connection Dashboard main angular module
|
||||
export const CreateLoginModule = (params: IBootstrapParams, selector: string, instantiationService: IInstantiationService): Type<any> => {
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
CreateLoginComponent
|
||||
],
|
||||
entryComponents: [CreateLoginComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
BrowserModule
|
||||
],
|
||||
providers: [
|
||||
{ provide: APP_BASE_HREF, useValue: '/' },
|
||||
{ provide: IBootstrapParams, useValue: params },
|
||||
...providerIterator(instantiationService)
|
||||
]
|
||||
})
|
||||
class ModuleClass {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver
|
||||
) {
|
||||
}
|
||||
|
||||
ngDoBootstrap(appRef: ApplicationRef) {
|
||||
const factory = this._resolver.resolveComponentFactory(CreateLoginComponent);
|
||||
(<any>factory).factory.selector = selector;
|
||||
appRef.bootstrap(factory);
|
||||
}
|
||||
}
|
||||
|
||||
return ModuleClass;
|
||||
};
|
||||
@@ -1,114 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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!sql/parts/query/editor/media/queryEditor';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CreateLoginInput } from 'sql/parts/admin/security/createLoginInput';
|
||||
import { CreateLoginModule } from 'sql/parts/admin/security/createLogin.module';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IMetadataService } from 'sql/platform/metadata/common/metadataService';
|
||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { bootstrapAngular, IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
export class CreateLoginEditor extends BaseEditor {
|
||||
|
||||
public static ID: string = 'workbench.editor.createlogin';
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@IMetadataService private _metadataService: IMetadataService,
|
||||
@IScriptingService private _scriptingService: IScriptingService,
|
||||
@IQueryEditorService private _queryEditorService: IQueryEditorService,
|
||||
@IStorageService storageService: IStorageService
|
||||
) {
|
||||
super(CreateLoginEditor.ID, telemetryService, themeService, storageService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to create the editor in the parent element.
|
||||
*/
|
||||
public createEditor(parent: HTMLElement): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets focus on this editor. Specifically, it sets the focus on the hosted text editor.
|
||||
*/
|
||||
public focus(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the internal variable keeping track of the editor's size, and re-calculates the sash position.
|
||||
* To be called when the container of this editor changes size.
|
||||
*/
|
||||
public layout(dimension: DOM.Dimension): void {
|
||||
}
|
||||
|
||||
public setInput(input: CreateLoginInput, options: EditorOptions): Promise<void> {
|
||||
if (this.input instanceof CreateLoginInput && this.input.matches(input)) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
if (!input.hasInitialized) {
|
||||
this.bootstrapAngular(input);
|
||||
}
|
||||
this.revealElementWithTagName(input.uniqueSelector, this.getContainer());
|
||||
|
||||
return super.setInput(input, options, CancellationToken.None);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reveal the child element with the given tagName and hide all other elements.
|
||||
*/
|
||||
private revealElementWithTagName(tagName: string, parent: HTMLElement): void {
|
||||
let elementToReveal: HTMLElement;
|
||||
|
||||
for (let i = 0; i < parent.children.length; i++) {
|
||||
let child: HTMLElement = <HTMLElement>parent.children[i];
|
||||
if (child.tagName && child.tagName.toLowerCase() === tagName && !elementToReveal) {
|
||||
elementToReveal = child;
|
||||
} else {
|
||||
child.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (elementToReveal) {
|
||||
elementToReveal.style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the angular components and record for this input that we have done so
|
||||
*/
|
||||
private bootstrapAngular(input: CreateLoginInput): void {
|
||||
|
||||
// Get the bootstrap params and perform the bootstrap
|
||||
let params: IBootstrapParams = {
|
||||
connection: input.getConnectionProfile(),
|
||||
ownerUri: input.getUri()
|
||||
};
|
||||
let uniqueSelector = bootstrapAngular(this.instantiationService,
|
||||
CreateLoginModule,
|
||||
this.getContainer(),
|
||||
CREATELOGIN_SELECTOR,
|
||||
params);
|
||||
input.setUniqueSelector(uniqueSelector);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
export class CreateLoginInput extends EditorInput {
|
||||
|
||||
public static ID: string = 'workbench.editorinputs.createlogininput';
|
||||
public static SCHEMA: string = 'adminlogincreate';
|
||||
|
||||
private _uniqueSelector: string;
|
||||
|
||||
constructor(private _uri: string, private _connection: IConnectionProfile) {
|
||||
super();
|
||||
}
|
||||
|
||||
public setUniqueSelector(uniqueSelector: string): void {
|
||||
this._uniqueSelector = uniqueSelector;
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
return UntitledEditorInput.ID;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this._connection.serverName + ':' + this._connection.databaseName;
|
||||
}
|
||||
|
||||
public getUri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public supportsSplitEditor(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getConnectionProfile(): IConnectionProfile {
|
||||
return this._connection;
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): Promise<EditorModel> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public get hasInitialized(): boolean {
|
||||
return !!this._uniqueSelector;
|
||||
}
|
||||
|
||||
public get uniqueSelector(): string {
|
||||
return this._uniqueSelector;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEditorRegistry, Extensions as EditorExtensions, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { TaskDialogEditor } from 'sql/parts/tasks/dialog/taskDialogEditor';
|
||||
import { TaskDialogInput } from 'sql/parts/tasks/dialog/taskDialogInput';
|
||||
import { CreateLoginEditor } from 'sql/parts/admin/security/createLoginEditor';
|
||||
import { CreateLoginInput } from 'sql/parts/admin/security/createLoginInput';
|
||||
|
||||
// Task Dialog registration
|
||||
const taskDialogEditorDescriptor = new EditorDescriptor(
|
||||
TaskDialogEditor,
|
||||
TaskDialogEditor.ID,
|
||||
'Task Dialog'
|
||||
);
|
||||
|
||||
// Create Login registration
|
||||
const createLoginEditorDescriptor = new EditorDescriptor(
|
||||
CreateLoginEditor,
|
||||
CreateLoginEditor.ID,
|
||||
'CreateLogin'
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(createLoginEditorDescriptor, [new SyncDescriptor(CreateLoginInput)]);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(taskDialogEditorDescriptor, [new SyncDescriptor(TaskDialogInput)]);
|
||||
@@ -1,18 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
/**
|
||||
* Interface for task dialog component events
|
||||
*/
|
||||
export interface ITaskDialogComponent {
|
||||
onOk(): void;
|
||||
|
||||
onGenerateScript(): void;
|
||||
|
||||
onCancel(): void;
|
||||
|
||||
injectBootstapper(parameters: ITaskDialogComponentParams ): void;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
-->
|
||||
|
||||
<div style="width: 100%; height: 100%">
|
||||
<router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet>
|
||||
</div>
|
||||
@@ -1,47 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
|
||||
import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ElementRef, Component, Inject, forwardRef } from '@angular/core';
|
||||
import { IBootstrapParams } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
export const TASKDIALOG_SELECTOR: string = 'taskdialog-component';
|
||||
|
||||
@Component({
|
||||
selector: TASKDIALOG_SELECTOR,
|
||||
templateUrl: decodeURI(require.toUrl('sql/parts/tasks/dialog/taskDialog.component.html')),
|
||||
})
|
||||
export class TaskDialogComponent {
|
||||
|
||||
private _currentComponent: ITaskDialogComponent;
|
||||
|
||||
public ownerUri: string;
|
||||
|
||||
public connection: ConnectionManagementInfo;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef,
|
||||
@Inject(IBootstrapParams) private _parameters: ITaskDialogComponentParams
|
||||
) {
|
||||
this.ownerUri = this._parameters.ownerUri;
|
||||
|
||||
}
|
||||
|
||||
public onActivate(component: any) {
|
||||
// validate the component implements ITaskDialogComponent (or at least part of the interface)
|
||||
if ((<ITaskDialogComponent>component).onOk) {
|
||||
this._currentComponent = <ITaskDialogComponent>component;
|
||||
this._currentComponent.injectBootstapper(this._parameters);
|
||||
} else {
|
||||
this._currentComponent = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
public onDeactivate(component: any) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import {
|
||||
ApplicationRef, ComponentFactoryResolver, ModuleWithProviders, NgModule,
|
||||
Inject, forwardRef, Type
|
||||
} from '@angular/core';
|
||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
import { TaskDialogComponent } from 'sql/parts/tasks/dialog/taskDialog.component';
|
||||
import { CreateDatabaseComponent } from 'sql/parts/admin/database/create/createDatabase.component';
|
||||
import { IBootstrapParams, ISelector, providerIterator } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
// Setup routes for various child components
|
||||
const appRoutes: Routes = [
|
||||
{ path: 'create-database', component: CreateDatabaseComponent },
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/create-database',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{ path: '**', component: CreateDatabaseComponent }
|
||||
];
|
||||
|
||||
export const TaskDialogModule = (params: IBootstrapParams, selector: string, instantiationService: IInstantiationService): Type<any> => {
|
||||
@NgModule({
|
||||
declarations: [
|
||||
TaskDialogComponent,
|
||||
CreateDatabaseComponent
|
||||
],
|
||||
entryComponents: [TaskDialogComponent],
|
||||
imports: [
|
||||
FormsModule,
|
||||
CommonModule,
|
||||
BrowserModule,
|
||||
<ModuleWithProviders>RouterModule.forRoot(appRoutes)
|
||||
],
|
||||
providers: [
|
||||
{ provide: APP_BASE_HREF, useValue: '/' },
|
||||
{ provide: IBootstrapParams, useValue: params },
|
||||
{ provide: ISelector, useValue: selector },
|
||||
...providerIterator(instantiationService)
|
||||
]
|
||||
})
|
||||
class ModuleClass {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
|
||||
@Inject(ISelector) private selector: string
|
||||
) {
|
||||
}
|
||||
|
||||
ngDoBootstrap(appRef: ApplicationRef) {
|
||||
const factory = this._resolver.resolveComponentFactory(TaskDialogComponent);
|
||||
(<any>factory).factory.selector = this.selector;
|
||||
appRef.bootstrap(factory);
|
||||
}
|
||||
}
|
||||
|
||||
return ModuleClass;
|
||||
};
|
||||
@@ -1,108 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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!sql/parts/query/editor/media/queryEditor';
|
||||
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
import { EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
import { TaskDialogInput } from './taskDialogInput';
|
||||
import { ITaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { TaskDialogModule } from 'sql/parts/tasks/dialog/taskDialog.module';
|
||||
import { TASKDIALOG_SELECTOR } from 'sql/parts/tasks/dialog/taskDialog.component';
|
||||
import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
export class TaskDialogEditor extends BaseEditor {
|
||||
|
||||
public static ID: string = 'workbench.editor.taskdialog';
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IStorageService storageService: IStorageService
|
||||
) {
|
||||
super(TaskDialogEditor.ID, telemetryService, themeService, storageService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to create the editor in the parent element.
|
||||
*/
|
||||
public createEditor(parent: HTMLElement): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets focus on this editor. Specifically, it sets the focus on the hosted text editor.
|
||||
*/
|
||||
public focus(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the internal variable keeping track of the editor's size, and re-calculates the sash position.
|
||||
* To be called when the container of this editor changes size.
|
||||
*/
|
||||
public layout(dimension: Dimension): void {
|
||||
}
|
||||
|
||||
public setInput(input: TaskDialogInput, options: EditorOptions): Promise<void> {
|
||||
if (this.input instanceof TaskDialogInput && this.input.matches(input)) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
if (!input.hasInitialized) {
|
||||
this.bootstrapAngular(input);
|
||||
}
|
||||
this.revealElementWithTagName(input.uniqueSelector, this.getContainer());
|
||||
|
||||
return super.setInput(input, options, CancellationToken.None);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reveal the child element with the given tagName and hide all other elements.
|
||||
*/
|
||||
private revealElementWithTagName(tagName: string, parent: HTMLElement): void {
|
||||
let elementToReveal: HTMLElement;
|
||||
|
||||
for (let i = 0; i < parent.children.length; i++) {
|
||||
let child: HTMLElement = <HTMLElement>parent.children[i];
|
||||
if (child.tagName && child.tagName.toLowerCase() === tagName && !elementToReveal) {
|
||||
elementToReveal = child;
|
||||
} else {
|
||||
child.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (elementToReveal) {
|
||||
elementToReveal.style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the angular components and record for this input that we have done so
|
||||
*/
|
||||
private bootstrapAngular(input: TaskDialogInput): void {
|
||||
|
||||
// Get the bootstrap params and perform the bootstrap
|
||||
let params: ITaskDialogComponentParams = {
|
||||
ownerUri: input.getUri()
|
||||
};
|
||||
let uniqueSelector = bootstrapAngular(this.instantiationService,
|
||||
TaskDialogModule,
|
||||
this.getContainer(),
|
||||
TASKDIALOG_SELECTOR,
|
||||
params);
|
||||
input.setUniqueSelector(uniqueSelector);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
export class TaskDialogInput extends EditorInput {
|
||||
|
||||
public static ID: string = 'workbench.editorinputs.taskdialoginputs';
|
||||
public static SCHEMA: string = 'taskdialog';
|
||||
|
||||
private _uniqueSelector: string;
|
||||
|
||||
constructor(private _uri: string, private _connection: IConnectionProfile) {
|
||||
super();
|
||||
}
|
||||
|
||||
public setUniqueSelector(uniqueSelector: string): void {
|
||||
this._uniqueSelector = uniqueSelector;
|
||||
}
|
||||
|
||||
public getTypeId(): string {
|
||||
return UntitledEditorInput.ID;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this._connection.serverName + ':' + this._connection.databaseName;
|
||||
}
|
||||
|
||||
public getUri(): string {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
public supportsSplitEditor(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public getConnectionProfile(): IConnectionProfile {
|
||||
return this._connection;
|
||||
}
|
||||
|
||||
public resolve(refresh?: boolean): Promise<EditorModel> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public get hasInitialized(): boolean {
|
||||
return !!this._uniqueSelector;
|
||||
}
|
||||
|
||||
public get uniqueSelector(): string {
|
||||
return this._uniqueSelector;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
import * as types from 'vs/base/common/types';
|
||||
|
||||
@@ -2,18 +2,15 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { TaskRegistry } from 'sql/platform/tasks/common/tasks';
|
||||
|
||||
import * as Actions from './actions';
|
||||
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { ShowCurrentReleaseNotesAction } from 'sql/workbench/update/releaseNotes';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IConfigurationRegistry, Extensions as ConfigExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
|
||||
new Actions.BackupAction().registerTask();
|
||||
@@ -49,4 +46,4 @@ Registry.as<IConfigurationRegistry>(ConfigExtensions.Configuration).registerConf
|
||||
'description': nls.localize('showConnectDialogOnStartup', 'Show connect dialog on startup')
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ import { IScriptingService } from 'sql/platform/scripting/common/scriptingServic
|
||||
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
|
||||
import { IAngularEventingService, AngularEventType } from 'sql/platform/angularEventing/common/angularEventingService';
|
||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/common/insightsDialogService';
|
||||
import { IAdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
import * as Constants from 'sql/common/constants';
|
||||
import { Task } from 'sql/platform/tasks/common/tasks';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService';
|
||||
@@ -58,22 +57,13 @@ export class NewQueryAction extends Task {
|
||||
}
|
||||
|
||||
public runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.newQuery(
|
||||
profile,
|
||||
accessor.get<IConnectionManagementService>(IConnectionManagementService),
|
||||
accessor.get<IQueryEditorService>(IQueryEditorService),
|
||||
accessor.get<IObjectExplorerService>(IObjectExplorerService),
|
||||
accessor.get<IEditorService>(IEditorService)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.newQuery(
|
||||
profile,
|
||||
accessor.get<IConnectionManagementService>(IConnectionManagementService),
|
||||
accessor.get<IQueryEditorService>(IQueryEditorService),
|
||||
accessor.get<IObjectExplorerService>(IObjectExplorerService),
|
||||
accessor.get<IEditorService>(IEditorService)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,21 +81,13 @@ export class ScriptSelectAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.scriptSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
});
|
||||
});
|
||||
return TaskUtilities.scriptSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,24 +106,15 @@ export class ScriptExecuteAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Execute,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Execute,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,24 +133,15 @@ export class ScriptAlterAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Alter,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Alter,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,22 +159,13 @@ export class EditDataAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.scriptEditSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.scriptEditSelect(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,24 +184,15 @@ export class ScriptCreateAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Create,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Create,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,24 +211,15 @@ export class ScriptDeleteAction extends Action {
|
||||
}
|
||||
|
||||
public run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Delete,
|
||||
this._errorMessageService
|
||||
).then(
|
||||
result => {
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(false);
|
||||
}
|
||||
);
|
||||
});
|
||||
return TaskUtilities.script(
|
||||
actionContext.profile,
|
||||
actionContext.object,
|
||||
this._connectionManagementService,
|
||||
this._queryEditorService,
|
||||
this._scriptingService,
|
||||
TaskUtilities.ScriptOperation.Delete,
|
||||
this._errorMessageService
|
||||
).then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +237,7 @@ export class BackupAction extends Task {
|
||||
});
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise<void> {
|
||||
if (!profile) {
|
||||
let objectExplorerService = accessor.get<IObjectExplorerService>(IObjectExplorerService);
|
||||
let connectionManagementService = accessor.get<IConnectionManagementService>(IConnectionManagementService);
|
||||
@@ -310,24 +247,13 @@ export class BackupAction extends Task {
|
||||
let configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||
if (!previewFeaturesEnabled) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.isPreviewFeature', 'You must enable preview features in order to use backup'));
|
||||
});
|
||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('backup.isPreviewFeature', 'You must enable preview features in order to use backup'));
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.showBackup(
|
||||
profile,
|
||||
accessor.get<IBackupUiService>(IBackupUiService)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
TaskUtilities.showBackup(
|
||||
profile,
|
||||
accessor.get<IBackupUiService>(IBackupUiService)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,28 +271,17 @@ export class RestoreAction extends Task {
|
||||
});
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): Promise<void> {
|
||||
runTask(accessor: ServicesAccessor, profile: IConnectionProfile): void | Promise<void> {
|
||||
let configurationService = accessor.get<IConfigurationService>(IConfigurationService);
|
||||
let previewFeaturesEnabled: boolean = configurationService.getValue('workbench')['enablePreviewFeatures'];
|
||||
if (!previewFeaturesEnabled) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.isPreviewFeature', 'You must enable preview features in order to use restore'));
|
||||
});
|
||||
return accessor.get<INotificationService>(INotificationService).info(nls.localize('restore.isPreviewFeature', 'You must enable preview features in order to use restore'));
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
TaskUtilities.showRestore(
|
||||
profile,
|
||||
accessor.get<IRestoreDialogController>(IRestoreDialogController)
|
||||
).then(
|
||||
result => {
|
||||
resolve(void 0);
|
||||
},
|
||||
error => {
|
||||
resolve(void 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
TaskUtilities.showRestore(
|
||||
profile,
|
||||
accessor.get<IRestoreDialogController>(IRestoreDialogController)
|
||||
).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,18 +298,12 @@ export class ManageAction extends Action {
|
||||
}
|
||||
|
||||
run(actionContext: ManageActionContext): Promise<boolean> {
|
||||
let self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
self._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
||||
() => {
|
||||
self._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
resolve(true);
|
||||
},
|
||||
error => {
|
||||
resolve(error);
|
||||
}
|
||||
);
|
||||
});
|
||||
return this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }).then(
|
||||
() => {
|
||||
this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,31 +319,8 @@ export class InsightAction extends Action {
|
||||
}
|
||||
|
||||
run(actionContext: InsightActionContext): Promise<boolean> {
|
||||
let self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
self._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class NewDatabaseAction extends Action {
|
||||
public static ID = 'newDatabase';
|
||||
public static LABEL = nls.localize('newDatabase', 'New Database');
|
||||
public static ICON = 'new-database';
|
||||
|
||||
constructor(
|
||||
id: string, label: string, icon: string,
|
||||
@IAdminService private _adminService: IAdminService,
|
||||
@IErrorMessageService private _errorMessageService: IErrorMessageService,
|
||||
) {
|
||||
super(id, label, icon);
|
||||
}
|
||||
|
||||
run(actionContext: BaseActionContext): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
TaskUtilities.showCreateDatabase(actionContext.profile, this._adminService, this._errorMessageService);
|
||||
});
|
||||
this._insightsDialogService.show(actionContext.insight, actionContext.profile);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,12 +340,6 @@ export class ConfigureDashboardAction extends Task {
|
||||
}
|
||||
|
||||
runTask(accessor: ServicesAccessor): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then((result) => {
|
||||
resolve(void 0);
|
||||
}, err => {
|
||||
resolve(void 0);
|
||||
});
|
||||
});
|
||||
return accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import ConnectionConstants = require('sql/platform/connection/common/constants');
|
||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as os from 'os';
|
||||
|
||||
@@ -15,7 +14,6 @@ import {
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
|
||||
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
||||
import { IAdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
import { IRestoreDialogController } from 'sql/platform/restore/common/restoreService';
|
||||
import { IInsightsConfig } from 'sql/workbench/parts/dashboard/widgets/insights/interfaces';
|
||||
import { IInsightsDialogService } from 'sql/workbench/services/insights/common/insightsDialogService';
|
||||
@@ -57,31 +55,6 @@ const targetDatabaseEngineEditionMap = {
|
||||
7: 'SqlServerStretchEdition'
|
||||
};
|
||||
|
||||
// map for object types for scripting
|
||||
const objectScriptMap = {
|
||||
Table: 'Table',
|
||||
View: 'View',
|
||||
StoredProcedure: 'Procedure',
|
||||
UserDefinedFunction: 'Function',
|
||||
UserDefinedDataType: 'Type',
|
||||
User: 'User',
|
||||
Default: 'Default',
|
||||
Rule: 'Rule',
|
||||
DatabaseRole: 'Role',
|
||||
ApplicationRole: 'Application Role',
|
||||
SqlAssembly: 'Assembly',
|
||||
DdlTrigger: 'Trigger',
|
||||
Synonym: 'Synonym',
|
||||
XmlSchemaCollection: 'Xml Schema Collection',
|
||||
Schema: 'Schema',
|
||||
PlanGuide: 'sp_create_plan_guide',
|
||||
UserDefinedType: 'Type',
|
||||
UserDefinedAggregate: 'Aggregate',
|
||||
FullTextCatalog: 'Fulltext Catalog',
|
||||
UserDefinedTableType: 'Type',
|
||||
MaterializedView: 'Materialized View'
|
||||
};
|
||||
|
||||
export enum ScriptOperation {
|
||||
Select = 0,
|
||||
Create = 1,
|
||||
@@ -111,31 +84,6 @@ export function GetScriptOperationName(operation: ScriptOperation) {
|
||||
}
|
||||
}
|
||||
|
||||
export function connectIfNotAlreadyConnected(connectionProfile: IConnectionProfile, connectionService: IConnectionManagementService): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
let connectionID = connectionService.getConnectionUri(connectionProfile);
|
||||
let uri: string = connectionService.getFormattedUri(connectionID, connectionProfile);
|
||||
if (!connectionService.isConnected(uri)) {
|
||||
let options: IConnectionCompletionOptions = {
|
||||
params: { connectionType: ConnectionType.editor, runQueryOnCompletion: RunQueryOnConnectionMode.executeQuery, input: undefined },
|
||||
saveTheConnection: false,
|
||||
showDashboard: false,
|
||||
showConnectionDialogOnError: false,
|
||||
showFirewallRuleOnError: true
|
||||
};
|
||||
connectionService.connect(connectionProfile, uri, options).then(() => {
|
||||
setTimeout(function () {
|
||||
resolve();
|
||||
}, 2000);
|
||||
}).catch(connectionError => {
|
||||
reject(connectionError);
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select the top rows from an object
|
||||
*/
|
||||
@@ -223,7 +171,7 @@ export function script(connectionProfile: IConnectionProfile, metadata: azdata.O
|
||||
let script: string = result.script;
|
||||
|
||||
if (script) {
|
||||
let description = (metadata.schema && metadata.schema !== '') ? `${metadata.schema}.${metadata.name}` : metadata.name;
|
||||
let description = (metadata.schema && metadata.schema !== '') ? `${metadata.schema}.${metadata.name}` : metadata.name;
|
||||
queryEditorService.newSqlEditor(script, connectionProfile.providerName, undefined, description).then((owner) => {
|
||||
// Connect our editor to the input connection
|
||||
let options: IConnectionCompletionOptions = {
|
||||
@@ -336,27 +284,6 @@ export function replaceConnection(oldUri: string, newUri: string, connectionServ
|
||||
});
|
||||
}
|
||||
|
||||
export function showCreateDatabase(
|
||||
connection: IConnectionProfile,
|
||||
adminService: IAdminService,
|
||||
errorMessageService: IErrorMessageService): Promise<void> {
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
// show not implemented
|
||||
errorMessageService.showDialog(Severity.Info,
|
||||
'Coming Soon',
|
||||
'This feature is not yet implemented. It will be available in an upcoming release.');
|
||||
|
||||
// adminService.showCreateDatabaseWizard(uri, connection);
|
||||
});
|
||||
}
|
||||
|
||||
export function showCreateLogin(uri: string, connection: IConnectionProfile, adminService: IAdminService): Promise<void> {
|
||||
return new Promise<void>((resolve) => {
|
||||
adminService.showCreateLoginWizard(uri, connection);
|
||||
});
|
||||
}
|
||||
|
||||
export function showBackup(connection: IConnectionProfile, backupUiService: IBackupUiService): Promise<void> {
|
||||
return new Promise<void>((resolve) => {
|
||||
backupUiService.showBackup(connection).then(() => {
|
||||
@@ -418,26 +345,6 @@ export function getCurrentGlobalConnection(objectExplorerService: IObjectExplore
|
||||
return connection;
|
||||
}
|
||||
|
||||
/* Helper Methods */
|
||||
function getStartPos(script: string, operation: ScriptOperation, typeName: string): number {
|
||||
let objectTypeName = objectScriptMap[typeName];
|
||||
if (objectTypeName && script) {
|
||||
let scriptTypeName = objectTypeName.toLowerCase();
|
||||
switch (operation) {
|
||||
case (ScriptOperation.Create):
|
||||
return script.toLowerCase().indexOf(`create ${scriptTypeName}`);
|
||||
case (ScriptOperation.Delete):
|
||||
return script.toLowerCase().indexOf(`drop ${scriptTypeName}`);
|
||||
default:
|
||||
/* script wasn't found for that object */
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getScriptingParamDetails(connectionService: IConnectionManagementService, ownerUri: string, metadata: azdata.ObjectMetadata): azdata.ScriptingParamDetails {
|
||||
let serverInfo: azdata.ServerInfo = getServerInfo(connectionService, ownerUri);
|
||||
let paramDetails: azdata.ScriptingParamDetails = {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
||||
@@ -2,19 +2,13 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
export const SERVICE_ID = 'adminService';
|
||||
|
||||
import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { CreateLoginInput } from 'sql/parts/admin/security/createLoginInput';
|
||||
import { TaskDialogInput } from 'sql/parts/tasks/dialog/taskDialogInput';
|
||||
|
||||
import { IEditorService, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
@@ -25,12 +19,6 @@ export interface IAdminService {
|
||||
|
||||
registerProvider(providerId: string, provider: azdata.AdminServicesProvider): void;
|
||||
|
||||
showCreateDatabaseWizard(uri: string, connection: IConnectionProfile): Promise<any>;
|
||||
|
||||
showCreateLoginWizard(uri: string, connection: IConnectionProfile): Promise<any>;
|
||||
|
||||
createDatabase(connectionUri: string, database: azdata.DatabaseInfo): Thenable<azdata.CreateDatabaseResponse>;
|
||||
|
||||
getDefaultDatabaseInfo(connectionUri: string): Thenable<azdata.DatabaseInfo>;
|
||||
|
||||
getDatabaseInfo(connectionUri: string): Thenable<azdata.DatabaseInfo>;
|
||||
@@ -42,8 +30,6 @@ export class AdminService implements IAdminService {
|
||||
private _providers: { [handle: string]: azdata.AdminServicesProvider; } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IEditorService private _editorService: IEditorService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService
|
||||
) {
|
||||
}
|
||||
@@ -62,49 +48,6 @@ export class AdminService implements IAdminService {
|
||||
}
|
||||
}
|
||||
|
||||
public showCreateDatabaseWizard(uri: string, connection: IConnectionProfile): Promise<any> {
|
||||
const self = this;
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let input: TaskDialogInput = self._instantiationService ? self._instantiationService.createInstance(TaskDialogInput, uri, connection) : undefined;
|
||||
self._editorService.openEditor(input, { pinned: true }, ACTIVE_GROUP);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
public createDatabase(connectionUri: string, database: azdata.DatabaseInfo): Thenable<azdata.CreateDatabaseResponse> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.createDatabase(connectionUri, database);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public showCreateLoginWizard(uri: string, connection: IConnectionProfile): Promise<any> {
|
||||
const self = this;
|
||||
self.createLogin(uri, { name: 'TEST: login name' });
|
||||
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
let loginInput: CreateLoginInput = self._instantiationService ? self._instantiationService.createInstance(CreateLoginInput, uri, connection) : undefined;
|
||||
self._editorService.openEditor(loginInput, { pinned: true }, ACTIVE_GROUP);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
public createLogin(connectionUri: string, login: azdata.LoginInfo): Thenable<azdata.CreateLoginResponse> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.createLogin(connectionUri, login);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getDefaultDatabaseInfo(connectionUri: string): Thenable<azdata.DatabaseInfo> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { AdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
|
||||
suite('SQL AdminService tests', () => {
|
||||
|
||||
let adminService: AdminService;
|
||||
setup(() => {
|
||||
adminService = new AdminService(
|
||||
undefined, undefined, undefined
|
||||
);
|
||||
});
|
||||
|
||||
test('createDatabase should call tools service provider', done => {
|
||||
done();
|
||||
// adminService.createDatabase(undefined, undefined).then((result) => {
|
||||
// assert.notEqual(result, undefined, 'Result is undefined');
|
||||
// done();
|
||||
// });
|
||||
});
|
||||
});
|
||||
@@ -433,7 +433,6 @@ import 'vs/workbench/contrib/issue/electron-browser/issue.contribution';
|
||||
// SQL
|
||||
import 'sql/parts/taskHistory/common/taskHistory.contribution';
|
||||
import 'sql/parts/taskHistory/viewlet/taskHistoryViewlet';
|
||||
import 'sql/parts/tasks/common/tasks.contribution';
|
||||
|
||||
// data explorer
|
||||
import 'sql/workbench/parts/dataExplorer/browser/dataExplorer.contribution';
|
||||
|
||||
Reference in New Issue
Block a user