mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-24 17:23:05 -05:00
Layering of everything else but query (#5085)
* layer profiler and edit data * relayering everything but query * fix css import * readd qp * fix script src * fix hygiene
This commit is contained in:
@@ -15,7 +15,7 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import * as ConnectionUtils from 'sql/platform/connection/common/utils';
|
||||
import { ProviderConnectionInfo } from 'sql/platform/connection/common/providerConnectionInfo';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { BackupDialog } from 'sql/parts/disasterRecovery/backup/backupDialog';
|
||||
import { BackupDialog } from 'sql/workbench/parts/backup/electron-browser/backupDialog';
|
||||
import { OptionsDialog } from 'sql/workbench/browser/modal/optionsDialog';
|
||||
import { IBackupService, TaskExecutionMode } from 'sql/platform/backup/common/backupService';
|
||||
import { IBackupUiService } from 'sql/workbench/services/backup/common/backupUiService';
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as azdata from 'azdata';
|
||||
import { INewProfilerState } from 'sql/parts/profiler/editor/profilerState';
|
||||
import { INewProfilerState } from 'sql/workbench/parts/profiler/common/profilerState';
|
||||
|
||||
const PROFILER_SERVICE_ID = 'profilerService';
|
||||
export const IProfilerService = createDecorator<IProfilerService>(PROFILER_SERVICE_ID);
|
||||
|
||||
103
src/sql/workbench/services/profiler/common/profilerFilter.ts
Normal file
103
src/sql/workbench/services/profiler/common/profilerFilter.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ProfilerFilterClause, ProfilerFilter, ProfilerFilterClauseOperator } from 'sql/workbench/services/profiler/common/interfaces';
|
||||
|
||||
|
||||
export function FilterData(filter: ProfilerFilter, data: any[]): any[] {
|
||||
if (!data || !filter) {
|
||||
return data;
|
||||
}
|
||||
return data.filter(item => matches(item, filter.clauses));
|
||||
}
|
||||
|
||||
function matches(item: any, clauses: ProfilerFilterClause[]): boolean {
|
||||
let match = true;
|
||||
if (!item) {
|
||||
match = false;
|
||||
} else if (clauses) {
|
||||
for (let i = 0; i < clauses.length; i++) {
|
||||
let clause = clauses[i];
|
||||
if (!!clause && !!clause.field) {
|
||||
let actualValue: any = item[clause.field];
|
||||
let expectedValue: any = clause.value;
|
||||
let actualValueString: string = actualValue === undefined ? undefined : actualValue.toLocaleLowerCase();
|
||||
let expectedValueString: string = expectedValue === undefined ? undefined : expectedValue.toLocaleLowerCase();
|
||||
let actualValueDate = new Date(actualValue).valueOf();
|
||||
let expectedValueDate = new Date(expectedValue).valueOf();
|
||||
let actualValueNumber = Number(actualValue).valueOf();
|
||||
let expectedValueNumber = Number(expectedValue).valueOf();
|
||||
|
||||
if (isValidNumber(actualValue) && isValidNumber(expectedValue)) {
|
||||
actualValue = actualValueNumber;
|
||||
expectedValue = expectedValueNumber;
|
||||
} else if (isValidDate(actualValue) && isValidDate(expectedValue)) {
|
||||
actualValue = actualValueDate;
|
||||
expectedValue = expectedValueDate;
|
||||
} else {
|
||||
actualValue = actualValueString;
|
||||
expectedValue = expectedValueString;
|
||||
}
|
||||
|
||||
switch (clause.operator) {
|
||||
case ProfilerFilterClauseOperator.Equals:
|
||||
match = actualValue === expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.NotEquals:
|
||||
match = actualValue !== expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.LessThan:
|
||||
match = actualValue < expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.LessThanOrEquals:
|
||||
match = actualValue <= expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.GreaterThan:
|
||||
match = actualValue > expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.GreaterThanOrEquals:
|
||||
match = actualValue >= expectedValue;
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.IsNull:
|
||||
match = actualValue === undefined || actualValue === null || actualValue === '';
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.IsNotNull:
|
||||
match = actualValue !== undefined && actualValue !== null && actualValue !== '';
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.Contains:
|
||||
match = actualValueString && actualValueString.includes(expectedValueString);
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.NotContains:
|
||||
match = !actualValueString || !actualValueString.includes(expectedValueString);
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.StartsWith:
|
||||
match = actualValueString.startsWith(expectedValueString);
|
||||
break;
|
||||
case ProfilerFilterClauseOperator.NotStartsWith:
|
||||
match = !actualValueString || !actualValueString.startsWith(expectedValueString);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Not a valid operator: ${clause.operator}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
function isValidNumber(value: string): boolean {
|
||||
let num = Number(value);
|
||||
return value !== undefined && !isNaN(num.valueOf()) && value.replace(' ', '') !== '';
|
||||
}
|
||||
|
||||
function isValidDate(value: string): boolean {
|
||||
let date = new Date(value);
|
||||
return value !== undefined && !isNaN(date.valueOf());
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
PROFILER_SETTINGS, IProfilerSettings
|
||||
} from './interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ProfilerInput } from 'sql/parts/profiler/editor/profilerInput';
|
||||
import { ProfilerColumnEditorDialog } from 'sql/parts/profiler/dialog/profilerColumnEditorDialog';
|
||||
import { ProfilerInput } from 'sql/workbench/parts/profiler/browser/profilerInput';
|
||||
import { ProfilerColumnEditorDialog } from 'sql/workbench/parts/profiler/browser/profilerColumnEditorDialog';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
@@ -20,7 +20,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { Memento } from 'vs/workbench/common/memento';
|
||||
import { ProfilerFilterDialog } from 'sql/parts/profiler/dialog/profilerFilterDialog';
|
||||
import { ProfilerFilterDialog } from 'sql/workbench/parts/profiler/browser/profilerFilterDialog';
|
||||
|
||||
class TwoWayMap<T, K> {
|
||||
private forwardMap: Map<T, K>;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
|
||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||
import { EditDataInput } from 'sql/parts/editData/common/editDataInput';
|
||||
import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput';
|
||||
import { IConnectableInput, IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IQueryEditorService, IQueryEditorOptions } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { QueryPlanInput } from 'sql/workbench/parts/queryPlan/common/queryPlanInput';
|
||||
import { sqlModeId, untitledFilePrefix, getSupportedInputResource } from 'sql/parts/common/customInputConverter';
|
||||
import { sqlModeId, untitledFilePrefix, getSupportedInputResource } from 'sql/workbench/common/customInputConverter';
|
||||
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
|
||||
|
||||
import { IMode } from 'vs/editor/common/modes';
|
||||
@@ -24,7 +24,7 @@ import paths = require('vs/base/common/extpath');
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { EditDataResultsInput } from 'sql/parts/editData/common/editDataResultsInput';
|
||||
import { EditDataResultsInput } from 'sql/workbench/parts/editData/common/editDataResultsInput';
|
||||
import { IEditorInput, IEditor } from 'vs/workbench/common/editor';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ILanguageSelection } from 'vs/editor/common/services/modeService';
|
||||
|
||||
Reference in New Issue
Block a user