mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 01:25:38 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
138
src/sql/parts/admin/common/adminService.ts
Normal file
138
src/sql/parts/admin/common/adminService.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { CreateLoginInput } from 'sql/parts/admin/security/createLoginInput';
|
||||
import { TaskDialogInput } from 'sql/parts/tasks/dialog/taskDialogInput';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
|
||||
import data = require('data');
|
||||
|
||||
export const IAdminService = createDecorator<IAdminService>(SERVICE_ID);
|
||||
|
||||
export interface IAdminService {
|
||||
_serviceBrand: any;
|
||||
|
||||
registerProvider(providerId: string, provider: data.AdminServicesProvider): void;
|
||||
|
||||
showCreateDatabaseWizard(uri: string, connection: IConnectionProfile): Promise<any>;
|
||||
|
||||
showCreateLoginWizard(uri: string, connection: IConnectionProfile): Promise<any>;
|
||||
|
||||
createDatabase(connectionUri: string, database: data.DatabaseInfo): Thenable<data.CreateDatabaseResponse>;
|
||||
|
||||
getDefaultDatabaseInfo(connectionUri: string): Thenable<data.DatabaseInfo>;
|
||||
|
||||
getDatabaseInfo(connectionUri: string): Thenable<data.DatabaseInfo>;
|
||||
}
|
||||
|
||||
export class AdminService implements IAdminService {
|
||||
_serviceBrand: any;
|
||||
|
||||
private _providers: { [handle: string]: data.AdminServicesProvider; } = Object.create(null);
|
||||
|
||||
private _providerOptions: { [handle: string]: data.AdminServicesOptions; } = Object.create(null);
|
||||
|
||||
constructor(
|
||||
@IInstantiationService private _instantiationService: IInstantiationService,
|
||||
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
|
||||
@IConnectionManagementService private _connectionService: IConnectionManagementService,
|
||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
|
||||
) {
|
||||
if (_capabilitiesService && _capabilitiesService.onProviderRegisteredEvent) {
|
||||
_capabilitiesService.onProviderRegisteredEvent((capabilities => {
|
||||
this._providerOptions[capabilities.providerName] = capabilities.adminServicesProvider;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private _runAction<T>(uri: string, action: (handler: data.AdminServicesProvider) => Thenable<T>): Thenable<T> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(uri);
|
||||
|
||||
if (!providerId) {
|
||||
return TPromise.wrapError(new Error(localize('providerIdNotValidError', 'Connection is required in order to interact with adminservice')));
|
||||
}
|
||||
let handler = this._providers[providerId];
|
||||
if (handler) {
|
||||
return action(handler);
|
||||
} else {
|
||||
return TPromise.wrapError(new Error(localize('noHandlerRegistered', 'No Handler Registered')));
|
||||
}
|
||||
}
|
||||
|
||||
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 }, false);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
public createDatabase(connectionUri: string, database: data.DatabaseInfo): Thenable<data.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 }, false);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
||||
|
||||
public createLogin(connectionUri: string, login: data.LoginInfo): Thenable<data.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<data.DatabaseInfo> {
|
||||
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
|
||||
if (providerId) {
|
||||
let provider = this._providers[providerId];
|
||||
if (provider) {
|
||||
return provider.getDefaultDatabaseInfo(connectionUri);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getDatabaseInfo(connectionUri: string): Thenable<data.DatabaseInfo> {
|
||||
return this._runAction(connectionUri, (runner) => {
|
||||
return runner.getDatabaseInfo(connectionUri);
|
||||
});
|
||||
}
|
||||
|
||||
public registerProvider(providerId: string, provider: data.AdminServicesProvider): void {
|
||||
this._providers[providerId] = provider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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>
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { TaskDialogComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { IAdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { ITaskDialogComponent } from 'sql/parts/tasks/common/tasks';
|
||||
|
||||
import data = require('data');
|
||||
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 {
|
||||
|
||||
private _adminService: IAdminService;
|
||||
|
||||
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(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
this._adminService = this._bootstrapService.adminService;
|
||||
}
|
||||
|
||||
private getDatabaseInfo(form: NgForm): data.DatabaseInfo {
|
||||
return <data.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: TaskDialogComponentParams ): 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
34
src/sql/parts/admin/security/createLogin.component.html
Normal file
34
src/sql/parts/admin/security/createLogin.component.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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>
|
||||
30
src/sql/parts/admin/security/createLogin.component.ts
Normal file
30
src/sql/parts/admin/security/createLogin.component.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/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(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
let parameters: DashboardComponentParams = this._bootstrapService.getBootstrapParams(this._el.nativeElement.tagName);
|
||||
|
||||
}
|
||||
}
|
||||
39
src/sql/parts/admin/security/createLogin.module.ts
Normal file
39
src/sql/parts/admin/security/createLogin.module.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 } from '@angular/core';
|
||||
import { APP_BASE_HREF, CommonModule } from '@angular/common';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IBootstrapService, BOOTSTRAP_SERVICE_ID } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
import { CreateLoginComponent, CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component';
|
||||
|
||||
// Connection Dashboard main angular module
|
||||
@NgModule({
|
||||
declarations: [
|
||||
CreateLoginComponent
|
||||
],
|
||||
entryComponents: [CreateLoginComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
BrowserModule
|
||||
],
|
||||
providers: [{ provide: APP_BASE_HREF, useValue: '/' }]
|
||||
})
|
||||
export class CreateLoginModule {
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver,
|
||||
@Inject(BOOTSTRAP_SERVICE_ID) private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
}
|
||||
|
||||
ngDoBootstrap(appRef: ApplicationRef) {
|
||||
const factory = this._resolver.resolveComponentFactory(CreateLoginComponent);
|
||||
const uniqueSelector: string = this._bootstrapService.getUniqueSelector(CREATELOGIN_SELECTOR);
|
||||
(<any>factory).factory.selector = uniqueSelector;
|
||||
appRef.bootstrap(factory);
|
||||
}
|
||||
}
|
||||
114
src/sql/parts/admin/security/createLoginEditor.ts
Normal file
114
src/sql/parts/admin/security/createLoginEditor.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
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 './createLoginInput';
|
||||
import { CreateLoginModule } from './createLogin.module';
|
||||
import { IConnectionManagementService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IMetadataService } from 'sql/services/metadata/metadataService';
|
||||
import { IScriptingService } from 'sql/services/scripting/scriptingService';
|
||||
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
|
||||
import { IBootstrapService } from 'sql/services/bootstrap/bootstrapService';
|
||||
import { DashboardComponentParams } from 'sql/services/bootstrap/bootstrapParams';
|
||||
import { CREATELOGIN_SELECTOR } from 'sql/parts/admin/security/createLogin.component';
|
||||
|
||||
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,
|
||||
@IBootstrapService private _bootstrapService: IBootstrapService
|
||||
) {
|
||||
super(CreateLoginEditor.ID, telemetryService, themeService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to create the editor in the parent builder.
|
||||
*/
|
||||
public createEditor(parent: Builder): 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: CreateLoginInput, options: EditorOptions): TPromise<void> {
|
||||
if (this.input instanceof CreateLoginInput && this.input.matches(input)) {
|
||||
return TPromise.as(undefined);
|
||||
}
|
||||
|
||||
if (!input.hasInitialized) {
|
||||
this.bootstrapAngular(input);
|
||||
}
|
||||
this.revealElementWithTagName(input.uniqueSelector, this.getContainer().getHTMLElement());
|
||||
|
||||
return super.setInput(input, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: DashboardComponentParams = {
|
||||
connection: input.getConnectionProfile(),
|
||||
ownerUri: input.getUri()
|
||||
};
|
||||
let uniqueSelector = this._bootstrapService.bootstrap(
|
||||
CreateLoginModule,
|
||||
this.getContainer().getHTMLElement(),
|
||||
CREATELOGIN_SELECTOR,
|
||||
params);
|
||||
input.setUniqueSelector(uniqueSelector);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
57
src/sql/parts/admin/security/createLoginInput.ts
Normal file
57
src/sql/parts/admin/security/createLoginInput.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { EditorInput, EditorModel } from 'vs/workbench/common/editor';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
import { IConnectionProfile } from 'sql/parts/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): TPromise<EditorModel> {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public get hasInitialized(): boolean {
|
||||
return !!this._uniqueSelector;
|
||||
}
|
||||
|
||||
public get uniqueSelector(): string {
|
||||
return this._uniqueSelector;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user