mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-22 02:11:29 +00:00
Refactor Data Access Utility (#112)
This commit is contained in:
@@ -7,7 +7,7 @@ import { AddDbUtilities } from "../Shared/AddDatabaseUtility";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { MessageHandler } from "../Common/MessageHandler";
|
||||
import { sendMessage } from "../Common/MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
@@ -108,7 +108,7 @@ export class CreateSqlCollectionUtilities {
|
||||
`Error creating collection: ${JSON.stringify(response)}`
|
||||
);
|
||||
if (response.status === HttpStatusCodes.Forbidden) {
|
||||
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
}
|
||||
throw new Error(`Error creating collection`);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ export class CreateCollectionUtilities {
|
||||
`Error creating graph: ${JSON.stringify(response)}`
|
||||
);
|
||||
if (response.status === HttpStatusCodes.Forbidden) {
|
||||
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
}
|
||||
throw new Error(`Error creating graph`);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ export class Utilities {
|
||||
`Error creating table: ${JSON.stringify(reason)}, Payload: ${params}`
|
||||
);
|
||||
if (reason.status === HttpStatusCodes.Forbidden) {
|
||||
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
return;
|
||||
}
|
||||
throw new Error(`Error creating table`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { config } from "../Config";
|
||||
import { ConsoleDataType } from "../Explorer/Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { CosmosClient } from "../Common/CosmosClient";
|
||||
import { HttpStatusCodes } from "../Common/Constants";
|
||||
import { MessageHandler } from "../Common/MessageHandler";
|
||||
import { sendMessage } from "../Common/MessageHandler";
|
||||
import { MessageTypes } from "../Contracts/ExplorerContracts";
|
||||
import { NotificationConsoleUtils } from "../Utils/NotificationConsoleUtils";
|
||||
import { ResourceProviderClient } from "../ResourceProvider/ResourceProviderClient";
|
||||
@@ -164,7 +164,7 @@ export class AddDbUtilities {
|
||||
`Error creating ${dbType}: ${JSON.stringify(reason)}, Payload: ${params}`
|
||||
);
|
||||
if (reason.status === HttpStatusCodes.Forbidden) {
|
||||
MessageHandler.sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
sendMessage({ type: MessageTypes.ForbiddenError });
|
||||
return;
|
||||
}
|
||||
throw new Error(`Error creating ${dbType}`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Action, ActionModifiers } from "./TelemetryConstants";
|
||||
import { MessageHandler } from "../../Common/MessageHandler";
|
||||
import { sendMessage } from "../../Common/MessageHandler";
|
||||
import { MessageTypes } from "../../Contracts/ExplorerContracts";
|
||||
import { appInsights } from "../appInsights";
|
||||
import { config } from "../../Config";
|
||||
@@ -11,7 +11,7 @@ import { config } from "../../Config";
|
||||
// TODO: Log telemetry for StorageExplorer case/other clients as well
|
||||
export default class TelemetryProcessor {
|
||||
public static trace(action: Action, actionModifier: string = ActionModifiers.Mark, data?: any): void {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -25,7 +25,7 @@ export default class TelemetryProcessor {
|
||||
|
||||
public static traceStart(action: Action, data?: any): number {
|
||||
const timestamp: number = Date.now();
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -40,7 +40,7 @@ export default class TelemetryProcessor {
|
||||
}
|
||||
|
||||
public static traceSuccess(action: Action, data?: any, timestamp?: number): void {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -54,7 +54,7 @@ export default class TelemetryProcessor {
|
||||
}
|
||||
|
||||
public static traceFailure(action: Action, data?: any, timestamp?: number): void {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -68,7 +68,7 @@ export default class TelemetryProcessor {
|
||||
}
|
||||
|
||||
public static traceCancel(action: Action, data?: any, timestamp?: number): void {
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -83,7 +83,7 @@ export default class TelemetryProcessor {
|
||||
|
||||
public static traceOpen(action: Action, data?: any, timestamp?: number): number {
|
||||
const validTimestamp = timestamp || Date.now();
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
@@ -99,7 +99,7 @@ export default class TelemetryProcessor {
|
||||
|
||||
public static traceMark(action: Action, data?: any, timestamp?: number): number {
|
||||
const validTimestamp = timestamp || Date.now();
|
||||
MessageHandler.sendMessage({
|
||||
sendMessage({
|
||||
type: MessageTypes.TelemetryInfo,
|
||||
data: {
|
||||
action: Action[action],
|
||||
|
||||
Reference in New Issue
Block a user