mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Feature: Ability to add connection name (#2332)
This commit is contained in:
@@ -145,6 +145,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
|
||||
|
||||
public toIConnectionProfile(): interfaces.IConnectionProfile {
|
||||
let result: interfaces.IConnectionProfile = {
|
||||
connectionName: this.connectionName,
|
||||
serverName: this.serverName,
|
||||
databaseName: this.databaseName,
|
||||
authenticationType: this.authenticationType,
|
||||
|
||||
@@ -45,6 +45,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
this.databaseName = model.databaseName;
|
||||
this.password = model.password;
|
||||
this.userName = model.userName;
|
||||
this.connectionName = model.connectionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +79,10 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
return this._serverCapabilities;
|
||||
}
|
||||
|
||||
public get connectionName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName);
|
||||
}
|
||||
|
||||
public get serverName(): string {
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName);
|
||||
}
|
||||
@@ -98,6 +103,10 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType);
|
||||
}
|
||||
|
||||
public set connectionName(value: string) {
|
||||
this.setSpecialTypeOptionName(ConnectionOptionSpecialType.connectionName, value);
|
||||
}
|
||||
|
||||
public set serverName(value: string) {
|
||||
this.setSpecialTypeOptionName(ConnectionOptionSpecialType.serverName, value);
|
||||
}
|
||||
@@ -127,16 +136,30 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
this.options[name] = value;
|
||||
}
|
||||
|
||||
private getServerInfo() {
|
||||
let databaseName = this.databaseName ? this.databaseName : '<default>';
|
||||
let userName = this.userName ? this.userName : 'Windows Authentication';
|
||||
return this.serverName + ', ' + databaseName + ' (' + userName + ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the title of the connection
|
||||
*/
|
||||
public get title(): string {
|
||||
let databaseName = this.databaseName ? this.databaseName : '<default>';
|
||||
let userName = this.userName ? this.userName : 'Windows Authentication';
|
||||
let label = this.serverName + ', ' + databaseName + ' (' + userName + ')';
|
||||
let label = '';
|
||||
|
||||
if (this.connectionName) {
|
||||
label = this.connectionName;
|
||||
} else {
|
||||
label = this.getServerInfo();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
public get serverInfo(): string {
|
||||
return this.getServerInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the capabilities and options are loaded correctly
|
||||
*/
|
||||
@@ -171,7 +194,9 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
let idNames = [];
|
||||
if (this._serverCapabilities) {
|
||||
idNames = this._serverCapabilities.connectionOptions.map(o => {
|
||||
if ((o.specialValueType || o.isIdentity) && o.specialValueType !== ConnectionOptionSpecialType.password) {
|
||||
if ((o.specialValueType || o.isIdentity)
|
||||
&& o.specialValueType !== ConnectionOptionSpecialType.password
|
||||
&& o.specialValueType !== ConnectionOptionSpecialType.connectionName) {
|
||||
return o.name;
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -267,6 +292,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
|
||||
element.specialValueType !== ConnectionOptionSpecialType.databaseName &&
|
||||
element.specialValueType !== ConnectionOptionSpecialType.authType &&
|
||||
element.specialValueType !== ConnectionOptionSpecialType.password &&
|
||||
element.specialValueType !== ConnectionOptionSpecialType.connectionName &&
|
||||
element.isIdentity && element.valueType === ServiceOptionType.string) {
|
||||
let value = this.getOptionValue(element.name);
|
||||
if (value) {
|
||||
|
||||
Reference in New Issue
Block a user