mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
Filter templates by supported engine type (#6133)
* Filter templates by supported engine type * fix the azure sql db name
This commit is contained in:
@@ -12,7 +12,7 @@ import * as nls from 'vs/nls';
|
||||
|
||||
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
|
||||
import { ProfilerEditor } from 'sql/workbench/parts/profiler/browser/profilerEditor';
|
||||
import { PROFILER_VIEW_TEMPLATE_SETTINGS, PROFILER_SESSION_TEMPLATE_SETTINGS, IProfilerViewTemplate, IProfilerSessionTemplate } from 'sql/workbench/services/profiler/common/interfaces';
|
||||
import { PROFILER_VIEW_TEMPLATE_SETTINGS, PROFILER_SESSION_TEMPLATE_SETTINGS, IProfilerViewTemplate, IProfilerSessionTemplate, EngineType } from 'sql/workbench/services/profiler/common/interfaces';
|
||||
|
||||
const profilerDescriptor = new EditorDescriptor(
|
||||
ProfilerEditor,
|
||||
@@ -271,6 +271,7 @@ const profilerSessionTemplateSchema: IJSONSchema = {
|
||||
{
|
||||
name: 'Standard_OnPrem',
|
||||
defaultView: 'Standard View',
|
||||
engineTypes: [EngineType.Standalone],
|
||||
createStatement:
|
||||
`CREATE EVENT SESSION [{sessionName}] ON SERVER
|
||||
ADD EVENT sqlserver.attention(
|
||||
@@ -296,6 +297,7 @@ const profilerSessionTemplateSchema: IJSONSchema = {
|
||||
},
|
||||
{
|
||||
name: 'Standard_Azure',
|
||||
engineTypes: [EngineType.AzureSQLDB],
|
||||
defaultView: 'Standard View',
|
||||
createStatement:
|
||||
`CREATE EVENT SESSION [{sessionName}] ON DATABASE
|
||||
@@ -322,6 +324,7 @@ const profilerSessionTemplateSchema: IJSONSchema = {
|
||||
},
|
||||
{
|
||||
name: 'TSQL_OnPrem',
|
||||
engineTypes: [EngineType.Standalone],
|
||||
defaultView: 'TSQL View',
|
||||
createStatement:
|
||||
`CREATE EVENT SESSION [{sessionName}] ON SERVER
|
||||
|
||||
@@ -147,8 +147,14 @@ export interface IProfilerViewTemplate {
|
||||
columns: Array<IColumnViewTemplate>;
|
||||
}
|
||||
|
||||
export enum EngineType {
|
||||
AzureSQLDB = 'AzureSQLDB',
|
||||
Standalone = 'Standalone'
|
||||
}
|
||||
|
||||
export interface IProfilerSessionTemplate {
|
||||
name: string;
|
||||
engineTypes?: EngineType[];
|
||||
defaultView: string;
|
||||
createStatement: string;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import {
|
||||
ProfilerSessionID, IProfilerSession, IProfilerService, IProfilerViewTemplate, IProfilerSessionTemplate,
|
||||
PROFILER_SETTINGS, IProfilerSettings
|
||||
PROFILER_SETTINGS, IProfilerSettings, EngineType
|
||||
} from './interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
|
||||
@@ -225,8 +225,17 @@ export class ProfilerService implements IProfilerService {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
public launchCreateSessionDialog(input?: ProfilerInput): Thenable<void> {
|
||||
return this._commandService.executeCommand('profiler.openCreateSessionDialog', input.id, input.providerType, this.getSessionTemplates());
|
||||
public launchCreateSessionDialog(input: ProfilerInput): Thenable<void> {
|
||||
const serverInfo = this._connectionService.getConnectionInfo(input.id).serverInfo;
|
||||
let templates = this.getSessionTemplates();
|
||||
if (serverInfo) {
|
||||
const engineType = serverInfo.isCloud ? EngineType.AzureSQLDB : EngineType.Standalone;
|
||||
// only use the templates that matches the following criteria:
|
||||
// 1. the template doesn't have any engine types specified - for backward compatibility (user with custom templates) or the templates applicable to both AzureSQLDB and standalone server
|
||||
// 2. the template supports the current engine type
|
||||
templates = templates.filter(template => !template.engineTypes || template.engineTypes.length === 0 || template.engineTypes.includes(engineType));
|
||||
}
|
||||
return this._commandService.executeCommand('profiler.openCreateSessionDialog', input.id, input.providerType, templates);
|
||||
}
|
||||
|
||||
public launchFilterSessionDialog(input: ProfilerInput): void {
|
||||
|
||||
Reference in New Issue
Block a user