More BDC updates (#6990)

This commit is contained in:
Charles Gagnon
2019-09-04 13:49:08 -07:00
committed by GitHub
parent f05b9396e8
commit 8b5ce753e4
11 changed files with 23 additions and 344 deletions

View File

@@ -11,7 +11,6 @@ import { getEndPoints, ControllerError } from '../controller/clusterControllerAp
import { ControllerTreeDataProvider } from '../tree/controllerTreeDataProvider';
import { TreeNode } from '../tree/treeNode';
import { showErrorMessage } from '../utils';
import { EndpointModel } from '../controller/apiGenerated';
const localize = nls.loadMessageBundle();
@@ -22,32 +21,26 @@ export class AddControllerDialogModel {
constructor(
public treeDataProvider: ControllerTreeDataProvider,
public node?: TreeNode,
public prefilledClusterName?: string,
public prefilledUrl?: string,
public prefilledUsername?: string,
public prefilledPassword?: string,
public prefilledRememberPassword?: boolean
) {
this.prefilledClusterName = prefilledClusterName || (node && node['clusterName']);
this.prefilledUrl = prefilledUrl || (node && node['url']);
this.prefilledUsername = prefilledUsername || (node && node['username']);
this.prefilledPassword = prefilledPassword || (node && node['password']);
this.prefilledRememberPassword = prefilledRememberPassword || (node && node['rememberPassword']);
}
public async onComplete(clusterName: string, url: string, username: string, password: string, rememberPassword: boolean): Promise<void> {
public async onComplete(url: string, username: string, password: string, rememberPassword: boolean): Promise<void> {
try {
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
let response = await getEndPoints(url, username, password, true);
if (response && response.endPoints) {
let masterInstance: EndpointModel = undefined;
if (response.endPoints) {
masterInstance = response.endPoints.find(e => e.name && e.name === 'sql-server-master');
}
if (this._canceled) {
return;
}
this.treeDataProvider.addController(clusterName, url, username, password, rememberPassword, masterInstance);
this.treeDataProvider.addController(url, username, password, rememberPassword);
await this.treeDataProvider.saveControllers();
}
} catch (error) {
@@ -76,7 +69,6 @@ export class AddControllerDialog {
private dialog: azdata.window.Dialog;
private uiModelBuilder: azdata.ModelBuilder;
private clusterNameInputBox: azdata.InputBoxComponent;
private urlInputBox: azdata.InputBoxComponent;
private usernameInputBox: azdata.InputBoxComponent;
private passwordInputBox: azdata.InputBoxComponent;
@@ -95,11 +87,6 @@ export class AddControllerDialog {
this.dialog.registerContent(async view => {
this.uiModelBuilder = view.modelBuilder;
this.clusterNameInputBox = this.uiModelBuilder.inputBox()
.withProperties<azdata.InputBoxProperties>({
placeHolder: localize('textClusterNameLower', 'mssql-cluster'),
value: this.model.prefilledUrl || 'mssql-cluster'
}).component();
this.urlInputBox = this.uiModelBuilder.inputBox()
.withProperties<azdata.InputBoxProperties>({
placeHolder: localize('textUrlLower', 'url'),
@@ -127,10 +114,6 @@ export class AddControllerDialog {
.withFormItems([{
components: [
{
component: this.clusterNameInputBox,
title: localize('textClusterNameCapital', 'Cluster Name'),
required: true
}, {
component: this.urlInputBox,
title: localize('textUrlCapital', 'URL'),
required: true
@@ -160,14 +143,13 @@ export class AddControllerDialog {
}
private async validate(): Promise<boolean> {
let clusterName = this.clusterNameInputBox && this.clusterNameInputBox.value;
let url = this.urlInputBox && this.urlInputBox.value;
let username = this.usernameInputBox && this.usernameInputBox.value;
let password = this.passwordInputBox && this.passwordInputBox.value;
let rememberPassword = this.passwordInputBox && !!this.rememberPwCheckBox.checked;
try {
await this.model.onComplete(clusterName, url, username, password, rememberPassword);
await this.model.onComplete(url, username, password, rememberPassword);
return true;
} catch (error) {
showErrorMessage(error);